refactor snackbar
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex items-center justify-center lg:justify-start flex-wrap my-4 m-auto"
|
||||
>
|
||||
<div class="flex items-center justify-center lg:justify-start flex-wrap my-4 m-auto">
|
||||
{#if isLoading}
|
||||
<QuizLoader />
|
||||
<QuizLoader />
|
||||
|
||||
@@ -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`);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)]);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
+15
-17
@@ -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';
|
||||
</script>
|
||||
|
||||
<svelte:window on:resize={handleResize} />
|
||||
@@ -278,7 +276,7 @@
|
||||
<link href="/css/carbon.css" rel="stylesheet" />
|
||||
</svelte:head>
|
||||
|
||||
<Theme bind:theme />
|
||||
<Theme bind:theme={carbonTheme} />
|
||||
|
||||
<Snackbar />
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<script lang="ts">
|
||||
import TextChip from '$lib/components/Chip/Text.svelte';
|
||||
import ComingSoon from '$lib/components/ComingSoon/index.svelte';
|
||||
import Filter from 'carbon-icons-svelte/lib/Filter.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import {
|
||||
Pagination,
|
||||
CopyButton,
|
||||
Search,
|
||||
StructuredList,
|
||||
@@ -33,7 +31,7 @@
|
||||
import type { Person, ProfileRole } from '$lib/components/Course/components/People/types';
|
||||
import { ROLE_LABEL, ROLES } from '$lib/utils/constants/roles';
|
||||
import { profile } from '$lib/utils/store/user';
|
||||
import { snackbarStore } from '$lib/components/Snackbar/store';
|
||||
import { snackbar } from '$lib/components/Snackbar/store';
|
||||
import Avatar from '$lib/components/Avatar/index.svelte';
|
||||
|
||||
export let data;
|
||||
@@ -101,8 +99,7 @@
|
||||
}
|
||||
|
||||
function copyToClipboard(studentAssignedId: string | null) {
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = `Copied to clipboard`;
|
||||
snackbar.success(`Copied to clipboard`);
|
||||
|
||||
if (studentAssignedId) {
|
||||
copy(studentAssignedId);
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
updateQuestionAnswer
|
||||
} from '$lib/utils/services/submissions';
|
||||
import { formatAnswers } from '$lib/components/Course/function';
|
||||
import { snackbarStore } from '$lib/components/Snackbar/store';
|
||||
import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
|
||||
import { snackbar } from '$lib/components/Snackbar/store';
|
||||
import isSubmissionEarly from '$lib/utils/functions/isSubmissionEarly';
|
||||
import formatDate from '$lib/utils/functions/formatDate';
|
||||
|
||||
@@ -157,9 +156,7 @@
|
||||
total: totalPoints
|
||||
}).then((res) => console.log('Updated submission', res));
|
||||
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = `Saved successfully`;
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
|
||||
snackbar.success();
|
||||
|
||||
await Promise.all(updates);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
askCommunityValidation,
|
||||
commentInCommunityValidation
|
||||
} from '$lib/utils/functions/validator';
|
||||
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 DeleteCommentModal from '$lib/components/Org/Community/DeleteCommentModal.svelte';
|
||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||
@@ -133,16 +132,11 @@
|
||||
|
||||
if (error) {
|
||||
console.error('Error: commenting', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error('Error - Please try again later');
|
||||
} else {
|
||||
console.log('Success: commenting', data);
|
||||
|
||||
// Notification
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Success';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
|
||||
snackbar.success();
|
||||
|
||||
// Add to comment
|
||||
const _c = data?.[0];
|
||||
@@ -189,9 +183,7 @@
|
||||
const { error } = await supabase.from(table).update({ votes }).match({ id: matchId });
|
||||
if (error) {
|
||||
console.error('Error: upvoteQuestion', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error();
|
||||
} else {
|
||||
if (isQuestion) {
|
||||
voted.question = true;
|
||||
@@ -229,9 +221,7 @@
|
||||
.match({ id: question.id });
|
||||
if (error) {
|
||||
console.error('Error: handleQuestionEdit', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error();
|
||||
} else {
|
||||
question.title = fields.title;
|
||||
question.body = fields.body;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
||||
import { askCommunityValidation } from '$lib/utils/functions/validator';
|
||||
import { supabase } from '$lib/utils/functions/supabase';
|
||||
import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
|
||||
import { snackbarStore } from '$lib/components/Snackbar/store';
|
||||
import { snackbar } from '$lib/components/Snackbar/store';
|
||||
import generateSlug from '$lib/utils/functions/generateSlug';
|
||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||
|
||||
@@ -37,14 +36,10 @@
|
||||
|
||||
if (error) {
|
||||
console.error('Error: asking question', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error();
|
||||
} else {
|
||||
console.log('Success: asking question', question);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Success';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
|
||||
snackbar.success();
|
||||
|
||||
goto(`/lms/community/${question[0].slug}`);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,11 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { flip } from 'svelte/animate';
|
||||
import { dndzone } from 'svelte-dnd-action';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import PageNav from '$lib/components/PageNav/index.svelte';
|
||||
import RoleBasedSecurity from '$lib/components/RoleBasedSecurity/index.svelte';
|
||||
import MarkExerciseModal from '$lib/components/Course/components/Lesson/Exercise/MarkExerciseModal.svelte';
|
||||
import Chip from '$lib/components/Chip/index.svelte';
|
||||
import PageBody from '$lib/components/PageBody/index.svelte';
|
||||
import CourseContainer from '$lib/components/CourseContainer/index.svelte';
|
||||
import { fetchCourse } from '$lib/utils/services/courses';
|
||||
import { setCourse, course } from '$lib/components/Course/store';
|
||||
import {
|
||||
fetchSubmissions,
|
||||
updateSubmission,
|
||||
updateQuestionAnswer
|
||||
} from '$lib/utils/services/submissions';
|
||||
import { formatAnswers } from '$lib/components/Course/function';
|
||||
import { snackbarStore } from '$lib/components/Snackbar/store';
|
||||
import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
|
||||
import isSubmissionEarly from '$lib/utils/functions/isSubmissionEarly';
|
||||
import formatDate from '$lib/utils/functions/formatDate';
|
||||
|
||||
const flipDurationMs = 300;
|
||||
|
||||
// export let data;
|
||||
// const { courseId } = data;
|
||||
let items;
|
||||
|
||||
let sections = [
|
||||
{
|
||||
id: 1,
|
||||
@@ -124,24 +101,6 @@
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
// // Update backend
|
||||
// if (itemToWithNewStatus) {
|
||||
// // Update key mapping for each submission also
|
||||
// submissionIdData[itemToWithNewStatus.id] = {
|
||||
// ...submissionIdData[itemToWithNewStatus.id],
|
||||
// status_id: itemToWithNewStatus.statusId
|
||||
// };
|
||||
// console.log(
|
||||
// `submissionIdData[itemToWithNewStatus.id]`,
|
||||
// submissionIdData[itemToWithNewStatus.id]
|
||||
// );
|
||||
|
||||
// updateSubmission({
|
||||
// id: itemToWithNewStatus.id,
|
||||
// status_id: itemToWithNewStatus.statusId
|
||||
// }).then((res) => console.log('Updated submission', res));
|
||||
// }
|
||||
}
|
||||
|
||||
function handleDndConsiderCards(columnIdx) {
|
||||
@@ -204,17 +163,12 @@
|
||||
class="flex w-full items-center cursor-pointer text-black mb-2"
|
||||
href={`${$page.url.pathname}?submissionId=${item.id}`}
|
||||
>
|
||||
<!-- <img
|
||||
alt="Student avatar"
|
||||
class="block rounded-full h-6 w-6"
|
||||
src={item.student.avatar_url}
|
||||
/> -->
|
||||
<p class="dark:text-white ml-2 text-sm">
|
||||
{item.student.username}
|
||||
</p>
|
||||
</a>
|
||||
<a
|
||||
class="text-primary-700 text-md font-bold"
|
||||
class="text-primary-700 dark:text-white text-md font-bold"
|
||||
href="{$page.url.pathname}?submissionId={item.id}"
|
||||
>
|
||||
{item.exercise.title}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
askCommunityValidation,
|
||||
commentInCommunityValidation
|
||||
} from '$lib/utils/functions/validator';
|
||||
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 DeleteCommentModal from '$lib/components/Org/Community/DeleteCommentModal.svelte';
|
||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||
@@ -132,16 +131,11 @@
|
||||
|
||||
if (error) {
|
||||
console.error('Error: commenting', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error('Error - Please try again later');
|
||||
} else {
|
||||
console.log('Success: commenting', data);
|
||||
|
||||
// Notification
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Success';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
|
||||
snackbar.success('Success');
|
||||
|
||||
// Add to comment
|
||||
const _c = data?.[0];
|
||||
@@ -188,9 +182,7 @@
|
||||
const { error } = await supabase.from(table).update({ votes }).match({ id: matchId });
|
||||
if (error) {
|
||||
console.error('Error: upvoteQuestion', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error('Error - Please try again later');
|
||||
} else {
|
||||
if (isQuestion) {
|
||||
voted.question = true;
|
||||
@@ -228,9 +220,7 @@
|
||||
.match({ id: question.id });
|
||||
if (error) {
|
||||
console.error('Error: handleQuestionEdit', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error('Error - Please try again later');
|
||||
} else {
|
||||
question.title = fields.title;
|
||||
question.body = fields.body;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
||||
import { askCommunityValidation } from '$lib/utils/functions/validator';
|
||||
import { supabase } from '$lib/utils/functions/supabase';
|
||||
import { SNACKBAR_SEVERITY } from '$lib/components/Snackbar/constants';
|
||||
import { snackbarStore } from '$lib/components/Snackbar/store';
|
||||
import { snackbar } from '$lib/components/Snackbar/store';
|
||||
import generateSlug from '$lib/utils/functions/generateSlug';
|
||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||
|
||||
@@ -37,15 +36,10 @@
|
||||
|
||||
if (error) {
|
||||
console.error('Error: asking question', error);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Error - Please try again later';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.ERROR;
|
||||
snackbar.error('Error - Please try again later');
|
||||
} else {
|
||||
console.log('Success: asking question', question);
|
||||
$snackbarStore.open = true;
|
||||
$snackbarStore.message = 'Success';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
|
||||
|
||||
snackbar.success('Success');
|
||||
goto(`${$currentOrgPath}/community/${question[0].slug}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
import DeleteModal from '$lib/components/Org/Quiz/DeleteModal.svelte';
|
||||
import Preview from '$lib/components/Org/Quiz/Play/Preview.svelte';
|
||||
import QuizQuestion from '$lib/components/Org/Quiz/QuizQuestion.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';
|
||||
|
||||
export let data;
|
||||
@@ -147,14 +146,10 @@
|
||||
console.log('data', data);
|
||||
console.log('error', error);
|
||||
if (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");
|
||||
return;
|
||||
} else {
|
||||
$snackbarStore.message = 'Saved Successfully';
|
||||
$snackbarStore.severity = SNACKBAR_SEVERITY.SUCCESS;
|
||||
$snackbarStore.open = true;
|
||||
snackbar.success('Saved Successfully');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user