70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
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 { getMaintenanceMode } from "@/lib/app-config";
|
|
import { AppCard } from "@/components/ui/app-card";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { CardContent } from "@/components/ui/card";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
const copy = {
|
|
title: "Wartungsmodus",
|
|
subtitle: "Steuerung fuer den globalen Wartungsstatus.",
|
|
overview: "Uebersicht",
|
|
maintenance: "Wartungsmodus",
|
|
uiKit: "UI Kit",
|
|
media: "Media",
|
|
siteSettings: "Settings",
|
|
portfolio: "Portfolio",
|
|
maintenanceText: "Wenn aktiv, werden alle Seiten auf die Coming Soon Seite weitergeleitet.",
|
|
maintenanceOn: "Aktiv",
|
|
maintenanceOff: "Inaktiv",
|
|
selectHint: "Aenderung erfolgt jetzt direkt ueber den Schalter in der Sidebar.",
|
|
logout: "Ausloggen",
|
|
backToSite: "Zur Website",
|
|
};
|
|
|
|
export default async function AdminMaintenancePage() {
|
|
const authenticated = await isAdminAuthenticated();
|
|
|
|
if (!authenticated) {
|
|
redirect(getAdminAppPath("/"));
|
|
}
|
|
|
|
const maintenanceEnabled = await getMaintenanceMode();
|
|
async function logoutAction() {
|
|
"use server";
|
|
|
|
await clearAdminSessionCookie();
|
|
redirect(getAdminAppPath("/"));
|
|
}
|
|
|
|
return (
|
|
<AdminDashboardShell
|
|
copy={copy}
|
|
active="maintenance"
|
|
logoutAction={logoutAction}
|
|
headerTitle={copy.title}
|
|
headerDescription={copy.subtitle}
|
|
>
|
|
<MotionFade delay={0.1}>
|
|
<AppCard layer="single">
|
|
<CardContent className="space-y-4 p-6">
|
|
<p className="text-sm text-muted-foreground">{copy.maintenanceText}</p>
|
|
<div className="flex flex-wrap items-center gap-3">
|
|
<Badge variant={maintenanceEnabled ? "warning" : "success"}>
|
|
{maintenanceEnabled ? copy.maintenanceOn : copy.maintenanceOff}
|
|
</Badge>
|
|
<p className="text-xs text-muted-foreground">{copy.selectHint}</p>
|
|
</div>
|
|
</CardContent>
|
|
</AppCard>
|
|
</MotionFade>
|
|
</AdminDashboardShell>
|
|
);
|
|
}
|