import { setRequestLocale, getTranslations } from 'next-intl/server';
import { notFound } from 'next/navigation';
import { prisma } from '@/lib/prisma';
import { Header } from '@/components/Header';
import { formatOre } from '@/lib/money';
import { Link } from '@/i18n/routing';
export default async function BookingConfirmedPage({
params,
}: {
params: Promise<{ locale: string; number: string }>;
}) {
const { locale, number } = await params;
setRequestLocale(locale);
const t = await getTranslations();
const booking = await prisma.booking.findUnique({
where: { bookingNumber: number },
include: { items: true, pickupSlot: true },
});
if (!booking) notFound();
const loc = locale as 'sv' | 'en';
return (
{t('booking.success.title')}
{t('booking.success.bookingNumber', { number: booking.bookingNumber })}
{t('booking.success.subtitle', { email: booking.email })}
{t('email.orderSummary')}
{booking.items.map((it) => (
|
{loc === 'sv' ? it.nameSv : it.nameEn}
×{it.quantity}
|
{formatOre(it.lineTotalOre, loc)}
|
))}
|
{t('common.subtotal')}
|
{formatOre(booking.subtotalOre, loc)}
|
| {t('common.ofWhichVat')} |
{formatOre(booking.vatOre, loc)}
|
| {t('common.total')} |
{formatOre(booking.totalOre, loc)}
|
{booking.pickupSlot && (
{t('email.pickup')}
{loc === 'sv'
? booking.pickupSlot.labelSv
: booking.pickupSlot.labelEn}{' '}
·{' '}
{booking.pickupSlot.startsAt.toLocaleString(
loc === 'sv' ? 'sv-SE' : 'en-SE',
{ dateStyle: 'medium', timeStyle: 'short' },
)}
)}
{t('email.invoiceInfo')}
{t('booking.success.newOrder')}
);
}