import { Loader2, Sparkles, FileText, Instagram, Bot } from "lucide-react"; import type { LucideIcon } from "lucide-react"; import { useAiHealth, type AiHealthOverview } from "~/requestHandler/use-admin-hooks"; import { KpiCard } from "~/components/admin/KpiCard"; import { AdminPageTitle, faNum, faDate } from "~/components/admin/DataTable"; const STATUS_LABEL: Record = { pending: "در انتظار", processing: "در حال پردازش", success: "موفق", ready: "آماده", failed: "ناموفق", }; const STATUS_TONE: Record = { pending: "bg-yellow-500/10 text-yellow-600", processing: "bg-VITROWN_BLUE/10 text-VITROWN_BLUE", success: "bg-GREEN/10 text-GREEN", ready: "bg-GREEN/10 text-GREEN", failed: "bg-RED/10 text-RED", }; function StatusPills({ byStatus }: { byStatus: Record }) { const entries = Object.entries(byStatus); if (entries.length === 0) return

داده‌ای نیست

; return (
{entries.map(([k, v]) => ( {STATUS_LABEL[k] || k}: {faNum(v)} ))}
); } function Failures({ rows, dateKey, }: { rows: AiHealthOverview["tryon"]["recentFailures"]; dateKey: "createdAt" | "updatedAt"; }) { if (rows.length === 0) return

خطای اخیری ثبت نشده ✓

; return (

خطاهای اخیر

{rows.map((r) => (
{r.id.slice(0, 8)} {faDate(r[dateKey])}

{r.error || "—"}

))}
); } function Section({ title, icon: Icon, children, }: { title: string; icon: LucideIcon; children: React.ReactNode; }) { return (

{title}

{children}
); } export default function AdminAiHealth() { const { data, isLoading, isError } = useAiHealth(); if (isLoading) return (
); if (isError || !data) return

خطا در بارگذاری وضعیت سرویس‌های هوش مصنوعی

; return (
سلامت سرویس‌های هوش مصنوعی
0 ? "red" : "default"} />

ایمپورت ۷ روز اخیر: {faNum(data.instagram.importedLast7d)}

{data.instagram.recentImports.length > 0 && (
{data.instagram.recentImports.map((im, i) => (
@{im.account} {faNum(im.importedCount)} — {faDate(im.date)}
))}
)}
0 ? "red" : "default"} />
); }