"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { api } from "@/lib/api"; import { useAuth } from "@/lib/auth"; import { useI18n } from "@/lib/i18n"; import type { NotificationItem } from "@/lib/types"; export default function NotificationsClient() { const { token } = useAuth(); const { t } = useI18n(); const [items, setItems] = useState([]); useEffect(() => { if (!token) return; api.getNotifications(token).then(setItems).catch(() => setItems([])); }, [token]); const markAll = async () => { if (!token) return; await api.markNotificationsRead(token); setItems((list) => list.map((n) => ({ ...n, read: true }))); }; if (!token) { return (
{t.nav.login}
); } return (

{t.notifications.title}

{t.notifSettings.title}
{items.map((n) => (
{n.title}

{n.body}

{n.created_at}
{n.link && {t.common.open}}
))} {items.length === 0 &&

{t.notifications.empty}

}
); }