Merged in feat/rework-contentstack (pull request #3493)
Feat(SW-3708): refactor contentstack fetching (removing all refs) and cache invalidation * Remove all REFS * Revalidate correct language * PR fixes * PR fixes * Throw when errors from contentstack api Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -4,8 +4,7 @@ import { GetDestinationCityListData } from "../../../graphql/Query/DestinationCi
|
||||
import { GetCountryPageUrls } from "../../../graphql/Query/DestinationCountryPage/DestinationCountryPageUrl.graphql"
|
||||
import { request } from "../../../graphql/request"
|
||||
import { ApiCountry } from "../../../types/country"
|
||||
import { DestinationCountryPageEnum } from "../../../types/destinationCountryPage"
|
||||
import { generateTag, generateTagsFromSystem } from "../../../utils/generateTag"
|
||||
import { generateTag } from "../../../utils/generateTag"
|
||||
import { getCitiesByCountry } from "../../hotels/services/getCitiesByCountry"
|
||||
import { destinationCityListDataSchema } from "../destinationCityPage/output"
|
||||
import { countryPageUrlsSchema } from "./output"
|
||||
@@ -14,60 +13,7 @@ import type { Country } from "@scandic-hotels/common/constants/country"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { GetDestinationCityListDataResponse } from "../../../types/destinationCityPage"
|
||||
import type {
|
||||
DestinationCountryPageRefs,
|
||||
GetCountryPageUrlsData,
|
||||
} from "../../../types/destinationCountryPage"
|
||||
import type { System } from "../schemas/system"
|
||||
|
||||
export function generatePageTags(
|
||||
validatedData: DestinationCountryPageRefs,
|
||||
lang: Lang
|
||||
): string[] {
|
||||
const connections = getConnections(validatedData)
|
||||
return [
|
||||
generateTagsFromSystem(lang, connections),
|
||||
generateTag(lang, validatedData.destination_country_page.system.uid),
|
||||
].flat()
|
||||
}
|
||||
|
||||
export function getConnections({
|
||||
destination_country_page,
|
||||
}: DestinationCountryPageRefs) {
|
||||
const connections: System["system"][] = [destination_country_page.system]
|
||||
if (destination_country_page.blocks) {
|
||||
destination_country_page.blocks.forEach((block) => {
|
||||
switch (block.__typename) {
|
||||
case DestinationCountryPageEnum.ContentStack.blocks.Accordion: {
|
||||
if (block.accordion.length) {
|
||||
connections.push(...block.accordion.filter((c) => !!c))
|
||||
}
|
||||
break
|
||||
}
|
||||
case DestinationCountryPageEnum.ContentStack.blocks.Content:
|
||||
{
|
||||
if (block?.content?.length) {
|
||||
// TS has trouble infering the filtered types
|
||||
// @ts-ignore
|
||||
connections.push(...block.content)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
if (destination_country_page.sidepeek_content) {
|
||||
destination_country_page.sidepeek_content?.content?.embedded_itemsConnection.edges.forEach(
|
||||
({ node }) => {
|
||||
if (node.system) {
|
||||
connections.push(node.system)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return connections
|
||||
}
|
||||
import type { GetCountryPageUrlsData } from "../../../types/destinationCountryPage"
|
||||
|
||||
export async function getCityListDataByCityIdentifier(
|
||||
lang: Lang,
|
||||
|
||||
Reference in New Issue
Block a user