diff --git a/src/lib/components/Course/components/Lesson/Exercise/MarkExerciseModal.svelte b/src/lib/components/Course/components/Lesson/Exercise/MarkExerciseModal.svelte
index 6833110c..e7741398 100644
--- a/src/lib/components/Course/components/Lesson/Exercise/MarkExerciseModal.svelte
+++ b/src/lib/components/Course/components/Lesson/Exercise/MarkExerciseModal.svelte
@@ -6,7 +6,7 @@
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
import Preview from './Preview.svelte';
import { SELECTABLE_STATUS } from './constants';
- import { snackbarStore } from '$lib/components/Snackbar/store';
+ import { snackbar } from '$lib/components/Snackbar/store';
export let open = false;
export let onClose = () => {};
@@ -38,8 +38,7 @@
total
});
- $snackbarStore.open = true;
- $snackbarStore.message = `Submission updated to '${status.label}'`;
+ snackbar.success(`Submission updated to '${status.label}'`);
}
function setStatus(data) {
diff --git a/src/lib/components/Course/components/Lesson/Exercise/index.svelte b/src/lib/components/Course/components/Lesson/Exercise/index.svelte
index 2c18b7a8..af73a590 100644
--- a/src/lib/components/Course/components/Lesson/Exercise/index.svelte
+++ b/src/lib/components/Course/components/Lesson/Exercise/index.svelte
@@ -17,14 +17,12 @@
import RoleBasedSecurity from '$lib/components/RoleBasedSecurity/index.svelte';
import ViewMode from './ViewMode.svelte';
import EditMode from './EditMode.svelte';
- import MODES from '$lib/utils/constants/mode.js';
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
- import { deleteExercise, upsertExercise } from '$lib/utils/services/courses';
+ import { upsertExercise } from '$lib/utils/services/courses';
import UpdateDescription from './UpdateDescription.svelte';
import { TrashCan } from 'carbon-icons-svelte';
import { exerciseMode } from './store';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
export let exerciseId;
export let goBack = () => {};
@@ -52,13 +50,10 @@
is_description_dirty: false,
questions: updatedQuestions
}));
- $snackbarStore.open = true;
- $snackbarStore.message = 'Saved Successfully';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
+ snackbar.success('Saved Successfully');
} catch (error) {
- $snackbarStore.open = true;
- $snackbarStore.message = `An Error Occurred`;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
+ console.error(error);
+ snackbar.error();
}
isSaving = false;
}
diff --git a/src/lib/components/Course/components/Settings/index.svelte b/src/lib/components/Course/components/Settings/index.svelte
index 9f0fd1d9..0c91790e 100644
--- a/src/lib/components/Course/components/Settings/index.svelte
+++ b/src/lib/components/Course/components/Settings/index.svelte
@@ -18,8 +18,7 @@
import { isObject } from '$lib/utils/functions/isObject';
import { lessons } from '../Lesson/store/lessons';
import { currentOrg } from '$lib/utils/store/org';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
let uploadingImage = false;
let isSaving = false;
@@ -109,13 +108,9 @@
a.click();
a.remove();
- $snackbarStore.message = 'Download Complete';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
- $snackbarStore.open = true;
+ snackbar.success('Download Complete');
} catch (error) {
- $snackbarStore.message = "Something's not right - Please try later";
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.open = true;
+ snackbar.error("Something's not right - Please try later");
}
isLoading = false;
};
@@ -131,9 +126,7 @@
isDeleting = false;
goto($currentOrgPath + '/courses');
} catch (error) {
- $snackbarStore.message = 'Something went wrong - Please try later';
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.open = true;
+ snackbar.error('Something went wrong - Please try later');
isDeleting = false;
}
}
@@ -171,13 +164,9 @@
grading: grading,
lessonDownload: lesson_download
};
- $snackbarStore.message = 'saved successfully';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
- $snackbarStore.open = true;
+ snackbar.success('Saved successfully');
} catch (error) {
- $snackbarStore.message = 'Something went wrong - Please try later';
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.open = true;
+ snackbar.error();
}
isSaving = false;
diff --git a/src/lib/components/Courses/components/CopyCourseModal/index.svelte b/src/lib/components/Courses/components/CopyCourseModal/index.svelte
index 2c1642be..3634f9a0 100644
--- a/src/lib/components/Courses/components/CopyCourseModal/index.svelte
+++ b/src/lib/components/Courses/components/CopyCourseModal/index.svelte
@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import Modal from '$lib/components/Modal/index.svelte';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import TextField from '$lib/components/Form/TextField.svelte';
import { copyCourseModalInitialState, copyCourseModal } from '$lib/components/Courses/store';
import { cloneCourse } from '$lib/utils/services/courses/clone';
@@ -22,11 +21,9 @@
} catch (error) {
console.error(error);
- // IIFI of snackbarStore to Show notification error
+ // IIFI of snackbar to Show notification error
(() => {
- $snackbarStore.message = "Something's not right - Please try later";
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.open = true;
+ snackbar.error();
})();
// Stop loader
diff --git a/src/lib/components/LMS/components/Profile.svelte b/src/lib/components/LMS/components/Profile.svelte
index 590182ad..de3f19b0 100644
--- a/src/lib/components/LMS/components/Profile.svelte
+++ b/src/lib/components/LMS/components/Profile.svelte
@@ -7,8 +7,7 @@
import UploadImage from '$lib/components/UploadImage/index.svelte';
import { supabase } from '$lib/utils/functions/supabase';
import { profile } from '$lib/utils/store/user';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
let avatar;
let loading = false;
@@ -50,9 +49,7 @@
..._profile,
...updates
}));
- $snackbarStore.open = true;
- $snackbarStore.message = 'Update successful';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
+ snackbar.success();
if (error) throw error;
} catch (error) {
@@ -60,9 +57,8 @@
if (message.includes('profile_username_key')) {
message = 'username already exists';
}
- $snackbarStore.open = true;
- $snackbarStore.message = `Update failed: ${message}`;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
+
+ snackbar.error(`Update failed: ${message}`);
loading = false;
} finally {
loading = false;
diff --git a/src/lib/components/Org/AddOrgModal/AddOrgModal.svelte b/src/lib/components/Org/AddOrgModal/AddOrgModal.svelte
index 5fa09efa..f04ff49d 100644
--- a/src/lib/components/Org/AddOrgModal/AddOrgModal.svelte
+++ b/src/lib/components/Org/AddOrgModal/AddOrgModal.svelte
@@ -8,8 +8,7 @@
import { getOrganizations } from '$lib/utils/services/org';
import { blockedSubdomain } from '$lib/utils/constants/app';
import { newOrgModal } from '../store';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import { createOrgValidation } from '$lib/utils/functions/validator';
type Error = {
@@ -93,10 +92,7 @@
return;
}
- $snackbarStore.open = true;
- $snackbarStore.message = 'Org created Successfully';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
-
+ snackbar.success();
await getOrganizations($profile.id);
resetForm();
diff --git a/src/lib/components/Org/Quiz/NewQuizModal.svelte b/src/lib/components/Org/Quiz/NewQuizModal.svelte
index 45f2b0c9..819445da 100644
--- a/src/lib/components/Org/Quiz/NewQuizModal.svelte
+++ b/src/lib/components/Org/Quiz/NewQuizModal.svelte
@@ -3,8 +3,7 @@
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import Modal from '$lib/components/Modal/index.svelte';
import TextField from '$lib/components/Form/TextField.svelte';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import { supabase } from '$lib/utils/functions/supabase';
import { currentOrg, createQuizModal, currentOrgPath, quizesStore } from '$lib/utils/store/org';
import { createQuizValidation } from '$lib/utils/functions/validator';
@@ -23,9 +22,7 @@
}
function errorNotification() {
- $snackbarStore.message = "Something's not right - Please try later";
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.open = true;
+ snackbar.error();
}
async function createQuiz() {
diff --git a/src/lib/components/Org/Quiz/Quizzes.svelte b/src/lib/components/Org/Quiz/Quizzes.svelte
index 8c711a5c..15d23996 100644
--- a/src/lib/components/Org/Quiz/Quizzes.svelte
+++ b/src/lib/components/Org/Quiz/Quizzes.svelte
@@ -4,8 +4,7 @@
import QuizLoader from './Loader.svelte';
import QuizCard from './QuizCard.svelte';
import CoursesEmptyIcon from '$lib/components/Icons/CoursesEmptyIcon.svelte';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import { supabase } from '$lib/utils/functions/supabase';
import { currentOrg, quizesStore } from '$lib/utils/store/org';
@@ -22,9 +21,7 @@
.order('updated_at', { ascending: false });
if (error) {
- $snackbarStore.message = "Something's not right - Please try later";
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.open = true;
+ snackbar.error();
return;
}
console.log('data', data);
@@ -35,9 +32,7 @@
$: fetchQuizes($currentOrg.id);
-
+
{#if isLoading}
diff --git a/src/lib/components/Org/Settings/Domains.svelte b/src/lib/components/Org/Settings/Domains.svelte
index 531386a3..f997c827 100644
--- a/src/lib/components/Org/Settings/Domains.svelte
+++ b/src/lib/components/Org/Settings/Domains.svelte
@@ -8,8 +8,7 @@
import { currentOrg } from '$lib/utils/store/org';
import { supabase } from '$lib/utils/functions/supabase';
import { blockedSubdomain } from '$lib/utils/constants/app';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import SectionTitle from '../SectionTitle.svelte';
import VisitOrgSiteButton from '$lib/components/Buttons/VisitOrgSite.svelte';
@@ -34,9 +33,7 @@
console.log('Error: create organisation', error);
errors = 'Sitename already exists.';
} else {
- $snackbarStore.open = true;
- $snackbarStore.message = 'Success';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
+ snackbar.success();
$currentOrg.siteName = siteName;
goto(`/org/${$currentOrg.siteName}/settings/domains`);
diff --git a/src/lib/components/Org/Settings/Integrations.svelte b/src/lib/components/Org/Settings/Integrations.svelte
index bdd4d302..c96dbd18 100644
--- a/src/lib/components/Org/Settings/Integrations.svelte
+++ b/src/lib/components/Org/Settings/Integrations.svelte
@@ -3,8 +3,7 @@
import CheckmarkFilled from 'carbon-icons-svelte/lib/CheckmarkFilled.svelte';
import { supabase } from '$lib/utils/functions/supabase';
import { profile } from '$lib/utils/store/user';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
- import { snackbarStore } from '$lib/components/Snackbar/store';
+ import { snackbar } from '$lib/components/Snackbar/store';
import TextField from '$lib/components/Form/TextField.svelte';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
@@ -14,54 +13,37 @@
let chatId: number | null;
async function addChatId() {
- const updates = {
- telegram_chat_id: chatId
- };
- if ($profile.telegram_chat_id === null) {
- let { error } = await supabase.from('profile').update(updates).match({ id: $profile.id });
- // Update the telegram_chat_id in the profile store with the value from the TextField
- profile.update((profileData) => ({
- ...profileData,
- ...updates
- }));
- // Clear the chatId variable after updating the store
- chatId = null;
+ if (!chatId || `${chatId}`.length < 5) return;
- if (error) {
- $snackbarStore.open = true;
- $snackbarStore.message = 'Integration Failed, please try again later';
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- console.log(error);
- } else {
- $snackbarStore.open = true;
- $snackbarStore.message = 'Integration successful';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
- }
+ const { error } = await supabase
+ .from('profile')
+ .update({
+ telegram_chat_id: chatId
+ })
+ .match({ id: $profile.id });
+
+ if (error) {
+ console.log(error);
+ snackbar.error('Integration Failed, please try again later');
+ } else {
+ $profile.telegram_chat_id = chatId;
+ chatId = null;
+ snackbar.success('Integration successful');
}
}
async function deleteChatId() {
- const updates = {
- telegram_chat_id: null
- };
- let { error } = await supabase.from('profile').update(updates).match({ id: $profile.id });
- if (typeof $profile.telegram_chat_id !== null) {
- profile.update((profileData) => ({
- ...profileData,
- telegram_chat_id: null
- }));
+ const { error } = await supabase
+ .from('profile')
+ .update({ telegram_chat_id: null })
+ .match({ id: $profile.id });
- if (error) {
- $snackbarStore.open = true;
- $snackbarStore.message = 'Deletion Failed, please try again later';
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- console.log(error);
- } else {
- // Show a success message in the snackbar
- $snackbarStore.open = true;
- $snackbarStore.message = 'Integration deleted';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
- }
+ if (error) {
+ snackbar.error('Deletion Failed, please try again later');
+ console.log(error);
+ } else {
+ $profile.telegram_chat_id = null;
+ snackbar.success('Integration deleted');
}
}
diff --git a/src/lib/components/Org/Settings/LandingpageSettings.svelte b/src/lib/components/Org/Settings/LandingpageSettings.svelte
index b3795c32..120ba7b9 100644
--- a/src/lib/components/Org/Settings/LandingpageSettings.svelte
+++ b/src/lib/components/Org/Settings/LandingpageSettings.svelte
@@ -10,8 +10,7 @@
import TextArea from '$lib/components/Form/TextArea.svelte';
import { currentOrg } from '$lib/utils/store/org';
import { getSupabase } from '$lib/utils/functions/supabase';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import { FileUploader } from 'carbon-components-svelte';
import { landingPageSettings } from './store';
import type { OrgLandingPageJson } from './store';
@@ -101,26 +100,21 @@
};
async function handleSave() {
isSaving = true;
- $landingPageSettings.footer.twitter = checkPrefix($landingPageSettings.footer.twitter);
- $landingPageSettings.footer.linkedin = checkPrefix($landingPageSettings.footer.linkedin);
- $landingPageSettings.footer.facebook = checkPrefix($landingPageSettings.footer.facebook);
- console.log($landingPageSettings.footer.twitter);
- const { data, error } = await supabase
+ $landingPageSettings.footer.twitter = checkPrefix($landingPageSettings.footer.twitter) || '';
+ $landingPageSettings.footer.linkedin = checkPrefix($landingPageSettings.footer.linkedin) || '';
+ $landingPageSettings.footer.facebook = checkPrefix($landingPageSettings.footer.facebook) || '';
+
+ const { error } = await supabase
.from('organization')
.update({ landingpage: $landingPageSettings })
.match({ id: $currentOrg.id });
if (error) {
- let message = error?.message || 'Please try again';
-
- $snackbarStore.open = true;
- $snackbarStore.message = `Update failed: ${message}`;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
+ const message = error?.message || 'Please try again';
+ snackbar.error(`Update failed: ${message}`);
} else {
$currentOrg.landingpage = $landingPageSettings;
- $snackbarStore.open = true;
- $snackbarStore.message = 'Saved successful';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
+ snackbar.success();
}
isSaving = false;
diff --git a/src/lib/components/Org/Settings/OrgSettings.svelte b/src/lib/components/Org/Settings/OrgSettings.svelte
index 7e4cf2fc..fe77c09e 100644
--- a/src/lib/components/Org/Settings/OrgSettings.svelte
+++ b/src/lib/components/Org/Settings/OrgSettings.svelte
@@ -6,8 +6,7 @@
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
import UploadImage from '$lib/components/UploadImage/index.svelte';
import { supabase } from '$lib/utils/functions/supabase';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import { currentOrg, currentOrgPath } from '$lib/utils/store/org';
import SectionTitle from '../SectionTitle.svelte';
@@ -73,9 +72,8 @@
..._currentOrg,
...updates
}));
- $snackbarStore.open = true;
- $snackbarStore.message = 'Update successful';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
+
+ snackbar.success('Update successful');
if (error) throw error;
} catch (error) {
@@ -83,9 +81,8 @@
if (message.includes('profile_username_key')) {
message = 'username already exists';
}
- $snackbarStore.open = true;
- $snackbarStore.message = `Update failed: ${message}`;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
+
+ snackbar.error(`Update failed: ${message}`);
loading = false;
} finally {
loading = false;
diff --git a/src/lib/components/Org/Settings/Profile.svelte b/src/lib/components/Org/Settings/Profile.svelte
index 378dbb88..63737fa7 100644
--- a/src/lib/components/Org/Settings/Profile.svelte
+++ b/src/lib/components/Org/Settings/Profile.svelte
@@ -8,8 +8,7 @@
import UploadImage from '$lib/components/UploadImage/index.svelte';
import { supabase } from '$lib/utils/functions/supabase';
import { profile } from '$lib/utils/store/user';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
let avatar;
let loading = false;
@@ -51,9 +50,7 @@
..._profile,
...updates
}));
- $snackbarStore.open = true;
- $snackbarStore.message = 'Update successful';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
+ snackbar.success('Update successful');
if (error) throw error;
} catch (error) {
@@ -61,9 +58,7 @@
if (message.includes('profile_username_key')) {
message = 'username already exists';
}
- $snackbarStore.open = true;
- $snackbarStore.message = `Update failed: ${message}`;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
+ snackbar.success(`Update failed: ${message}`);
loading = false;
} finally {
loading = false;
diff --git a/src/lib/components/Org/Settings/TeamMembers.svelte b/src/lib/components/Org/Settings/TeamMembers.svelte
index b7fb4108..2a036602 100644
--- a/src/lib/components/Org/Settings/TeamMembers.svelte
+++ b/src/lib/components/Org/Settings/TeamMembers.svelte
@@ -9,8 +9,7 @@
import { validateEmailInString } from '$lib/utils/functions/validator';
import { ROLE_LABEL, ROLE } from '$lib/utils/constants/roles';
import { currentOrg, orgTeam } from '$lib/utils/store/org';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import { getOrgTeam } from '$lib/utils/services/org';
import { profile } from '$lib/utils/store/user';
import { supabase } from '$lib/utils/functions/supabase';
@@ -51,10 +50,7 @@
apiError = error;
console.error('onSendInvite:', error);
- $snackbarStore.open = true;
- $snackbarStore.message = `Failed to send invite, please try again`;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
-
+ snackbar.error(`Failed to send invite, please try again`);
isLoading = false;
return;
}
@@ -81,9 +77,7 @@
const isLast = index === emails.length - 1;
if (isLast) {
- $snackbarStore.open = true;
- $snackbarStore.message = 'Success';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
+ snackbar.success('Success');
emailsStr = '';
isLoading = false;
@@ -98,9 +92,7 @@
if (error) {
console.error('onRemove:', error);
- $snackbarStore.open = true;
- $snackbarStore.message = `Failed to remove user, please try again`;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
+ snackbar.error('Failed to remove user, please try again');
} else {
orgTeam.update((team) => [...team.filter((member) => member.id !== id)]);
}
diff --git a/src/lib/components/Snackbar/store.js b/src/lib/components/Snackbar/store.js
index f49c77be..38a4f1b5 100644
--- a/src/lib/components/Snackbar/store.js
+++ b/src/lib/components/Snackbar/store.js
@@ -6,7 +6,28 @@ export const snackbarStoreInitialState = {
message: '',
severity: SNACKBAR_SEVERITY.DEFAULT,
handleClose: () => {},
- autoHideDuration: 6000,
+ autoHideDuration: 6000
};
export const snackbarStore = writable({ ...snackbarStoreInitialState });
+
+export const snackbar = {
+ success(message = 'Success') {
+ snackbarStore.update((store) => {
+ store.open = true;
+ store.message = message;
+ store.severity = SNACKBAR_SEVERITY.SUCCESS;
+
+ return store;
+ });
+ },
+ error(message = 'Something went wrong - Please try later') {
+ snackbarStore.update((store) => {
+ store.open = true;
+ store.message = message;
+ store.severity = SNACKBAR_SEVERITY.ERROR;
+
+ return store;
+ });
+ }
+};
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 083a51f1..ff4f62b7 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -45,7 +45,7 @@
let supabase = getSupabase();
let path = $page.url?.pathname?.replace('/', '');
- let theme = 'white';
+ let carbonTheme = 'white';
const delayedPreloading = derived(navigating, (currentPreloading, set) => {
setTimeout(() => set(currentPreloading), 250);
@@ -166,7 +166,7 @@
if (data.isOrgSite) {
if (params.has('redirect')) {
goto(params.get('redirect') || '');
- } else {
+ } else if (!path.includes('lms')) {
goto('/lms');
}
} else {
@@ -179,10 +179,9 @@
// By default redirect to first organization
goto(`/org/${orgRes.currentOrg.siteName}`);
}
-
- if (typeof orgRes?.currentOrg?.theme === 'string') {
- setTheme(orgRes.currentOrg.theme);
- }
+ }
+ if (typeof orgRes?.currentOrg?.theme === 'string') {
+ setTheme(orgRes.currentOrg.theme);
}
}
}
@@ -197,11 +196,6 @@
$page.url.host,
`\nIs student domain: ${data.isOrgSite}`
);
- // Disable GA on localhost
- if (dev) {
- console.log('disable GA');
- window['ga-disable-G-C7WBN0S06R'] = true;
- }
if (browser) {
// Update theme - dark or light mode
@@ -209,7 +203,11 @@
toggleBodyByMode($appStore.isDark);
const theme = localStorage.getItem('theme');
- if (theme) setTheme(theme);
+ if (data.isOrgSite && data.org?.theme) {
+ setTheme(data.org?.theme);
+ } else if (theme) {
+ setTheme(theme);
+ }
}
setupSentry();
@@ -250,7 +248,6 @@
});
if (data.isOrgSite) {
- console.log('data', data);
if (!data.org) {
goto('/404');
} else {
@@ -258,18 +255,19 @@
$appStore.isOrgSite = data.isOrgSite;
currentOrg.set(data.org);
- setTheme(data.org.theme);
}
}
return () => {
console.log('unsubscribed');
- authListener?.unsubscribe();
+ if (typeof authListener?.unsubscribe === 'function') {
+ authListener?.unsubscribe();
+ }
};
});
$: path = $page.url?.pathname?.replace('/', '');
- $: theme = $appStore.isDark ? 'g100' : 'white';
+ $: carbonTheme = $appStore.isDark ? 'g100' : 'white';
@@ -278,7 +276,7 @@
-
+
diff --git a/src/routes/courses/[id]/attendance/+page.svelte b/src/routes/courses/[id]/attendance/+page.svelte
index fe58149a..07db2447 100644
--- a/src/routes/courses/[id]/attendance/+page.svelte
+++ b/src/routes/courses/[id]/attendance/+page.svelte
@@ -21,14 +21,12 @@
import { lessons } from '$lib/components/Course/components/Lesson/store/lessons';
import { ROLE } from '$lib/utils/constants/roles';
import { takeAttendance } from '$lib/utils/services/attendance';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import { attendance } from '$lib/utils/store/attendance';
import { profile } from '$lib/utils/store/user';
export let data;
- let borderBottomGrey = 'border-r-0 border-b border-l-0 border-gray-300';
let students = [];
let isStudent;
let searchValue = '';
@@ -65,12 +63,8 @@
This validation is useless. We shouldn't assume we already have an attendance item id
because it might be a new attendance.
if (!attendanceItem.id) {
- $snackbarStore.open = true;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.message =
- "Something isn't right. Please reload and take attendance again";
+ snackbar.error("Something isn't right. Please reload and take attendance again");
console.error(`Attendance Id Missing`, courseId, student.id, lesson.id);
-
return;
}
*/
@@ -86,9 +80,7 @@
takeAttendance(_data).then((res) => {
if (res.error) {
console.error(`res.error`, res.error);
- $snackbarStore.open = true;
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.message = "Something isn't right. Please reload and take attendance again";
+ snackbar.error("Something isn't right. Please reload and take attendance again");
} else {
// console.log('res', JSON.stringify(res));
const { id, is_present } = res.data[0];
diff --git a/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte b/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte
index f504ecb0..32874efa 100644
--- a/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte
+++ b/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte
@@ -24,8 +24,7 @@
} from '$lib/components/Course/components/Lesson/store/lessons';
import { browser } from '$app/environment';
import { currentOrg } from '$lib/utils/store/org';
- import { snackbarStore } from '$lib/components/Snackbar/store';
- import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
+ import { snackbar } from '$lib/components/Snackbar/store';
import type { LessonCompletion, LessonPage } from '$lib/utils/types';
import { profile } from '$lib/utils/store/user.js';
import { getIsLessonComplete } from '$lib/components/Course/components/Lesson/functions';
@@ -157,14 +156,10 @@
a.click();
a.remove();
- $snackbarStore.message = 'Download Complete';
- $snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
- $snackbarStore.open = true;
+ snackbar.success('Download Complete');
} catch (error) {
console.log('error downloading lesson', error);
- $snackbarStore.message = "Something's not right - Please try later";
- $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
- $snackbarStore.open = true;
+ snackbar.error("Something's not right - Please try later");
}
isLoading = false;
diff --git a/src/routes/courses/[id]/people/+page.svelte b/src/routes/courses/[id]/people/+page.svelte
index 16b0fcbd..e481c409 100644
--- a/src/routes/courses/[id]/people/+page.svelte
+++ b/src/routes/courses/[id]/people/+page.svelte
@@ -1,11 +1,9 @@