Added toast on deleted entities

This commit is contained in:
Alexis
2024-09-08 19:26:38 +02:00
parent a69553e089
commit 2f79de8483
9 changed files with 64 additions and 10 deletions

View File

@@ -1,7 +1,11 @@
<script lang="ts" setup>
import { PhCircleNotch } from "@phosphor-icons/vue";
import { useToast } from "~/components/ui/toast";
import type { Calendar } from "~/models/CalendarConfig";
const { toast } = useToast()
const { t } = useI18n()
const props = defineProps<{
modalState: boolean,
calendar: Calendar | null
@@ -19,11 +23,20 @@ async function handleAction(): Promise<void> {
try {
await $fetch(`/api/calendars/${props.calendar.id}`, { method: "DELETE" })
emit("on-close")
// isDeleteEventModalOpen.value = false
toast({
title: t("entity.calendar.deletedToast.title", { calendar: props.calendar.name }),
variant: "success",
duration: 3000
})
} catch (err) {
console.log(err)
if (err instanceof Error) {
// formErrors.message = err.message
toast({
title: err.message,
variant: "destructive"
})
}
} finally {
isLoading.value = false