import { cookies } from "next/headers" import { notFound } from "next/navigation" import ScandicLogoIcon from "@scandic-hotels/design-system/Icons/ScandicLogoIcon" import { Typography } from "@scandic-hotels/design-system/Typography" import { dt } from "@/lib/dt" import { getAncillaryPackages, getBookingConfirmation, getProfileSafely, } from "@/lib/trpc/memoizedRequests" import AdditionalInfoForm from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm" import accessBooking, { ACCESS_GRANTED, ERROR_BAD_REQUEST, ERROR_UNAUTHORIZED, } from "@/components/HotelReservation/MyStay/accessBooking" import Footer from "@/components/HotelReservation/MyStay/Receipt/Footer" import Specification from "@/components/HotelReservation/MyStay/Receipt/Specification" import Total from "@/components/HotelReservation/MyStay/Receipt/Total" import { getIntl } from "@/i18n" import { parseRefId } from "@/utils/refId" import styles from "./page.module.css" import { CurrencyEnum } from "@/types/enums/currency" import type { LangParams, PageArgs } from "@/types/params" export default async function ReceiptPage({ params, searchParams, }: PageArgs) { const refId = searchParams.RefId if (!refId) { notFound() } const { confirmationNumber, lastName } = parseRefId(refId) const bookingConfirmation = await getBookingConfirmation( confirmationNumber, params.lang ) if (!bookingConfirmation) { return notFound() } const { booking, hotelData, room } = bookingConfirmation const { hotel } = hotelData const intl = await getIntl() const user = await getProfileSafely() const bv = cookies().get("bv")?.value const access = accessBooking(booking.guest, lastName, user, bv) if (access === ACCESS_GRANTED) { const ancillaryPackages = await getAncillaryPackages({ fromDate: dt(booking.checkInDate).format("YYYY-MM-DD"), hotelId: hotel.operaId, toDate: dt(booking.checkOutDate).format("YYYY-MM-DD"), }) const currency = booking.currencyCode !== CurrencyEnum.POINTS ? booking.currencyCode : (booking.ancillaries.find((a) => a.currency !== CurrencyEnum.POINTS) ?.currency ?? booking.packages.find((p) => p.currency !== CurrencyEnum.POINTS) ?.currency) return (
{hotel.name}
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} {`${hotel.address.streetAddress}, ${hotel.address.zipCode} ${hotel.address.city}`}
{hotel.contactInformation.email}
{hotel.contactInformation.phoneNumber}
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
{`${booking.guest.firstName} ${booking.guest.lastName}`}
{booking.guest.membershipNumber && ( {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
{`${intl.formatMessage({ defaultMessage: "Member", })} ${booking.guest.membershipNumber}`}
)}
{booking.guest.email}
{booking.guest.phoneNumber}

) } if (access === ERROR_BAD_REQUEST) { return (
) } if (access === ERROR_UNAUTHORIZED) { return (

{intl.formatMessage({ defaultMessage: "You need to be logged in to view your booking", })}

{intl.formatMessage({ defaultMessage: "And you need to be logged in with the same member account that made the booking.", })}

) } return notFound() }