fix: pass lang to create booking
This commit is contained in:
@@ -206,6 +206,7 @@ export default function PaymentClient({
|
|||||||
const paymentRedirectUrl = `${env.NEXT_PUBLIC_NODE_ENV === "development" ? `http://localhost:${env.NEXT_PUBLIC_PORT}` : ""}/${lang}/hotelreservation/payment-callback`
|
const paymentRedirectUrl = `${env.NEXT_PUBLIC_NODE_ENV === "development" ? `http://localhost:${env.NEXT_PUBLIC_PORT}` : ""}/${lang}/hotelreservation/payment-callback`
|
||||||
|
|
||||||
initiateBooking.mutate({
|
initiateBooking.mutate({
|
||||||
|
language: lang,
|
||||||
hotelId: hotel,
|
hotelId: hotel,
|
||||||
checkInDate: fromDate,
|
checkInDate: fromDate,
|
||||||
checkOutDate: toDate,
|
checkOutDate: toDate,
|
||||||
|
|||||||
@@ -171,6 +171,7 @@
|
|||||||
"How it works": "Hur det fungerar",
|
"How it works": "Hur det fungerar",
|
||||||
"Hurry up and use them before they expire!": "Skynda dig och använd dem innan de går ut!",
|
"Hurry up and use them before they expire!": "Skynda dig och använd dem innan de går ut!",
|
||||||
"I accept the terms and conditions": "Jag accepterar villkoren",
|
"I accept the terms and conditions": "Jag accepterar villkoren",
|
||||||
|
"I would like to get my booking confirmation via sms": "Jag vill få min bokningsbekräftelse via sms",
|
||||||
"Image gallery": "{name} - Bildgalleri",
|
"Image gallery": "{name} - Bildgalleri",
|
||||||
"In adults bed": "I vuxens säng",
|
"In adults bed": "I vuxens säng",
|
||||||
"In crib": "I spjälsäng",
|
"In crib": "I spjälsäng",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { ChildBedTypeEnum } from "@/constants/booking"
|
import { ChildBedTypeEnum } from "@/constants/booking"
|
||||||
|
import { Lang, langToApiLang } from "@/constants/languages"
|
||||||
|
|
||||||
const signupSchema = z.discriminatedUnion("becomeMember", [
|
const signupSchema = z.discriminatedUnion("becomeMember", [
|
||||||
z.object({
|
z.object({
|
||||||
@@ -81,6 +82,7 @@ export const createBookingInput = z.object({
|
|||||||
checkOutDate: z.string(),
|
checkOutDate: z.string(),
|
||||||
rooms: roomsSchema,
|
rooms: roomsSchema,
|
||||||
payment: paymentSchema,
|
payment: paymentSchema,
|
||||||
|
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const priceChangeInput = z.object({
|
export const priceChangeInput = z.object({
|
||||||
|
|||||||
@@ -47,16 +47,18 @@ export const bookingMutationRouter = router({
|
|||||||
.input(createBookingInput)
|
.input(createBookingInput)
|
||||||
.mutation(async function ({ ctx, input }) {
|
.mutation(async function ({ ctx, input }) {
|
||||||
const accessToken = ctx.session?.token.access_token ?? ctx.serviceToken
|
const accessToken = ctx.session?.token.access_token ?? ctx.serviceToken
|
||||||
const { checkInDate, checkOutDate, hotelId } = input
|
const { language, ...inputWithoutLang } = input
|
||||||
|
const { hotelId, checkInDate, checkOutDate } = inputWithoutLang
|
||||||
|
|
||||||
const loggingAttributes = {
|
const loggingAttributes = {
|
||||||
membershipNumber: await getMembershipNumber(ctx.session),
|
membershipNumber: await getMembershipNumber(ctx.session),
|
||||||
checkInDate,
|
checkInDate,
|
||||||
checkOutDate,
|
checkOutDate,
|
||||||
hotelId,
|
hotelId,
|
||||||
|
language,
|
||||||
}
|
}
|
||||||
|
|
||||||
createBookingCounter.add(1, { hotelId, checkInDate, checkOutDate })
|
createBookingCounter.add(1, loggingAttributes)
|
||||||
|
|
||||||
console.info(
|
console.info(
|
||||||
"api.booking.create start",
|
"api.booking.create start",
|
||||||
@@ -68,10 +70,14 @@ export const bookingMutationRouter = router({
|
|||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiResponse = await api.post(api.endpoints.v1.Booking.bookings, {
|
const apiResponse = await api.post(
|
||||||
headers,
|
api.endpoints.v1.Booking.bookings,
|
||||||
body: input,
|
{
|
||||||
})
|
headers,
|
||||||
|
body: inputWithoutLang,
|
||||||
|
},
|
||||||
|
{ language }
|
||||||
|
)
|
||||||
|
|
||||||
if (!apiResponse.ok) {
|
if (!apiResponse.ok) {
|
||||||
const text = await apiResponse.text()
|
const text = await apiResponse.text()
|
||||||
|
|||||||
Reference in New Issue
Block a user