Merged in feat/SW-2999-cleanup (pull request #2810)
feat(SW-2999): cleanup current web * feat(SW-2999): cleanup current web * Merge master * Removed unused fonts Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
#import "../../Fragments/Aside/Contact.graphql"
|
||||
#import "../../Fragments/Aside/Puff.graphql"
|
||||
#import "../../Fragments/Blocks/List.graphql"
|
||||
#import "../../Fragments/Blocks/Puff.graphql"
|
||||
#import "../../Fragments/Blocks/Text.graphql"
|
||||
#import "../../Fragments/Breadcrumbs/CurrentBlocksPage.graphql"
|
||||
#import "../../Fragments/Hero.graphql"
|
||||
#import "../../Fragments/Preamble.graphql"
|
||||
|
||||
query GetCurrentBlockPage($locale: String!, $url: String!) {
|
||||
all_current_blocks_page(limit: 1, locale: $locale, where: { url: $url }) {
|
||||
items {
|
||||
aside {
|
||||
__typename
|
||||
...ContactAside
|
||||
...PuffAside
|
||||
}
|
||||
blocks {
|
||||
__typename
|
||||
...ListBlock
|
||||
...PuffBlock
|
||||
...TextBlock
|
||||
}
|
||||
...CurrentBlocksPageBreadcrumbs
|
||||
hero {
|
||||
...Hero
|
||||
}
|
||||
...Preamble
|
||||
system {
|
||||
created_at
|
||||
uid
|
||||
updated_at
|
||||
}
|
||||
title
|
||||
url
|
||||
}
|
||||
total
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
query GetCurrentBlockPageTrackingData($uid: String!) {
|
||||
current_blocks_page(uid: $uid, locale: "en") {
|
||||
url
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#import "../../Fragments/CurrentFooter/AppDownloads.graphql"
|
||||
#import "../../Fragments/CurrentFooter/Logo.graphql"
|
||||
#import "../../Fragments/CurrentFooter/Navigation.graphql"
|
||||
#import "../../Fragments/CurrentFooter/SocialMedia.graphql"
|
||||
#import "../../Fragments/CurrentFooter/TripAdvisor.graphql"
|
||||
#import "../../Fragments/System.graphql"
|
||||
|
||||
query GetCurrentFooter($locale: String!) {
|
||||
all_current_footer(limit: 1, locale: $locale) {
|
||||
items {
|
||||
...CurrentFooterAppDownloads
|
||||
...CurrentFooterSocialMedia
|
||||
...Logo
|
||||
...Navigation
|
||||
...TripAdvisor
|
||||
title
|
||||
about {
|
||||
text
|
||||
title
|
||||
}
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetCurrentFooterRef($locale: String!) {
|
||||
all_current_footer(limit: 1, locale: $locale) {
|
||||
items {
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#import "../../Fragments/SysAsset.graphql"
|
||||
#import "../../Fragments/System.graphql"
|
||||
|
||||
query GetCurrentHeader($locale: String!) {
|
||||
all_current_header(limit: 1, locale: $locale) {
|
||||
items {
|
||||
frontpage_link_text
|
||||
logoConnection {
|
||||
edges {
|
||||
node {
|
||||
...SysAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
menu {
|
||||
links {
|
||||
href
|
||||
title
|
||||
}
|
||||
}
|
||||
top_menu {
|
||||
links {
|
||||
link {
|
||||
href
|
||||
title
|
||||
}
|
||||
show_on_mobile
|
||||
sort_order_mobile
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetCurrentHeaderRef($locale: String!) {
|
||||
all_current_header(limit: 1, locale: $locale) {
|
||||
items {
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
query GetDaDeEnUrlsCurrentBlocksPage($uid: String!) {
|
||||
de: all_current_blocks_page(where: { uid: $uid }, locale: "de") {
|
||||
items {
|
||||
url
|
||||
}
|
||||
}
|
||||
en: all_current_blocks_page(where: { uid: $uid }, locale: "en") {
|
||||
items {
|
||||
url
|
||||
}
|
||||
}
|
||||
da: all_current_blocks_page(where: { uid: $uid }, locale: "da") {
|
||||
items {
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetFiNoSvUrlsCurrentBlocksPage($uid: String!) {
|
||||
fi: all_current_blocks_page(where: { uid: $uid }, locale: "fi") {
|
||||
items {
|
||||
url
|
||||
}
|
||||
}
|
||||
no: all_current_blocks_page(where: { uid: $uid }, locale: "no") {
|
||||
items {
|
||||
url
|
||||
}
|
||||
}
|
||||
sv: all_current_blocks_page(where: { uid: $uid }, locale: "sv") {
|
||||
items {
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,7 @@ import {
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url"
|
||||
import {
|
||||
nullableStringUrlValidator,
|
||||
nullableStringValidator,
|
||||
} from "@scandic-hotels/common/utils/zod/stringValidator"
|
||||
import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator"
|
||||
|
||||
import { discriminatedUnion } from "../../../utils/discriminatedUnion"
|
||||
import {
|
||||
@@ -27,8 +24,6 @@ import {
|
||||
} from "../schemas/pageLinks"
|
||||
import { systemSchema } from "../schemas/system"
|
||||
|
||||
import type { Image } from "../../../types/image"
|
||||
|
||||
// Help me write this zod schema based on the type ContactConfig
|
||||
export const validateContactConfigSchema = z.object({
|
||||
all_contact_config: z.object({
|
||||
@@ -91,114 +86,7 @@ export type ContactFields = {
|
||||
footnote?: string | null
|
||||
}
|
||||
|
||||
export const validateCurrentHeaderConfigSchema = z
|
||||
.object({
|
||||
all_current_header: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
frontpage_link_text: z.string(),
|
||||
logoConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
description: z.string().nullish(),
|
||||
dimension: z.object({
|
||||
height: z.number(),
|
||||
width: z.number(),
|
||||
}),
|
||||
metadata: z.any().nullable(),
|
||||
system: z.object({
|
||||
uid: z.string(),
|
||||
}),
|
||||
title: nullableStringValidator,
|
||||
url: nullableStringUrlValidator,
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
menu: z.object({
|
||||
links: z.array(
|
||||
z.object({
|
||||
href: z.string(),
|
||||
title: z.string(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
top_menu: z.object({
|
||||
links: z.array(
|
||||
z.object({
|
||||
link: z.object({
|
||||
href: z.string(),
|
||||
title: z.string(),
|
||||
}),
|
||||
show_on_mobile: z.boolean(),
|
||||
sort_order_mobile: z.number(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
if (!data.all_current_header.items.length) {
|
||||
return {
|
||||
header: null,
|
||||
}
|
||||
}
|
||||
const header = data.all_current_header.items[0]
|
||||
return {
|
||||
header: {
|
||||
frontpageLinkText: header.frontpage_link_text,
|
||||
logo: header.logoConnection.edges[0].node,
|
||||
menu: header.menu,
|
||||
topMenu: header.top_menu,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
export interface GetCurrentHeaderData
|
||||
extends z.input<typeof validateCurrentHeaderConfigSchema> {}
|
||||
export type HeaderData = z.output<typeof validateCurrentHeaderConfigSchema>
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const validateCurrentHeaderRefConfigSchema = z.object({
|
||||
all_current_header: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
system: systemSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
|
||||
export type CurrentHeaderRefDataRaw = z.infer<
|
||||
typeof validateCurrentHeaderRefConfigSchema
|
||||
>
|
||||
|
||||
const validateAppDownload = z.object({
|
||||
href: z.string(),
|
||||
imageConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
description: z.string().nullish(),
|
||||
dimension: z.object({
|
||||
height: z.number(),
|
||||
width: z.number(),
|
||||
}),
|
||||
metadata: z.any().nullable(),
|
||||
system: z.object({
|
||||
uid: z.string(),
|
||||
}),
|
||||
title: z.string(),
|
||||
url: z.string(),
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
|
||||
const validateNavigationItem = z.object({
|
||||
links: z.array(z.object({ href: z.string(), title: z.string() })),
|
||||
title: z.string(),
|
||||
@@ -206,99 +94,6 @@ const validateNavigationItem = z.object({
|
||||
|
||||
export type NavigationItem = z.infer<typeof validateNavigationItem>
|
||||
|
||||
export const validateCurrentFooterConfigSchema = z.object({
|
||||
all_current_footer: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
title: z.string(),
|
||||
about: z.object({
|
||||
title: z.string(),
|
||||
text: z.string(),
|
||||
}),
|
||||
app_downloads: z.object({
|
||||
title: z.string(),
|
||||
app_store: validateAppDownload,
|
||||
google_play: validateAppDownload,
|
||||
}),
|
||||
logoConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
description: z.string().nullish(),
|
||||
dimension: z.object({
|
||||
height: z.number(),
|
||||
width: z.number(),
|
||||
}),
|
||||
metadata: z.any().nullable(),
|
||||
system: z.object({
|
||||
uid: z.string(),
|
||||
}),
|
||||
title: z.string(),
|
||||
url: z.string(),
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
navigation: z.array(validateNavigationItem),
|
||||
social_media: z.object({
|
||||
title: z.string(),
|
||||
facebook: z.object({ href: z.string(), title: z.string() }),
|
||||
instagram: z.object({ href: z.string(), title: z.string() }),
|
||||
twitter: z.object({ href: z.string(), title: z.string() }),
|
||||
}),
|
||||
trip_advisor: z.object({
|
||||
title: z.string(),
|
||||
logoConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
description: z.string().nullish(),
|
||||
dimension: z.object({
|
||||
height: z.number(),
|
||||
width: z.number(),
|
||||
}),
|
||||
metadata: z.any().nullable(),
|
||||
system: z.object({
|
||||
uid: z.string(),
|
||||
}),
|
||||
title: z.string(),
|
||||
url: z.string(),
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
|
||||
export type CurrentFooterDataRaw = z.infer<
|
||||
typeof validateCurrentFooterConfigSchema
|
||||
>
|
||||
|
||||
export type CurrentFooterData = Omit<
|
||||
CurrentFooterDataRaw["all_current_footer"]["items"][0],
|
||||
"logoConnection"
|
||||
> & {
|
||||
logo: Image
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const validateCurrentFooterRefConfigSchema = z.object({
|
||||
all_current_footer: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
system: systemSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
|
||||
export type CurrentFooterRefDataRaw = z.infer<
|
||||
typeof validateCurrentFooterRefConfigSchema
|
||||
>
|
||||
|
||||
const validateExternalLink = z
|
||||
.object({
|
||||
href: z.string(),
|
||||
|
||||
@@ -5,14 +5,6 @@ import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { GetContactConfig } from "../../../graphql/Query/ContactConfig.graphql"
|
||||
import {
|
||||
GetCurrentFooter,
|
||||
GetCurrentFooterRef,
|
||||
} from "../../../graphql/Query/Current/Footer.graphql"
|
||||
import {
|
||||
GetCurrentHeader,
|
||||
GetCurrentHeaderRef,
|
||||
} from "../../../graphql/Query/Current/Header.graphql"
|
||||
import { GetFooter, GetFooterRef } from "../../../graphql/Query/Footer.graphql"
|
||||
import { GetHeader, GetHeaderRef } from "../../../graphql/Query/Header.graphql"
|
||||
import {
|
||||
@@ -31,17 +23,11 @@ import {
|
||||
} from "../../../utils/generateTag"
|
||||
import {
|
||||
type ContactConfigData,
|
||||
type CurrentFooterDataRaw,
|
||||
type CurrentFooterRefDataRaw,
|
||||
type CurrentHeaderRefDataRaw,
|
||||
type GetCurrentHeaderData,
|
||||
headerRefsSchema,
|
||||
headerSchema,
|
||||
siteConfigRefSchema,
|
||||
siteConfigSchema,
|
||||
validateContactConfigSchema,
|
||||
validateCurrentFooterConfigSchema,
|
||||
validateCurrentHeaderConfigSchema,
|
||||
validateFooterConfigSchema,
|
||||
validateFooterRefConfigSchema,
|
||||
} from "./output"
|
||||
@@ -180,139 +166,6 @@ export const baseQueryRouter = router({
|
||||
data: validatedHeaderConfig.data.header,
|
||||
}
|
||||
}),
|
||||
currentHeader: contentstackBaseProcedure
|
||||
.input(langInput)
|
||||
.query(async ({ input }) => {
|
||||
const getCurrentHeaderRefsCounter = createCounter(
|
||||
"trpc.contentstack",
|
||||
"currentHeader.get.refs"
|
||||
)
|
||||
const metricsGetCurrentHeaderRefs = getCurrentHeaderRefsCounter.init({
|
||||
lang: input.lang,
|
||||
})
|
||||
|
||||
metricsGetCurrentHeaderRefs.start()
|
||||
|
||||
const responseRef = await request<CurrentHeaderRefDataRaw>(
|
||||
GetCurrentHeaderRef,
|
||||
{
|
||||
locale: input.lang,
|
||||
},
|
||||
{
|
||||
key: generateRefsResponseTag(input.lang, "current_header"),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
|
||||
const getCurrentHeaderCounter = createCounter(
|
||||
"trpc.contentstack",
|
||||
"currentHeader.get"
|
||||
)
|
||||
const metricsGetCurrentHeader = getCurrentHeaderCounter.init({
|
||||
lang: input.lang,
|
||||
})
|
||||
|
||||
metricsGetCurrentHeader.start()
|
||||
|
||||
const currentHeaderUID =
|
||||
responseRef.data.all_current_header.items[0].system.uid
|
||||
// There's currently no error handling/validation for the responseRef, should it be added?
|
||||
const response = await request<GetCurrentHeaderData>(
|
||||
GetCurrentHeader,
|
||||
{ locale: input.lang },
|
||||
{
|
||||
key: generateTag(input.lang, currentHeaderUID),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetCurrentHeader.noDataError()
|
||||
throw notFoundError
|
||||
}
|
||||
|
||||
const validatedHeaderConfig = validateCurrentHeaderConfigSchema.safeParse(
|
||||
response.data
|
||||
)
|
||||
|
||||
if (!validatedHeaderConfig.success) {
|
||||
metricsGetCurrentHeader.validationError(validatedHeaderConfig.error)
|
||||
return null
|
||||
}
|
||||
|
||||
metricsGetCurrentHeader.success()
|
||||
|
||||
return validatedHeaderConfig.data
|
||||
}),
|
||||
currentFooter: contentstackBaseProcedure
|
||||
.input(langInput)
|
||||
.query(async ({ input }) => {
|
||||
const getCurrentFooterRefsCounter = createCounter(
|
||||
"trpc.contentstack",
|
||||
"currentFooter.get.refs"
|
||||
)
|
||||
const metricsGetCurrentFooterRefs = getCurrentFooterRefsCounter.init({
|
||||
lang: input.lang,
|
||||
})
|
||||
|
||||
metricsGetCurrentFooterRefs.start()
|
||||
|
||||
const responseRef = await request<CurrentFooterRefDataRaw>(
|
||||
GetCurrentFooterRef,
|
||||
{
|
||||
locale: input.lang,
|
||||
},
|
||||
{
|
||||
key: generateRefsResponseTag(input.lang, "current_footer"),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
|
||||
const getCurrentFooterCounter = createCounter(
|
||||
"trpc.contentstack",
|
||||
"currentFooter.get"
|
||||
)
|
||||
const metricsGetCurrentFooter = getCurrentFooterCounter.init({
|
||||
lang: input.lang,
|
||||
})
|
||||
|
||||
metricsGetCurrentFooter.start()
|
||||
|
||||
const currentFooterUID =
|
||||
responseRef.data.all_current_footer.items[0].system.uid
|
||||
|
||||
const response = await request<CurrentFooterDataRaw>(
|
||||
GetCurrentFooter,
|
||||
{
|
||||
locale: input.lang,
|
||||
},
|
||||
{
|
||||
key: generateTag(input.lang, currentFooterUID),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetCurrentFooter.noDataError()
|
||||
throw notFoundError
|
||||
}
|
||||
|
||||
const validatedCurrentFooterConfig =
|
||||
validateCurrentFooterConfigSchema.safeParse(response.data)
|
||||
|
||||
if (!validatedCurrentFooterConfig.success) {
|
||||
metricsGetCurrentFooter.validationError(
|
||||
validatedCurrentFooterConfig.error
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
metricsGetCurrentFooter.success()
|
||||
|
||||
return validatedCurrentFooterConfig.data.all_current_footer.items[0]
|
||||
}),
|
||||
footer: contentstackBaseProcedure.query(async ({ ctx }) => {
|
||||
const { lang } = ctx
|
||||
|
||||
|
||||
@@ -26,10 +26,6 @@ import {
|
||||
GetDaDeEnUrlsContentPage,
|
||||
GetFiNoSvUrlsContentPage,
|
||||
} from "../../../graphql/Query/ContentPage/ContentPage.graphql"
|
||||
import {
|
||||
GetDaDeEnUrlsCurrentBlocksPage,
|
||||
GetFiNoSvUrlsCurrentBlocksPage,
|
||||
} from "../../../graphql/Query/Current/LanguageSwitcher.graphql"
|
||||
import {
|
||||
GetDaDeEnUrlsDestinationCityPage,
|
||||
GetFiNoSvUrlsDestinationCityPage,
|
||||
@@ -103,10 +99,6 @@ export async function getUrlsOfAllLanguages(
|
||||
daDeEnDocument = GetDaDeEnUrlsAccountPage
|
||||
fiNoSvDocument = GetFiNoSvUrlsAccountPage
|
||||
break
|
||||
case PageContentTypeEnum.currentBlocksPage:
|
||||
daDeEnDocument = GetDaDeEnUrlsCurrentBlocksPage
|
||||
fiNoSvDocument = GetFiNoSvUrlsCurrentBlocksPage
|
||||
break
|
||||
case PageContentTypeEnum.campaignOverviewPage:
|
||||
daDeEnDocument = GetDaDeEnUrlsCampaignOverviewPage
|
||||
fiNoSvDocument = GetFiNoSvUrlsCampaignOverviewPage
|
||||
|
||||
Reference in New Issue
Block a user