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') { if (router.currentRoute.value.hash === '#login-success') {
localStorage.removeItem('redirectPath'); localStorage.removeItem('redirectPath');
showSnackbar({ showSnackbar({
color: 'success', status: 'success',
title: 'Success',
message: "You're logged in!" message: "You're logged in!"
}); });
} }

View File

@ -1,11 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useSnackbar } from '@/composables/useSnackbar'; 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> </script>
<template> <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> <h6 class="text-h6 mb-1">{{ title }}</h6>
<p class="text-body-1">{{ message }}</p> <p class="text-body-1">{{ message }}</p>
</v-snackbar> </v-snackbar>

View File

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

View File

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