diff --git a/src/app/(shop)/konto/actions.ts b/src/app/(shop)/konto/actions.ts new file mode 100644 index 0000000..2549148 --- /dev/null +++ b/src/app/(shop)/konto/actions.ts @@ -0,0 +1,109 @@ +"use server"; +import { revalidatePath } from "next/cache"; +import { z } from "zod"; +import { db } from "@/lib/db"; +import { getCurrentUser, hashPassword, verifyPassword } from "@/lib/auth"; +import { COUNTRIES } from "@/lib/settings"; + +export type AccountState = { ok?: string; error?: string; errors?: Record; values?: Record } | null; + +const issues = (e: z.ZodError) => { + const errors: Record = {}; + for (const i of e.issues) errors[String(i.path[0])] ??= i.message; + return errors; +}; + +const profileSchema = z.object({ + firstName: z.string().trim().min(1, "Bitte gib deinen Vornamen ein.").max(80), + lastName: z.string().trim().min(1, "Bitte gib deinen Nachnamen ein.").max(80), + phone: z.string().trim().max(40).regex(/^[0-9+()/ -]*$/, "Bitte gib eine gültige Telefonnummer ein."), +}); + +export async function updateProfile(_prev: AccountState, fd: FormData): Promise { + const user = await getCurrentUser(); + if (!user) return { error: "Bitte melde dich erneut an." }; + const parsed = profileSchema.safeParse({ firstName: fd.get("firstName"), lastName: fd.get("lastName"), phone: fd.get("phone") ?? "" }); + if (!parsed.success) return { errors: issues(parsed.error), values: { firstName: String(fd.get("firstName") ?? ""), lastName: String(fd.get("lastName") ?? ""), phone: String(fd.get("phone") ?? "") } }; + const newsletter = fd.get("newsletter") === "on"; + await db.user.update({ where: { id: user.id }, data: { ...parsed.data, newsletter } }); + if (newsletter) await db.newsletterSubscriber.upsert({ where: { email: user.email }, create: { email: user.email }, update: {} }); + else await db.newsletterSubscriber.deleteMany({ where: { email: user.email } }); + revalidatePath("/konto", "layout"); + return { ok: "Deine Daten sind gespeichert." }; +} + +export async function changePassword(_prev: AccountState, fd: FormData): Promise { + const user = await getCurrentUser(); + if (!user) return { error: "Bitte melde dich erneut an." }; + const current = String(fd.get("current") ?? ""); + const next = String(fd.get("next") ?? ""); + const errors: Record = {}; + if (user.passwordHash && !(await verifyPassword(current, user.passwordHash))) errors.current = "Das aktuelle Passwort stimmt nicht."; + if (next.length < 8) errors.next = "Das neue Passwort braucht mindestens 8 Zeichen."; + else if (next !== String(fd.get("repeat") ?? "")) errors.repeat = "Die beiden Passwörter stimmen nicht überein."; + if (Object.keys(errors).length) return { errors }; + await db.user.update({ where: { id: user.id }, data: { passwordHash: await hashPassword(next) } }); + return { ok: user.passwordHash ? "Dein Passwort ist geändert." : "Dein Passwort ist gesetzt. Du kannst dich jetzt auch mit E-Mail und Passwort anmelden." }; +} + +const addressSchema = z.object({ + firstName: z.string().trim().min(1, "Bitte gib den Vornamen ein.").max(80), + lastName: z.string().trim().min(1, "Bitte gib den Nachnamen ein.").max(80), + company: z.string().trim().max(120).default(""), + street: z.string().trim().min(3, "Bitte gib Straße und Hausnummer ein.").max(120), + extra: z.string().trim().max(120).default(""), + zip: z.string().trim().regex(/^[0-9A-Za-z -]{4,10}$/, "Bitte gib eine gültige Postleitzahl ein."), + city: z.string().trim().min(2, "Bitte gib den Ort ein.").max(80), + country: z.string().trim().refine((c) => c in COUNTRIES, "Bitte wähle ein Land."), +}); + +const MAX_ADDRESSES = 10; + +export async function saveAddressBook(_prev: AccountState, fd: FormData): Promise { + const user = await getCurrentUser(); + if (!user) return { error: "Bitte melde dich erneut an." }; + const raw: Record = {}; + for (const k of ["firstName", "lastName", "company", "street", "extra", "zip", "city", "country"]) raw[k] = String(fd.get(k) ?? ""); + const parsed = addressSchema.safeParse(raw); + // Eingaben zurückgeben, damit das Formular sie nach einem Fehler behält + if (!parsed.success) return { errors: issues(parsed.error), values: raw }; + const id = String(fd.get("id") ?? ""); + const count = await db.address.count({ where: { userId: user.id } }); + if (!id && count >= MAX_ADDRESSES) return { error: `Du kannst höchstens ${MAX_ADDRESSES} Adressen speichern.`, values: raw }; + if (id && !(await db.address.findFirst({ where: { id, userId: user.id } }))) return { error: "Diese Adresse gibt es nicht mehr." }; + const makeDefault = fd.get("isDefault") === "on" || count === 0 || (count === 1 && Boolean(id)); + await db.$transaction(async (tx) => { + if (makeDefault) await tx.address.updateMany({ where: { userId: user.id }, data: { isDefault: false } }); + if (id) await tx.address.update({ where: { id }, data: { ...parsed.data, ...(makeDefault ? { isDefault: true } : {}) } }); + else await tx.address.create({ data: { ...parsed.data, userId: user.id, isDefault: makeDefault } }); + }); + revalidatePath("/konto", "layout"); + return { ok: id ? "Die Adresse ist gespeichert." : "Die Adresse ist hinzugefügt." }; +} + +export async function deleteAddress(fd: FormData) { + const user = await getCurrentUser(); + if (!user) return; + const id = String(fd.get("id") ?? ""); + const addr = await db.address.findFirst({ where: { id, userId: user.id } }); + if (!addr) return; + await db.address.delete({ where: { id } }); + if (addr.isDefault) { + const next = await db.address.findFirst({ where: { userId: user.id } }); + if (next) await db.address.update({ where: { id: next.id }, data: { isDefault: true } }); + } + revalidatePath("/konto", "layout"); +} + +export async function setDefaultAddress(fd: FormData) { + const user = await getCurrentUser(); + if (!user) return; + const id = String(fd.get("id") ?? ""); + const addr = await db.address.findFirst({ where: { id, userId: user.id } }); + if (!addr) return; + await db.$transaction([ + db.address.updateMany({ where: { userId: user.id }, data: { isDefault: false } }), + db.address.update({ where: { id }, data: { isDefault: true } }), + ]); + revalidatePath("/konto", "layout"); +} diff --git a/src/app/(shop)/konto/adressen/page.tsx b/src/app/(shop)/konto/adressen/page.tsx new file mode 100644 index 0000000..6669aa9 --- /dev/null +++ b/src/app/(shop)/konto/adressen/page.tsx @@ -0,0 +1,22 @@ +import { redirect } from "next/navigation"; +import { db } from "@/lib/db"; +import { getCurrentUser } from "@/lib/auth"; +import { COUNTRIES, getSettings } from "@/lib/settings"; +import { AccountShell } from "@/components/shop/account/AccountShell"; +import { AddressBook } from "@/components/shop/account/AddressBook"; + +export const metadata = { title: "Meine Adressen" }; + +export default async function AddressesPage() { + const user = await getCurrentUser(); + if (!user) redirect("/konto/anmelden?weiter=/konto/adressen"); + const [addresses, settings] = await Promise.all([ + db.address.findMany({ where: { userId: user.id }, orderBy: [{ isDefault: "desc" }, { id: "asc" }] }), + getSettings(), + ]); + return ( + + [c, COUNTRIES[c] ?? c])} max={10} /> + + ); +} diff --git a/src/app/(shop)/konto/bestellung/[number]/page.tsx b/src/app/(shop)/konto/bestellung/[number]/page.tsx index 9b8af28..ab45db4 100644 --- a/src/app/(shop)/konto/bestellung/[number]/page.tsx +++ b/src/app/(shop)/konto/bestellung/[number]/page.tsx @@ -1,47 +1,67 @@ +/* eslint-disable @next/next/no-img-element */ import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { db } from "@/lib/db"; import { getCurrentUser } from "@/lib/auth"; import { formatPrice } from "@/lib/money"; -import { ORDER_STATUS, PAYMENT_STATUS, dayFmt } from "@/lib/status"; +import { PAYMENT_STATUS, dayFmt } from "@/lib/status"; import type { AddressData } from "@/lib/checkout"; import { AddressLines } from "@/components/shop/AddressLines"; import { DhlTracking } from "@/components/shop/DhlTracking"; +import { AccountShell } from "@/components/shop/account/AccountShell"; +import { StatusBadge } from "@/components/shop/account/OrderCard"; import { fetchTracking, getDhlConfig, syncDelivered } from "@/lib/dhl"; export default async function OrderDetail({ params }: { params: Promise<{ number: string }> }) { const { number } = await params; const user = await getCurrentUser(); - if (!user) redirect("/konto/anmelden"); - const order = await db.order.findUnique({ where: { number }, include: { items: true } }); + if (!user) redirect(`/konto/anmelden?weiter=/konto/bestellung/${encodeURIComponent(number)}`); + const order = await db.order.findUnique({ where: { number }, include: { items: { include: { product: { select: { images: true, slug: true, active: true } } } } } }); if (!order || order.userId !== user.id) notFound(); const dhl = await getDhlConfig(); const tracking = order.trackingNumber ? await fetchTracking(dhl, order.trackingNumber) : null; if (await syncDelivered(dhl, order, tracking)) order.status = "COMPLETED"; return ( -
- ← Zurück zum Konto -

Bestellung {order.number}

-

- vom {dayFmt.format(order.createdAt)} · {ORDER_STATUS[order.status].label} · {PAYMENT_STATUS[order.paymentStatus].label} -

- {order.trackingNumber && } -
- - - {order.items.map((i) => ( - - ))} - - {order.discount > 0 && } - - -
{i.quantity} × {i.name}{i.variantName ? ` – ${i.variantName}` : ""}{formatPrice(i.total)}
Versand{formatPrice(order.shippingCost)}
Gutschein−{formatPrice(order.discount)}
Gesamt{formatPrice(order.total)}
+ vom {dayFmt.format(order.createdAt)}} + > +
+ + {PAYMENT_STATUS[order.paymentStatus].label}
+ {order.trackingNumber && } +
+

Artikel

+
    + {order.items.map((i) => { + const href = i.product?.active && i.product.slug ? `/produkt/${i.product.slug}` : null; + const img = i.product?.images[0]; + return ( +
  • + {img ? : {i.name.charAt(0)}} +
    + {href ? {i.name} : {i.name}} + {i.variantName ? `${i.variantName} · ` : ""}{i.quantity} × {formatPrice(i.unitPrice)} +
    + {formatPrice(i.total)} +
  • + ); + })} +
+
+
Zwischensumme
{formatPrice(order.subtotal)}
+
Versand
{order.shippingCost === 0 ? "Kostenlos" : formatPrice(order.shippingCost)}
+ {order.discount > 0 &&
Gutschein
−{formatPrice(order.discount)}
} +
Gesamt
{formatPrice(order.total)}
+
+

Lieferadresse

Rechnungsadresse

{order.billingAddress ? :

Wie Lieferadresse

}
-
+

← Alle Bestellungen

+ ); } diff --git a/src/app/(shop)/konto/bestellungen/page.tsx b/src/app/(shop)/konto/bestellungen/page.tsx new file mode 100644 index 0000000..671d19e --- /dev/null +++ b/src/app/(shop)/konto/bestellungen/page.tsx @@ -0,0 +1,28 @@ +import Link from "next/link"; +import { redirect } from "next/navigation"; +import { db } from "@/lib/db"; +import { getCurrentUser } from "@/lib/auth"; +import { Icon } from "@/components/Icon"; +import { AccountShell } from "@/components/shop/account/AccountShell"; +import { OrderCard } from "@/components/shop/account/OrderCard"; + +export const metadata = { title: "Meine Bestellungen" }; + +export default async function OrdersPage() { + const user = await getCurrentUser(); + if (!user) redirect("/konto/anmelden?weiter=/konto/bestellungen"); + const orders = await db.order.findMany({ where: { userId: user.id }, orderBy: { createdAt: "desc" }, include: { items: { include: { product: { select: { images: true } } } } } }); + return ( + + {orders.length === 0 ? ( +
+ +

Du hast noch nichts bestellt.

+ Zum Shop +
+ ) : ( +
{orders.map((o) => )}
+ )} +
+ ); +} diff --git a/src/app/(shop)/konto/page.tsx b/src/app/(shop)/konto/page.tsx index a60f242..50d2fd6 100644 --- a/src/app/(shop)/konto/page.tsx +++ b/src/app/(shop)/konto/page.tsx @@ -2,44 +2,80 @@ import Link from "next/link"; import { redirect } from "next/navigation"; import { db } from "@/lib/db"; import { getCurrentUser } from "@/lib/auth"; -import { logout } from "@/lib/auth-actions"; import { formatPrice } from "@/lib/money"; -import { ORDER_STATUS, dayFmt } from "@/lib/status"; +import { dayFmt } from "@/lib/status"; +import { AddressLines } from "@/components/shop/AddressLines"; +import { Icon } from "@/components/Icon"; +import { AccountShell } from "@/components/shop/account/AccountShell"; +import { OrderCard } from "@/components/shop/account/OrderCard"; export const metadata = { title: "Mein Konto" }; export default async function AccountPage() { const user = await getCurrentUser(); if (!user) redirect("/konto/anmelden"); - const orders = await db.order.findMany({ where: { userId: user.id }, orderBy: { createdAt: "desc" } }); + const [orders, orderCount, spent, address] = await Promise.all([ + db.order.findMany({ where: { userId: user.id }, orderBy: { createdAt: "desc" }, take: 3, include: { items: { include: { product: { select: { images: true } } } } } }), + db.order.count({ where: { userId: user.id } }), + db.order.aggregate({ where: { userId: user.id, status: { notIn: ["CANCELLED", "REFUNDED"] } }, _sum: { total: true } }), + db.address.findFirst({ where: { userId: user.id }, orderBy: { isDefault: "desc" } }), + ]); + const open = orders.find((o) => ["PENDING", "PAID", "PROCESSING", "SHIPPED"].includes(o.status)); return ( -
- Mein Konto -

Hallo {user.firstName || user.email}

-
- {user.role && Zum Admin-Bereich} -
-
-

Deine Bestellungen

- {orders.length === 0 ? ( -

Du hast noch nichts bestellt. Zum Shop

- ) : ( -
- - - - {orders.map((o) => ( - - - - - - - ))} - -
BestellungDatumStatusSumme
{o.number}{dayFmt.format(o.createdAt)}{ORDER_STATUS[o.status].label}{formatPrice(o.total)}
-
+ + {open && ( + + +
+ {open.status === "SHIPPED" ? "Deine Bestellung ist unterwegs" : "Wir bereiten deine Bestellung vor"} + Bestellung {open.number} vom {dayFmt.format(open.createdAt)}{open.trackingNumber ? " · Sendung verfolgen" : ""} +
+ + )} -
+ +
+
Bestellungen{orderCount}
+
Gesamtwert{formatPrice(spent._sum.total ?? 0)}
+
Newsletter{user.newsletter ? "Ja" : "Nein"}
+
+ +
+
+

Letzte Bestellungen

+ {orderCount > 3 && Alle {orderCount} ansehen} +
+ {orders.length === 0 ? ( +
+ +

Du hast noch nichts bestellt.

+ Zum Shop +
+ ) : ( +
{orders.map((o) => )}
+ )} +
+ +
+
+
+

Standardadresse

+ {address ? "Verwalten" : "Hinzufügen"} +
+ {address ? :

Noch keine Adresse gespeichert. Mit einer gespeicherten Adresse geht die nächste Bestellung schneller.

} +
+
+
+

Persönliche Daten

+ Bearbeiten +
+

+ {[user.firstName, user.lastName].filter(Boolean).join(" ") || "Kein Name hinterlegt"}
+ {user.email}
+ {user.phone || Keine Telefonnummer} +

+
+
+ ); } diff --git a/src/app/(shop)/konto/profil/page.tsx b/src/app/(shop)/konto/profil/page.tsx new file mode 100644 index 0000000..51b2c98 --- /dev/null +++ b/src/app/(shop)/konto/profil/page.tsx @@ -0,0 +1,33 @@ +import { redirect } from "next/navigation"; +import { db } from "@/lib/db"; +import { getCurrentUser } from "@/lib/auth"; +import { AccountShell } from "@/components/shop/account/AccountShell"; +import { PasswordForm, ProfileForm } from "@/components/shop/account/ProfileForms"; + +export const metadata = { title: "Profil & Sicherheit" }; + +const PROVIDERS: Record = { google: "Google", apple: "Apple" }; + +export default async function ProfilePage() { + const user = await getCurrentUser(); + if (!user) redirect("/konto/anmelden?weiter=/konto/profil"); + const identities = await db.userIdentity.findMany({ where: { userId: user.id }, select: { provider: true } }); + return ( + +
+

Persönliche Daten

+ +
+
+

{user.passwordHash ? "Passwort ändern" : "Passwort festlegen"}

+ {identities.length > 0 && ( +

+ Du meldest dich mit {identities.map((i) => PROVIDERS[i.provider] ?? i.provider).join(" und ")} an. + {!user.passwordHash && " Wenn du möchtest, kannst du zusätzlich ein Passwort festlegen."} +

+ )} + +
+
+ ); +} diff --git a/src/components/shop/AddressForm.tsx b/src/components/shop/AddressForm.tsx index d619ba7..16388e0 100644 --- a/src/components/shop/AddressForm.tsx +++ b/src/components/shop/AddressForm.tsx @@ -5,7 +5,7 @@ import type { AddressData } from "@/lib/checkout"; import { Field, SelectField } from "../Field"; import { Alert } from "./Blocks"; -function AddressFields({ prefix, values, errors, countries }: { prefix: string; values?: Partial; errors: Record; countries: [string, string][] }) { +export function AddressFields({ prefix, values, errors, countries }: { prefix: string; values?: Partial; errors: Record; countries: [string, string][] }) { const e = (k: string) => errors[prefix + k]; return ( <> diff --git a/src/components/shop/account/AccountNav.tsx b/src/components/shop/account/AccountNav.tsx new file mode 100644 index 0000000..f62c1af --- /dev/null +++ b/src/components/shop/account/AccountNav.tsx @@ -0,0 +1,26 @@ +"use client"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { Icon, type IconName } from "../../Icon"; + +const LINKS: { href: string; label: string; icon: IconName }[] = [ + { href: "/konto", label: "Übersicht", icon: "dashboard" }, + { href: "/konto/bestellungen", label: "Bestellungen", icon: "box" }, + { href: "/konto/adressen", label: "Adressen", icon: "truck" }, + { href: "/konto/profil", label: "Profil & Sicherheit", icon: "user" }, +]; + +export function AccountNav() { + const path = usePathname(); + const active = (href: string) => (href === "/konto" ? path === href : path.startsWith(href) || (href === "/konto/bestellungen" && path.startsWith("/konto/bestellung/"))); + return ( + + ); +} diff --git a/src/components/shop/account/AccountShell.tsx b/src/components/shop/account/AccountShell.tsx new file mode 100644 index 0000000..6123153 --- /dev/null +++ b/src/components/shop/account/AccountShell.tsx @@ -0,0 +1,32 @@ +import Link from "next/link"; +import type { CurrentUser } from "@/lib/auth"; +import { logout } from "@/lib/auth-actions"; +import { Icon } from "../../Icon"; +import { AccountNav } from "./AccountNav"; + +export function AccountShell({ user, title, lead, children }: { user: CurrentUser; title: string; lead?: React.ReactNode; children: React.ReactNode }) { + const name = [user.firstName, user.lastName].filter(Boolean).join(" ") || user.email; + return ( +
+ +
+

{title}

+ {lead &&

{lead}

} + {children} +
+
+ ); +} diff --git a/src/components/shop/account/AddressBook.tsx b/src/components/shop/account/AddressBook.tsx new file mode 100644 index 0000000..491dfa3 --- /dev/null +++ b/src/components/shop/account/AddressBook.tsx @@ -0,0 +1,93 @@ +"use client"; +import { useActionState, useEffect, useState } from "react"; +import type { Address } from "@prisma/client"; +import { deleteAddress, saveAddressBook, setDefaultAddress } from "@/app/(shop)/konto/actions"; +import { AddressFields } from "../AddressForm"; +import { Alert } from "../Blocks"; +import { Icon } from "../../Icon"; + +function AddressEditor({ address, countries, onDone, first }: { address?: Address; countries: [string, string][]; onDone: () => void; first: boolean }) { + const [state, action, pending] = useActionState(saveAddressBook, null); + useEffect(() => { + if (state?.ok) onDone(); + }, [state, onDone]); + return ( +
+

{address ? "Adresse bearbeiten" : "Neue Adresse"}

+ {state?.error &&
} + {address && } + + {!first && !address?.isDefault && ( + + )} +
+ + +
+ + ); +} + +export function AddressBook({ addresses, countries, max }: { addresses: Address[]; countries: [string, string][]; max: number }) { + const [editing, setEditing] = useState(addresses.length === 0 ? "new" : null); + const [saved, setSaved] = useState(false); + const [confirm, setConfirm] = useState(null); + const names = Object.fromEntries(countries); + const done = () => { + setEditing(null); + setSaved(true); + }; + return ( +
+ {saved && !editing &&
} +
+ {addresses.map((a) => + editing === a.id ? ( + + ) : ( +
+ {a.isDefault && Standard} +

+ {a.firstName} {a.lastName}
+ {a.company && <>{a.company}
} + {a.street}
+ {a.extra && <>{a.extra}
} + {a.zip} {a.city}
+ {names[a.country] ?? a.country} +

+
+ + {!a.isDefault && ( +
+ )} + {confirm === a.id ? ( +
+ + Wirklich löschen? + + +
+ ) : ( + + )} +
+
+ ), + )} + {editing === "new" ? ( + + ) : ( + addresses.length < max && ( + + ) + )} +
+
+ ); +} diff --git a/src/components/shop/account/OrderCard.tsx b/src/components/shop/account/OrderCard.tsx new file mode 100644 index 0000000..046b513 --- /dev/null +++ b/src/components/shop/account/OrderCard.tsx @@ -0,0 +1,36 @@ +/* eslint-disable @next/next/no-img-element */ +import Link from "next/link"; +import type { Order, OrderItem } from "@prisma/client"; +import { formatPrice } from "@/lib/money"; +import { ORDER_STATUS, dayFmt } from "@/lib/status"; + +export type OrderWithItems = Order & { items: (OrderItem & { product: { images: string[] } | null })[] }; + +export function StatusBadge({ status }: { status: Order["status"] }) { + const s = ORDER_STATUS[status]; + return {s.label}; +} + +export function OrderCard({ order }: { order: OrderWithItems }) { + const count = order.items.reduce((n, i) => n + i.quantity, 0); + const thumbs = order.items.slice(0, 4); + return ( + + +
+ Bestellung {order.number} + {dayFmt.format(order.createdAt)} · {count} Artikel +
+ + {formatPrice(order.total)} + + + ); +} diff --git a/src/components/shop/account/ProfileForms.tsx b/src/components/shop/account/ProfileForms.tsx new file mode 100644 index 0000000..eb13ed9 --- /dev/null +++ b/src/components/shop/account/ProfileForms.tsx @@ -0,0 +1,49 @@ +"use client"; +import { useActionState } from "react"; +import { changePassword, updateProfile } from "@/app/(shop)/konto/actions"; +import { Field } from "../../Field"; +import { Alert } from "../Blocks"; + +export function ProfileForm({ user }: { user: { firstName: string; lastName: string; email: string; phone: string; newsletter: boolean } }) { + const [state, action, pending] = useActionState(updateProfile, null); + const e = state?.errors ?? {}; + const v = { ...user, ...state?.values }; + return ( +
+ {state?.ok &&
} + {state?.error &&
} +
+ + +
+ + + +
+ +
+ + ); +} + +export function PasswordForm({ hasPassword }: { hasPassword: boolean }) { + const [state, action, pending] = useActionState(changePassword, null); + const e = state?.errors ?? {}; + return ( +
+ {state?.ok &&
} + {state?.error &&
} + {hasPassword && } +
+ + +
+
+ +
+ + ); +} diff --git a/src/lib/auth-actions.ts b/src/lib/auth-actions.ts index 553f56d..16ae488 100644 --- a/src/lib/auth-actions.ts +++ b/src/lib/auth-actions.ts @@ -63,6 +63,7 @@ export async function register(_prev: AuthState, formData: FormData): Promise div { display: grid; min-width: 0; } +.sm-account__who strong { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.sm-account__who span:not(.sm-account__avatar) { font-size: 13px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.sm-account__avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-content: center; background: var(--noir); color: var(--gold); font-family: var(--font-serif); font-size: 20px; } +.sm-account__nav { display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--space-4)); padding-inline: var(--space-4); } +.sm-account__nav::-webkit-scrollbar { display: none; } +.sm-account__nav a { display: flex; align-items: center; gap: var(--space-2); flex: none; min-height: 44px; padding: 0 var(--space-4); border: var(--hairline) solid var(--line); border-radius: var(--radius-pill); color: var(--ink); text-decoration: none; font-size: 14px; background: var(--surface-raised); } +.sm-account__nav a .sm-icon { width: 18px; height: 18px; color: var(--ink-muted); } +.sm-account__nav a[aria-current="page"] { background: var(--noir); border-color: var(--noir); color: var(--on-noir); } +.sm-account__nav a[aria-current="page"] .sm-icon { color: var(--gold); } +@media (min-width: 900px) { + .sm-account__nav { flex-direction: column; gap: 2px; margin: 0; padding: 0; overflow: visible; } + .sm-account__nav a { border: 0; border-radius: var(--radius-sm); background: transparent; } + .sm-account__nav a:hover { background: var(--surface-sunken); } + .sm-account__nav a[aria-current="page"] { background: var(--surface-sunken); color: var(--ink); font-weight: 500; box-shadow: inset 2px 0 0 var(--gold); } +} +.sm-account__side-foot { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding-top: var(--space-3); border-top: var(--hairline) solid var(--line); } +.sm-account__side-foot a, .sm-account__side-foot button { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0; border: 0; background: none; color: var(--ink-muted); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; } +.sm-account__side-foot a:hover, .sm-account__side-foot button:hover { color: var(--ink); } +.sm-account__side-foot .sm-icon { width: 18px; height: 18px; } +@media (min-width: 900px) { .sm-account__side-foot { flex-direction: column; gap: 0; } } +.sm-account__main { min-width: 0; } +.sm-account__main > .sm-page__lead { margin-bottom: var(--space-6); } +.sm-account__highlight { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5); border-radius: var(--radius-md); background: var(--noir); color: var(--on-noir); text-decoration: none; } +.sm-account__highlight .sm-icon { flex: none; width: 26px; height: 26px; color: var(--gold); } +.sm-account__highlight div { display: grid; flex: 1; min-width: 0; } +.sm-account__highlight strong { font-weight: 500; } +.sm-account__highlight span { font-size: 14px; opacity: 0.8; } +.sm-account__highlight > span:last-child { font-size: 24px; opacity: 1; color: var(--gold); } +.sm-account__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-7); } +.sm-account__stats .sm-box { display: grid; gap: var(--space-1); padding: var(--space-4); } +.sm-account__stats span { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); } +.sm-account__stats strong { font-family: var(--font-serif); font-variant-numeric: lining-nums; font-size: 24px; font-weight: 500; line-height: 1.2; } +@media (max-width: 599px) { .sm-account__stats strong { font-size: 17px; } .sm-account__stats .sm-box { padding: var(--space-3); } } +.sm-account__section { margin-bottom: var(--space-7); } +.sm-account__section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); } +.sm-account__section-head h2 { margin: 0; } +.sm-account__cards { display: grid; gap: var(--space-4); } +@media (min-width: 700px) { .sm-account__cards { grid-template-columns: 1fr 1fr; } } +.sm-account__card .body { margin: 0; } +.sm-account__empty { display: grid; justify-items: center; gap: var(--space-3); text-align: center; padding: var(--space-7) var(--space-5); } +.sm-account__empty .sm-icon { width: 32px; height: 32px; color: var(--gold-deep); } +.sm-account__empty .body { margin: 0; color: var(--ink-muted); } +.sm-account__panel { margin-bottom: var(--space-5); } +.sm-account__panel > h2 { margin: 0 0 var(--space-4); } +.sm-account__panel > .body { margin: 0 0 var(--space-4); } +.sm-account__alert { margin-bottom: var(--space-4); } +.sm-account__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); } +.sm-account__badges { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: calc(-1 * var(--space-3)) 0 var(--space-5); } +.sm-status--gold { background: var(--gold-soft); color: var(--gold-deep); } +.sm-status--success { background: var(--success-soft); color: var(--success); } +.sm-status--danger { background: var(--danger-soft); color: var(--danger); } +.sm-status { text-transform: none; letter-spacing: 0; font-size: 13px; } + +.sm-orderlist { display: grid; gap: var(--space-3); } +.sm-ordercard { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "thumbs info go" "thumbs status total"; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-4); border: var(--hairline) solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); color: var(--ink); text-decoration: none; transition: border-color 150ms, box-shadow 150ms; } +.sm-ordercard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); } +.sm-ordercard__thumbs { grid-area: thumbs; display: flex; } +.sm-ordercard__thumbs .sm-ordercard__thumb + .sm-ordercard__thumb { margin-left: -14px; } +.sm-ordercard__thumb { flex: none; width: 52px; height: 52px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-sunken); border: 2px solid var(--surface-raised); display: grid; place-content: center; color: var(--ink-muted); font-size: 15px; } +.sm-ordercard__thumb img { width: 100%; height: 100%; object-fit: cover; } +.sm-ordercard__more { font-size: 13px; font-weight: 500; } +.sm-ordercard__info { grid-area: info; display: grid; min-width: 0; } +.sm-ordercard__number { font-weight: 500; } +.sm-ordercard__meta { font-size: 13px; color: var(--ink-muted); } +.sm-ordercard .sm-status { grid-area: status; justify-self: start; } +.sm-ordercard__total { grid-area: total; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; } +.sm-ordercard__go { grid-area: go; justify-self: end; font-size: 22px; color: var(--ink-muted); } +@media (min-width: 700px) { + .sm-ordercard { grid-template-columns: auto minmax(0, 1fr) auto auto auto; grid-template-areas: "thumbs info status total go"; gap: var(--space-5); } + .sm-ordercard__total { min-width: 90px; } +} + +.sm-orderitems { list-style: none; margin: 0; padding: 0; } +.sm-orderitems li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: var(--hairline) solid var(--line); } +.sm-orderitems li:first-child { padding-top: 0; } +.sm-orderitems li > div { display: grid; min-width: 0; } +.sm-orderitems a { color: var(--ink); text-decoration: none; font-weight: 500; } +.sm-orderitems a:hover { text-decoration: underline; } +.sm-orderitems small { font-size: 13px; color: var(--ink-muted); } +.sm-orderitems strong { font-weight: 500; font-variant-numeric: tabular-nums; } +.sm-ordersum { margin: var(--space-4) 0 0; display: grid; gap: var(--space-2); font-size: 14px; } +.sm-ordersum div { display: flex; justify-content: space-between; gap: var(--space-4); } +.sm-ordersum dt { color: var(--ink-muted); } +.sm-ordersum dd { margin: 0; font-variant-numeric: tabular-nums; } +.sm-ordersum__total { padding-top: var(--space-3); margin-top: var(--space-1); border-top: var(--hairline) solid var(--line); font-size: 16px; } +.sm-ordersum__total dt { color: var(--ink); font-weight: 500; } +.sm-ordersum__total dd { font-weight: 600; } + +.sm-addressgrid { display: grid; gap: var(--space-4); align-items: start; } +@media (min-width: 700px) { .sm-addressgrid { grid-template-columns: 1fr 1fr; } } +.sm-addresscard { display: grid; gap: var(--space-3); align-content: start; } +.sm-addresscard.is-default { border-color: var(--gold); } +.sm-addresscard .sm-badge { justify-self: start; } +.sm-addresscard .body { margin: 0; } +.sm-addresscard__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-4); padding-top: var(--space-3); border-top: var(--hairline) solid var(--line); } +.sm-addresscard__confirm { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); font-size: 14px; } +.sm-addresscard--add { min-height: 180px; place-content: center; justify-items: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); background: transparent; color: var(--ink-muted); font: inherit; font-size: 15px; cursor: pointer; } +.sm-addresscard--add:hover { border-color: var(--ink); color: var(--ink); } +.sm-account__editor { grid-column: 1 / -1; } +.sm-account__editor > h2 { margin: 0 0 var(--space-4); } +.sm-linkbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); } +.sm-linkbtn:hover { text-decoration-color: currentColor; } +.sm-linkbtn--danger { color: var(--danger); }