From 734444fddc35b1a32b4549825fb779f4a9a297b0 Mon Sep 17 00:00:00 2001 From: Felix Ruf Date: Wed, 31 Jul 2024 17:30:45 +0200 Subject: [PATCH] fixed several typing issues --- .../src/api/getParticipationsByDay.ts | 2 +- .../src/components/dashboard/Day.vue | 21 ++++++++++++------- .../src/components/dashboard/EventData.vue | 6 +++--- .../src/components/dashboard/Week.vue | 8 +++---- .../eventParticipation/EventPopup.vue | 2 +- .../menu/MenuDishVariationsCombobox.vue | 3 +-- src/Resources/src/stores/eventsStore.ts | 14 +++++++------ src/Resources/src/types/VueTabs.ts | 6 ++++++ 8 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 src/Resources/src/types/VueTabs.ts diff --git a/src/Resources/src/api/getParticipationsByDay.ts b/src/Resources/src/api/getParticipationsByDay.ts index 041975c8b..2e317160c 100644 --- a/src/Resources/src/api/getParticipationsByDay.ts +++ b/src/Resources/src/api/getParticipationsByDay.ts @@ -27,7 +27,7 @@ export function useParticipationsListData(date: string) { await request(); loaded.value = true; - listDataState.value = listData.value; + listDataState.value = listData.value as string[]; } } return { diff --git a/src/Resources/src/components/dashboard/Day.vue b/src/Resources/src/components/dashboard/Day.vue index f7d204ef9..ecd6ae774 100644 --- a/src/Resources/src/components/dashboard/Day.vue +++ b/src/Resources/src/components/dashboard/Day.vue @@ -7,7 +7,7 @@ :class="[day?.isLocked || !day?.isEnabled || (emptyDay && !isEventDay) ? 'bg-[#80909F]' : 'bg-primary-2']" > {{ weekday }} (); -const day = dashboardStore.getDay(props.weekID, props.dayID); -const weekday = computed(() => translateWeekday(day.date, locale)); -const emptyDay = Object.keys(day.meals).length === 0; -const isEventDay = day.event !== null; +const day = dashboardStore.getDay(props.weekID ?? -1, props.dayID ?? -1); +const weekday = computed(() => { + if (day !== undefined) { + return translateWeekday(day.date, locale) + } + return 'unknown' +}); +const emptyDay = Object.keys(day?.meals ?? {}).length === 0; +const isEventDay = day?.event !== null; const date = computed(() => { if (day === null || day === undefined) { return ''; diff --git a/src/Resources/src/components/dashboard/EventData.vue b/src/Resources/src/components/dashboard/EventData.vue index 8d5811a68..6c7b97179 100644 --- a/src/Resources/src/components/dashboard/EventData.vue +++ b/src/Resources/src/components/dashboard/EventData.vue @@ -17,11 +17,11 @@ - {{ getEventById(day.event.eventId)?.title }} + {{ getEventById(day?.event?.eventId ?? -1)?.title }}

- {{ (startLocale + ' - ' + endLocale).replaceAll(',', '') }} + {{ (startLocale + ' - ' + endLocale).replace(/,/g, '') }}

startDate.toLocaleDateString(locale.value, { weekday: 'short', month: 'numeric', day: 'numeric' }) ); -const endDate = new Date(week.endDate.date); +const endDate = new Date(week?.endDate?.date ?? ''); const endLocale = computed(() => endDate.toLocaleDateString(locale.value, { weekday: 'short', month: 'numeric', day: 'numeric' }) ); diff --git a/src/Resources/src/components/eventParticipation/EventPopup.vue b/src/Resources/src/components/eventParticipation/EventPopup.vue index fc32d83b3..ddc014ac3 100644 --- a/src/Resources/src/components/eventParticipation/EventPopup.vue +++ b/src/Resources/src/components/eventParticipation/EventPopup.vue @@ -77,7 +77,7 @@ const isLoading = ref(false); watch(showParticipations, async () => { if (showParticipations.value === true) { isLoading.value = true; - participations.value = await getParticipantsForEvent(props.date); + participations.value = (await getParticipantsForEvent(props.date)) as string[]; isLoading.value = false; } }); diff --git a/src/Resources/src/components/menu/MenuDishVariationsCombobox.vue b/src/Resources/src/components/menu/MenuDishVariationsCombobox.vue index 1632f3570..693825127 100644 --- a/src/Resources/src/components/menu/MenuDishVariationsCombobox.vue +++ b/src/Resources/src/components/menu/MenuDishVariationsCombobox.vue @@ -50,7 +50,7 @@ import { Listbox, ListboxButton, ListboxOptions, ListboxOption } from '@headlessui/vue'; import { useI18n } from 'vue-i18n'; import { computed } from 'vue'; -import { Dish } from '@/stores/dishesStore'; +import { type Dish } from '@/stores/dishesStore'; import { useWeeks } from '@/stores/weeksStore'; const { MenuCountState } = useWeeks(); @@ -63,7 +63,6 @@ const props = withDefaults( }>(), { modelValue: null, - dish: null } ); diff --git a/src/Resources/src/stores/eventsStore.ts b/src/Resources/src/stores/eventsStore.ts index e0f82db9c..9fc58ac3b 100644 --- a/src/Resources/src/stores/eventsStore.ts +++ b/src/Resources/src/stores/eventsStore.ts @@ -78,7 +78,7 @@ export function useEvents() { const { error, events } = await getEvents(); if (isResponseArrayOkay(error, events, isEvent) === true) { - EventsState.events = events.value; + EventsState.events = events.value as Event[]; EventsState.error = ''; } else { EventsState.error = 'Error on fetching events'; @@ -98,7 +98,7 @@ export function useEvents() { const { error, response } = await postCreateEvent(title, isPublic); if (error.value === true || isMessage(response.value) === true) { - EventsState.error = response.value?.message; + EventsState.error = (response.value as IMessage).message; return; } @@ -124,10 +124,12 @@ export function useEvents() { EventsState.error = (response.value as IMessage)?.message; } else if (error.value === false && isEvent(response.value as Event)) { const event = getEventBySlug(slug); - event.public = (response.value as Event).public; - event.title = (response.value as Event).title; - event.slug = (response.value as Event).slug; - event.id = (response.value as Event).id; + if (event !== undefined) { + event.public = (response.value as Event).public; + event.title = (response.value as Event).title; + event.slug = (response.value as Event).slug; + event.id = (response.value as Event).id; + } EventsState.error = ''; sendFlashMessage({ diff --git a/src/Resources/src/types/VueTabs.ts b/src/Resources/src/types/VueTabs.ts new file mode 100644 index 000000000..22bbb1b2e --- /dev/null +++ b/src/Resources/src/types/VueTabs.ts @@ -0,0 +1,6 @@ +declare module 'vue3-tabs' { + export const Tabs: any; + export const Tab: any; + export const TabPanels: any; + export const TabPanel: any; +} \ No newline at end of file