"use client"; import { useEffect, useMemo, useState } from "react"; import Link from "next/link"; import { AuthGuard } from "@/components/AuthGuard"; import { Button } from "@/components/ui"; import { loadCommercialNotifications } from "@/modules/commercial/adapters"; import type { AdapterResult, CommercialNotification } from "@/modules/commercial/types"; import { CommercialEmptyState, CommercialSkeleton, PlatformShell, } from "@/modules/commercial/components"; type Filter = "all" | "unread" | "high" | "medium" | "low"; function NotificationsInner() { const [result, setResult] = useState | null>(null); const [filter, setFilter] = useState("all"); const [loading, setLoading] = useState(true); useEffect(() => { void loadCommercialNotifications().then((r) => { setResult(r); setLoading(false); }); }, []); const items = useMemo(() => { const list = result?.data || []; return list.filter((n) => { if (filter === "unread") return !n.read; if (filter === "high" || filter === "medium" || filter === "low") { const p = (n.priority || n.severity || "").toLowerCase(); return p === filter || (filter === "high" && (p === "critical" || p === "urgent")); } return true; }); }, [result, filter]); return (
{( [ ["all", "همه"], ["unread", "خوانده‌نشده"], ["high", "اولویت بالا"], ["medium", "متوسط"], ["low", "پایین"], ] as const ).map(([id, label]) => ( ))}
{loading ? : null} {!loading && (!result || result.availability !== "ready" || !items.length) ? ( ) : null} {!loading && items.length ? (
    {items.map((n) => (
  • {n.title}

    {n.priority || n.severity || "normal"} {!n.read ? " · unread" : ""}
    {n.body ?

    {n.body}

    : null} {n.href ? ( باز کردن ) : null}
  • ))}
) : null}
); } export default function NotificationsPage() { return ( ); }