Remove title field and rename color to message

This commit is contained in:
Maciej Pędzich 2023-05-27 12:30:07 +02:00
parent f8465276e3
commit 92e43959e6
4 changed files with 8 additions and 10 deletions

View File

@ -18,8 +18,7 @@ onMounted(async () => {
if (router.currentRoute.value.hash === '#login-success') {
localStorage.removeItem('redirectPath');
showSnackbar({
color: 'success',
title: 'Success',
status: 'success',
message: "You're logged in!"
});
}

View File

@ -1,11 +1,13 @@
<script lang="ts" setup>
import { useSnackbar } from '@/composables/useSnackbar';
import { computed } from 'vue';
const { visible, color, title, message } = useSnackbar();
const { visible, status, message } = useSnackbar();
const title = computed(() => (status.value === 'error' ? 'Error' : 'Success'));
</script>
<template>
<v-snackbar v-model="visible" :color="color" vertical>
<v-snackbar v-model="visible" :color="status" vertical>
<h6 class="text-h6 mb-1">{{ title }}</h6>
<p class="text-body-1">{{ message }}</p>
</v-snackbar>

View File

@ -2,14 +2,12 @@ import { reactive, toRefs } from 'vue';
interface Snackbar {
visible: boolean;
color: '' | 'error' | 'success';
title: string;
status: '' | 'error' | 'success';
message: string;
}
const snackbar = reactive<Snackbar>({
color: '',
title: '',
status: '',
message: '',
visible: false
});

View File

@ -12,8 +12,7 @@ const { showSnackbar } = useSnackbar();
onMounted(() => {
if (route.hash === '#login-error') {
showSnackbar({
color: 'error',
title: 'Error',
status: 'error',
message: 'Failed to log you in.'
});
}