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
@@ -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;