From f4586ba35ba6f17a0ef71a346a78e306934a0704 Mon Sep 17 00:00:00 2001 From: Chuma McPhoy Date: Tue, 20 Aug 2024 17:23:23 +0200 Subject: [PATCH] fi(SW-188): implement PR feedback --- .../ContentType/HotelPage/IntroSection/index.tsx | 7 +++++-- .../ContentType/HotelPage/Rooms/RoomCard/index.tsx | 14 ++++++-------- i18n/dictionaries/en.json | 1 + i18n/dictionaries/sv.json | 2 +- lib/api/index.ts | 4 ++-- server/routers/hotels/output.ts | 14 ++++++++------ 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/components/ContentType/HotelPage/IntroSection/index.tsx b/components/ContentType/HotelPage/IntroSection/index.tsx index 47553c61a..f93031011 100644 --- a/components/ContentType/HotelPage/IntroSection/index.tsx +++ b/components/ContentType/HotelPage/IntroSection/index.tsx @@ -30,8 +30,11 @@ export default async function IntroSection({ ) const lang = getLang() const formattedLocationText = `${streetAddress}, ${city} (${formattedDistanceText})` - const hasTripAdvisorData = - tripAdvisor?.rating && tripAdvisor?.numberOfReviews && tripAdvisor?.webUrl + const hasTripAdvisorData = !!( + tripAdvisor?.rating && + tripAdvisor?.numberOfReviews && + tripAdvisor?.webUrl + ) const formattedTripAdvisorText = hasTripAdvisorData ? intl.formatMessage( { id: "Tripadvisor reviews" }, diff --git a/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx b/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx index 6acdea99e..3cba06d8c 100644 --- a/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx +++ b/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx @@ -35,11 +35,11 @@ export function RoomCard({ return (
diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index 57f57bfd7..1cf4c1c46 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -105,6 +105,7 @@ "Retype new password": "Retype new password", "Rooms": "Rooms", "Save": "Save", + "See room details": "See room details", "Select a country": "Select a country", "Select country of residence": "Select country of residence", "Select date of birth": "Select date of birth", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index e0ec7b543..0b26bc9b4 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -54,7 +54,7 @@ "How it works": "Hur det fungerar", "hotelPages.rooms.roomCard.person": "person", "hotelPages.rooms.roomCard.persons": "personer", - "hotelPages.rooms.roomCard.seeRoomDetails": "Se rumsdetaljer", + "See room details": "Se rumsdetaljer", "Join Scandic Friends": "Gå med i Scandic Friends", "Language": "Språk", "Level": "Nivå", diff --git a/lib/api/index.ts b/lib/api/index.ts index 9ede9b315..97d24039b 100644 --- a/lib/api/index.ts +++ b/lib/api/index.ts @@ -7,7 +7,7 @@ import type { RequestOptionsWithJSONBody, RequestOptionsWithOutBody, } from "@/types/fetch" -import type { Endpoint } from "./endpoints" +import type { Endpoint, endpoints } from "./endpoints" export { endpoints } from "./endpoints" @@ -27,7 +27,7 @@ const fetch = fetchRetry(global.fetch, { }) export async function get( - endpoint: Endpoint | `${Endpoint}/${string}`, + endpoint: Endpoint | `${endpoints.v1.hotels}/${string}`, options: RequestOptionsWithOutBody, params?: URLSearchParams ) { diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index 0fdb2f96c..b11189d2e 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -19,11 +19,13 @@ const ratingsSchema = z }), }) ), - reviews: z.object({ - widgetHtmlTagId: z.string(), - widgetScriptEmbedUrlIframe: z.string(), - widgetScriptEmbedUrlJavaScript: z.string(), - }), + reviews: z + .object({ + widgetHtmlTagId: z.string(), + widgetScriptEmbedUrlIframe: z.string(), + widgetScriptEmbedUrlJavaScript: z.string(), + }) + .optional(), }), }) .optional() @@ -153,7 +155,7 @@ const detailedFacilitySchema = z.object({ code: z.string().optional(), applyToAllHotels: z.boolean(), public: z.boolean(), - icon: z.string(), //Check output. + icon: z.string(), iconName: z.string().optional(), sortOrder: z.number(), })