diff --git a/project.inlang/messages/de.json b/project.inlang/messages/de.json index 5e4bcec..305fd6f 100644 --- a/project.inlang/messages/de.json +++ b/project.inlang/messages/de.json @@ -944,6 +944,18 @@ "title": "Kalender", "selectDate": "Datum auswählen", "today": "Heute", + "zoomOptions": { + "title": "Kalender Zoom-Optionen", + "zoomIn": "Hinein-zoomen", + "zoomOut": "Heraus-zoomen" + }, + "viewOptions": { + "title": "Kalender Ansicht", + "day": "Tagesansicht", + "week": "Wochenansicht", + "week-workdays": "Wochenansicht (ohne Wochenende)" + }, + "calendarWeek": "KW {week}, {year}", "thisMonth": "Aktueller Monat", "addThreeMonths": "+3", "addSixMonths": "+6", diff --git a/project.inlang/messages/en.json b/project.inlang/messages/en.json index 6e87e59..d418e13 100644 --- a/project.inlang/messages/en.json +++ b/project.inlang/messages/en.json @@ -952,6 +952,18 @@ "title": "Calendar", "selectDate": "Select a date", "today": "Today", + "zoomOptions": { + "title": "Calendar zoom options", + "zoomIn": "zoom-in", + "zoomOut": "zoom-out" + }, + "viewOptions": { + "title": "Calendar view options", + "day": "Day", + "week": "Week", + "week-workdays": "Week (without weekend)" + }, + "calendarWeek": "CW {week}, {year}", "thisMonth": "Current month", "addThreeMonths": "+3", "addSixMonths": "+6", diff --git a/src/lib/assets/custom-icons/calendar-week-workdays.svelte b/src/lib/assets/custom-icons/calendar-week-workdays.svelte new file mode 100644 index 0000000..be2956b --- /dev/null +++ b/src/lib/assets/custom-icons/calendar-week-workdays.svelte @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/src/lib/assets/custom-icons/calendar-week.svelte b/src/lib/assets/custom-icons/calendar-week.svelte new file mode 100644 index 0000000..d644f19 --- /dev/null +++ b/src/lib/assets/custom-icons/calendar-week.svelte @@ -0,0 +1,32 @@ + + + + calendar-week + + + + + + + + + + + + + + diff --git a/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte b/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte index f629082..637bc27 100644 --- a/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte +++ b/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte @@ -13,6 +13,7 @@ import { toDisplayDateTime } from "$lib/utils/datetime"; import { getCurrentTranlslation } from "$lib/utils/localizations"; import { getLocalTimeZone } from "@internationalized/date"; + import { useQueryClient } from "@tanstack/svelte-query"; import { onMount } from "svelte"; let { @@ -23,6 +24,7 @@ closePopover: () => void; } = $props(); + const queryClient = useQueryClient(); const channels = $derived($channelsStore.channels); let appointment: TAppointment | undefined = $state(); @@ -57,6 +59,9 @@ onclick={() => { if (appointment) { closePopover(); + queryClient.invalidateQueries({ + queryKey: ["calendar"], + }); if (page.url.pathname === ROUTES.DASHBOARD.CALENDAR) { goto(resolve(ROUTES.DASHBOARD.CALENDAR), { state: { diff --git a/src/lib/components/ui/calendar-custom/day.svelte b/src/lib/components/ui/calendar-custom/day.svelte index 49dbe82..249105d 100644 --- a/src/lib/components/ui/calendar-custom/day.svelte +++ b/src/lib/components/ui/calendar-custom/day.svelte @@ -19,17 +19,20 @@ - {#if !outsideMonth} -
-
- {day.day} -
- {#if isDateHighlighted && isDateHighlighted(day)} - - {/if} +
+
+ {day.day}
- {/if} + {#if isDateHighlighted && isDateHighlighted(day)} + + {/if} +
diff --git a/src/lib/utils/datetime.ts b/src/lib/utils/datetime.ts index 643fa98..462a1e2 100644 --- a/src/lib/utils/datetime.ts +++ b/src/lib/utils/datetime.ts @@ -1,6 +1,7 @@ import { getLocale } from "$i18n/runtime"; import type { TCalendarSlot } from "$lib/types/calendar"; import { + CalendarDate, getLocalTimeZone, parseAbsoluteToLocal, toCalendarDateTime, @@ -228,3 +229,22 @@ export const getWeekStartsOn = (): 0 | 1 | 2 | 3 | 4 | 5 | 6 => { if (sundayStartLocales.has(locale)) return 0; return 1; }; + +export const getWeekDays = (day: CalendarDate, skipWeekend = false): CalendarDate[] => { + const jsDay = day.toDate("UTC").getDay(); + const weekStartsOn = getWeekStartsOn(); + let offset = jsDay - weekStartsOn; + if (offset < 0) offset += 7; + + const weekStart = day.subtract({ days: offset }); + const days = Array.from({ length: 7 }, (_, i) => weekStart.add({ days: i })); + + if (skipWeekend) { + return days.filter((d) => { + const dow = d.toDate("UTC").getDay(); + return dow !== 0 && dow !== 6; + }); + } + + return days; +}; diff --git a/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte b/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte index 41afaeb..1799c0f 100644 --- a/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte +++ b/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte @@ -8,11 +8,14 @@ import { calendarStore } from "$lib/stores/calendar"; import { Button } from "$lib/components/ui/button"; import { m } from "$i18n/messages"; + import { cn } from "$lib/utils"; let { item, + scale, }: { item: TCalendarItem; + scale: number; } = $props(); let decrypted = $state(); @@ -101,13 +104,16 @@ {:else if decrypted === undefined}
- {m["calendar.decrypting"]()} + + {m["calendar.decrypting"]()} +
{:else if decrypted}