diff --git a/src/components/layout/app-shell.tsx b/src/components/layout/app-shell.tsx index 6a5aae6..7998d8b 100644 --- a/src/components/layout/app-shell.tsx +++ b/src/components/layout/app-shell.tsx @@ -5,6 +5,7 @@ import { CelebiPanel } from "@/components/layout/celebi-panel"; import { CommandPalette } from "@/components/layout/command-palette"; import { MobileTabBar } from "@/components/layout/mobile-tab-bar"; import { NavBar } from "@/components/layout/nav-bar"; +import { NotificationCenter } from "@/components/layout/notification-center"; import { RightNav } from "@/components/layout/right-nav"; import { SideNav } from "@/components/layout/side-nav"; import { SidebarAccount } from "@/components/layout/sidebar-account"; @@ -176,7 +177,8 @@ export function AppShell(props: ParentProps) { -
+
+ + +
+ + {/* Notifications List */} +
+ + {t("common.loading")} +
+ } + > + 0} + fallback={ +
+
+ +
+

+ Henüz yeni bir bildiriminiz yok. +

+
+ } + > + + {(item) => ( +
handleSelectNotification(item)} + class="group relative flex items-start gap-3 rounded-xl p-2.5 text-xs transition-colors cursor-pointer hover:bg-accent/60 select-none" + > + {/* Icon by Type */} +
+ + + + + + + + + + + + +
+ + {/* Content */} +
+
+ + {item.title} + +
+

+ {item.description} +

+
+ + {/* Single Dismiss Button */} + +
+ )} +
+
+ +
+ + + ); +} diff --git a/src/components/layout/right-nav.tsx b/src/components/layout/right-nav.tsx index 90ce090..5caf5dd 100644 --- a/src/components/layout/right-nav.tsx +++ b/src/components/layout/right-nav.tsx @@ -207,7 +207,7 @@ export function RightNav() { 0}> {unreadCount() > 9 ? "9+" : unreadCount()} diff --git a/src/components/ui/icons.tsx b/src/components/ui/icons.tsx index a1287f1..01efb93 100644 --- a/src/components/ui/icons.tsx +++ b/src/components/ui/icons.tsx @@ -693,3 +693,12 @@ export function IconExternalLink(props: IconProps) { ); } +export function IconBell(props: IconProps) { + return ( + + + + + ); +} + diff --git a/src/lib/notifications.ts b/src/lib/notifications.ts new file mode 100644 index 0000000..42c9e9b --- /dev/null +++ b/src/lib/notifications.ts @@ -0,0 +1,54 @@ +export type NotificationType = "message" | "event" | "exam" | "homework"; + +export interface NotificationItem { + id: string; + type: NotificationType; + title: string; + description: string; + targetUrl: string; + timestamp: number; +} + +const STORAGE_KEY = "hezarfen.dismissedNotifications"; + +function canUseStorage(): boolean { + return typeof window !== "undefined" && typeof localStorage !== "undefined"; +} + +export function getDismissedNotificationIds(): Set { + if (!canUseStorage()) return new Set(); + try { + const raw = localStorage.getItem(STORAGE_KEY); + if (!raw) return new Set(); + const arr = JSON.parse(raw); + return Array.isArray(arr) ? new Set(arr) : new Set(); + } catch { + return new Set(); + } +} + +export function dismissNotificationId(id: string): Set { + const current = getDismissedNotificationIds(); + current.add(id); + if (canUseStorage()) { + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify(Array.from(current))); + } catch { + // ignore + } + } + return current; +} + +export function dismissAllNotificationIds(ids: string[]): Set { + const current = getDismissedNotificationIds(); + ids.forEach((id) => current.add(id)); + if (canUseStorage()) { + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify(Array.from(current))); + } catch { + // ignore + } + } + return current; +}