forge
Explore
Log in

Don't you dare go Hollow

🧹 drop the unreachable right-nav flyout drawer

Browse files at this commit

164cfdc60a419f71a1d82cbf68605bcd4baf7051Ahmet Kaan GümüşParent: f9efbbc
  • refactor
    • 🧹 drop the unreachable right-nav flyout drawer
Show full message
refactor: 🧹 drop the unreachable right-nav flyout drawer

The drawer could never open. `activeTab` starts null and `setActiveTab` had a
single call site — `closePanel()` — which also passes null; both icon buttons
navigate to /messages or /calendar instead. So every Show gated on it, and the
effect that would refetch the whole shell feed on open, were dead from the
moment the buttons became direct links.

- delete the drawer markup and the state that only fed it: activeTab,
  unreadOnly, selectedMessage, calPage, calFilter, selectedCalItem, plus the
  filteredMessages/recentMessages/combinedCalendarItems/paginatedCalItems
  memos, closePanel, toggleReadStatus and handleSelectMessage
- drop the imports they orphaned; every one still has consumers elsewhere, so
  nothing else changes
- keep the live sticky icon bar untouched: unread badge, the today event/exam
  dots, and the active-route pill
- restate the badge comment, which described an inbox page the file no longer
  reads

right-nav.tsx 834 -> 141 lines. Also removes the full shell-feed refetch that
the dead effect would have fired on every drawer open.
src/components/layout/right-nav.tsxmodified+15 -708
@@ -1,96 +1,37 @@
1-import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js";
1+import { Show, createMemo } from "solid-js";
22 import { useLocation, useNavigate } from "@tanstack/solid-router";
3-import { patchMessageById } from "@/api/messages";
4-import type { Appointment, Event, Exam, Message } from "@/api/client";
5-import { appointmentStatusClass, appointmentStatusDotClass, appointmentStatusLabelKey } from "@/lib/appointment-status";
6-import { Badge } from "@/components/ui/badge";
7-import { Button } from "@/components/ui/button";
8-import { PageSpinner } from "@/components/ui/page-spinner";
9-import { PaginationControls } from "@/components/ui/pagination-controls";
10-import {
11- IconCalendarDays,
12- IconChevronLeft,
13- IconChevronRight,
14- IconClock,
15- IconExternalLink,
16- IconMessage,
17- IconX,
18-} from "@/components/ui/icons";
3+import type { Event, Exam } from "@/api/client";
4+import { IconCalendarDays, IconMessage } from "@/components/ui/icons";
195 import { cn } from "@/lib/cn";
20-import { appointmentCounterpart, personLabel } from "@/lib/person";
21-import { useAuth } from "@/stores/auth-context";
22-import { usePreferences, useT } from "@/stores/preferences-context";
6+import { useT } from "@/stores/preferences-context";
237 import { useShellFeed } from "@/stores/shell-feed-context";
248
25-type ActiveTab = "messages" | "calendar" | null;
26-type CalendarItemRef =
27- | { type: "event"; data: Event }
28- | { type: "exam"; data: Exam }
29- | { type: "appointment"; data: Appointment };
30-
31-const PAGE_SIZE = 5;
32-
339 export function RightNav() {
3410 const t = useT();
3511 const navigate = useNavigate();
3612 const location = useLocation();
37- const { locale } = usePreferences();
3813 const feed = useShellFeed();
39- const auth = useAuth();
4014
4115 const isMessagesActive = () => location().pathname === "/messages";
4216 const isCalendarActive = () => location().pathname === "/calendar";
4317
44- // Active drawer tab
45- const [activeTab, setActiveTab] = createSignal<ActiveTab>(null);
46-
47- // Messages drawer state
48- const [unreadOnly, setUnreadOnly] = createSignal(false);
49- const [selectedMessage, setSelectedMessage] = createSignal<Message | null>(null);
50-
51- // Calendar drawer state
52- const [calPage, setCalPage] = createSignal(0);
53- const [calFilter, setCalFilter] = createSignal<"all" | "events" | "exams" | "appointments">("all");
54- const [selectedCalItem, setSelectedCalItem] = createSignal<CalendarItemRef | null>(null);
55-
5618 // Shell feed data comes from the shared poller (ShellFeedProvider), so
57- // messages/events/exams/appointments are fetched once for the whole shell,
58- // not independently here and in NotificationCenter.
59- const refetchMessages = feed.refetchMessages;
60- const refreshAll = feed.refreshAll;
61-
62- // Computed message data
63- // `.latest` (via the store accessor), not a bare `resource()`: this feeds the
64- // always-rendered unread badge outside any <Suspense>. A bare read re-suspends
65- // on every 60s refetch and — since RightNav sits beside <Outlet> in AppShell —
66- // blanks the whole page for the fetch duration. `.latest` keeps the last value.
67- const allMessages = () => feed.messages().items;
68- // Same source of truth as NotificationCenter: the dedicated `read=false` page,
69- // whose `total` is the exact server-side unread count. The inbox page above is
70- // capped at 100 and ordered by id DESC, so filtering it silently drops older
71- // unread messages and the two shell badges disagree.
19+ // messages/events/exams are fetched once for the whole shell, not
20+ // independently here and in NotificationCenter.
21+
22+ // Two rules ride on this one line:
23+ // 1. `.latest` (via the store accessor), never a bare `resource()`: this feeds
24+ // the always-rendered badge outside any <Suspense>, and RightNav sits beside
25+ // <Outlet> in AppShell, so a re-suspend blanks the whole page for the fetch.
26+ // 2. The dedicated `read=false` page's `total` — the exact server-side count,
27+ // and the same source NotificationCenter reads. Deriving unread by filtering
28+ // the general inbox page instead silently drops anything older than its
29+ // newest 100 rows, and the two shell badges then disagree.
7230 const unreadCount = createMemo(() => feed.unreadMessages().total);
7331
74- const filteredMessages = createMemo(() => {
75- let list = allMessages();
76- if (unreadOnly()) {
77- list = list.filter((m: Message) => !m.read);
78- }
79- return list;
80- });
81-
82- // Top 5 recent messages only for side panel
83- const recentMessages = createMemo(() => {
84- return filteredMessages().slice(0, 5);
85- });
86-
8732 // Reactive clock from the shared poller so passed items clear without a remount.
8833 const nowMs = feed.nowMs;
8934
90- createEffect(() => {
91- if (activeTab() !== null) refreshAll();
92- });
93-
9435 // An item is still notifiable until it has ended (ends_at, else starts_at).
9536 const notEnded = (starts?: number | null, ends?: number | null) => {
9637 if (!starts) return false;
@@ -106,85 +47,13 @@ export function RightNav() {
10647 return feed.exams().items.filter((e: Exam) => !e.draft && notEnded(e.starts_at, e.ends_at));
10748 });
10849
109- const activeAppointments = createMemo(() => {
110- return feed.appointments().items.filter(
111- (a: Appointment) => (a.status === "pending" || a.status === "approved") && notEnded(a.starts_at, a.ends_at)
112- );
113- });
114-
11550 const hasTodayEvents = createMemo(() => activeEvents().length > 0);
11651 const hasTodayExams = createMemo(() => activeExams().length > 0);
11752
118- const combinedCalendarItems = createMemo(() => {
119- const items: CalendarItemRef[] = [];
120-
121- if (calFilter() === "all" || calFilter() === "events") {
122- for (const ev of activeEvents()) {
123- items.push({ type: "event", data: ev });
124- }
125- }
126-
127- if (calFilter() === "all" || calFilter() === "exams") {
128- for (const ex of activeExams()) {
129- items.push({ type: "exam", data: ex });
130- }
131- }
132-
133- if (calFilter() === "all" || calFilter() === "appointments") {
134- for (const ap of activeAppointments()) {
135- items.push({ type: "appointment", data: ap });
136- }
137- }
138-
139- // Sort chronologically by start date
140- return items.sort((a, b) => {
141- const timeA = a.data.starts_at ? new Date(a.data.starts_at).getTime() : 0;
142- const timeB = b.data.starts_at ? new Date(b.data.starts_at).getTime() : 0;
143- return timeA - timeB;
144- });
145- });
146-
147- const calTotalPages = createMemo(() => Math.max(1, Math.ceil(combinedCalendarItems().length / PAGE_SIZE)));
148- const paginatedCalItems = createMemo(() => {
149- const start = calPage() * PAGE_SIZE;
150- return combinedCalendarItems().slice(start, start + PAGE_SIZE);
151- });
152-
153- const closePanel = () => {
154- setActiveTab(null);
155- setSelectedMessage(null);
156- setSelectedCalItem(null);
157- };
158-
15953 const goTo = (path: string) => {
160- closePanel();
16154 void navigate({ to: path });
16255 };
16356
164- // Mark message as read/unread toggle
165- const toggleReadStatus = async (msg: Message) => {
166- try {
167- await patchMessageById(msg.id, { read: !msg.read });
168- setSelectedMessage({ ...msg, read: !msg.read });
169- void refetchMessages();
170- } catch {
171- // ignore
172- }
173- };
174-
175- // Mark as read if unread and navigate directly to /messages page
176- const handleSelectMessage = async (msg: Message) => {
177- if (!msg.read) {
178- try {
179- await patchMessageById(msg.id, { read: true });
180- void refetchMessages();
181- } catch {
182- // ignore
183- }
184- }
185- goTo("/messages");
186- };
187-
18857 return (
18958 <>
19059 {/* Sticky Right Icon Bar */}
@@ -267,568 +136,6 @@ export function RightNav() {
267136 <div class="h-1.5 w-1.5 rounded-full bg-muted-foreground/30" />
268137 </div>
269138 </aside>
270-
271- {/* Flyout Side Drawer Panel */}
272- <Show when={activeTab() !== null}>
273- {/* Backdrop overlay blurring main page content on the left */}
274- <div
275- class="fixed inset-0 z-40 bg-black/20 backdrop-blur-xs transition-all"
276- onClick={closePanel}
277- />
278-
279- <div
280- class="fixed right-14 top-0 z-50 flex h-screen w-80 sm:w-96 flex-col border-l border-black/8 bg-card text-card-foreground shadow-2xl dark:border-white/8 dark:bg-[#0c0c0e] animate-in slide-in-from-right-4 duration-200"
281- >
282- {/* Drawer Header */}
283- <div class="flex h-14 shrink-0 items-center justify-between border-b border-border/60 px-4">
284- <div class="flex items-center gap-2 font-display text-sm font-semibold tracking-tight">
285- <Show when={activeTab() === "messages"}>
286- <Show
287- when={selectedMessage()}
288- fallback={
289- <>
290- <IconMessage class="h-4 w-4 text-primary" />
291- <span>{t("rightPanel.messagesTitle")}</span>
292- <Show when={unreadCount() > 0}>
293- <Badge variant="destructive" class="ml-1.5 px-1.5 py-0 text-[10px]">
294- {unreadCount()} {t("rightPanel.unreadBadge")}
295- </Badge>
296- </Show>
297- </>
298- }
299- >
300- <Button
301- type="button"
302- variant="ghost"
303- size="sm"
304- class="h-7 px-2 text-xs gap-1 rounded-lg hover:bg-secondary"
305- onClick={() => setSelectedMessage(null)}
306- >
307- <IconChevronLeft class="h-3.5 w-3.5" />
308- <span>{t("common.back")}</span>
309- </Button>
310- </Show>
311- </Show>
312-
313- <Show when={activeTab() === "calendar"}>
314- <Show
315- when={selectedCalItem()}
316- fallback={
317- <>
318- <IconCalendarDays class="h-4 w-4 text-primary" />
319- <span>{t("rightPanel.calendarTitle")}</span>
320- </>
321- }
322- >
323- <Button
324- type="button"
325- variant="ghost"
326- size="sm"
327- class="h-7 px-2 text-xs gap-1 rounded-lg hover:bg-secondary"
328- onClick={() => setSelectedCalItem(null)}
329- >
330- <IconChevronLeft class="h-3.5 w-3.5" />
331- <span>{t("common.back")}</span>
332- </Button>
333- </Show>
334- </Show>
335- </div>
336-
337- <Button
338- type="button"
339- variant="ghost"
340- size="sm"
341- class="h-8 w-8 rounded-lg p-0 text-muted-foreground hover:text-foreground"
342- onClick={closePanel}
343- aria-label={t("nav.close")}
344- >
345- <IconX class="h-4 w-4" />
346- </Button>
347- </div>
348-
349- {/* Drawer Body */}
350- <div class="min-h-0 flex-1 overflow-y-auto p-4 space-y-3">
351- {/* MESSAGES TAB */}
352- <Show when={activeTab() === "messages"}>
353- {/* Message Details Preview View */}
354- <Show
355- when={selectedMessage()}
356- fallback={
357- /* Messages List View */
358- <Suspense fallback={<PageSpinner />}>
359- {/* Filter Bar */}
360- <div class="flex items-center justify-between gap-2 pb-1 border-b border-border/40 text-xs">
361- <div class="flex items-center gap-1">
362- <button
363- type="button"
364- onClick={() => setUnreadOnly(false)}
365- class={cn(
366- "rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors",
367- !unreadOnly()
368- ? "bg-primary text-primary-foreground font-semibold"
369- : "text-muted-foreground hover:bg-secondary hover:text-foreground"
370- )}
371- >
372- {t("common.all")} ({allMessages().length})
373- </button>
374- <button
375- type="button"
376- onClick={() => setUnreadOnly(true)}
377- class={cn(
378- "rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors",
379- unreadOnly()
380- ? "bg-primary text-primary-foreground font-semibold"
381- : "text-muted-foreground hover:bg-secondary hover:text-foreground"
382- )}
383- >
384- {t("rightPanel.unreadBadge")} ({unreadCount()})
385- </button>
386- </div>
387- </div>
388-
389- <Show
390- when={recentMessages().length > 0}
391- fallback={
392- <div class="flex h-48 flex-col items-center justify-center text-center text-xs text-muted-foreground space-y-2">
393- <IconMessage class="h-8 w-8 text-muted-foreground/40" />
394- <p>{t("rightPanel.noUnread")}</p>
395- </div>
396- }
397- >
398- <div class="space-y-2">
399- <For each={recentMessages()}>
400- {(msg) => (
401- <div
402- onClick={() => handleSelectMessage(msg)}
403- class={cn(
404- "group flex cursor-pointer flex-col gap-1 rounded-xl border p-2.5 transition-all hover:border-primary/50 hover:bg-muted/40 shadow-2xs max-w-full overflow-hidden",
405- !msg.read
406- ? "border-primary/30 bg-primary/3 dark:bg-primary/6"
407- : "border-border/60 bg-card"
408- )}
409- >
410- <div class="flex items-center justify-between text-xs gap-2 min-w-0">
411- <div class="flex items-center gap-1.5 min-w-0 max-w-[70%]">
412- <span class="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[9px] font-bold text-primary">
413- {personLabel(msg.sender).charAt(0).toUpperCase()}
414- </span>
415- <span class="font-semibold text-foreground truncate max-w-[140px]">
416- {personLabel(msg.sender)}
417- </span>
418- </div>
419- <span class="text-[10px] text-muted-foreground shrink-0">
420- {msg.sent_at
421- ? new Date(msg.sent_at).toLocaleTimeString(
422- locale() === "tr" ? "tr-TR" : "en-US",
423- { hour: "2-digit", minute: "2-digit" }
424- )
425- : ""}
426- </span>
427- </div>
428- <Show when={msg.subject}>
429- <p class="text-xs font-medium text-foreground truncate max-w-[280px]">
430- {msg.subject}
431- </p>
432- </Show>
433- <p class="line-clamp-1 text-xs text-muted-foreground leading-relaxed truncate max-w-full">
434- {msg.body}
435- </p>
436- <div class="flex items-center justify-between pt-0.5 text-[10px]">
437- <Show when={!msg.read}>
438- <span class="inline-flex items-center gap-1 font-semibold text-primary">
439- <span class="h-1.5 w-1.5 rounded-full bg-primary animate-pulse" />
440- {t("rightPanel.unreadBadge")}
441- </span>
442- </Show>
443- <span class="text-muted-foreground/70 group-hover:text-primary transition-colors ml-auto font-medium">
444- Mesaja Git →
445- </span>
446- </div>
447- </div>
448- )}
449- </For>
450- </div>
451-
452- {/* Redirect link for all messages if total > 5 */}
453- <Show when={filteredMessages().length > 5}>
454- <div class="pt-2 text-center">
455- <Button
456- type="button"
457- variant="outline"
458- size="sm"
459- class="w-full h-8 text-xs text-primary border-primary/20 hover:bg-primary/5 rounded-lg justify-center gap-1.5 font-medium"
460- onClick={() => goTo("/messages")}
461- >
462- <span>Tüm Mesajları Aç ({filteredMessages().length})</span>
463- <IconExternalLink class="h-3.5 w-3.5" />
464- </Button>
465- </div>
466- </Show>
467- </Show>
468- </Suspense>
469- }
470- >
471- {(msg) => (
472- <div class="space-y-4 animate-in fade-in-50">
473- <div class="rounded-xl border border-border/80 bg-muted/20 p-3.5 space-y-3">
474- <div class="flex items-start justify-between gap-2 border-b border-border/50 pb-2.5">
475- <div class="flex items-center gap-2.5 min-w-0">
476- <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary text-xs font-bold text-primary-foreground shadow-xs">
477- {personLabel(msg().sender).charAt(0).toUpperCase()}
478- </span>
479- <div class="min-w-0">
480- <h4 class="text-xs font-semibold text-foreground truncate">
481- {personLabel(msg().sender)}
482- </h4>
483- <p class="text-[10px] text-muted-foreground">
484- {msg().sent_at
485- ? new Date(msg().sent_at).toLocaleString(
486- locale() === "tr" ? "tr-TR" : "en-US",
487- { dateStyle: "medium", timeStyle: "short" }
488- )
489- : ""}
490- </p>
491- </div>
492- </div>
493-
494- <Button
495- type="button"
496- variant="outline"
497- size="sm"
498- class="h-7 px-2 text-[10px] rounded-lg shrink-0"
499- onClick={() => toggleReadStatus(msg())}
500- >
501- {msg().read ? "Okunmadı Yap" : "Okundu İşaretle"}
502- </Button>
503- </div>
504-
505- <Show when={msg().subject}>
506- <h3 class="text-sm font-semibold text-foreground tracking-tight">
507- {msg().subject}
508- </h3>
509- </Show>
510-
511- <div class="rounded-lg bg-card p-3 border border-border/40 text-xs text-foreground leading-relaxed whitespace-pre-wrap">
512- {msg().body}
513- </div>
514-
515- <div class="pt-2 flex justify-end">
516- <Button
517- type="button"
518- variant="secondary"
519- size="sm"
520- class="h-8 rounded-lg gap-1.5 text-xs font-medium"
521- onClick={() => goTo("/messages")}
522- >
523- <span>{t("rightPanel.openFullMessages")}</span>
524- <IconExternalLink class="h-3.5 w-3.5" />
525- </Button>
526- </div>
527- </div>
528- </div>
529- )}
530- </Show>
531- </Show>
532-
533- {/* CALENDAR TAB */}
534- <Show when={activeTab() === "calendar"}>
535- {/* Calendar Item Preview View */}
536- <Show
537- when={selectedCalItem()}
538- fallback={
539- /* Calendar Items List View */
540- <Suspense fallback={<PageSpinner />}>
541- {/* Filter Chips */}
542- <div class="flex items-center gap-1.5 pb-1 border-b border-border/40 text-xs">
543- <button
544- type="button"
545- onClick={() => { setCalFilter("all"); setCalPage(0); }}
546- class={cn(
547- "rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors",
548- calFilter() === "all"
549- ? "bg-primary text-primary-foreground font-semibold"
550- : "text-muted-foreground hover:bg-secondary hover:text-foreground"
551- )}
552- >
553- {t("common.all")}
554- </button>
555- <button
556- type="button"
557- onClick={() => { setCalFilter("events"); setCalPage(0); }}
558- class={cn(
559- "rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors border",
560- calFilter() === "events"
561- ? "bg-emerald-500 text-white font-semibold border-emerald-500"
562- : "text-emerald-600 dark:text-emerald-400 border-emerald-500/30 hover:bg-emerald-500/10"
563- )}
564- >
565- {t("calendar.events")} ({activeEvents().length})
566- </button>
567- <button
568- type="button"
569- onClick={() => { setCalFilter("exams"); setCalPage(0); }}
570- class={cn(
571- "rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors border",
572- calFilter() === "exams"
573- ? "bg-rose-500 text-white font-semibold border-rose-500"
574- : "text-rose-600 dark:text-rose-400 border-rose-500/30 hover:bg-rose-500/10"
575- )}
576- >
577- {t("calendar.exams")} ({activeExams().length})
578- </button>
579- <button
580- type="button"
581- onClick={() => { setCalFilter("appointments"); setCalPage(0); }}
582- class={cn(
583- "rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors border",
584- calFilter() === "appointments"
585- ? "bg-violet-500 text-white font-semibold border-violet-500"
586- : "text-violet-600 dark:text-violet-400 border-violet-500/30 hover:bg-violet-500/10"
587- )}
588- >
589- {t("calendar.appointments")} ({activeAppointments().length})
590- </button>
591- </div>
592-
593- <Show
594- when={paginatedCalItems().length > 0}
595- fallback={
596- <div class="flex h-48 flex-col items-center justify-center text-center text-xs text-muted-foreground space-y-2">
597- <IconCalendarDays class="h-8 w-8 text-muted-foreground/40" />
598- <p>{t("rightPanel.noUpcoming")}</p>
599- </div>
600- }
601- >
602- <div class="space-y-2">
603- <For each={paginatedCalItems()}>
604- {(item) => {
605- const isEvent = item.type === "event";
606- const isAppt = item.type === "appointment";
607- const title = item.type === "appointment"
608- ? appointmentCounterpart(item.data, auth.user()?.id)
609- : item.data.title;
610- return (
611- <div
612- onClick={() => setSelectedCalItem(item)}
613- class={cn(
614- "group flex cursor-pointer items-start justify-between gap-2.5 rounded-xl border p-3 shadow-2xs transition-all hover:shadow-md",
615- isEvent
616- ? "border-emerald-500/30 bg-emerald-500/2 hover:border-emerald-500/60 hover:bg-emerald-500/5"
617- : isAppt
618- ? "border-violet-500/30 bg-violet-500/2 hover:border-violet-500/60 hover:bg-violet-500/5"
619- : "border-rose-500/30 bg-rose-500/2 hover:border-rose-500/60 hover:bg-rose-500/5"
620- )}
621- >
622- <div class="min-w-0 space-y-1">
623- <p
624- class={cn(
625- "truncate text-xs font-semibold",
626- isEvent
627- ? "text-emerald-700 dark:text-emerald-300 group-hover:text-emerald-600"
628- : isAppt
629- ? "text-violet-700 dark:text-violet-300 group-hover:text-violet-600"
630- : "text-rose-700 dark:text-rose-300 group-hover:text-rose-600"
631- )}
632- >
633- {title}
634- </p>
635- <Show when={item.type === "appointment" && item.data.reason}>
636- <p class="truncate text-[11px] text-muted-foreground">
637- {item.type === "appointment" ? item.data.reason : ""}
638- </p>
639- </Show>
640- <div class="flex items-center gap-1.5 text-[11px] text-muted-foreground">
641- <IconClock class="h-3 w-3 shrink-0" />
642- <span>
643- {item.data.starts_at
644- ? new Date(item.data.starts_at).toLocaleDateString(
645- locale() === "tr" ? "tr-TR" : "en-US",
646- { day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" }
647- )
648- : ""}
649- </span>
650- </div>
651- </div>
652-
653- <Show
654- when={isAppt}
655- fallback={
656- <Badge
657- variant="outline"
658- class={cn(
659- "shrink-0 text-[9px] font-semibold px-2 py-0.5",
660- isEvent
661- ? "border-emerald-500/40 text-emerald-700 dark:text-emerald-300 bg-emerald-500/10"
662- : "border-rose-500/40 text-rose-700 dark:text-rose-300 bg-rose-500/10"
663- )}
664- >
665- {isEvent ? t("calendar.events") : t("calendar.exams")}
666- </Badge>
667- }
668- >
669- <Badge
670- variant="outline"
671- class={cn("shrink-0 gap-1 text-[9px] font-semibold px-2 py-0.5", appointmentStatusClass((item.data as Appointment).status))}
672- >
673- <span class={cn("h-1.5 w-1.5 rounded-full", appointmentStatusDotClass((item.data as Appointment).status))} />
674- {t(appointmentStatusLabelKey((item.data as Appointment).status))}
675- </Badge>
676- </Show>
677- </div>
678- );
679- }}
680- </For>
681- </div>
682-
683- {/* Pagination Controls */}
684- <Show when={calTotalPages() > 1}>
685- <PaginationControls
686- page={calPage()}
687- totalPages={calTotalPages()}
688- onPageChange={setCalPage}
689- />
690- </Show>
691- </Show>
692- </Suspense>
693- }
694- >
695- {(item) => {
696- const isEvent = item().type === "event";
697- const isAppt = item().type === "appointment";
698- const cur = item();
699- const appt = () => (cur.type === "appointment" ? cur.data : null);
700- const title = () => {
701- const a = appt();
702- if (a) return appointmentCounterpart(a, auth.user()?.id);
703- return (cur.data as Event | Exam).title;
704- };
705- return (
706- <div class="space-y-4 animate-in fade-in-50">
707- <div
708- class={cn(
709- "rounded-xl border p-4 space-y-3",
710- isEvent
711- ? "border-emerald-500/30 bg-emerald-500/3"
712- : isAppt
713- ? "border-violet-500/30 bg-violet-500/3"
714- : "border-rose-500/30 bg-rose-500/3"
715- )}
716- >
717- <div class="flex items-center justify-between">
718- <Show
719- when={appt()}
720- fallback={
721- <Badge
722- variant="outline"
723- class={cn(
724- "text-xs font-semibold px-2.5 py-0.5",
725- isEvent
726- ? "border-emerald-500/50 text-emerald-700 dark:text-emerald-300 bg-emerald-500/10"
727- : "border-rose-500/50 text-rose-700 dark:text-rose-300 bg-rose-500/10"
728- )}
729- >
730- {isEvent ? t("calendar.events") : t("calendar.exams")}
731- </Badge>
732- }
733- >
734- {(a) => (
735- <>
736- <Badge variant="outline" class="text-xs font-semibold px-2.5 py-0.5 border-violet-500/50 text-violet-700 dark:text-violet-300 bg-violet-500/10">
737- {t("calendar.appointments")}
738- </Badge>
739- <Badge variant="outline" class={cn("gap-1 text-xs font-semibold px-2.5 py-0.5", appointmentStatusClass(a().status))}>
740- <span class={cn("h-1.5 w-1.5 rounded-full", appointmentStatusDotClass(a().status))} />
741- {t(appointmentStatusLabelKey(a().status))}
742- </Badge>
743- </>
744- )}
745- </Show>
746- </div>
747-
748- <h3 class="text-base font-bold text-foreground tracking-tight">
749- {title()}
750- </h3>
751-
752- <div class="space-y-2 text-xs text-muted-foreground border-t border-border/40 pt-2.5">
753- <div class="flex items-center gap-2">
754- <IconClock class="h-4 w-4 text-primary shrink-0" />
755- <span>
756- {cur.data.starts_at
757- ? new Date(cur.data.starts_at).toLocaleString(
758- locale() === "tr" ? "tr-TR" : "en-US",
759- { dateStyle: "full", timeStyle: "short" }
760- )
761- : "—"}
762- </span>
763- </div>
764-
765- <Show when={appt()}>
766- {(a) => (
767- <Show when={a().reason}>
768- <div class="pt-2 border-t border-border/30 text-foreground">
769- <p class="text-xs font-medium text-muted-foreground mb-1">{t("appointments.reason")}</p>
770- <p class="text-xs leading-relaxed whitespace-pre-wrap">{a().reason}</p>
771- </div>
772- </Show>
773- )}
774- </Show>
775-
776- <Show when={!isAppt && "description" in cur.data && cur.data.description}>
777- <div class="pt-2 border-t border-border/30 text-foreground">
778- <p class="text-xs font-medium text-muted-foreground mb-1">Açıklama / Detay:</p>
779- <p class="text-xs leading-relaxed whitespace-pre-wrap">{String((cur.data as Event).description)}</p>
780- </div>
781- </Show>
782- </div>
783-
784- <div class="pt-3 flex justify-end">
785- <Button
786- type="button"
787- variant="secondary"
788- size="sm"
789- class="h-8 rounded-lg gap-1.5 text-xs font-medium"
790- onClick={() => goTo(isAppt ? "/appointments" : isEvent ? `/events/${cur.data.id}` : `/exams/${cur.data.id}`)}
791- >
792- <span>Detay Sayfasına Git</span>
793- <IconExternalLink class="h-3.5 w-3.5" />
794- </Button>
795- </div>
796- </div>
797- </div>
798- );
799- }}
800- </Show>
801- </Show>
802- </div>
803-
804- {/* Drawer Footer Action */}
805- <div class="shrink-0 border-t border-border/60 p-3 bg-card/60">
806- <Show when={activeTab() === "messages"}>
807- <Button
808- type="button"
809- variant="outline"
810- class="w-full justify-between h-9 rounded-lg text-xs font-medium"
811- onClick={() => goTo("/messages")}
812- >
813- <span>{t("rightPanel.openFullMessages")}</span>
814- <IconChevronRight class="h-3.5 w-3.5 text-muted-foreground" />
815- </Button>
816- </Show>
817-
818- <Show when={activeTab() === "calendar"}>
819- <Button
820- type="button"
821- variant="outline"
822- class="w-full justify-between h-9 rounded-lg text-xs font-medium"
823- onClick={() => goTo("/calendar")}
824- >
825- <span>{t("rightPanel.openFullCalendar")}</span>
826- <IconChevronRight class="h-3.5 w-3.5 text-muted-foreground" />
827- </Button>
828- </Show>
829- </div>
830- </div>
831- </Show>
832139 </>
833140 );
834141 }