Merged in fix/destination-city-page-cache-revalidate (pull request #2492)
Fix: destination city page invalidate cache in webhook * Fix: destination city page invalidate cache in webhook * Use correct uid Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -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)")
|
||||
|
||||
Reference in New Issue
Block a user