From 6a68105a0f6eb9a8c00481264965729aeb68c0ca Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Wed, 27 Nov 2024 14:07:18 +0100 Subject: [PATCH] Added toast when navigating out of bounds of event pages --- components/calendar/CalendarMenuSubnav.vue | 11 ++++++++++- i18n.config.ts | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/components/calendar/CalendarMenuSubnav.vue b/components/calendar/CalendarMenuSubnav.vue index 172de20..3b0d7d0 100644 --- a/components/calendar/CalendarMenuSubnav.vue +++ b/components/calendar/CalendarMenuSubnav.vue @@ -2,9 +2,13 @@ import { type RPGDate } from "@/models/Date" import { PhArrowLineLeft, PhArrowLineRight } from "@phosphor-icons/vue" +import { useToast } from "../ui/toast"; const { currentDate, currentConfig, jumpToDate, getRelativeEventFromDate } = useCalendar() +const { toast } = useToast() +const { t } = useI18n() + function handleGotoPreviousEventPage(position: "next" | "prev" = "next") { let fromDate: RPGDate @@ -55,7 +59,12 @@ function handleGotoPreviousEventPage(position: "next" | "prev" = "next") { jumpToDate(targetDate) } catch (err) { - console.log(err) + toast({ + title: t("entity.calendar.event.outOfBoundsTitle"), + variant: "default", + description: t("entity.calendar.event.outOfBoundsMessage"), + duration: 4000, + }) } } diff --git a/i18n.config.ts b/i18n.config.ts index f00c1b2..2955061 100644 --- a/i18n.config.ts +++ b/i18n.config.ts @@ -136,6 +136,8 @@ export default defineI18nConfig(() => ({ addLocation: "Add a place", prevPage: "Previous page with events", nextPage: "Next page with events", + outOfBoundsTitle: "No next or previous events were found", + outOfBoundsMessage: "Maybe the event is the first or last one ?", patterns: { title: "Between 3 and 120 caracters.", description: "1200 caracters max.", @@ -355,6 +357,8 @@ export default defineI18nConfig(() => ({ addLocation: "Ajouter un endroit", prevPage: "Précédente page à évènements", nextPage: "Prochaine page à évènements", + outOfBoundsTitle: "Aucun évènement suivant ou précédent trouvé", + outOfBoundsMessage: "Peut-être l'évènement se situe au début ou à la fin du calendrier ?", patterns: { title: "Entre 3 et 120 charactères.", description: "Maximum 1200 charactères.",