36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { connection } from "next/server";
|
|
|
|
import { StructuredDashboard } from "@/components/admin/structured-dashboard";
|
|
import { AdminHeader } from "@/components/admin/admin-header";
|
|
import { LiveRefresh } from "@/components/live-refresh";
|
|
import { getAdminSession } from "@/lib/auth/server";
|
|
import { getCurrentCatalogVersion } from "@/lib/catalog/sync";
|
|
import { listGuideCards } from "@/lib/guides/queries";
|
|
|
|
export const instant = false;
|
|
|
|
export default async function AdminPage() {
|
|
await connection();
|
|
if (!(await getAdminSession())) redirect("/auth/login?next=%2Fadmin");
|
|
const [guides, trash, catalogVersion] = await Promise.all([
|
|
listGuideCards(),
|
|
listGuideCards(true),
|
|
getCurrentCatalogVersion(),
|
|
]);
|
|
return (
|
|
<div className="min-h-svh">
|
|
<LiveRefresh endpoint="/api/events/admin" />
|
|
<AdminHeader />
|
|
<main className="mx-auto flex w-full max-w-7xl flex-col gap-8 p-4 sm:p-6 lg:p-8">
|
|
<header>
|
|
<p className="text-sm font-medium text-primary">Content workspace</p>
|
|
<h1 className="font-heading text-3xl font-semibold">Guide Dashboard</h1>
|
|
<p className="mt-2 text-muted-foreground">จัดการ Guide แบบภาพ-first และบันทึกขึ้นเว็บไซต์ทันที</p>
|
|
</header>
|
|
<StructuredDashboard guides={guides} trash={trash} catalogVersion={catalogVersion} />
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|