refactor snackbar

This commit is contained in:
Rotimi Best
2023-09-27 05:35:06 +01:00
parent ff2ba21de1
commit a391af49a3
26 changed files with 143 additions and 304 deletions
+5 -15
View File
@@ -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;