"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 { useEffect, useTransition } from "react"; import { toast } from "sonner"; import { deleteStructuredGuide, moveGuideToTrash, restoreStructuredGuide, startCatalogSync } from "@/app/admin/actions"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; 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 }; type SyncJob = { id: string; status: string; version: string | null; progress: number; total: number; error: string | null } | null; export function StructuredDashboard({ guides, trash, syncJob, catalogVersion }: { guides: GuideCard[]; trash: GuideCard[]; syncJob: SyncJob; catalogVersion: string | null }) { const router = useRouter(); const [pending, startTransition] = useTransition(); const syncing = syncJob?.status === "pending" || syncJob?.status === "processing"; useEffect(() => { if (!syncing) return; const timer = window.setInterval(() => router.refresh(), 3_000); return () => window.clearInterval(timer); }, [router, syncing]); 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 (
แก้ไขล่าสุด {new Date(guide.updatedAt).toLocaleString("th-TH")}
Guide ที่ซ่อนไว้จากเว็บไซต์