Merged in feat/SW-1450-destination-pages (pull request #1215)
feat(SW-1450): removed country reference from destination city pages * feat(SW-1450): removed country reference from destination city pages Approved-by: Fredrik Thorsson
This commit is contained in:
@@ -2,7 +2,6 @@ import { z } from "zod"
|
||||
|
||||
import { tempImageVaultAssetSchema } from "../schemas/imageVault"
|
||||
import {
|
||||
destinationCountryPageRefSchema,
|
||||
linkRefsUnionSchema,
|
||||
linkUnionSchema,
|
||||
transformPageLink,
|
||||
@@ -14,7 +13,6 @@ import {
|
||||
TrackingChannelEnum,
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import { Country } from "@/types/enums/country"
|
||||
|
||||
export const destinationCityPageSchema = z
|
||||
.object({
|
||||
@@ -22,22 +20,6 @@ export const destinationCityPageSchema = z
|
||||
title: z.string(),
|
||||
destination_settings: z
|
||||
.object({
|
||||
countryConnection: z
|
||||
.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
destination_settings: z.object({
|
||||
country: z.nativeEnum(Country),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
),
|
||||
})
|
||||
.transform(
|
||||
(countryConnection) =>
|
||||
countryConnection.edges[0].node.destination_settings.country
|
||||
),
|
||||
city_denmark: z.string().optional().nullable(),
|
||||
city_finland: z.string().optional().nullable(),
|
||||
city_germany: z.string().optional().nullable(),
|
||||
@@ -47,7 +29,6 @@ export const destinationCityPageSchema = z
|
||||
})
|
||||
.transform(
|
||||
({
|
||||
countryConnection: country,
|
||||
city_denmark,
|
||||
city_finland,
|
||||
city_germany,
|
||||
@@ -55,22 +36,16 @@ export const destinationCityPageSchema = z
|
||||
city_poland,
|
||||
city_sweden,
|
||||
}) => {
|
||||
switch (country) {
|
||||
case Country.Denmark:
|
||||
return { country, city: city_denmark }
|
||||
case Country.Finland:
|
||||
return { country, city: city_finland }
|
||||
case Country.Germany:
|
||||
return { country, city: city_germany }
|
||||
case Country.Poland:
|
||||
return { country, city: city_poland }
|
||||
case Country.Norway:
|
||||
return { country, city: city_norway }
|
||||
case Country.Sweden:
|
||||
return { country, city: city_sweden }
|
||||
default:
|
||||
throw new Error(`Invalid country: ${country}`)
|
||||
}
|
||||
const cities = [
|
||||
city_denmark,
|
||||
city_finland,
|
||||
city_germany,
|
||||
city_poland,
|
||||
city_norway,
|
||||
city_sweden,
|
||||
].filter((city): city is string => Boolean(city))
|
||||
|
||||
return { city: cities[0] }
|
||||
}
|
||||
),
|
||||
heading: z.string(),
|
||||
@@ -145,15 +120,6 @@ export const destinationCityPageSchema = z
|
||||
/** REFS */
|
||||
export const destinationCityPageRefsSchema = z.object({
|
||||
destination_city_page: z.object({
|
||||
destination_settings: z.object({
|
||||
countryConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: destinationCountryPageRefSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
sidepeek_content: z.object({
|
||||
content: z.object({
|
||||
embedded_itemsConnection: z.object({
|
||||
|
||||
@@ -19,12 +19,6 @@ export function getConnections({
|
||||
destination_city_page,
|
||||
}: GetDestinationCityPageRefsSchema) {
|
||||
const connections: System["system"][] = [destination_city_page.system]
|
||||
|
||||
connections.push(
|
||||
destination_city_page.destination_settings.countryConnection.edges[0].node
|
||||
.system
|
||||
)
|
||||
|
||||
if (destination_city_page.sidepeek_content) {
|
||||
destination_city_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach(
|
||||
({ node }) => {
|
||||
|
||||
Reference in New Issue
Block a user