diff --git a/apps/scandic-web/app/api/web/revalidate/route.ts b/apps/scandic-web/app/api/web/revalidate/route.ts index c3c8d2818..d036dfbea 100644 --- a/apps/scandic-web/app/api/web/revalidate/route.ts +++ b/apps/scandic-web/app/api/web/revalidate/route.ts @@ -5,6 +5,7 @@ import { z } from "zod" import { Lang } from "@scandic-hotels/common/constants/language" import { getCacheClient } from "@scandic-hotels/common/dataCache" import { affix as breadcrumbsAffix } from "@scandic-hotels/trpc/routers/contentstack/breadcrumbs/utils" +import { destinationCityPageDestinationSettingsSchema } from "@scandic-hotels/trpc/routers/contentstack/destinationCityPage/output" import { languageSwitcherAffix } from "@scandic-hotels/trpc/routers/contentstack/languageSwitcher/utils" import { affix as metadataAffix } from "@scandic-hotels/trpc/routers/contentstack/metadata/utils" import { affix as pageSettingsAffix } from "@scandic-hotels/trpc/routers/contentstack/pageSettings/utils" @@ -40,6 +41,8 @@ const validateJsonBody = z.object({ hide_booking_widget: z.boolean(), }) .optional(), + destination_settings: + destinationCityPageDestinationSettingsSchema.optional(), }), }), }) @@ -160,6 +163,18 @@ export async function POST(request: NextRequest) { await cacheClient.deleteKey(pageSettingsTag, { fuzzy: true }) } + if (content_type.uid === "destination_city_page") { + const cityIdentifier = entry.destination_settings?.city + if (cityIdentifier) { + const cityPageTag = generateTag( + entryLocale, + "city_list_data", + cityIdentifier + ) + await cacheClient.deleteKey(cityPageTag, { fuzzy: true }) + } + } + return Response.json({ revalidated: true, now: Date.now() }) } catch (error) { console.error("Failed to revalidate tag(s)") diff --git a/packages/trpc/lib/routers/contentstack/destinationCityPage/output.ts b/packages/trpc/lib/routers/contentstack/destinationCityPage/output.ts index 6ad72e449..29d9d7bea 100644 --- a/packages/trpc/lib/routers/contentstack/destinationCityPage/output.ts +++ b/packages/trpc/lib/routers/contentstack/destinationCityPage/output.ts @@ -21,7 +21,7 @@ import { systemSchema } from "../schemas/system" import type { ImageVaultAsset } from "../../../types/imageVault" -const destinationCityPageDestinationSettingsSchema = z +export const destinationCityPageDestinationSettingsSchema = z .object({ city_denmark: z.string().optional().nullable(), city_finland: z.string().optional().nullable(),