feat(admin) : flag Lunaris catalog updates
This commit is contained in:
@@ -17,10 +17,11 @@ 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, catalogVersion }: { guides: GuideCard[]; trash: GuideCard[]; catalogVersion: string | null }) {
|
||||
export function StructuredDashboard({ guides, trash, catalogVersion, latestCatalogVersion }: { guides: GuideCard[]; trash: GuideCard[]; catalogVersion: string | null; latestCatalogVersion: string | null }) {
|
||||
const router = useRouter();
|
||||
const [pending, startTransition] = useTransition();
|
||||
const catalogReady = Boolean(catalogVersion);
|
||||
const updateAvailable = Boolean(catalogVersion && latestCatalogVersion && catalogVersion !== latestCatalogVersion);
|
||||
|
||||
function run(action: () => Promise<{ status: string; message?: string }>, success: string) {
|
||||
startTransition(async () => {
|
||||
@@ -33,7 +34,7 @@ export function StructuredDashboard({ guides, trash, catalogVersion }: { guides:
|
||||
return (
|
||||
<div className="flex flex-col gap-10">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2"><Badge variant="outline">Lunaris {catalogVersion ? `v${catalogVersion}` : "ยังไม่ Sync"}</Badge></div>
|
||||
<div className="flex flex-wrap items-center gap-2"><Badge variant="outline">Lunaris ที่ Sync: {catalogVersion ? `v${catalogVersion}` : "ยังไม่ Sync"}</Badge><Badge variant={updateAvailable ? "default" : "secondary"}>{latestCatalogVersion ? updateAvailable ? `มีอัปเดต: v${latestCatalogVersion}` : `ล่าสุด: v${latestCatalogVersion}` : "ตรวจสอบเวอร์ชันล่าสุดไม่ได้"}</Badge></div>
|
||||
<div className="flex gap-2"><Button variant="outline" disabled={pending} onClick={() => run(startCatalogSync, "Sync สำเร็จแล้ว")}>{pending ? <Spinner data-icon="inline-start" /> : <RefreshCwIcon data-icon="inline-start" />}Sync Catalog</Button><Button render={<Link href="/admin/create" />} nativeButton={false} disabled={!catalogReady}><PlusIcon data-icon="inline-start" />สร้าง Guide</Button></div>
|
||||
</div>
|
||||
{guides.length ? (
|
||||
|
||||
Reference in New Issue
Block a user