Merged in feat(SW-1944)-update-url-to-mystay (pull request #1566)

feat(SW-1944) Update to correct URL to my stay (for my pages/my stays and confirmation page)

* feat(SW-1944) Update to correct URL to my stay (for my pages/my stays and confirmation page)

* feat(SW-1944) updated to RefId

* feat(SW-1944) updated myStay path

* feat(SW-1944) updated refId check


Approved-by: Christian Andolf
This commit is contained in:
Pontus Dreij
2025-03-20 09:55:24 +00:00
parent e0b7c3be7b
commit 8f9e268802
13 changed files with 93 additions and 65 deletions

View File

@@ -11,12 +11,13 @@ export default function Confirmation({
booking,
hotel,
children,
refId,
}: React.PropsWithChildren<ConfirmationProps>) {
const mainRef = useRef<HTMLElement | null>(null)
return (
<main className={styles.main} ref={mainRef}>
<Header booking={booking} hotel={hotel} mainRef={mainRef} />
<Header booking={booking} hotel={hotel} mainRef={mainRef} refId={refId} />
{children}
</main>
)

View File

@@ -1,23 +1,15 @@
"use client"
import { useIntl } from "react-intl"
import { myBooking } from "@/constants/myBooking"
import { env } from "@/env/client"
import { EditIcon } from "@/components/Icons"
import Button from "@/components/TempDesignSystem/Button"
import Link from "@/components/TempDesignSystem/Link"
import useLang from "@/hooks/useLang"
import type { ManageBookingProps } from "@/types/components/hotelReservation/bookingConfirmation/actions/manageBooking"
export default function ManageBooking({
confirmationNumber,
lastName,
}: ManageBookingProps) {
export default function ManageBooking({ bookingUrl }: ManageBookingProps) {
const intl = useIntl()
const lang = useLang()
const myBookingUrl = myBooking[env.NEXT_PUBLIC_NODE_ENV][lang]
return (
<Button
asChild
@@ -27,11 +19,7 @@ export default function ManageBooking({
variant="icon"
wrapping
>
<Link
color="none"
href={`${myBookingUrl}?bookingId=${confirmationNumber}&lastName=${lastName}`}
weight="bold"
>
<Link color="none" href={bookingUrl} weight="bold">
<EditIcon />
{intl.formatMessage({ id: "Manage booking" })}
</Link>

View File

@@ -1,10 +1,13 @@
"use client"
import { useIntl } from "react-intl"
import { myStay } from "@/constants/routes/myStay"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import Title from "@/components/TempDesignSystem/Text/Title"
import useLang from "@/hooks/useLang"
import AddToCalendar from "../../AddToCalendar"
import AddToCalendarButton from "./Actions/AddToCalendarButton"
@@ -22,8 +25,10 @@ export default function Header({
booking,
hotel,
mainRef,
refId,
}: BookingConfirmationHeaderProps) {
const intl = useIntl()
const lang = useLang()
const text = intl.formatMessage(
{
@@ -57,6 +62,8 @@ export default function Header({
url: hotel.contactInformation.websiteUrl,
}
const bookingUrlPath = `${myStay[lang]}?RefId=${refId}`
return (
<header className={styles.header}>
<hgroup className={styles.hgroup}>
@@ -83,10 +90,7 @@ export default function Header({
hotelName={hotel.name}
renderButton={(onPress) => <AddToCalendarButton onPress={onPress} />}
/>
<ManageBooking
confirmationNumber={booking.confirmationNumber}
lastName={booking.guest.lastName}
/>
<ManageBooking bookingUrl={bookingUrlPath} />
<DownloadInvoice mainRef={mainRef} />
</div>
</header>

View File

@@ -1,6 +1,7 @@
import { notFound } from "next/navigation"
import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests"
import { encrypt } from "@/server/routers/utils/encryption"
import HotelDetails from "@/components/HotelReservation/BookingConfirmation/HotelDetails"
import PaymentDetails from "@/components/HotelReservation/BookingConfirmation/PaymentDetails"
@@ -33,6 +34,10 @@ export default async function BookingConfirmation({
return notFound()
}
const refId = encrypt(
`${booking.confirmationNumber},${booking.guest.lastName}`
)
return (
<BookingConfirmationProvider
bookingCode={booking.bookingCode}
@@ -46,7 +51,7 @@ export default async function BookingConfirmation({
]}
vat={booking.vatPercentage}
>
<Confirmation booking={booking} hotel={hotel} room={room}>
<Confirmation booking={booking} hotel={hotel} room={room} refId={refId}>
<div className={styles.booking}>
<Alerts booking={booking} />
<Rooms

View File

@@ -6,7 +6,7 @@ import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl"
import { customerService } from "@/constants/currentWebHrefs"
import { hotelreservation } from "@/constants/routes/hotelReservation"
import { myStay } from "@/constants/routes/myStay"
import { trpc } from "@/lib/trpc/client"
import Button from "@/components/TempDesignSystem/Button"
@@ -44,7 +44,7 @@ export default function FindMyBooking() {
const values = form.getValues()
const value = new URLSearchParams(values).toString()
document.cookie = `bv=${encodeURIComponent(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
router.push(`${hotelreservation(lang)}/my-stay?RefId=${result.refId}`)
router.push(`${myStay[lang]}?RefId=${result.refId}`)
},
onError: (error) => {
console.error("Failed to create ref id", error)