wip
This commit is contained in:
@@ -79,10 +79,20 @@ export default async function MyStay({
|
|||||||
email
|
email
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return renderAdditionalInfoForm()
|
return (
|
||||||
|
<RenderAdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return renderAdditionalInfoForm()
|
return (
|
||||||
|
<RenderAdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bookingConfirmation) {
|
if (!bookingConfirmation) {
|
||||||
@@ -258,18 +268,24 @@ export default async function MyStay({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderAdditionalInfoForm() {
|
|
||||||
return (
|
|
||||||
<main className={styles.main}>
|
|
||||||
<div className={styles.form}>
|
|
||||||
<AdditionalInfoForm
|
|
||||||
confirmationNumber={confirmationNumber}
|
|
||||||
lastName={lastName}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function RenderAdditionalInfoForm({
|
||||||
|
confirmationNumber,
|
||||||
|
lastName,
|
||||||
|
}: {
|
||||||
|
confirmationNumber: string
|
||||||
|
lastName: string
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<main className={styles.main}>
|
||||||
|
<div className={styles.form}>
|
||||||
|
<AdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Typography } from "@scandic-hotels/design-system/Typography"
|
|||||||
import { env } from "@/env/server"
|
import { env } from "@/env/server"
|
||||||
import { dt } from "@/lib/dt"
|
import { dt } from "@/lib/dt"
|
||||||
import {
|
import {
|
||||||
|
findBooking,
|
||||||
getAncillaryPackages,
|
getAncillaryPackages,
|
||||||
getBookingConfirmation,
|
getBookingConfirmation,
|
||||||
getLinkedReservations,
|
getLinkedReservations,
|
||||||
@@ -15,6 +16,7 @@ import {
|
|||||||
} from "@/lib/trpc/memoizedRequests"
|
} from "@/lib/trpc/memoizedRequests"
|
||||||
import { decrypt } from "@/server/routers/utils/encryption"
|
import { decrypt } from "@/server/routers/utils/encryption"
|
||||||
|
|
||||||
|
import { auth } from "@/auth"
|
||||||
import AdditionalInfoForm from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm"
|
import AdditionalInfoForm from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm"
|
||||||
import accessBooking, {
|
import accessBooking, {
|
||||||
ACCESS_GRANTED,
|
ACCESS_GRANTED,
|
||||||
@@ -32,6 +34,7 @@ import Image from "@/components/Image"
|
|||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
import { setLang } from "@/i18n/serverContext"
|
import { setLang } from "@/i18n/serverContext"
|
||||||
import MyStayProvider from "@/providers/MyStay"
|
import MyStayProvider from "@/providers/MyStay"
|
||||||
|
import { isValidSession } from "@/utils/session"
|
||||||
import { getCurrentWebUrl } from "@/utils/url"
|
import { getCurrentWebUrl } from "@/utils/url"
|
||||||
|
|
||||||
import styles from "./page.module.css"
|
import styles from "./page.module.css"
|
||||||
@@ -54,9 +57,42 @@ export default async function MyStay({
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
const session = await auth()
|
||||||
|
const isLoggedIn = isValidSession(session)
|
||||||
|
|
||||||
const [confirmationNumber, lastName] = value.split(",")
|
const [confirmationNumber, lastName] = value.split(",")
|
||||||
const bookingConfirmation = await getBookingConfirmation(confirmationNumber)
|
const bv = cookies().get("bv")?.value
|
||||||
|
let bookingConfirmation
|
||||||
|
if (isLoggedIn) {
|
||||||
|
bookingConfirmation = await getBookingConfirmation(confirmationNumber)
|
||||||
|
} else if (bv) {
|
||||||
|
const params = new URLSearchParams(bv)
|
||||||
|
const firstName = params.get("firstName")
|
||||||
|
const email = params.get("email")
|
||||||
|
|
||||||
|
if (firstName && email) {
|
||||||
|
bookingConfirmation = await findBooking(
|
||||||
|
confirmationNumber,
|
||||||
|
lastName,
|
||||||
|
firstName,
|
||||||
|
email
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<RenderAdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<RenderAdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
if (!bookingConfirmation) {
|
if (!bookingConfirmation) {
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
@@ -64,7 +100,6 @@ export default async function MyStay({
|
|||||||
const { additionalData, booking, hotel, roomCategories } = bookingConfirmation
|
const { additionalData, booking, hotel, roomCategories } = bookingConfirmation
|
||||||
|
|
||||||
const user = await getProfileSafely()
|
const user = await getProfileSafely()
|
||||||
const bv = cookies().get("bv")?.value
|
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
const access = accessBooking(booking.guest, lastName, user, bv)
|
const access = accessBooking(booking.guest, lastName, user, bv)
|
||||||
@@ -232,3 +267,22 @@ export default async function MyStay({
|
|||||||
|
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function RenderAdditionalInfoForm({
|
||||||
|
confirmationNumber,
|
||||||
|
lastName,
|
||||||
|
}: {
|
||||||
|
confirmationNumber: string
|
||||||
|
lastName: string
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<main className={styles.main}>
|
||||||
|
<div className={styles.form}>
|
||||||
|
<AdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ import { Typography } from "@scandic-hotels/design-system/Typography"
|
|||||||
|
|
||||||
import { dt } from "@/lib/dt"
|
import { dt } from "@/lib/dt"
|
||||||
import {
|
import {
|
||||||
|
findBooking,
|
||||||
getAncillaryPackages,
|
getAncillaryPackages,
|
||||||
getBookingConfirmation,
|
getBookingConfirmation,
|
||||||
getProfileSafely,
|
getProfileSafely,
|
||||||
} from "@/lib/trpc/memoizedRequests"
|
} from "@/lib/trpc/memoizedRequests"
|
||||||
import { decrypt } from "@/server/routers/utils/encryption"
|
import { decrypt } from "@/server/routers/utils/encryption"
|
||||||
|
|
||||||
|
import { auth } from "@/auth"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
|
import { isValidSession } from "@/utils/session"
|
||||||
|
|
||||||
import AdditionalInfoForm from "../../FindMyBooking/AdditionalInfoForm"
|
import AdditionalInfoForm from "../../FindMyBooking/AdditionalInfoForm"
|
||||||
import accessBooking, {
|
import accessBooking, {
|
||||||
@@ -33,15 +36,48 @@ export async function Receipt({ refId }: { refId: string }) {
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
const session = await auth()
|
||||||
|
const isLoggedIn = isValidSession(session)
|
||||||
|
|
||||||
const [confirmationNumber, lastName] = value.split(",")
|
const [confirmationNumber, lastName] = value.split(",")
|
||||||
const bookingConfirmation = await getBookingConfirmation(confirmationNumber)
|
const bv = cookies().get("bv")?.value
|
||||||
|
let bookingConfirmation
|
||||||
|
if (isLoggedIn) {
|
||||||
|
bookingConfirmation = await getBookingConfirmation(confirmationNumber)
|
||||||
|
} else if (bv) {
|
||||||
|
const params = new URLSearchParams(bv)
|
||||||
|
const firstName = params.get("firstName")
|
||||||
|
const email = params.get("email")
|
||||||
|
|
||||||
|
if (firstName && email) {
|
||||||
|
bookingConfirmation = await findBooking(
|
||||||
|
confirmationNumber,
|
||||||
|
lastName,
|
||||||
|
firstName,
|
||||||
|
email
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<RenderAdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<RenderAdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
if (!bookingConfirmation) {
|
if (!bookingConfirmation) {
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
const { booking, hotel, room } = bookingConfirmation
|
const { booking, hotel, room } = bookingConfirmation
|
||||||
const user = await getProfileSafely()
|
const user = await getProfileSafely()
|
||||||
const bv = cookies().get("bv")?.value
|
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
const access = accessBooking(booking.guest, lastName, user, bv)
|
const access = accessBooking(booking.guest, lastName, user, bv)
|
||||||
@@ -166,3 +202,22 @@ export async function Receipt({ refId }: { refId: string }) {
|
|||||||
|
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function RenderAdditionalInfoForm({
|
||||||
|
confirmationNumber,
|
||||||
|
lastName,
|
||||||
|
}: {
|
||||||
|
confirmationNumber: string
|
||||||
|
lastName: string
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<main className={styles.main}>
|
||||||
|
<div className={styles.form}>
|
||||||
|
<AdditionalInfoForm
|
||||||
|
confirmationNumber={confirmationNumber}
|
||||||
|
lastName={lastName}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -81,16 +81,7 @@ export const bookingQueryRouter = router({
|
|||||||
}),
|
}),
|
||||||
findBooking: safeProtectedServiceProcedure
|
findBooking: safeProtectedServiceProcedure
|
||||||
.input(findBookingInput)
|
.input(findBookingInput)
|
||||||
.use(async ({ ctx, input, next }) => {
|
|
||||||
const lang = input.lang ?? ctx.lang
|
|
||||||
const token = ctx.session?.token.access_token ?? ctx.serviceToken
|
|
||||||
return next({
|
|
||||||
ctx: {
|
|
||||||
lang,
|
|
||||||
token,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.query(async function ({
|
.query(async function ({
|
||||||
ctx,
|
ctx,
|
||||||
input: { confirmationNumber, lastName, firstName, email },
|
input: { confirmationNumber, lastName, firstName, email },
|
||||||
@@ -99,10 +90,11 @@ export const bookingQueryRouter = router({
|
|||||||
const metricsFindBooking = findBookingCounter.init({ confirmationNumber })
|
const metricsFindBooking = findBookingCounter.init({ confirmationNumber })
|
||||||
|
|
||||||
metricsFindBooking.start()
|
metricsFindBooking.start()
|
||||||
|
|
||||||
const booking = await findBooking(
|
const booking = await findBooking(
|
||||||
confirmationNumber,
|
confirmationNumber,
|
||||||
ctx.lang,
|
ctx.lang,
|
||||||
ctx.token,
|
ctx.serviceToken,
|
||||||
lastName,
|
lastName,
|
||||||
firstName,
|
firstName,
|
||||||
email
|
email
|
||||||
|
|||||||
Reference in New Issue
Block a user