import { redirect, notFound } from "next/navigation"; import { Container, SectionHeading, Button } from "@/components/ui"; import { BackLink } from "@/components/back-link"; import { getCurrentCustomer } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; import { requestReturnAction } from "../../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export const dynamic = "force-dynamic"; const RETURN_ELIGIBLE_STATUSES = [ "BEZAHLT", "IN_VORBEREITUNG", "VERSANDBEREIT", "VERSENDET", "ABHOLBEREIT", "ABGEHOLT", ]; export default async function RetourePage(props: PageProps<"/konto/bestellungen/[id]/retoure">) { const t = getDictionary(await getLocale()); const { id } = await props.params; const customer = await getCurrentCustomer(); if (!customer) redirect("/konto"); const order = await prisma.order.findUnique({ where: { id }, select: { id: true, orderNumber: true, customerId: true, status: true, items: { select: { id: true, productName: true, quantity: true } }, returnRequest: { select: { id: true } }, }, }); if (!order || order.customerId !== customer.id) notFound(); if (!RETURN_ELIGIBLE_STATUSES.includes(order.status) || order.returnRequest) { redirect("/konto/bestellungen"); } return (
    {order.items.map((item) => (
  • {item.quantity} × {item.productName}
  • ))}