feat: WEB-210 Updated as per review comments
This commit is contained in:
@@ -32,8 +32,11 @@ SEAMLESS_LOGOUT_NO="http://www.example.no/updatelogout?newweb=1"
|
|||||||
SEAMLESS_LOGOUT_SV="http://www.example.sv/updatelogout?newweb=1"
|
SEAMLESS_LOGOUT_SV="http://www.example.sv/updatelogout?newweb=1"
|
||||||
WEBVIEW_ENCRYPTION_KEY="MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="
|
WEBVIEW_ENCRYPTION_KEY="MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="
|
||||||
BOOKING_ENCRYPTION_KEY=""
|
BOOKING_ENCRYPTION_KEY=""
|
||||||
// (WEB-210) Note below both variables are required to Support Legacy encryption
|
// WEB-210 NodeJS v17+ uses OPENSSL 3.0 in which the encryption algorithm “DES-ECB” is deprecated and
|
||||||
|
// to enable support NODE_OPTIONS="--openssl-legacy-provider" is required.
|
||||||
NODE_OPTIONS="--openssl-legacy-provider"
|
NODE_OPTIONS="--openssl-legacy-provider"
|
||||||
|
// The runtime execution is happening in AWS functions as per Netlify setup, the AWS functions need another variable
|
||||||
|
// OPENSSL_MODULES="/var/lang/lib/ossl-modules" to enable legacy encryption support.
|
||||||
OPENSSL_MODULES="/var/lang/lib/ossl-modules"
|
OPENSSL_MODULES="/var/lang/lib/ossl-modules"
|
||||||
|
|
||||||
PUBLIC_URL="http://localhost:3000"
|
PUBLIC_URL="http://localhost:3000"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default async function SoonestStays({
|
|||||||
<SectionHeader title={title} subtitle={subtitle} link={link} />
|
<SectionHeader title={title} subtitle={subtitle} link={link} />
|
||||||
{response.data.length ? (
|
{response.data.length ? (
|
||||||
<Grids.Stackable>
|
<Grids.Stackable>
|
||||||
{response.data.map((stay) => (
|
{response.data.map((stay: any) => (
|
||||||
<StayCard
|
<StayCard
|
||||||
key={stay.attributes.confirmationNumber}
|
key={stay.attributes.confirmationNumber}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default function StayCard({ stay, lang }: StayCardProps) {
|
|||||||
const departDateTime = depart.format("YYYY-MM-DD")
|
const departDateTime = depart.format("YYYY-MM-DD")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={bookingUrl ?? ""}>
|
<Link href={bookingUrl}>
|
||||||
<article className={styles.stay}>
|
<article className={styles.stay}>
|
||||||
<Image
|
<Image
|
||||||
className={styles.image}
|
className={styles.image}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export const getStaysSchema = z.object({
|
|||||||
checkinDate: z.string(),
|
checkinDate: z.string(),
|
||||||
checkoutDate: z.string(),
|
checkoutDate: z.string(),
|
||||||
isWebAppOrigin: z.boolean(),
|
isWebAppOrigin: z.boolean(),
|
||||||
bookingUrl: z.string().optional(),
|
bookingUrl: z.string().default(""),
|
||||||
}),
|
}),
|
||||||
relationships: z.object({
|
relationships: z.object({
|
||||||
hotel: z.object({
|
hotel: z.object({
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { env } from "process"
|
||||||
|
|
||||||
import * as api from "@/lib/api"
|
import * as api from "@/lib/api"
|
||||||
import {
|
import {
|
||||||
protectedProcedure,
|
protectedProcedure,
|
||||||
@@ -63,6 +65,60 @@ function fakingRequest<T>(payload: T): Promise<T> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateStaysBookingUrl = async (verifiedData: any, ctx: any) => {
|
||||||
|
// Tenporary API call needed till we have user name in ctx session data
|
||||||
|
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
||||||
|
cache: "no-store",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Temporary domain and lang support for current web
|
||||||
|
let localeDomain = env.PUBLIC_URL
|
||||||
|
let fullBookingUrl = localeDomain + "/hotelreservation/my-booking"
|
||||||
|
switch (ctx.lang) {
|
||||||
|
case "sv":
|
||||||
|
localeDomain = localeDomain?.replace(".com", ".se")
|
||||||
|
fullBookingUrl = localeDomain + "/hotelreservation/din-bokning"
|
||||||
|
break
|
||||||
|
case "no":
|
||||||
|
localeDomain = localeDomain?.replace(".com", ".no")
|
||||||
|
fullBookingUrl = localeDomain + "/hotelreservation/my-booking"
|
||||||
|
break
|
||||||
|
case "da":
|
||||||
|
localeDomain = localeDomain?.replace(".com", ".dk")
|
||||||
|
fullBookingUrl = localeDomain + "/hotelreservation/min-booking"
|
||||||
|
break
|
||||||
|
case "fi":
|
||||||
|
localeDomain = localeDomain?.replace(".com", ".fi")
|
||||||
|
fullBookingUrl = localeDomain + "/varaa-hotelli/varauksesi"
|
||||||
|
break
|
||||||
|
case "de":
|
||||||
|
localeDomain = localeDomain?.replace(".com", ".de")
|
||||||
|
fullBookingUrl = localeDomain + "/hotelreservation/my-booking"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apiResponse.ok) {
|
||||||
|
const apiJson = await apiResponse.json()
|
||||||
|
if (apiJson.data?.attributes) {
|
||||||
|
verifiedData.data.data.forEach((stay: any) => {
|
||||||
|
const originalString =
|
||||||
|
stay.attributes.confirmationNumber.toString() +
|
||||||
|
"," +
|
||||||
|
apiJson.data.attributes.lastName
|
||||||
|
let encryptedBookingValue = encryptValue(originalString)
|
||||||
|
stay.attributes.bookingUrl =
|
||||||
|
fullBookingUrl + "?RefId=" + encryptedBookingValue
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return verifiedData
|
||||||
|
}
|
||||||
|
|
||||||
export const userQueryRouter = router({
|
export const userQueryRouter = router({
|
||||||
get: protectedProcedure
|
get: protectedProcedure
|
||||||
.input(getUserInputSchema)
|
.input(getUserInputSchema)
|
||||||
@@ -213,33 +269,10 @@ export const userQueryRouter = router({
|
|||||||
? verifiedData.data.links.offset
|
? verifiedData.data.links.offset
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
// Tenporary till we have user name in ctx session data
|
const updatedData = await updateStaysBookingUrl(verifiedData, ctx)
|
||||||
// ----
|
|
||||||
const apiResponseUser = await api.get(api.endpoints.v1.profile, {
|
|
||||||
cache: "no-store",
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
if (apiResponseUser.ok) {
|
|
||||||
const apiJsonUser = await apiResponseUser.json()
|
|
||||||
if (apiJsonUser.data?.attributes) {
|
|
||||||
verifiedData.data.data.forEach((stay) => {
|
|
||||||
const originalString =
|
|
||||||
stay.attributes.confirmationNumber.toString() +
|
|
||||||
"," +
|
|
||||||
apiJsonUser.data.attributes.lastName
|
|
||||||
let bookingUrl = encryptValue(originalString)
|
|
||||||
stay.attributes.bookingUrl =
|
|
||||||
"/hotelreservation/my-booking?RefId=" + bookingUrl
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ------------------
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: verifiedData.data.data,
|
data: updatedData.data.data,
|
||||||
nextCursor,
|
nextCursor,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@@ -298,33 +331,10 @@ export const userQueryRouter = router({
|
|||||||
? verifiedData.data.links.offset
|
? verifiedData.data.links.offset
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
// Tenporary till we have user name in ctx session data
|
const updatedData = await updateStaysBookingUrl(verifiedData, ctx)
|
||||||
// ----
|
|
||||||
const apiResponseUser = await api.get(api.endpoints.v1.profile, {
|
|
||||||
cache: "no-store",
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
if (apiResponseUser.ok) {
|
|
||||||
const apiJsonUser = await apiResponseUser.json()
|
|
||||||
if (apiJsonUser.data?.attributes) {
|
|
||||||
verifiedData.data.data.forEach((stay) => {
|
|
||||||
const originalString =
|
|
||||||
stay.attributes.confirmationNumber.toString() +
|
|
||||||
"," +
|
|
||||||
apiJsonUser.data.attributes.lastName
|
|
||||||
let bookingUrl = encryptValue(originalString)
|
|
||||||
stay.attributes.bookingUrl =
|
|
||||||
"/hotelreservation/my-booking?RefId=" + bookingUrl
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ------------------
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: verifiedData.data.data,
|
data: updatedData.data.data,
|
||||||
nextCursor,
|
nextCursor,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user