"use client"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { PlusIcon, RefreshCwIcon, RotateCcwIcon, Trash2Icon } from "lucide-react"; import { useTransition } from "react"; import { toast } from "sonner"; import { deleteStructuredGuide, moveGuideToTrash, restoreStructuredGuide, startCatalogSync } from "@/app/admin/actions"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty"; import { Spinner } from "@/components/ui/spinner"; type GuideCard = { id: string; characterKey: string; name: string; overview: string; coverUrl: string; version: number; updatedAt: Date; trashedAt: Date | null }; export function StructuredDashboard({ guides, trash, catalogReady }: { guides: GuideCard[]; trash: GuideCard[]; catalogReady: boolean }) { const router = useRouter(); const [pending, startTransition] = useTransition(); function run(action: () => Promise<{ status: string; message?: string }>, success: string) { startTransition(async () => { const result = await action(); if (result.status === "error") toast.error(result.message); else { toast.success(success); router.refresh(); } }); } return (
Lunaris {catalogReady ? "พร้อมใช้งาน" : "ยังไม่ Sync"}
{guides.length ? (
{guides.map((guide) => (
{`Guide
{guide.name}{guide.overview}v{guide.version}

แก้ไขล่าสุด {new Date(guide.updatedAt).toLocaleString("th-TH")}

}>ย้าย {guide.name} ไปถังขยะย้าย {guide.name} ไปถังขยะ?Guide จะหายจากหน้าเว็บไซต์ทันที และสามารถกู้คืนได้ภายหลังยกเลิก run(() => moveGuideToTrash(guide.id), "ย้ายไปถังขยะแล้ว")}>ย้ายไปถังขยะ
))}
) : ยังไม่มี GuideSync Catalog แล้วเลือกตัวละครเพื่อสร้าง Guide แรก} {trash.length ?

ถังขยะ

Guide ที่ซ่อนไว้จากเว็บไซต์

{trash.map((guide) => {guide.name}{guide.overview}
}>ลบถาวรลบ {guide.name} ถาวร?ข้อมูล Weapons, Artifacts, Constellations, Team และ Extra ทั้งหมดจะกู้คืนไม่ได้ยกเลิก run(() => deleteStructuredGuide(guide.id), "ลบ Guide ถาวรแล้ว")}>ยืนยันลบถาวร
)}
: null}
); }