From 00c04de09a97e7e3911079766b7229bd6163e19d Mon Sep 17 00:00:00 2001 From: Chuma McPhoy Date: Thu, 27 Jun 2024 13:05:19 +0200 Subject: [PATCH] feat: add ability to access localized entries of Hotel pages through language switcher --- .../(public)/[contentType]/[uid]/layout.tsx | 2 +- components/ContentType/HotelPage.tsx | 2 +- lib/graphql/Query/HotelPage.graphql | 36 +++++++++++++++++++ .../contentstack/languageSwitcher/query.ts | 17 +++++++++ types/requests/pageType.ts | 1 + 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx b/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx index 15fe17b28..b271a84b4 100644 --- a/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx +++ b/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx @@ -7,7 +7,7 @@ import { UIDParams, } from "@/types/params" -export default function ContentTypeLayout({ +export default async function ContentTypeLayout({ breadcrumbs, children, }: React.PropsWithChildren< diff --git a/components/ContentType/HotelPage.tsx b/components/ContentType/HotelPage.tsx index 382e1e27f..d0ebc1bb8 100644 --- a/components/ContentType/HotelPage.tsx +++ b/components/ContentType/HotelPage.tsx @@ -13,7 +13,7 @@ export default async function HotelPage({ lang }: LangParams) { } return (
- ID: {hotelPage.hotel_page_id} + {hotelPage.title}
) } diff --git a/lib/graphql/Query/HotelPage.graphql b/lib/graphql/Query/HotelPage.graphql index 7bf4041d4..84de71e64 100644 --- a/lib/graphql/Query/HotelPage.graphql +++ b/lib/graphql/Query/HotelPage.graphql @@ -5,3 +5,39 @@ query GetHotelPage($locale: String!, $uid: String!) { title } } + +query GetDaDeEnUrlsHotelPage($uid: String!) { + de: all_hotel_page(where: { uid: $uid }, locale: "de") { + items { + url + } + } + en: all_hotel_page(where: { uid: $uid }, locale: "en") { + items { + url + } + } + da: all_hotel_page(where: { uid: $uid }, locale: "da") { + items { + url + } + } +} + +query GetFiNoSvUrlsHotelPage($uid: String!) { + fi: all_hotel_page(where: { uid: $uid }, locale: "fi") { + items { + url + } + } + no: all_hotel_page(where: { uid: $uid }, locale: "no") { + items { + url + } + } + sv: all_hotel_page(where: { uid: $uid }, locale: "sv") { + items { + url + } + } +} diff --git a/server/routers/contentstack/languageSwitcher/query.ts b/server/routers/contentstack/languageSwitcher/query.ts index 77a4cedef..82b64be14 100644 --- a/server/routers/contentstack/languageSwitcher/query.ts +++ b/server/routers/contentstack/languageSwitcher/query.ts @@ -5,6 +5,10 @@ import { GetDaDeEnUrlsAccountPage, GetFiNoSvUrlsAccountPage, } from "@/lib/graphql/Query/AccountPage.graphql" +import { + GetDaDeEnUrlsHotelPage, + GetFiNoSvUrlsHotelPage, +} from "@/lib/graphql/Query/HotelPage.graphql" import { GetDaDeEnUrlsCurrentBlocksPage, GetFiNoSvUrlsCurrentBlocksPage, @@ -84,6 +88,19 @@ async function getLanguageSwitcher(options: LanguageSwitcherVariables) { tags: tagsFiNoSv, }, ]) + case PageTypeEnum.hotelPage: + return await batchRequest([ + { + document: GetDaDeEnUrlsHotelPage, + variables, + tags: tagsDaDeEn, + }, + { + document: GetFiNoSvUrlsHotelPage, + variables, + tags: tagsFiNoSv, + }, + ]) default: console.info(`type: [${options.contentType}]`) console.error(`Trying to get a content type that is not supported`) diff --git a/types/requests/pageType.ts b/types/requests/pageType.ts index 1fcc273eb..993a697e4 100644 --- a/types/requests/pageType.ts +++ b/types/requests/pageType.ts @@ -1,5 +1,6 @@ export enum PageTypeEnum { accountPage = "account-page", loyaltyPage = "loyalty-page", + hotelPage = "hotel-page", currentBlocksPage = "current-blocks-page", }