diff --git a/src/routes/(pages)/dashboard/calendar/(components)/CalendarDay.svelte b/src/routes/(pages)/dashboard/calendar/(components)/CalendarDay.svelte index c50e0a1..0cf2649 100644 --- a/src/routes/(pages)/dashboard/calendar/(components)/CalendarDay.svelte +++ b/src/routes/(pages)/dashboard/calendar/(components)/CalendarDay.svelte @@ -126,7 +126,7 @@
{#if isWeekView && items} - {@const isSelected = selectedDate.toString() === items[0]?.date} + {@const isSelected = selectedDate.toString() === day.toString()} {@const isToday = toCalendarDate(day).toString() === today(getLocalTimeZone()).toString()} - {toDisplayDateTime(day.toDate(getLocalTimeZone()), { weekday: "short" })} + {toDisplayDateTime(day.toDate(getLocalTimeZone()), { + day: "numeric", + weekday: "short", + })} = () => { + const onSelectDay = (v: DateValue | undefined) => { open = false; + if (view === "week-workdays" && v && isWeekend(v, getLocale())) { + view = "week"; + } }; const getISOWeek = (date: CalendarDate): { week: number; year: number } => { @@ -76,7 +84,7 @@
-
+
diff --git a/src/routes/(pages)/dashboard/calendar/(components)/CalendarLines.svelte b/src/routes/(pages)/dashboard/calendar/(components)/CalendarLines.svelte index 7a8875e..e858dd6 100644 --- a/src/routes/(pages)/dashboard/calendar/(components)/CalendarLines.svelte +++ b/src/routes/(pages)/dashboard/calendar/(components)/CalendarLines.svelte @@ -17,14 +17,12 @@ latestEndHour, scale = $bindable(), isLoading, - isWeekView, }: { day: CalendarDate; earliestStartHour: number; latestEndHour: number; scale: number; isLoading: boolean; - isWeekView?: boolean; } = $props(); const hourSize = $derived(60 * scale); @@ -73,15 +71,13 @@ class="relative z-0 flex w-full items-start justify-between transition-all duration-200 select-none" style:height={`${hourSize}px`} > - {#if !isWeekView} - - {Intl.DateTimeFormat(getLocale(), { - hour: "2-digit", - minute: "2-digit", - timeZone: getLocalTimeZone().toString(), - }).format(toCalendarDateTime(day).set({ hour }).toDate(getLocalTimeZone()))} - - {/if} + + {Intl.DateTimeFormat(getLocale(), { + hour: "2-digit", + minute: "2-digit", + timeZone: getLocalTimeZone().toString(), + }).format(toCalendarDateTime(day).set({ hour }).toDate(getLocalTimeZone()))} +
diff --git a/src/routes/(pages)/dashboard/calendar/+page.svelte b/src/routes/(pages)/dashboard/calendar/+page.svelte index ac23845..1522ad4 100644 --- a/src/routes/(pages)/dashboard/calendar/+page.svelte +++ b/src/routes/(pages)/dashboard/calendar/+page.svelte @@ -66,13 +66,6 @@ }); let scale = $state(page.data.calendarZoom); - $effect(() => { - const getMonth = (x: string | undefined) => (x ? new Date(x).getMonth() + 1 : undefined); - if (!calendar || getMonth(calendar?.period.startDate) !== getMonth(selectedDate.toString())) { - updateCalendar(); - } - }); - $effect(() => { if (calendar && history.state["sveltekit:states"]?.appointmentId) { // Wait 100ms to ensure that the calendar items are rendered @@ -96,21 +89,24 @@ "date" in page.state && "appointmentId" in page.state ) { + shownAppointments = "all"; + + // navigate to date const date = convertDate(page.state.date as string); if (date.toString() !== selectedDate.toString()) { selectedDate = date; - replaceState("", { appointmentId: page.state.appointmentId }); - } else { - if (calendar) { - openAppointmentById( - calendar, - channels, - history.state["sveltekit:states"].appointmentId, - () => { - replaceState("", {}); - }, - ); - } + } + + // open appointment + if (calendar) { + openAppointmentById( + calendar, + channels, + history.state["sveltekit:states"].appointmentId, + () => { + replaceState("", {}); + }, + ); } } }); @@ -142,7 +138,7 @@
- +