fix: add content-page handling in languageSwitcher query

This commit is contained in:
Arvid Norlin
2024-08-14 11:54:16 +02:00
committed by Erik Tiekstra
parent 8220a39a8f
commit a01aa10bf2
3 changed files with 55 additions and 0 deletions

View File

@@ -17,3 +17,39 @@ query GetContentPage($locale: String!, $uid: String!) {
}
}
}
query GetDaDeEnUrlsContentPage($uid: String!) {
de: all_content_page(where: { uid: $uid }, locale: "de") {
items {
url
}
}
en: all_content_page(where: { uid: $uid }, locale: "en") {
items {
url
}
}
da: all_content_page(where: { uid: $uid }, locale: "da") {
items {
url
}
}
}
query GetFiNoSvUrlsContentPage($uid: String!) {
fi: all_content_page(where: { uid: $uid }, locale: "fi") {
items {
url
}
}
no: all_content_page(where: { uid: $uid }, locale: "no") {
items {
url
}
}
sv: all_content_page(where: { uid: $uid }, locale: "sv") {
items {
url
}
}
}

View File

@@ -5,6 +5,10 @@ import {
GetDaDeEnUrlsAccountPage,
GetFiNoSvUrlsAccountPage,
} from "@/lib/graphql/Query/AccountPage.graphql"
import {
GetDaDeEnUrlsContentPage,
GetFiNoSvUrlsContentPage,
} from "@/lib/graphql/Query/ContentPage.graphql"
import {
GetDaDeEnUrlsHotelPage,
GetFiNoSvUrlsHotelPage,
@@ -101,6 +105,20 @@ async function getLanguageSwitcher(options: LanguageSwitcherVariables) {
tags: tagsFiNoSv,
},
])
case PageTypeEnum.contentPage:
return await batchRequest<LanguageSwitcherQueryDataRaw>([
{
document: GetDaDeEnUrlsContentPage,
variables,
tags: tagsDaDeEn,
},
{
document: GetFiNoSvUrlsContentPage,
variables,
tags: tagsFiNoSv,
},
])
default:
console.error(`type: [${options.contentType}]`)
console.error(`Trying to get a content type that is not supported`)

View File

@@ -2,5 +2,6 @@ export enum PageTypeEnum {
accountPage = "account-page",
loyaltyPage = "loyalty-page",
hotelPage = "hotel-page",
contentPage = "content-page",
currentBlocksPage = "current-blocks-page",
}