import Link from "next/link"; import { setArchivedAction } from "@/app/admin/actions"; import { ARCHIVE_VIEW_PARAM, ARCHIVE_VIEW_VALUE, type ArchiveKind } from "@/lib/archive"; import { formatDate } from "@/lib/format"; /** * Tabs "Aktiv" / "Archiv" fuer die Admin-Listen Bestellungen, Retouren und * Produkte. Reine Links statt Client-State: der Tab steht in der URL * (?ansicht=archiv), bleibt also beim Neuladen, nach einer Server Action und * beim Teilen eines Links erhalten. Uebrige Filter (Suche, Status) bleiben * beim Wechsel stehen. */ export function AdminArchiveTabs({ basePath, isArchive, counts, keepParams, labels, }: { basePath: string; isArchive: boolean; counts: { active: number; archived: number }; keepParams: Record; labels: { ariaLabel: string; active: string; archive: string }; }) { const hrefFor = (archive: boolean): string => { const params = new URLSearchParams(Object.entries(keepParams).filter(([, value]) => value !== "")); if (archive) params.set(ARCHIVE_VIEW_PARAM, ARCHIVE_VIEW_VALUE); const query = params.toString(); return query ? `${basePath}?${query}` : basePath; }; const tabClass = (selected: boolean): string => `px-4 py-2 text-sm border-b-2 -mb-px transition-colors ${ selected ? "border-forest text-forest" : "border-transparent text-ink/60 hover:text-forest" }`; return ( ); } /** Knopf "Archivieren" bzw. "Wiederherstellen" samt Archivdatum. */ export function AdminArchiveToggle({ kind, id, archivedAt, archivedManually, labels, }: { kind: ArchiveKind; id: string; archivedAt: Date | null; archivedManually: boolean; labels: { archive: string; restore: string; archivedOn: (date: string) => string; manualHint: string }; }) { return (
{archivedAt ? ( {labels.archivedOn(formatDate(archivedAt))} {archivedManually ? ` ยท ${labels.manualHint}` : null} ) : null}
); }