diff --git a/src/app/admin/benutzer/[id]/page.tsx b/src/app/admin/benutzer/[id]/page.tsx index 4e4f708..b013fc4 100644 --- a/src/app/admin/benutzer/[id]/page.tsx +++ b/src/app/admin/benutzer/[id]/page.tsx @@ -2,8 +2,11 @@ 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, @@ -16,6 +19,7 @@ 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([ @@ -28,60 +32,56 @@ export default async function AdminBenutzerEditPage(props: PageProps<"/admin/ben const isTemporarilyLocked = Boolean(customer.lockedUntil && customer.lockedUntil > new Date()); return ( -
- +
+

{customer.firstName} {customer.lastName}

-

{t.adminUserEditPage.createdOn(formatDate(customer.createdAt))}

+

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

- -
+ {tu.save}}> -
- - -
- - - - - - - -
-

{t.adminUserEditPage.securityHeading}

-
-
-
{t.adminUserEditPage.twoFactorLabel}
-
{customer.twoFactorEnabled ? t.adminUserEditPage.twoFactorActive : t.adminUserEditPage.twoFactorInactive}
+ +
+ +
-
-
{t.adminUserEditPage.statusLabel}
+ + + + + + + + + +
+

{tu.securityHeading}

+
+
+
{tu.twoFactorLabel}
- {customer.blockedAt ? ( - - {t.adminUserEditPage.blockedSince(formatDate(customer.blockedAt))} - - ) : isTemporarilyLocked ? ( - {t.adminUserEditPage.temporarilyLockedFailedAttempts} + {customer.twoFactorEnabled ? ( + {tu.twoFactorActive} ) : ( - {t.adminUserEditPage.statusActive} + {tu.twoFactorInactive} + )} +
+
+
+
{tu.statusLabel}
+
+ {customer.blockedAt ? ( + {tu.blockedSince(formatDate(customer.blockedAt))} + ) : isTemporarilyLocked ? ( + {tu.temporarilyLockedFailedAttempts} + ) : ( + {tu.statusActive} )}
@@ -89,67 +89,39 @@ export default async function AdminBenutzerEditPage(props: PageProps<"/admin/ben
- +
+ {/* Sperren/Loeschen des eigenen Kontos ist serverseitig ohnehin + verboten — hier gar nicht erst angeboten. */} {!isSelf ? ( -
- {customer.blockedAt ? ( -
+
+

{tu.sectionDanger}

+
+ {customer.blockedAt ? ( + + + {tu.unblock} + + ) : ( +
+ + {tu.block} +
+ )} + - - - ) : ( -
- - -
- )} - - - - + {tu.deleteAccount} +
+
) : null} -
+
); } - -function Field({ - name, - label, - type = "text", - defaultValue, - required = false, -}: { - name: string; - label: string; - type?: string; - defaultValue?: string; - required?: boolean; -}) { - return ( - - ); -} diff --git a/src/app/admin/benutzer/neu/page.tsx b/src/app/admin/benutzer/neu/page.tsx index 5d66a8b..2b26a4b 100644 --- a/src/app/admin/benutzer/neu/page.tsx +++ b/src/app/admin/benutzer/neu/page.tsx @@ -1,64 +1,33 @@ import { BackLink } from "@/components/back-link"; +import { Button } from "@/components/ui"; +import { AdminField, AdminFormPanel, AdminSelect } from "@/components/admin-form"; import { createCustomerAction } from "../../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export default async function AdminBenutzerNewPage() { const t = getDictionary(await getLocale()); + const tu = t.adminUserNewPage; return (
- -

{t.adminUserNewPage.title}

-

{t.adminUserNewPage.intro}

+ +

{tu.title}

+

{tu.intro}

- -
-
- - + {tu.createAndSend}}> +
+
+ + +
+ + + + +
- - - - - +
); } - -function Field({ - name, - label, - type = "text", - required = false, -}: { - name: string; - label: string; - type?: string; - required?: boolean; -}) { - return ( - - ); -} diff --git a/src/app/admin/chargen/[id]/page.tsx b/src/app/admin/chargen/[id]/page.tsx index c45252f..c0a0681 100644 --- a/src/app/admin/chargen/[id]/page.tsx +++ b/src/app/admin/chargen/[id]/page.tsx @@ -2,96 +2,79 @@ import { notFound } from "next/navigation"; import { prisma } from "@/lib/prisma"; import { asStringArray } from "@/lib/json-array"; import { BackLink } from "@/components/back-link"; +import { Button } from "@/components/ui"; import { AdminImageField } from "@/components/admin-image-field"; +import { AdminField, AdminFieldset, AdminFormPanel } from "@/components/admin-form"; import { updateBatchAction } from "../../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export default async function AdminBatchEditPage(props: PageProps<"/admin/chargen/[id]">) { const t = getDictionary(await getLocale()); + const tb = t.adminBatchEditPage; const { id } = await props.params; const rawBatch = await prisma.batch.findUnique({ where: { id }, include: { harvest: true } }); if (!rawBatch) notFound(); const batch = { ...rawBatch, images: asStringArray(rawBatch.images) }; return ( -
- -

{t.adminBatchEditPage.title}

+
+ +

{tb.title}

{batch.code} · {batch.harvest.type} {batch.harvest.year}

-
+ + {tb.save}}> -
-
); } diff --git a/src/app/admin/ernten/[id]/page.tsx b/src/app/admin/ernten/[id]/page.tsx index fc31d52..219073a 100644 --- a/src/app/admin/ernten/[id]/page.tsx +++ b/src/app/admin/ernten/[id]/page.tsx @@ -2,13 +2,23 @@ import { notFound } from "next/navigation"; import { prisma } from "@/lib/prisma"; import { asStringArray } from "@/lib/json-array"; import { BackLink } from "@/components/back-link"; +import { Button } from "@/components/ui"; import { AdminImageField } from "@/components/admin-image-field"; +import { + AdminField, + AdminFieldset, + AdminFormPanel, + AdminHint, + AdminSwitch, + AdminTextarea, +} from "@/components/admin-form"; import { updateHarvestAction, toggleHarvestPublishedAction } from "../../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export default async function AdminHarvestEditPage(props: PageProps<"/admin/ernten/[id]">) { const t = getDictionary(await getLocale()); + const th = t.adminHarvestEditPage; const { id } = await props.params; const rawHarvest = await prisma.harvest.findUnique({ where: { id } }); if (!rawHarvest) notFound(); @@ -17,102 +27,63 @@ export default async function AdminHarvestEditPage(props: PageProps<"/admin/ernt const harvestDateValue = harvest.harvestDate.toISOString().slice(0, 10); return ( -
- -

{t.adminHarvestEditPage.title}

+
+ +

{th.title}

{harvest.isPublished ? null : ( -
-

{t.adminHarvestEditPage.draftNotice}

+
+

{th.draftNotice}

- +
)} -
+ {th.save}}> -
-