import type { Metadata } from "next"; import { redirect } from "next/navigation"; import Link from "next/link"; import { Container, SectionHeading, LinkButton } from "@/components/ui"; import { BackLink } from "@/components/back-link"; import { ReorderButton } from "@/components/reorder-button"; import { AccountEmptyState, OrderStatusBadge, OrderStatusTimeline, OrderIcon } from "@/components/account-ui"; import { getCurrentCustomer } from "@/lib/auth"; import { getOrdersForCustomer } from "@/lib/account-data"; import { formatPrice, formatDate } from "@/lib/format"; import { getCarrierTrackingUrl } from "@/lib/shipment-tracking"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export const metadata: Metadata = { title: "Meine Bestellungen" }; export const dynamic = "force-dynamic"; // Deckt sich mit RETURN_ELIGIBLE_STATUSES in bestellungen/actions.ts. const RETURN_ELIGIBLE_STATUSES = [ "BEZAHLT", "IN_VORBEREITUNG", "VERSANDBEREIT", "VERSENDET", "ABHOLBEREIT", "ABGEHOLT", ]; export default async function KontoBestellungenPage() { const locale = await getLocale(); const t = getDictionary(locale); const statusLabels = t.orderStatusBadge; const returnStatusLabels = t.ordersPage.returnStatusLabels; const customer = await getCurrentCustomer(); if (!customer) redirect("/konto"); const orders = await getOrdersForCustomer(customer.id); return (
{order.orderNumber}
{formatDate(order.createdAt, locale)}
{order.fulfillmentMethod === "VERSAND" ? order.shipment?.shippedAt ? t.ordersPage.shippedOn(formatDate(order.shipment.shippedAt, locale)) : t.ordersPage.shippingPending : order.pickup?.pickedUpAt ? t.ordersPage.pickedUpOn(formatDate(order.pickup.pickedUpAt, locale)) : order.pickup?.readyAt ? t.ordersPage.readySince(formatDate(order.pickup.readyAt, locale)) : t.ordersPage.pickupPending}
{t.shipmentInfo.carrierLabel}: {order.shipment.carrier} ยท {t.shipmentInfo.trackingNumberLabel}:{" "} {order.shipment.trackingNumber} {(() => { const url = getCarrierTrackingUrl(order.shipment.carrier, order.shipment.trackingNumber); return url ? ( <> {" "} ยท{" "} {t.shipmentInfo.trackPackage} > ) : null; })()}
) : null} {order.giftMessage ? (๐ {t.ordersPage.giftMessagePrefix} โ{order.giftMessage}โ
) : null}{formatPrice(order.totalCents, order.currency, locale)}