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:
Erik Tiekstra
2025-01-27 13:38:02 +00:00
parent dc105992c5
commit 5b0b82da80
4 changed files with 10 additions and 74 deletions

View File

@@ -81,7 +81,6 @@ export default async function DestinationCityPage() {
<div className={styles.mapWrapper}> <div className={styles.mapWrapper}>
<StaticMap <StaticMap
city={destination_settings.city} city={destination_settings.city}
country={destination_settings.country}
width={320} width={320}
height={200} height={200}
zoomLevel={10} zoomLevel={10}

View File

@@ -24,19 +24,6 @@ query GetDestinationCityPage($locale: String!, $uid: String!) {
destination_city_page(uid: $uid, locale: $locale) { destination_city_page(uid: $uid, locale: $locale) {
title title
destination_settings { destination_settings {
countryConnection {
edges {
node {
... on DestinationCountryPage {
title
url
destination_settings {
country
}
}
}
}
}
city_denmark city_denmark
city_finland city_finland
city_germany city_germany
@@ -89,16 +76,6 @@ query GetDestinationCityPage($locale: String!, $uid: String!) {
query GetDestinationCityPageRefs($locale: String!, $uid: String!) { query GetDestinationCityPageRefs($locale: String!, $uid: String!) {
destination_city_page(locale: $locale, uid: $uid) { destination_city_page(locale: $locale, uid: $uid) {
destination_settings {
countryConnection {
edges {
node {
__typename
...DestinationCountryPageRef
}
}
}
}
sidepeek_content { sidepeek_content {
content { content {
embedded_itemsConnection { embedded_itemsConnection {

View File

@@ -2,7 +2,6 @@ import { z } from "zod"
import { tempImageVaultAssetSchema } from "../schemas/imageVault" import { tempImageVaultAssetSchema } from "../schemas/imageVault"
import { import {
destinationCountryPageRefSchema,
linkRefsUnionSchema, linkRefsUnionSchema,
linkUnionSchema, linkUnionSchema,
transformPageLink, transformPageLink,
@@ -14,7 +13,6 @@ import {
TrackingChannelEnum, TrackingChannelEnum,
type TrackingSDKPageData, type TrackingSDKPageData,
} from "@/types/components/tracking" } from "@/types/components/tracking"
import { Country } from "@/types/enums/country"
export const destinationCityPageSchema = z export const destinationCityPageSchema = z
.object({ .object({
@@ -22,22 +20,6 @@ export const destinationCityPageSchema = z
title: z.string(), title: z.string(),
destination_settings: z destination_settings: z
.object({ .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_denmark: z.string().optional().nullable(),
city_finland: z.string().optional().nullable(), city_finland: z.string().optional().nullable(),
city_germany: z.string().optional().nullable(), city_germany: z.string().optional().nullable(),
@@ -47,7 +29,6 @@ export const destinationCityPageSchema = z
}) })
.transform( .transform(
({ ({
countryConnection: country,
city_denmark, city_denmark,
city_finland, city_finland,
city_germany, city_germany,
@@ -55,22 +36,16 @@ export const destinationCityPageSchema = z
city_poland, city_poland,
city_sweden, city_sweden,
}) => { }) => {
switch (country) { const cities = [
case Country.Denmark: city_denmark,
return { country, city: city_denmark } city_finland,
case Country.Finland: city_germany,
return { country, city: city_finland } city_poland,
case Country.Germany: city_norway,
return { country, city: city_germany } city_sweden,
case Country.Poland: ].filter((city): city is string => Boolean(city))
return { country, city: city_poland }
case Country.Norway: return { city: cities[0] }
return { country, city: city_norway }
case Country.Sweden:
return { country, city: city_sweden }
default:
throw new Error(`Invalid country: ${country}`)
}
} }
), ),
heading: z.string(), heading: z.string(),
@@ -145,15 +120,6 @@ export const destinationCityPageSchema = z
/** REFS */ /** REFS */
export const destinationCityPageRefsSchema = z.object({ export const destinationCityPageRefsSchema = z.object({
destination_city_page: 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({ sidepeek_content: z.object({
content: z.object({ content: z.object({
embedded_itemsConnection: z.object({ embedded_itemsConnection: z.object({

View File

@@ -19,12 +19,6 @@ export function getConnections({
destination_city_page, destination_city_page,
}: GetDestinationCityPageRefsSchema) { }: GetDestinationCityPageRefsSchema) {
const connections: System["system"][] = [destination_city_page.system] 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) { if (destination_city_page.sidepeek_content) {
destination_city_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach( destination_city_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach(
({ node }) => { ({ node }) => {