From 4288e643c6d21cc48696fa27b64fdf301c783a0a Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Tue, 3 Dec 2024 09:11:32 +0100 Subject: [PATCH] fix: pass lang to create booking --- .../EnterDetails/Payment/PaymentClient.tsx | 1 + i18n/dictionaries/sv.json | 1 + server/routers/booking/input.ts | 2 ++ server/routers/booking/mutation.ts | 18 ++++++++++++------ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx b/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx index ae1e523d8..827f34636 100644 --- a/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx +++ b/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx @@ -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` initiateBooking.mutate({ + language: lang, hotelId: hotel, checkInDate: fromDate, checkOutDate: toDate, diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index a67214de5..3ed973d0a 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -171,6 +171,7 @@ "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!", "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", "In adults bed": "I vuxens säng", "In crib": "I spjälsäng", diff --git a/server/routers/booking/input.ts b/server/routers/booking/input.ts index b6c82f906..43c0e670d 100644 --- a/server/routers/booking/input.ts +++ b/server/routers/booking/input.ts @@ -1,6 +1,7 @@ import { z } from "zod" import { ChildBedTypeEnum } from "@/constants/booking" +import { Lang, langToApiLang } from "@/constants/languages" const signupSchema = z.discriminatedUnion("becomeMember", [ z.object({ @@ -81,6 +82,7 @@ export const createBookingInput = z.object({ checkOutDate: z.string(), rooms: roomsSchema, payment: paymentSchema, + language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]), }) export const priceChangeInput = z.object({ diff --git a/server/routers/booking/mutation.ts b/server/routers/booking/mutation.ts index 06ae675a7..e8028bf79 100644 --- a/server/routers/booking/mutation.ts +++ b/server/routers/booking/mutation.ts @@ -47,16 +47,18 @@ export const bookingMutationRouter = router({ .input(createBookingInput) .mutation(async function ({ ctx, input }) { 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 = { membershipNumber: await getMembershipNumber(ctx.session), checkInDate, checkOutDate, hotelId, + language, } - createBookingCounter.add(1, { hotelId, checkInDate, checkOutDate }) + createBookingCounter.add(1, loggingAttributes) console.info( "api.booking.create start", @@ -68,10 +70,14 @@ export const bookingMutationRouter = router({ Authorization: `Bearer ${accessToken}`, } - const apiResponse = await api.post(api.endpoints.v1.Booking.bookings, { - headers, - body: input, - }) + const apiResponse = await api.post( + api.endpoints.v1.Booking.bookings, + { + headers, + body: inputWithoutLang, + }, + { language } + ) if (!apiResponse.ok) { const text = await apiResponse.text()