From f6acb3d2716faced59feac18e3cf5907a50615b1 Mon Sep 17 00:00:00 2001 From: "t.indorf" Date: Thu, 21 May 2026 13:24:42 +0200 Subject: [PATCH] feat: default to Month view and implement household services filter toggle for parents --- .../_components/calendar-overview-client.tsx | 123 ++++++++++++++---- .../kalender/_components/termin-list.tsx | 7 +- src/app/dashboard/kalender/page.tsx | 25 ++-- 3 files changed, 118 insertions(+), 37 deletions(-) diff --git a/src/app/dashboard/kalender/_components/calendar-overview-client.tsx b/src/app/dashboard/kalender/_components/calendar-overview-client.tsx index 2009011..7ad835e 100644 --- a/src/app/dashboard/kalender/_components/calendar-overview-client.tsx +++ b/src/app/dashboard/kalender/_components/calendar-overview-client.tsx @@ -61,7 +61,8 @@ const categories = [ { label: "Elternabend", type: TerminType.ELTERNABEND, color: "oklch(0.50 0.10 280)" }, { label: "Fest", type: TerminType.KITA_FEST, color: "var(--good)" }, { label: "Geburtstag", type: TerminType.GEBURTSTAG_INTERN, color: "oklch(0.50 0.10 320)" }, - { label: "Elterndienst", type: "elterndienst", color: "oklch(0.60 0.15 160)" }, + { label: "Mein Elterndienst", type: "mein-elterndienst", color: "oklch(0.60 0.16 160)" }, + { label: "Elterndienst", type: "elterndienst", color: "oklch(0.75 0.08 160)" }, { label: "Mein Notdienst", type: "mein-notdienst", color: "oklch(0.60 0.18 45)" }, { label: "Notdienst", type: "notdienst", color: "oklch(0.75 0.10 50)" }, { label: "Sonstiges", type: TerminType.SONSTIGES, color: "var(--ink-muted)" }, @@ -76,9 +77,10 @@ export function CalendarOverviewClient({ userId: string; isAdmin: boolean; }) { - const [view, setView] = useState<"liste" | "monat" | "agenda">("liste"); + const [view, setView] = useState<"liste" | "monat" | "agenda">("monat"); const [searchQuery, setSearchQuery] = useState(""); const [activeTypes, setActiveTypes] = useState>(new Set()); + const [filterScope, setFilterScope] = useState<"own" | "all">(isAdmin ? "all" : "own"); // Month navigation state const [currentMonthDate, setCurrentMonthDate] = useState(new Date()); @@ -106,6 +108,12 @@ export function CalendarOverviewClient({ // Filter logic const filteredEvents = useMemo(() => { return termine.filter((item) => { + // 0. Filter by scope (own vs all) + if (filterScope === "own") { + if (item.kind === "duty" && !item.isOwn) return false; + if (item.kind === "notdienst" && !item.isOwn) return false; + } + // 1. Search Query filter const query = searchQuery.trim().toLowerCase(); if (query) { @@ -129,7 +137,9 @@ export function CalendarOverviewClient({ if (activeTypes.size > 0) { const itemType = item.kind === "duty" - ? "elterndienst" + ? item.isOwn + ? "mein-elterndienst" + : "elterndienst" : item.kind === "notdienst" ? item.isOwn ? "mein-notdienst" @@ -140,7 +150,7 @@ export function CalendarOverviewClient({ return true; }); - }, [termine, searchQuery, activeTypes]); + }, [termine, searchQuery, activeTypes, filterScope]); // Check if an event falls on a specific day const isEventOnDay = (item: CalendarListItemDto, day: Date) => { @@ -177,23 +187,54 @@ export function CalendarOverviewClient({
{/* Search and Filters Header */}
-
- {(["liste", "monat", "agenda"] as const).map((v) => ( - - ))} +
+
+ {(["liste", "monat", "agenda"] as const).map((v) => ( + + ))} +
+ + {!isAdmin && ( +
+ + +
+ )}
@@ -291,16 +332,40 @@ export function CalendarOverviewClient({ > {item.kind === "duty" ? (
-
- +
+
+

{item.title}

- - Elterndienst + + {item.isOwn ? "Mein Elterndienst" : "Elterndienst"}

@@ -604,7 +669,9 @@ function MonthView({ {dayEvents.slice(0, 3).map((item) => { const color = item.kind === "duty" - ? "oklch(0.60 0.15 160)" + ? item.isOwn + ? "oklch(0.60 0.16 160)" + : "oklch(0.75 0.08 160)" : item.kind === "notdienst" ? item.isOwn ? "oklch(0.60 0.18 45)" @@ -709,6 +776,10 @@ function AgendaView({ ? item.isOwn ? "oklch(0.60 0.18 45)" : "oklch(0.75 0.10 50)" + : item.kind === "duty" + ? item.isOwn + ? "oklch(0.60 0.16 160)" + : "oklch(0.75 0.08 160)" : "oklch(0.60 0.15 160)"; return ( diff --git a/src/app/dashboard/kalender/_components/termin-list.tsx b/src/app/dashboard/kalender/_components/termin-list.tsx index c143246..a38c0c9 100644 --- a/src/app/dashboard/kalender/_components/termin-list.tsx +++ b/src/app/dashboard/kalender/_components/termin-list.tsx @@ -63,6 +63,7 @@ export type DutyCalendarItemDto = { status: DutyAssignmentStatus; startDate: Date; endDate: Date; + isOwn: boolean; }; export type NotdienstCalendarItemDto = { @@ -150,7 +151,7 @@ export function TerminList({ } function DutyRow({ duty, isAdmin }: { duty: DutyCalendarItemDto; isAdmin: boolean }) { - const color = "var(--good)"; + const color = duty.isOwn ? "oklch(0.60 0.16 160)" : "oklch(0.75 0.08 160)"; const [menuOpen, setMenuOpen] = useState(false); return ( @@ -170,7 +171,9 @@ function DutyRow({ duty, isAdmin }: { duty: DutyCalendarItemDto; isAdmin: boolea

- Elterndienst + + {duty.isOwn ? "Mein Elterndienst" : "Elterndienst"} + {isAdmin ? (