fix: snackbar for profile component (#588)

This commit is contained in:
Adeyemi Adetunji
2025-10-31 18:28:52 +01:00
committed by GitHub
parent 8efffcb7f6
commit 97fb446df5
2 changed files with 12 additions and 10 deletions
@@ -58,12 +58,13 @@
if (error) throw error;
} catch (error) {
let message = error.message;
let message = error instanceof Error ? error.message : `${error}`;
if (message.includes('profile_username_key')) {
message = $t('username already exists');
}
snackbar.error(`snackbar.lms.error.update: ${message}`);
snackbar.error(`${$t('snackbar.lms.error.update')}: ${message}`);
loading = false;
} finally {
loading = false;
@@ -73,18 +74,18 @@
$: locale = $profile.locale;
</script>
<Grid class="border-c rounded border-gray-200 dark:border-neutral-600 w-full mt-5">
<Row class="flex flex-col lg:flex-row items-center lg:items-start py-7 border-bottom-c ">
<Grid class="border-c mt-5 w-full rounded border-gray-200 dark:border-neutral-600">
<Row class="border-bottom-c flex flex-col items-center py-7 lg:flex-row lg:items-start ">
<Column sm={4} md={8} lg={4} class="mt-2 md:mt-0">
<p class="dark:text-white font-bold">{$t('settings.profile.profile_picture.heading')}</p>
<p class="font-bold dark:text-white">{$t('settings.profile.profile_picture.heading')}</p>
</Column>
<Column sm={2} md={4} lg={8} class="mt-2 lg:mt-0">
<UploadImage bind:avatar src={$profile.avatar_url} widthHeight="w-16 h-16 lg:w-24 lg:h-24" />
</Column>
</Row>
<Row class="flex flex-col lg:flex-row py-7 border-bottom-c">
<Row class="border-bottom-c flex flex-col py-7 lg:flex-row">
<Column sm={4} md={4} lg={4}>
<p class="dark:text-white font-bold">{$t('settings.profile.personal_information.heading')}</p>
<p class="font-bold dark:text-white">{$t('settings.profile.personal_information.heading')}</p>
</Column>
<Column sm={8} md={8} lg={8} class="mt-2 lg:mt-0">
<TextField
@@ -110,7 +111,7 @@
/>
</Column>
</Row>
<Row class="m-5 w-full flex items-center gap-2 lg:justify-center">
<Row class="m-5 flex w-full items-center gap-2 lg:justify-center">
<PrimaryButton
label={$t('settings.profile.update_profile')}
variant={VARIANTS.CONTAINED_DARK}
@@ -71,11 +71,12 @@
hasUnsavedChanges = false;
if (error) throw error;
} catch (error) {
let message = error.message;
let message = error instanceof Error ? error.message : `${error}`;
if (message.includes('profile_username_key')) {
message = $t('snackbar.lms.error.username_exists');
}
snackbar.error(`${$t('snackbar.lms.error.update')} ${message}`);
snackbar.error(`${$t('snackbar.lms.error.update')}: ${message}`);
loading = false;
} finally {
loading = false;