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:
Linus Flood
2025-09-16 11:28:57 +00:00
parent 48324ef935
commit fd0198f57b
137 changed files with 5 additions and 146805 deletions

View File

@@ -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(),

View File

@@ -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

View File

@@ -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