import { notFound } from "next/navigation"; import { prisma } from "@/lib/prisma"; import { BackLink } from "@/components/back-link"; import { ConfirmForm } from "@/components/confirm-form"; import { Button } from "@/components/ui"; import { getCurrentAdmin } from "@/lib/auth"; import { formatDate } from "@/lib/format"; import { AdminField, AdminFieldset, AdminFormPanel, AdminSelect } from "@/components/admin-form"; import { AdminActionButton, AdminBadge } from "@/components/admin-list"; import { updateCustomerAction, blockCustomerAction, unblockCustomerAction, deleteCustomerAction, sendCustomerPasswordResetAction, } from "../../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export default async function AdminBenutzerEditPage(props: PageProps<"/admin/benutzer/[id]">) { const t = getDictionary(await getLocale()); const tu = t.adminUserEditPage; const { id } = await props.params; const [admin, customer] = await Promise.all([ getCurrentAdmin(), prisma.customer.findUnique({ where: { id } }), ]); if (!customer) notFound(); const isSelf = customer.id === admin?.id; const isTemporarilyLocked = Boolean(customer.lockedUntil && customer.lockedUntil > new Date()); return (

{customer.firstName} {customer.lastName}

{tu.createdOn(formatDate(customer.createdAt))}

{tu.save}}>

{tu.securityHeading}

{tu.twoFactorLabel}
{customer.twoFactorEnabled ? ( {tu.twoFactorActive} ) : ( {tu.twoFactorInactive} )}
{tu.statusLabel}
{customer.blockedAt ? ( {tu.blockedSince(formatDate(customer.blockedAt))} ) : isTemporarilyLocked ? ( {tu.temporarilyLockedFailedAttempts} ) : ( {tu.statusActive} )}
{/* Sperren/Loeschen des eigenen Kontos ist serverseitig ohnehin verboten — hier gar nicht erst angeboten. */} {!isSelf ? (

{tu.sectionDanger}

{customer.blockedAt ? (
{tu.unblock}
) : (
{tu.block}
)} {tu.deleteAccount}
) : null}
); }