From dc45fae81b356713dd09001574716d934ffab662 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 16:45:53 +0000 Subject: [PATCH] =?UTF-8?q?Gutscheine:=20Neuer=20Gutschein=20als=20Popup?= =?UTF-8?q?=20=C3=BCber=20=E2=80=9EGutschein=20erstellen=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL --- src/app/admin/(panel)/gutscheine/page.tsx | 45 +++++-------------- src/components/admin/CouponFields.tsx | 28 ++++++++++++ src/components/admin/NewCouponDialog.tsx | 55 +++++++++++++++++++++++ src/styles/admin.css | 14 ++++++ 4 files changed, 109 insertions(+), 33 deletions(-) create mode 100644 src/components/admin/CouponFields.tsx create mode 100644 src/components/admin/NewCouponDialog.tsx diff --git a/src/app/admin/(panel)/gutscheine/page.tsx b/src/app/admin/(panel)/gutscheine/page.tsx index a946612..007f4d2 100644 --- a/src/app/admin/(panel)/gutscheine/page.tsx +++ b/src/app/admin/(panel)/gutscheine/page.tsx @@ -1,42 +1,25 @@ import { db } from "@/lib/db"; import { requireAdmin } from "@/lib/auth"; -import { centsToInput, formatPrice } from "@/lib/money"; -import { Field, SelectField } from "@/components/Field"; +import { formatPrice } from "@/lib/money"; import { AdminForm, ConfirmButton } from "@/components/admin/AdminForm"; -import { PageHead, Pill } from "@/components/admin/ui"; +import { CouponFields } from "@/components/admin/CouponFields"; +import { NewCouponDialog } from "@/components/admin/NewCouponDialog"; +import { Empty, PageHead, Pill } from "@/components/admin/ui"; import { deleteCoupon, saveCoupon } from "./actions"; -import type { Coupon } from "@prisma/client"; - -function CouponFields({ c }: { c?: Coupon }) { - return ( - <> - {c && } -
- - - - - -
-
- - -
-
- - -
- - - ); -} export default async function CouponsPage() { await requireAdmin("coupons.edit"); const coupons = await db.coupon.findMany({ orderBy: { createdAt: "desc" } }); return (
- + + + + {coupons.length === 0 && ( +
+ +
+ )} {coupons.map((c) => (
@@ -53,10 +36,6 @@ export default async function CouponsPage() {
))} -
-

Neuer Gutschein

-
-
); } diff --git a/src/components/admin/CouponFields.tsx b/src/components/admin/CouponFields.tsx new file mode 100644 index 0000000..66c965c --- /dev/null +++ b/src/components/admin/CouponFields.tsx @@ -0,0 +1,28 @@ +import type { Coupon } from "@prisma/client"; +import { centsToInput } from "@/lib/money"; +import { Field, SelectField } from "../Field"; + +/** Felder eines Gutscheins, für Bearbeiten und Anlegen (im Popup). */ +export function CouponFields({ c }: { c?: Coupon }) { + return ( + <> + {c && } +
+ + + + + +
+
+ + +
+
+ + +
+ + + ); +} diff --git a/src/components/admin/NewCouponDialog.tsx b/src/components/admin/NewCouponDialog.tsx new file mode 100644 index 0000000..1dab98f --- /dev/null +++ b/src/components/admin/NewCouponDialog.tsx @@ -0,0 +1,55 @@ +"use client"; +import { useEffect, useRef } from "react"; +import type { ActionResult } from "@/lib/action-result"; +import { saveCoupon } from "@/app/admin/(panel)/gutscheine/actions"; +import { AdminForm } from "./AdminForm"; +import { CouponFields } from "./CouponFields"; +import { Icon } from "../Icon"; + +function CloseOnSuccess({ state, close }: { state: ActionResult; close: () => void }) { + useEffect(() => { + if (state?.ok) close(); + }, [state, close]); + return null; +} + +/** Knopf „Gutschein erstellen“, das Formular öffnet sich als Popup und schließt nach dem Anlegen. */ +export function NewCouponDialog() { + const dialog = useRef(null); + const close = useRef(() => dialog.current?.close()).current; + return ( + <> + + e.target === e.currentTarget && close()} + > +
+
+

Neuer Gutschein

+ +
+
+ + {(state) => ( + <> + + + + )} + +
+
+
+ + ); +} diff --git a/src/styles/admin.css b/src/styles/admin.css index 4ff658b..431985e 100644 --- a/src/styles/admin.css +++ b/src/styles/admin.css @@ -288,3 +288,17 @@ a.ad-kpi:hover { border-color: var(--line-strong); } .ad-nl-confirm { display: inline-flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; } .ad-nl-progress { height: 8px; border-radius: 4px; background: var(--surface); overflow: hidden; } .ad-nl-progress span { display: block; height: 100%; background: var(--gold); transition: width 0.4s; } + +/* Popup */ +.ad-dialog { padding: 0; border: 0; background: transparent; max-width: min(640px, calc(100vw - 32px)); width: 100%; max-height: calc(100dvh - 32px); color: var(--ink); } +.ad-dialog::backdrop { background: rgb(22 20 17 / 0.45); backdrop-filter: blur(2px); } +.ad-dialog[open] { animation: ad-dialog-in 0.18s ease-out; } +@keyframes ad-dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } } +@media (prefers-reduced-motion: reduce) { .ad-dialog[open] { animation: none; } } +.ad-dialog__panel { background: var(--surface-raised); border: var(--hairline) solid var(--line); border-top: 2px solid var(--gold); border-radius: var(--radius-md); box-shadow: 0 24px 60px rgb(0 0 0 / 0.18); } +.ad-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: var(--hairline) solid var(--line); } +.ad-dialog__head h2 { margin: 0; font-family: var(--font-serif); font-size: 24px; font-weight: 500; } +.ad-dialog__close { width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-muted); font-size: 26px; line-height: 1; cursor: pointer; } +.ad-dialog__close:hover { background: var(--surface-sunken); color: var(--ink); } +.ad-dialog__body { padding: var(--space-4) var(--space-5) var(--space-2); } +.ad-dialog__body .ad-savebar { position: static; background: none; }