import { redirect } from "next/navigation";

import { MotionFade } from "@/components/motion-fade";
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { getAdminAppPath } from "@/lib/admin-routing";
import { UiKitShowcase } from "@/components/ui/ui-kit-showcase";

export const dynamic = "force-dynamic";

const copy = {
  title: "UI Kit",
  subtitle: "Globale Referenz fuer das visuelle System im Admin Bereich.",
  maintenance: "Wartungsmodus",
  overview: "Uebersicht",
  uiKit: "UI Kit",
  media: "Media",
  siteSettings: "Settings",
  portfolio: "Portfolio",
  logout: "Ausloggen",
  backToSite: "Zur Website",
};

export default async function AdminUiKitPage() {
  const authenticated = await isAdminAuthenticated();

  if (!authenticated) {
    redirect(getAdminAppPath("/"));
  }

  async function logoutAction() {
    "use server";

    await clearAdminSessionCookie();
    redirect(getAdminAppPath("/"));
  }

  return (
    <AdminDashboardShell
      copy={copy}
      active="ui-kit"
      logoutAction={logoutAction}
      headerTitle={copy.title}
      headerDescription={copy.subtitle}
    >
      <MotionFade delay={0.1}>
        <UiKitShowcase localeKey="de" />
      </MotionFade>
    </AdminDashboardShell>
  );
}
