aktueller stand

This commit is contained in:
torbinus
2026-09-17 16:02:51 +02:00
parent 7e51514383
commit 065cb8b64f
295 changed files with 642342 additions and 1059 deletions
+106
View File
@@ -0,0 +1,106 @@
---
import Layout from "../../layouts/Layout.astro";
import { getCustomerMe, listMyOrders } from "../../lib/auth";
export const prerender = false;
const token = Astro.cookies.get("customer_jwt")?.value;
if (!token) {
return Astro.redirect("/konto/anmelden?redirect=/konto");
}
let customer;
let orders: Awaited<ReturnType<typeof listMyOrders>> = [];
try {
customer = await getCustomerMe(token);
orders = await listMyOrders(token);
} catch {
Astro.cookies.delete("customer_jwt", { path: "/" });
return Astro.redirect("/konto/anmelden?redirect=/konto");
}
const STATUS_LABELS: Record<string, string> = {
pending: "In Bearbeitung",
completed: "Abgeschlossen",
canceled: "Storniert",
requires_action: "Aktion erforderlich",
archived: "Archiviert",
draft: "Entwurf",
};
---
<Layout title="Mein Konto" description="Ihre Bestellungen bei place4bees im Überblick.">
<section class="honeycomb-bg pt-24 pb-[var(--section-y)] sm:pt-28">
<div class="mx-auto max-w-[60rem] px-[var(--gutter)]">
<div class="flex flex-wrap items-end justify-between gap-5">
<div>
<span class="section-label">Konto</span>
<h1 class="mt-5">Hallo{customer?.first_name ? `, ${customer.first_name}` : ""}</h1>
<p class="mt-2.5 text-brand-text">{customer?.email}</p>
</div>
<button id="logout-button" class="btn btn-outline">Abmelden</button>
</div>
<h2 class="mt-16 text-h3">Meine Bestellungen</h2>
{orders.length === 0 && (
<div class="surface mt-6 px-8 py-16 text-center shadow-xs">
<p class="text-brand-text">Sie haben noch keine Bestellung aufgegeben.</p>
<a href="/shop" class="btn btn-primary mt-6">Zum Shop</a>
</div>
)}
{orders.length > 0 && (
<ul class="mt-6 grid gap-3">
{orders.map((order) => (
<li>
<a
href={`/konto/bestellungen/${order.id}`}
class="group card-interactive flex flex-wrap items-center justify-between gap-x-6 gap-y-3 p-6"
>
<div>
<p class="font-medium tabular-nums text-brand-ink">Bestellung #{order.display_id}</p>
<p class="mt-1 text-sm text-brand-text-muted">
{new Intl.DateTimeFormat("de-DE", { dateStyle: "medium" }).format(new Date(order.created_at))}
</p>
</div>
<div class="flex items-center gap-5">
<span class="rounded-[6px] bg-brand-surface-sunk px-3 py-1.5 text-xs font-medium text-brand-text">
{STATUS_LABELS[order.status] ?? order.status}
</span>
<span class="font-medium tabular-nums text-brand-ink">
{new Intl.NumberFormat("de-DE", { style: "currency", currency: order.currency_code.toUpperCase() }).format(order.total)}
</span>
<svg
viewBox="0 0 20 20"
class="h-4 w-4 text-brand-primary transition-transform duration-200 ease-out group-hover:translate-x-1"
fill="none"
stroke="currentColor"
stroke-width="1.75"
aria-hidden="true"
>
<path d="M4 10h12M11 5l5 5-5 5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</div>
</a>
</li>
))}
</ul>
)}
</div>
</section>
</Layout>
<script>
import { clearCustomerTokenClient } from "../../lib/customerCookie";
// astro:page-load feuert beim ersten Laden und nach jedem
// View-Transition-Wechsel.
document.addEventListener("astro:page-load", () => {
document.getElementById("logout-button")?.addEventListener("click", () => {
clearCustomerTokenClient();
window.location.href = "/";
});
});
</script>