feat(SW-1273): find my booking page with rudimentary validation and redirect
This commit is contained in:
@@ -108,6 +108,11 @@ export const cancelBookingInput = z.object({
|
||||
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
|
||||
})
|
||||
|
||||
export const createRefIdInput = z.object({
|
||||
confirmationNumber: z.string(),
|
||||
lastName: z.string(),
|
||||
})
|
||||
|
||||
// Query
|
||||
const confirmationNumberInput = z.object({
|
||||
confirmationNumber: z.string(),
|
||||
|
||||
@@ -10,7 +10,12 @@ import {
|
||||
} from "@/server/trpc"
|
||||
|
||||
import { getHotel } from "../hotels/query"
|
||||
import { bookingConfirmationInput, getBookingStatusInput } from "./input"
|
||||
import encryptValue from "../utils/encryptValue"
|
||||
import {
|
||||
bookingConfirmationInput,
|
||||
createRefIdInput,
|
||||
getBookingStatusInput,
|
||||
} from "./input"
|
||||
import { bookingConfirmationSchema, createBookingSchema } from "./output"
|
||||
import { getBookedHotelRoom } from "./utils"
|
||||
|
||||
@@ -228,4 +233,14 @@ export const bookingQueryRouter = router({
|
||||
|
||||
return verifiedData.data
|
||||
}),
|
||||
createRefId: serviceProcedure
|
||||
.input(createRefIdInput)
|
||||
.mutation(async function ({ input }) {
|
||||
const { confirmationNumber, lastName } = input
|
||||
const encryptedRefId = encryptValue(`${confirmationNumber},${lastName}`)
|
||||
|
||||
return {
|
||||
refId: encryptedRefId,
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { metrics } from "@opentelemetry/api"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { findMyBooking } from "@/constants/myBooking"
|
||||
import { baseUrls } from "@/constants/routes/baseUrls"
|
||||
import { batchRequest } from "@/lib/graphql/batchRequest"
|
||||
import {
|
||||
@@ -179,6 +180,18 @@ export const languageSwitcherQueryRouter = router({
|
||||
}
|
||||
|
||||
if (!uid || !lang) {
|
||||
// we have pages that are not currently routed within contentstack context,
|
||||
// therefor this fix is needed for some of these pages
|
||||
if (input && Object.values(findMyBooking).includes(input.pathName)) {
|
||||
const urls: Record<string, { url: string }> = {}
|
||||
return {
|
||||
lang,
|
||||
urls: Object.entries(findMyBooking).reduce((acc, [lang, url]) => {
|
||||
acc[lang] = { url }
|
||||
return urls
|
||||
}, urls),
|
||||
}
|
||||
}
|
||||
return { lang: lang, urls: baseUrls }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user