Skip to content

Commit

Permalink
fixed several typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Ruf committed Jul 31, 2024
1 parent a180878 commit 734444f
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Resources/src/api/getParticipationsByDay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 13 additions & 8 deletions src/Resources/src/components/dashboard/Day.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
:class="[day?.isLocked || !day?.isEnabled || (emptyDay && !isEventDay) ? 'bg-[#80909F]' : 'bg-primary-2']"
>
<InformationButton
v-if="!day.isLocked && !emptyDay"
v-if="!day?.isLocked && !emptyDay"
:dayID="dayID"
:index="index"
class="hover: row-start-1 size-[24px] cursor-pointer p-1 text-center"
@click="openModal"
/>
<span
class="row-start-2 rotate-180 place-self-center text-center text-[11px] font-bold uppercase leading-4 tracking-[3px] text-white [writing-mode:vertical-lr]"
:class="day.isLocked || emptyDay ? '' : 'pb-[0px]'"
:class="day?.isLocked || emptyDay ? '' : 'pb-[0px]'"
>
{{ weekday }}
</span>
<GuestButton
v-if="!day.isLocked && !emptyDay && day.isEnabled"
v-if="!day?.isLocked && !emptyDay && day?.isEnabled && dayID && index"
:dayID="dayID"
:index="index"
:invitation="Invitation.MEAL"
Expand Down Expand Up @@ -90,7 +90,7 @@
</span>
</div>
<EventData
v-if="isEventDay"
v-if="isEventDay && day && dayID"
class="col-start-2 row-start-2 print:hidden"
:day="day"
:dayId="dayID"
Expand Down Expand Up @@ -122,10 +122,15 @@ const props = defineProps<{
index?: number;
}>();
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 '';
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/src/components/dashboard/EventData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
<span
class="inline-block grow self-start break-words text-[12px] font-bold leading-[20px] tracking-[0.5px] text-primary-1 max-[380px]:basis-9/12 min-[380px]:self-center min-[380px]:text-note"
>
{{ getEventById(day.event.eventId)?.title }}
{{ getEventById(day?.event?.eventId ?? -1)?.title }}
</span>
<div class="flex w-fit flex-row items-center gap-1 self-end justify-self-end max-[380px]:basis-3/12">
<GuestButton
v-if="!day.isLocked && day.event.isPublic"
v-if="!day.isLocked && day?.event?.isPublic"
:dayID="dayId"
:index="0"
:invitation="Invitation.EVENT"
:icon-white="false"
class="col-start-1 w-[24px] text-center"
/>
<EventPopup
:event-title="getEventById(day.event.eventId)?.title"
:event-title="getEventById(day?.event?.eventId ?? -1)?.title"
:date="day.date.date"
/>
<ParticipationCounter
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/src/components/dashboard/Week.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{{ t('dashboard.' + index) }}
</h2>
<p class="description text-primary print:hidden">
{{ (startLocale + ' - ' + endLocale).replaceAll(',', '') }}
{{ (startLocale + ' - ' + endLocale).replace(/,/g, '') }}
</p>
</div>
<div
v-if="Object.keys(days).length === 0 || !dashboardStore.getWeek(weekID).isEnabled"
v-if="Object.keys(days ?? {}).length === 0 || !dashboardStore.getWeek(weekID)?.isEnabled"
class="mb-20 text-center text-[18px] tracking-[1.5px] text-[#acbdc7]"
>
<img
Expand Down Expand Up @@ -52,12 +52,12 @@ const props = defineProps<{
const week = dashboardStore.getWeek(props.weekID);
const days = dashboardStore.getDays(props.weekID);
const startDate = new Date(week.startDate.date);
const startDate = new Date(week?.startDate?.date ?? '');
const startLocale = computed(() =>
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' })
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -63,7 +63,6 @@ const props = withDefaults(
}>(),
{
modelValue: null,
dish: null
}
);
Expand Down
14 changes: 8 additions & 6 deletions src/Resources/src/stores/eventsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function useEvents() {

const { error, events } = await getEvents();
if (isResponseArrayOkay<Event>(error, events, isEvent) === true) {
EventsState.events = events.value;
EventsState.events = events.value as Event[];
EventsState.error = '';
} else {
EventsState.error = 'Error on fetching events';
Expand All @@ -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;
}

Expand All @@ -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({
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/src/types/VueTabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'vue3-tabs' {
export const Tabs: any;
export const Tab: any;
export const TabPanels: any;
export const TabPanel: any;
}

0 comments on commit 734444f

Please sign in to comment.