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;
|
||||
|
||||
Reference in New Issue
Block a user