import { Boxes, ExternalLink, FolderKanban, Layers3, Plus, Tags } from "lucide-react"; import Link from "next/link"; import { redirect } from "next/navigation"; import { RootDashboardShell } from "@/components/root/root-dashboard-shell"; import { MotionFade } from "@/components/motion-fade"; import { FlashMessage } from "@/components/root/flash-message"; import { AppCard } from "@/components/ui/app-card"; import { Button } from "@/components/ui/button"; import { CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth"; import { getAdminPortfolioCategories, getAdminPortfolioProjects, getLocalizedValue, } from "@/lib/portfolio"; import { getLocalizedPath } from "@/lib/locale"; export const dynamic = "force-dynamic"; const copy = { title: "Portfolio", subtitle: "Verwaltung fuer Kategorien, Projekte und Inhalte.", overview: "Uebersicht", maintenance: "Wartungsmodus", uiKit: "UI Kit", media: "Media", siteSettings: "SEO", portfolio: "Portfolio", logout: "Ausloggen", backToSite: "Zur Website", totalCategories: "Kategorien", totalProjects: "Projekte", publishedProjects: "Veroeffentlicht", newProject: "Neues Projekt", newCategory: "Neue Kategorie", category: "Kategorie", all: "Alle", status: "Status", draft: "Entwurf", published: "Veroeffentlicht", filter: "Filtern", sort: "Sortierung", previewSet: "Preview Link gesetzt", previewMissing: "Kein Preview Link", editProject: "Projekt bearbeiten", openProject: "Projekt ansehen", empty: "Keine Projekte fuer die aktuellen Filter gefunden.", }; type RootPortfolioPageProps = { searchParams?: { category?: string; status?: "all" | "draft" | "published"; success?: string; error?: string; }; }; export default async function RootPortfolioPage({ searchParams }: RootPortfolioPageProps) { if (!isAdminAuthenticated()) { redirect("/root"); } async function logoutAction() { "use server"; clearAdminSessionCookie(); redirect("/root"); } const selectedStatus = searchParams?.status === "draft" || searchParams?.status === "published" ? searchParams.status : "all"; const [categories, projects] = await Promise.all([ getAdminPortfolioCategories(), getAdminPortfolioProjects({ categoryId: searchParams?.category || undefined, status: selectedStatus, }), ]); const publishedProjects = projects.filter((project) => project.isPublished).length; return ( } >
{searchParams?.success ? ( ) : null} {searchParams?.error ? ( ) : null}
{[ { icon: Layers3, label: copy.totalCategories, value: categories.length, }, { icon: FolderKanban, label: copy.totalProjects, value: projects.length, }, { icon: Boxes, label: copy.publishedProjects, value: publishedProjects, }, ].map((item, index) => { const Icon = item.icon; return (

{item.label}

{item.value}

); })}
{projects.map((project, index) => (
{getLocalizedValue(project.title, "de")}

{project.category.name.de}

{project.isPublished ? copy.published : copy.draft} {project.projectYear} {copy.sort} {project.sortOrder}

{project.slug}

{project.previewUrl ? copy.previewSet : copy.previewMissing}

))} {projects.length === 0 ? ( {copy.empty} ) : null}
); }