Merged in feat/SW-1442-destination-overview-page (pull request #1188)
feat(SW-1442): added destination overview page * feat(SW-1442): added destination overview page Approved-by: Fredrik Thorsson Approved-by: Matilda Landström
This commit is contained in:
@@ -5,6 +5,7 @@ import { isSignupPage } from "@/constants/routes/signup"
|
|||||||
import { env } from "@/env/server"
|
import { env } from "@/env/server"
|
||||||
import { getHotelPage } from "@/lib/trpc/memoizedRequests"
|
import { getHotelPage } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
|
import DestinationOverviewPage from "@/components/ContentType/DestinationOverviewPage"
|
||||||
import HotelPage from "@/components/ContentType/HotelPage"
|
import HotelPage from "@/components/ContentType/HotelPage"
|
||||||
import LoyaltyPage from "@/components/ContentType/LoyaltyPage"
|
import LoyaltyPage from "@/components/ContentType/LoyaltyPage"
|
||||||
import CollectionPage from "@/components/ContentType/StaticPages/CollectionPage"
|
import CollectionPage from "@/components/ContentType/StaticPages/CollectionPage"
|
||||||
@@ -55,6 +56,8 @@ export default async function ContentTypePage({
|
|||||||
}
|
}
|
||||||
case PageContentTypeEnum.loyaltyPage:
|
case PageContentTypeEnum.loyaltyPage:
|
||||||
return <LoyaltyPage />
|
return <LoyaltyPage />
|
||||||
|
case PageContentTypeEnum.destinationOverviewPage:
|
||||||
|
return <DestinationOverviewPage />
|
||||||
case PageContentTypeEnum.hotelPage:
|
case PageContentTypeEnum.hotelPage:
|
||||||
if (env.HIDE_FOR_NEXT_RELEASE) {
|
if (env.HIDE_FOR_NEXT_RELEASE) {
|
||||||
return notFound()
|
return notFound()
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
.pageContainer {
|
||||||
|
display: grid;
|
||||||
|
max-width: var(--max-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 768px) {
|
||||||
|
.pageContainer {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
28
components/ContentType/DestinationOverviewPage/index.tsx
Normal file
28
components/ContentType/DestinationOverviewPage/index.tsx
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { Suspense } from "react"
|
||||||
|
|
||||||
|
import { getDestinationOverviewPage } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
|
import TrackingSDK from "@/components/TrackingSDK"
|
||||||
|
|
||||||
|
import styles from "./destinationOverviewPage.module.css"
|
||||||
|
|
||||||
|
export default async function DestinationOverviewPage() {
|
||||||
|
const pageData = await getDestinationOverviewPage()
|
||||||
|
|
||||||
|
if (!pageData) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const { tracking, destinationOverviewPage } = pageData
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={styles.pageContainer}>
|
||||||
|
<h1>Destination Overview Page</h1>
|
||||||
|
</div>
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<TrackingSDK pageData={tracking} />
|
||||||
|
</Suspense>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ export const breadcrumbsVariants = cva(styles.breadcrumbs, {
|
|||||||
[PageContentTypeEnum.accountPage]: styles.fullWidth,
|
[PageContentTypeEnum.accountPage]: styles.fullWidth,
|
||||||
[PageContentTypeEnum.contentPage]: styles.contentWidth,
|
[PageContentTypeEnum.contentPage]: styles.contentWidth,
|
||||||
[PageContentTypeEnum.collectionPage]: styles.contentWidth,
|
[PageContentTypeEnum.collectionPage]: styles.contentWidth,
|
||||||
|
[PageContentTypeEnum.destinationOverviewPage]: styles.contentWidth,
|
||||||
[PageContentTypeEnum.hotelPage]: styles.hotelHeaderWidth,
|
[PageContentTypeEnum.hotelPage]: styles.hotelHeaderWidth,
|
||||||
[PageContentTypeEnum.loyaltyPage]: styles.fullWidth,
|
[PageContentTypeEnum.loyaltyPage]: styles.fullWidth,
|
||||||
default: styles.fullWidth,
|
default: styles.fullWidth,
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ query GetContentPageSettings($uid: String!, $locale: String!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
query GetDestinationOverviewPageSettings($uid: String!, $locale: String!) {
|
||||||
|
destination_overview_page(uid: $uid, locale: $locale) {
|
||||||
|
page_settings {
|
||||||
|
hide_booking_widget
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
query GetHotelPageSettings($uid: String!, $locale: String!) {
|
query GetHotelPageSettings($uid: String!, $locale: String!) {
|
||||||
hotel_page(uid: $uid, locale: $locale) {
|
hotel_page(uid: $uid, locale: $locale) {
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#import "../../Fragments/Breadcrumbs/Breadcrumbs.graphql"
|
||||||
|
#import "../../Fragments/System.graphql"
|
||||||
|
|
||||||
|
query GetDestinationOverviewPageBreadcrumbs($locale: String!, $uid: String!) {
|
||||||
|
destination_overview_page(locale: $locale, uid: $uid) {
|
||||||
|
web {
|
||||||
|
breadcrumbs {
|
||||||
|
...Breadcrumbs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
system {
|
||||||
|
...System
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query GetDestinationOverviewPageBreadcrumbsRefs(
|
||||||
|
$locale: String!
|
||||||
|
$uid: String!
|
||||||
|
) {
|
||||||
|
destination_overview_page(locale: $locale, uid: $uid) {
|
||||||
|
web {
|
||||||
|
breadcrumbs {
|
||||||
|
...BreadcrumbsRefs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
system {
|
||||||
|
...System
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#import "../../Fragments/System.graphql"
|
||||||
|
|
||||||
|
query GetDestinationOverviewPage($locale: String!, $uid: String!) {
|
||||||
|
destination_overview_page(uid: $uid, locale: $locale) {
|
||||||
|
title
|
||||||
|
url
|
||||||
|
system {
|
||||||
|
...System
|
||||||
|
created_at
|
||||||
|
updated_at
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trackingProps: destination_overview_page(locale: "en", uid: $uid) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query GetDestinationOverviewPageRefs($locale: String!, $uid: String!) {
|
||||||
|
destination_overview_page(locale: $locale, uid: $uid) {
|
||||||
|
system {
|
||||||
|
...System
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query GetDaDeEnUrlsDestinationOverviewPage($uid: String!) {
|
||||||
|
de: destination_overview_page(locale: "de", uid: $uid) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
en: destination_overview_page(locale: "en", uid: $uid) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
da: destination_overview_page(locale: "da", uid: $uid) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query GetFiNoSvUrlsDestinationOverviewPage($uid: String!) {
|
||||||
|
fi: destination_overview_page(locale: "fi", uid: $uid) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
no: destination_overview_page(locale: "no", uid: $uid) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
sv: destination_overview_page(locale: "sv", uid: $uid) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
18
lib/graphql/Query/DestinationOverviewPage/Metadata.graphql
Normal file
18
lib/graphql/Query/DestinationOverviewPage/Metadata.graphql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#import "../../Fragments/Metadata.graphql"
|
||||||
|
#import "../../Fragments/System.graphql"
|
||||||
|
|
||||||
|
query GetDestinationOverviewPageMetadata($locale: String!, $uid: String!) {
|
||||||
|
destination_overview_page(locale: $locale, uid: $uid) {
|
||||||
|
web {
|
||||||
|
breadcrumbs {
|
||||||
|
title
|
||||||
|
}
|
||||||
|
seo_metadata {
|
||||||
|
...Metadata
|
||||||
|
}
|
||||||
|
}
|
||||||
|
system {
|
||||||
|
...System
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#import "../Fragments/System.graphql"
|
#import "../Fragments/System.graphql"
|
||||||
|
|
||||||
query ResolveEntryByUrl($locale: String!, $url: String!) {
|
query EntryByUrlBatch1($locale: String!, $url: String!) {
|
||||||
all_account_page(where: { url: $url }, locale: $locale) {
|
all_account_page(where: { url: $url }, locale: $locale) {
|
||||||
items {
|
items {
|
||||||
system {
|
system {
|
||||||
@@ -50,3 +50,14 @@ query ResolveEntryByUrl($locale: String!, $url: String!) {
|
|||||||
total
|
total
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query EntryByUrlBatch2($locale: String!, $url: String!) {
|
||||||
|
all_destination_overview_page(where: { url: $url }, locale: $locale) {
|
||||||
|
items {
|
||||||
|
system {
|
||||||
|
...System
|
||||||
|
}
|
||||||
|
}
|
||||||
|
total
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
41
lib/graphql/batchEdgeRequest.ts
Normal file
41
lib/graphql/batchEdgeRequest.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import deepmerge from "deepmerge"
|
||||||
|
|
||||||
|
import { arrayMerge } from "@/utils/merge"
|
||||||
|
|
||||||
|
import { edgeRequest } from "./edgeRequest"
|
||||||
|
|
||||||
|
import type { BatchRequestDocument } from "graphql-request"
|
||||||
|
|
||||||
|
import type { Data } from "@/types/request"
|
||||||
|
|
||||||
|
export async function batchEdgeRequest<T>(
|
||||||
|
queries: BatchRequestDocument[]
|
||||||
|
): Promise<Data<T>> {
|
||||||
|
try {
|
||||||
|
const response = await Promise.allSettled(
|
||||||
|
queries.map((query) => edgeRequest<T>(query.document, query.variables))
|
||||||
|
)
|
||||||
|
|
||||||
|
let data = {} as T
|
||||||
|
const reasons: PromiseRejectedResult["reason"][] = []
|
||||||
|
response.forEach((res) => {
|
||||||
|
if (res.status === "fulfilled") {
|
||||||
|
data = deepmerge(data, res.value.data, { arrayMerge })
|
||||||
|
} else {
|
||||||
|
reasons.push(res.reason)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (reasons.length) {
|
||||||
|
reasons.forEach((reason) => {
|
||||||
|
console.error(`Batch request failed`, reason)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return { data }
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in batched graphql request")
|
||||||
|
console.error(error)
|
||||||
|
throw new Error("Something went wrong")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -170,3 +170,9 @@ export const getMeetingRooms = cache(
|
|||||||
return serverClient().hotel.meetingRooms(input)
|
return serverClient().hotel.meetingRooms(input)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export const getDestinationOverviewPage = cache(
|
||||||
|
async function getMemoizedDestinationOverviewPage() {
|
||||||
|
return serverClient().contentstack.destinationOverviewPage.get()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ const bookingWidgetToggleSchema = z
|
|||||||
|
|
||||||
export const validateBookingWidgetToggleSchema = z.object({
|
export const validateBookingWidgetToggleSchema = z.object({
|
||||||
account_page: bookingWidgetToggleSchema,
|
account_page: bookingWidgetToggleSchema,
|
||||||
loyalty_page: bookingWidgetToggleSchema,
|
|
||||||
collection_page: bookingWidgetToggleSchema,
|
collection_page: bookingWidgetToggleSchema,
|
||||||
content_page: bookingWidgetToggleSchema,
|
content_page: bookingWidgetToggleSchema,
|
||||||
hotel_page: bookingWidgetToggleSchema,
|
|
||||||
current_blocks_page: bookingWidgetToggleSchema,
|
current_blocks_page: bookingWidgetToggleSchema,
|
||||||
|
destination_overview_page: bookingWidgetToggleSchema,
|
||||||
|
hotel_page: bookingWidgetToggleSchema,
|
||||||
|
loyalty_page: bookingWidgetToggleSchema,
|
||||||
})
|
})
|
||||||
|
|
||||||
export type ValidateBookingWidgetToggleType = z.infer<
|
export type ValidateBookingWidgetToggleType = z.infer<
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
GetCollectionPageSettings,
|
GetCollectionPageSettings,
|
||||||
GetContentPageSettings,
|
GetContentPageSettings,
|
||||||
GetCurrentBlocksPageSettings,
|
GetCurrentBlocksPageSettings,
|
||||||
|
GetDestinationOverviewPageSettings,
|
||||||
GetHotelPageSettings,
|
GetHotelPageSettings,
|
||||||
GetLoyaltyPageSettings,
|
GetLoyaltyPageSettings,
|
||||||
} from "@/lib/graphql/Query/BookingWidgetToggle.graphql"
|
} from "@/lib/graphql/Query/BookingWidgetToggle.graphql"
|
||||||
@@ -50,6 +51,9 @@ export const bookingwidgetQueryRouter = router({
|
|||||||
case PageContentTypeEnum.contentPage:
|
case PageContentTypeEnum.contentPage:
|
||||||
GetPageSettings = GetContentPageSettings
|
GetPageSettings = GetContentPageSettings
|
||||||
break
|
break
|
||||||
|
case PageContentTypeEnum.destinationOverviewPage:
|
||||||
|
GetPageSettings = GetDestinationOverviewPageSettings
|
||||||
|
break
|
||||||
case PageContentTypeEnum.hotelPage:
|
case PageContentTypeEnum.hotelPage:
|
||||||
GetPageSettings = GetHotelPageSettings
|
GetPageSettings = GetHotelPageSettings
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ import {
|
|||||||
GetContentPageBreadcrumbs,
|
GetContentPageBreadcrumbs,
|
||||||
GetContentPageBreadcrumbsRefs,
|
GetContentPageBreadcrumbsRefs,
|
||||||
} from "@/lib/graphql/Query/Breadcrumbs/ContentPage.graphql"
|
} from "@/lib/graphql/Query/Breadcrumbs/ContentPage.graphql"
|
||||||
|
import {
|
||||||
|
GetDestinationOverviewPageBreadcrumbs,
|
||||||
|
GetDestinationOverviewPageBreadcrumbsRefs,
|
||||||
|
} from "@/lib/graphql/Query/Breadcrumbs/DestinationOverviewPage.graphql"
|
||||||
import {
|
import {
|
||||||
GetHotelPageBreadcrumbs,
|
GetHotelPageBreadcrumbs,
|
||||||
GetHotelPageBreadcrumbsRefs,
|
GetHotelPageBreadcrumbsRefs,
|
||||||
@@ -203,6 +207,17 @@ export const breadcrumbsQueryRouter = router({
|
|||||||
},
|
},
|
||||||
variables
|
variables
|
||||||
)
|
)
|
||||||
|
case PageContentTypeEnum.destinationOverviewPage:
|
||||||
|
return await getBreadcrumbs<{
|
||||||
|
destination_overview_page: RawBreadcrumbsSchema
|
||||||
|
}>(
|
||||||
|
{
|
||||||
|
dataKey: "destination_overview_page",
|
||||||
|
refQuery: GetDestinationOverviewPageBreadcrumbsRefs,
|
||||||
|
query: GetDestinationOverviewPageBreadcrumbs,
|
||||||
|
},
|
||||||
|
variables
|
||||||
|
)
|
||||||
case PageContentTypeEnum.hotelPage:
|
case PageContentTypeEnum.hotelPage:
|
||||||
return await getBreadcrumbs<{
|
return await getBreadcrumbs<{
|
||||||
hotel_page: RawBreadcrumbsSchema
|
hotel_page: RawBreadcrumbsSchema
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { mergeRouters } from "@/server/trpc"
|
||||||
|
|
||||||
|
import { destinationOverviewPageQueryRouter } from "./query"
|
||||||
|
|
||||||
|
export const destinationOverviewPageRouter = mergeRouters(
|
||||||
|
destinationOverviewPageQueryRouter
|
||||||
|
)
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import { systemSchema } from "../schemas/system"
|
||||||
|
|
||||||
|
export const destinationOverviewPageSchema = z.object({
|
||||||
|
destination_overview_page: z.object({
|
||||||
|
title: z.string(),
|
||||||
|
system: systemSchema.merge(
|
||||||
|
z.object({
|
||||||
|
created_at: z.string(),
|
||||||
|
updated_at: z.string(),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
trackingProps: z.object({
|
||||||
|
url: z.string(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
/** REFS */
|
||||||
|
export const destinationOverviewPageRefsSchema = z.object({
|
||||||
|
destination_overview_page: z.object({
|
||||||
|
system: systemSchema,
|
||||||
|
}),
|
||||||
|
})
|
||||||
190
server/routers/contentstack/destinationOverviewPage/query.ts
Normal file
190
server/routers/contentstack/destinationOverviewPage/query.ts
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
import {
|
||||||
|
GetDestinationOverviewPage,
|
||||||
|
GetDestinationOverviewPageRefs,
|
||||||
|
} from "@/lib/graphql/Query/DestinationOverviewPage/DestinationOverviewPage.graphql"
|
||||||
|
import { request } from "@/lib/graphql/request"
|
||||||
|
import { notFound } from "@/server/errors/trpc"
|
||||||
|
import { contentstackExtendedProcedureUID, router } from "@/server/trpc"
|
||||||
|
|
||||||
|
import { generateTag } from "@/utils/generateTag"
|
||||||
|
|
||||||
|
import {
|
||||||
|
destinationOverviewPageRefsSchema,
|
||||||
|
destinationOverviewPageSchema,
|
||||||
|
} from "./output"
|
||||||
|
import {
|
||||||
|
getDestinationOverviewPageCounter,
|
||||||
|
getDestinationOverviewPageFailCounter,
|
||||||
|
getDestinationOverviewPageRefsCounter,
|
||||||
|
getDestinationOverviewPageRefsFailCounter,
|
||||||
|
getDestinationOverviewPageRefsSuccessCounter,
|
||||||
|
getDestinationOverviewPageSuccessCounter,
|
||||||
|
} from "./telemetry"
|
||||||
|
|
||||||
|
import {
|
||||||
|
TrackingChannelEnum,
|
||||||
|
type TrackingSDKPageData,
|
||||||
|
} from "@/types/components/tracking"
|
||||||
|
import type {
|
||||||
|
GetDestinationOverviewPageData,
|
||||||
|
GetDestinationOverviewPageRefsSchema,
|
||||||
|
} from "@/types/trpc/routers/contentstack/destinationOverviewPage"
|
||||||
|
|
||||||
|
export const destinationOverviewPageQueryRouter = router({
|
||||||
|
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
||||||
|
const { lang, uid } = ctx
|
||||||
|
|
||||||
|
getDestinationOverviewPageRefsCounter.add(1, { lang, uid: `${uid}` })
|
||||||
|
console.info(
|
||||||
|
"contentstack.destinationOverviewPage.refs start",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
|
const refsResponse = await request<GetDestinationOverviewPageRefsSchema>(
|
||||||
|
GetDestinationOverviewPageRefs,
|
||||||
|
{
|
||||||
|
locale: lang,
|
||||||
|
uid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cache: "force-cache",
|
||||||
|
next: {
|
||||||
|
tags: [generateTag(lang, uid)],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if (!refsResponse.data) {
|
||||||
|
const notFoundError = notFound(refsResponse)
|
||||||
|
getDestinationOverviewPageRefsFailCounter.add(1, {
|
||||||
|
lang,
|
||||||
|
uid,
|
||||||
|
error_type: "not_found",
|
||||||
|
error: JSON.stringify({ code: notFoundError.code }),
|
||||||
|
})
|
||||||
|
console.error(
|
||||||
|
"contentstack.destinationOverviewPage.refs not found error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: { code: notFoundError.code },
|
||||||
|
})
|
||||||
|
)
|
||||||
|
throw notFoundError
|
||||||
|
}
|
||||||
|
|
||||||
|
const validatedRefsData = destinationOverviewPageRefsSchema.safeParse(
|
||||||
|
refsResponse.data
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!validatedRefsData.success) {
|
||||||
|
getDestinationOverviewPageRefsFailCounter.add(1, {
|
||||||
|
lang,
|
||||||
|
uid,
|
||||||
|
error_type: "validation_error",
|
||||||
|
error: JSON.stringify(validatedRefsData.error),
|
||||||
|
})
|
||||||
|
console.error(
|
||||||
|
"contentstack.destinationOverviewPage.refs validation error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: validatedRefsData.error,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
getDestinationOverviewPageRefsSuccessCounter.add(1, { lang, uid: `${uid}` })
|
||||||
|
console.info(
|
||||||
|
"contentstack.destinationOverviewPage.refs success",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
getDestinationOverviewPageCounter.add(1, { lang, uid: `${uid}` })
|
||||||
|
console.info(
|
||||||
|
"contentstack.destinationOverviewPage start",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
|
const response = await request<GetDestinationOverviewPageData>(
|
||||||
|
GetDestinationOverviewPage,
|
||||||
|
{
|
||||||
|
locale: lang,
|
||||||
|
uid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cache: "force-cache",
|
||||||
|
next: {
|
||||||
|
tags: [generateTag(lang, uid)],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if (!response.data) {
|
||||||
|
const notFoundError = notFound(response)
|
||||||
|
getDestinationOverviewPageFailCounter.add(1, {
|
||||||
|
lang,
|
||||||
|
uid: `${uid}`,
|
||||||
|
error_type: "not_found",
|
||||||
|
error: JSON.stringify({ code: notFoundError.code }),
|
||||||
|
})
|
||||||
|
console.error(
|
||||||
|
"contentstack.destinationOverviewPage not found error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: { code: notFoundError.code },
|
||||||
|
})
|
||||||
|
)
|
||||||
|
throw notFoundError
|
||||||
|
}
|
||||||
|
|
||||||
|
const destinationOverviewPage = destinationOverviewPageSchema.safeParse(
|
||||||
|
response.data
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!destinationOverviewPage.success) {
|
||||||
|
getDestinationOverviewPageFailCounter.add(1, {
|
||||||
|
lang,
|
||||||
|
uid: `${uid}`,
|
||||||
|
error_type: "validation_error",
|
||||||
|
error: JSON.stringify(destinationOverviewPage.error),
|
||||||
|
})
|
||||||
|
console.error(
|
||||||
|
"contentstack.destinationOverviewPage validation error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: destinationOverviewPage.error,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
getDestinationOverviewPageSuccessCounter.add(1, { lang, uid: `${uid}` })
|
||||||
|
console.info(
|
||||||
|
"contentstack.destinationOverviewPage success",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const system = destinationOverviewPage.data.destination_overview_page.system
|
||||||
|
const tracking: TrackingSDKPageData = {
|
||||||
|
pageId: system.uid,
|
||||||
|
domainLanguage: lang,
|
||||||
|
publishDate: system.updated_at,
|
||||||
|
createDate: system.created_at,
|
||||||
|
channel: TrackingChannelEnum["destination-overview-page"],
|
||||||
|
pageType: "staticcontentpage",
|
||||||
|
pageName: destinationOverviewPage.data.trackingProps.url,
|
||||||
|
siteSections: destinationOverviewPage.data.trackingProps.url,
|
||||||
|
siteVersion: "new-web",
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
destinationOverviewPage:
|
||||||
|
destinationOverviewPage.data.destination_overview_page,
|
||||||
|
tracking,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
})
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { metrics } from "@opentelemetry/api"
|
||||||
|
|
||||||
|
const meter = metrics.getMeter("trpc.contentstack.destinationOverviewPage")
|
||||||
|
|
||||||
|
export const getDestinationOverviewPageRefsCounter = meter.createCounter(
|
||||||
|
"trpc.contentstack.destinationOverviewPage.get"
|
||||||
|
)
|
||||||
|
export const getDestinationOverviewPageRefsFailCounter = meter.createCounter(
|
||||||
|
"trpc.contentstack.destinationOverviewPage.get-fail"
|
||||||
|
)
|
||||||
|
export const getDestinationOverviewPageRefsSuccessCounter = meter.createCounter(
|
||||||
|
"trpc.contentstack.destinationOverviewPage.get-success"
|
||||||
|
)
|
||||||
|
|
||||||
|
export const getDestinationOverviewPageCounter = meter.createCounter(
|
||||||
|
"trpc.contentstack.destinationOverviewPage.get"
|
||||||
|
)
|
||||||
|
export const getDestinationOverviewPageSuccessCounter = meter.createCounter(
|
||||||
|
"trpc.contentstack.destinationOverviewPage.get-success"
|
||||||
|
)
|
||||||
|
export const getDestinationOverviewPageFailCounter = meter.createCounter(
|
||||||
|
"trpc.contentstack.destinationOverviewPage.get-fail"
|
||||||
|
)
|
||||||
@@ -6,6 +6,7 @@ import { bookingwidgetRouter } from "./bookingwidget"
|
|||||||
import { breadcrumbsRouter } from "./breadcrumbs"
|
import { breadcrumbsRouter } from "./breadcrumbs"
|
||||||
import { collectionPageRouter } from "./collectionPage"
|
import { collectionPageRouter } from "./collectionPage"
|
||||||
import { contentPageRouter } from "./contentPage"
|
import { contentPageRouter } from "./contentPage"
|
||||||
|
import { destinationOverviewPageRouter } from "./destinationOverviewPage"
|
||||||
import { hotelPageRouter } from "./hotelPage"
|
import { hotelPageRouter } from "./hotelPage"
|
||||||
import { languageSwitcherRouter } from "./languageSwitcher"
|
import { languageSwitcherRouter } from "./languageSwitcher"
|
||||||
import { loyaltyLevelRouter } from "./loyaltyLevel"
|
import { loyaltyLevelRouter } from "./loyaltyLevel"
|
||||||
@@ -24,6 +25,7 @@ export const contentstackRouter = router({
|
|||||||
loyaltyPage: loyaltyPageRouter,
|
loyaltyPage: loyaltyPageRouter,
|
||||||
collectionPage: collectionPageRouter,
|
collectionPage: collectionPageRouter,
|
||||||
contentPage: contentPageRouter,
|
contentPage: contentPageRouter,
|
||||||
|
destinationOverviewPage: destinationOverviewPageRouter,
|
||||||
myPages: myPagesRouter,
|
myPages: myPagesRouter,
|
||||||
metadata: metadataRouter,
|
metadata: metadataRouter,
|
||||||
rewards: rewardRouter,
|
rewards: rewardRouter,
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ import {
|
|||||||
GetDaDeEnUrlsCurrentBlocksPage,
|
GetDaDeEnUrlsCurrentBlocksPage,
|
||||||
GetFiNoSvUrlsCurrentBlocksPage,
|
GetFiNoSvUrlsCurrentBlocksPage,
|
||||||
} from "@/lib/graphql/Query/Current/LanguageSwitcher.graphql"
|
} from "@/lib/graphql/Query/Current/LanguageSwitcher.graphql"
|
||||||
|
import {
|
||||||
|
GetDaDeEnUrlsDestinationOverviewPage,
|
||||||
|
GetFiNoSvUrlsDestinationOverviewPage,
|
||||||
|
} from "@/lib/graphql/Query/DestinationOverviewPage/DestinationOverviewPage.graphql"
|
||||||
import {
|
import {
|
||||||
GetDaDeEnUrlsHotelPage,
|
GetDaDeEnUrlsHotelPage,
|
||||||
GetFiNoSvUrlsHotelPage,
|
GetFiNoSvUrlsHotelPage,
|
||||||
@@ -96,6 +100,10 @@ async function getLanguageSwitcher(options: LanguageSwitcherVariables) {
|
|||||||
daDeEnDocument = GetDaDeEnUrlsCollectionPage
|
daDeEnDocument = GetDaDeEnUrlsCollectionPage
|
||||||
fiNoSvDocument = GetFiNoSvUrlsCollectionPage
|
fiNoSvDocument = GetFiNoSvUrlsCollectionPage
|
||||||
break
|
break
|
||||||
|
case PageContentTypeEnum.destinationOverviewPage:
|
||||||
|
daDeEnDocument = GetDaDeEnUrlsDestinationOverviewPage
|
||||||
|
fiNoSvDocument = GetFiNoSvUrlsDestinationOverviewPage
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
console.error(`type: [${options.contentType}]`)
|
console.error(`type: [${options.contentType}]`)
|
||||||
console.error(`Trying to get a content type that is not supported`)
|
console.error(`Trying to get a content type that is not supported`)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { cache } from "react"
|
|||||||
import { GetAccountPageMetadata } from "@/lib/graphql/Query/AccountPage/Metadata.graphql"
|
import { GetAccountPageMetadata } from "@/lib/graphql/Query/AccountPage/Metadata.graphql"
|
||||||
import { GetCollectionPageMetadata } from "@/lib/graphql/Query/CollectionPage/Metadata.graphql"
|
import { GetCollectionPageMetadata } from "@/lib/graphql/Query/CollectionPage/Metadata.graphql"
|
||||||
import { GetContentPageMetadata } from "@/lib/graphql/Query/ContentPage/Metadata.graphql"
|
import { GetContentPageMetadata } from "@/lib/graphql/Query/ContentPage/Metadata.graphql"
|
||||||
|
import { GetDestinationOverviewPageMetadata } from "@/lib/graphql/Query/DestinationOverviewPage/Metadata.graphql"
|
||||||
import { GetHotelPageMetadata } from "@/lib/graphql/Query/HotelPage/Metadata.graphql"
|
import { GetHotelPageMetadata } from "@/lib/graphql/Query/HotelPage/Metadata.graphql"
|
||||||
import { GetLoyaltyPageMetadata } from "@/lib/graphql/Query/LoyaltyPage/Metadata.graphql"
|
import { GetLoyaltyPageMetadata } from "@/lib/graphql/Query/LoyaltyPage/Metadata.graphql"
|
||||||
import { request } from "@/lib/graphql/request"
|
import { request } from "@/lib/graphql/request"
|
||||||
@@ -136,6 +137,13 @@ export const metadataQueryRouter = router({
|
|||||||
content_page: RawMetadataSchema
|
content_page: RawMetadataSchema
|
||||||
}>(GetContentPageMetadata, variables)
|
}>(GetContentPageMetadata, variables)
|
||||||
return getTransformedMetadata(contentPageResponse.content_page)
|
return getTransformedMetadata(contentPageResponse.content_page)
|
||||||
|
case PageContentTypeEnum.destinationOverviewPage:
|
||||||
|
const destinationOverviewPageResponse = await fetchMetadata<{
|
||||||
|
destination_overview_page: RawMetadataSchema
|
||||||
|
}>(GetDestinationOverviewPageMetadata, variables)
|
||||||
|
return getTransformedMetadata(
|
||||||
|
destinationOverviewPageResponse.destination_overview_page
|
||||||
|
)
|
||||||
case PageContentTypeEnum.loyaltyPage:
|
case PageContentTypeEnum.loyaltyPage:
|
||||||
const loyaltyPageResponse = await fetchMetadata<{
|
const loyaltyPageResponse = await fetchMetadata<{
|
||||||
loyalty_page: RawMetadataSchema
|
loyalty_page: RawMetadataSchema
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export enum TrackingChannelEnum {
|
|||||||
"static-content-page" = "static-content-page",
|
"static-content-page" = "static-content-page",
|
||||||
"hotelreservation" = "hotelreservation",
|
"hotelreservation" = "hotelreservation",
|
||||||
"collection-page" = "collection-page",
|
"collection-page" = "collection-page",
|
||||||
|
"destination-overview-page" = "destination-overview-page",
|
||||||
"hotels" = "hotels",
|
"hotels" = "hotels",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export type ContentTypeParams = {
|
|||||||
| PageContentTypeEnum.contentPage
|
| PageContentTypeEnum.contentPage
|
||||||
| PageContentTypeEnum.hotelPage
|
| PageContentTypeEnum.hotelPage
|
||||||
| PageContentTypeEnum.collectionPage
|
| PageContentTypeEnum.collectionPage
|
||||||
|
| PageContentTypeEnum.destinationOverviewPage
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ContentTypeWebviewParams = {
|
export type ContentTypeWebviewParams = {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
export enum PageContentTypeEnum {
|
export enum PageContentTypeEnum {
|
||||||
accountPage = "account_page",
|
accountPage = "account_page",
|
||||||
loyaltyPage = "loyalty_page",
|
|
||||||
hotelPage = "hotel_page",
|
|
||||||
collectionPage = "collection_page",
|
collectionPage = "collection_page",
|
||||||
contentPage = "content_page",
|
contentPage = "content_page",
|
||||||
currentBlocksPage = "current_blocks_page",
|
currentBlocksPage = "current_blocks_page",
|
||||||
|
destinationOverviewPage = "destination_overview_page",
|
||||||
|
hotelPage = "hotel_page",
|
||||||
|
loyaltyPage = "loyalty_page",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,4 +19,5 @@ export const validateEntryResolveSchema = z.object({
|
|||||||
all_loyalty_page: entryResolveSchema,
|
all_loyalty_page: entryResolveSchema,
|
||||||
all_current_blocks_page: entryResolveSchema,
|
all_current_blocks_page: entryResolveSchema,
|
||||||
all_hotel_page: entryResolveSchema,
|
all_hotel_page: entryResolveSchema,
|
||||||
|
all_destination_overview_page: entryResolveSchema,
|
||||||
})
|
})
|
||||||
|
|||||||
17
types/trpc/routers/contentstack/destinationOverviewPage.ts
Normal file
17
types/trpc/routers/contentstack/destinationOverviewPage.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import type { z } from "zod"
|
||||||
|
|
||||||
|
import type {
|
||||||
|
destinationOverviewPageRefsSchema,
|
||||||
|
destinationOverviewPageSchema,
|
||||||
|
} from "@/server/routers/contentstack/destinationOverviewPage/output"
|
||||||
|
|
||||||
|
export interface GetDestinationOverviewPageData
|
||||||
|
extends z.input<typeof destinationOverviewPageSchema> {}
|
||||||
|
export interface DestinationPage
|
||||||
|
extends z.output<typeof destinationOverviewPageSchema> {}
|
||||||
|
|
||||||
|
export interface GetDestinationOverviewPageRefsSchema
|
||||||
|
extends z.input<typeof destinationOverviewPageRefsSchema> {}
|
||||||
|
|
||||||
|
export interface DestinationOverviewPageRefs
|
||||||
|
extends z.output<typeof destinationOverviewPageRefsSchema> {}
|
||||||
@@ -1,23 +1,25 @@
|
|||||||
import { Lang } from "@/constants/languages"
|
import { Lang } from "@/constants/languages"
|
||||||
import { edgeRequest } from "@/lib/graphql/edgeRequest"
|
import { batchEdgeRequest } from "@/lib/graphql/batchEdgeRequest"
|
||||||
import { ResolveEntryByUrl } from "@/lib/graphql/Query/ResolveEntry.graphql"
|
import {
|
||||||
|
EntryByUrlBatch1,
|
||||||
|
EntryByUrlBatch2,
|
||||||
|
} from "@/lib/graphql/Query/ResolveEntry.graphql"
|
||||||
import { internalServerError } from "@/server/errors/next"
|
import { internalServerError } from "@/server/errors/next"
|
||||||
|
|
||||||
import { validateEntryResolveSchema } from "@/types/requests/entry"
|
import { validateEntryResolveSchema } from "@/types/requests/entry"
|
||||||
|
|
||||||
export async function resolve(url: string, lang = Lang.en) {
|
export async function resolve(url: string, lang = Lang.en) {
|
||||||
const response = await edgeRequest(
|
const variables = { locale: lang, url }
|
||||||
ResolveEntryByUrl,
|
const response = await batchEdgeRequest([
|
||||||
{
|
{
|
||||||
locale: lang,
|
document: EntryByUrlBatch1,
|
||||||
url,
|
variables,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
next: {
|
document: EntryByUrlBatch2,
|
||||||
revalidate: 3600,
|
variables,
|
||||||
},
|
},
|
||||||
}
|
])
|
||||||
)
|
|
||||||
|
|
||||||
const validatedData = validateEntryResolveSchema.safeParse(response.data)
|
const validatedData = validateEntryResolveSchema.safeParse(response.data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user