Merged in chore/cleanup-unused (pull request #3461)

chore: Cleanup unused vars, exports, types

* Cleanup some unused exports

* Remove more

* Readd CampaignPageIncludedHotelsRef

* Add alias comment to procedure exports

* Remove unused exports


Approved-by: Linus Flood
This commit is contained in:
Anton Gunnarsson
2026-01-22 12:34:07 +00:00
parent 4de24e9f2a
commit f79ff9b570
56 changed files with 84 additions and 411 deletions

View File

@@ -1,26 +0,0 @@
"use client"
import { type IntlConfig, IntlProvider } from "react-intl"
import type { Lang } from "@scandic-hotels/common/constants/language"
export type ClientIntlProviderProps = React.PropsWithChildren<
Pick<IntlConfig, "defaultLocale" | "messages"> & { locale: Lang }
>
export default function ClientIntlProvider({
children,
locale,
defaultLocale,
messages,
}: ClientIntlProviderProps) {
return (
<IntlProvider
locale={locale}
defaultLocale={defaultLocale}
messages={messages}
>
{children}
</IntlProvider>
)
}

View File

@@ -30,7 +30,7 @@ type LanguageSwitcherProps = {
type?: "footer" | "header"
}
export function replaceUrlPart(currentPath: string, newPart: string): string {
function replaceUrlPart(currentPath: string, newPart: string): string {
const pathSegments = currentPath.split("/").filter((segment) => segment)
const newPathSegments = newPart

View File

@@ -1,11 +1,13 @@
"use client"
import { IntlProvider } from "react-intl"
import { type IntlConfig, IntlProvider } from "react-intl"
import { Lang } from "@scandic-hotels/common/constants/language"
import { logger } from "@scandic-hotels/common/logger"
import type { ClientIntlProviderProps } from "@/components/IntlProvider"
type ClientIntlProviderProps = React.PropsWithChildren<
Pick<IntlConfig, "defaultLocale" | "messages"> & { locale: Lang }
>
const logged: Record<string, boolean> = {}

View File

@@ -28,20 +28,6 @@ export function badRequest(cause?: unknown) {
)
}
export function notFound(cause?: unknown) {
const resInit = {
status: 404,
statusText: "Not found",
}
return NextResponse.json(
{
cause,
},
resInit
)
}
export function internalServerError(cause?: unknown) {
const resInit = {
status: 500,
@@ -56,20 +42,6 @@ export function internalServerError(cause?: unknown) {
)
}
export function serviceUnavailable(cause?: unknown) {
const resInit = {
status: 503,
statusText: "Service Unavailable",
}
return NextResponse.json(
{
cause,
},
resInit
)
}
export function response<T>(data: T, status: number, statusText: string) {
return NextResponse.json(data, {
status,

View File

@@ -1,8 +1,6 @@
import { NextRequest } from "next/server"
import { logger } from "@scandic-hotels/common/logger"
import { env } from "@/env/server"
import type { NextRequest } from "next/server"
/**
* Use this function when you want to create URLs that are public facing, for
* example for redirects or redirectTo query parameters.
@@ -44,51 +42,3 @@ export function getPublicURL(request: NextRequest) {
}
return request.nextUrl.origin
}
/**
* Use this function when you want to create URLs that are internal (behind Akamai),
* for example for rewrites. Mainly used for middleware wrapped in auth().
* The auth() function overrides the origin of the incoming request. It sets it
* to the origin of AUTH_URL/NEXTAUTH_URL. This means we cannot use the augmented
* request from auth() for rewrites, as those will point to auth url origin
* (in front of Akamai) and not the origin of the incoming request (behind Akamai).
* This results in rewrites going over the internet instead of going through the
* internal routing at Netlify.
* For dedicated environments (test, stage and production) we are behind Akamai.
* For those we have set a value for AUTH_URL/NEXTAUTH_URL, they point to the
* PUBLIC_URL. For rewrites we need the internal origin inside Netlify.
* In middleware.ts we copy the incoming origin to a header 'x-sh-origin'. We try
* and use that first, if not present we assume the internal origin is the value
* of the host header, as that is what Netlify used for routing to this deployment.
* @param request The incoming request.
* @returns NextURL The internal request, in Netlify behind Akamai.
*/
export function getInternalNextURL(request: NextRequest) {
const { href, origin } = request.nextUrl
const originHeader = request.headers.get("x-sh-origin")
if (originHeader) {
logger.debug(`[internalNextUrl] using x-sh-origin header`, {
origin,
originHeader,
newOrigin: href.replace(origin, originHeader),
})
return new NextRequest(href.replace(origin, originHeader), request).nextUrl
}
const hostHeader = request.headers.get("host")
if (hostHeader) {
const inputHostOrigin = `${request.nextUrl.protocol}//${hostHeader}`
logger.debug(`[internalNextUrl] using host header`, {
origin,
hostHeader,
hostOrigin: inputHostOrigin,
newOrigin: href.replace(origin, inputHostOrigin),
})
const { origin: hostOrigin } = new URL(inputHostOrigin)
return new NextRequest(href.replace(origin, hostOrigin), request).nextUrl
}
logger.debug(`[internalNextUrl] falling back to incoming request`)
return request.nextUrl
}

View File

@@ -14,6 +14,6 @@ export type LangParams = {
lang: Lang
}
export type LayoutArgs<P = undefined> = P extends undefined ? {} : Params<P>
type LayoutArgs<P = undefined> = P extends undefined ? {} : Params<P>
export type PageArgs<P = undefined> = LayoutArgs<P> & SearchParams

View File

@@ -5,10 +5,6 @@ export function csvFilePath(lang: Lang) {
return `${import.meta.dirname}/../data/csv/${lang}.csv`
}
export function jsonFilePath(lang: Lang) {
return `${import.meta.dirname}/../data/json/${lang}.json`
}
export function outputFilepath(lang: Lang) {
return path.resolve(
import.meta.dirname,

View File

@@ -2,7 +2,7 @@ import { dt } from "@scandic-hotels/common/dt"
import type { IntlShape } from "react-intl"
export const DAYS_UNTIL_EXPIRY_WARNING = 30
const DAYS_UNTIL_EXPIRY_WARNING = 30
/**
* Get expiry label for points based on the expiry date.

View File

@@ -11,7 +11,6 @@ export enum NodeNames {
table = "table",
tbody = "tbody",
td = "td",
text = "text",
th = "th",
tr = "tr",
ul = "ul",

View File

@@ -5,7 +5,7 @@ import FooterNavigation from "./Navigation"
import styles from "./footer.module.css"
export function preload() {
function preload() {
void getFooter()
}

View File

@@ -7,11 +7,10 @@ import styles from "./topLink.module.css"
import type { Header } from "@scandic-hotels/trpc/types/header"
import type { ComponentProps } from "react"
export interface TopLinkProps
extends Omit<
ComponentProps<typeof HeaderLink>,
"href" | "iconName" | "children"
> {
interface TopLinkProps extends Omit<
ComponentProps<typeof HeaderLink>,
"href" | "iconName" | "children"
> {
isLoggedIn: boolean
topLink: Header["header"]["topLink"]
iconSize?: number

View File

@@ -7,7 +7,6 @@ export {
ACCESS_GRANTED,
accessBooking as default,
ERROR_BAD_REQUEST,
ERROR_FORBIDDEN,
ERROR_NOT_FOUND,
ERROR_UNAUTHORIZED,
}
@@ -66,11 +65,6 @@ const ERROR_UNAUTHORIZED = {
status: 401,
} as const
const ERROR_FORBIDDEN = {
code: "FORBIDDEN",
status: 403,
} as const
const ERROR_NOT_FOUND = {
code: "NOT_FOUND",
status: 404,

View File

@@ -96,7 +96,6 @@ Located at `utils/profilingConsent.ts`:
- `storageKey(memberKey)` — Generate storage key
- `readDismissed(memberKey)` — Check if modal was dismissed
- `setDismissed(memberKey)` — Mark modal as dismissed
- `clearDismissed(memberKey)` — Clear dismissal flag
- `profilingConsentOpenEvent` — CustomEvent name for opening modal
- `requestOpen()` — Dispatch event to open modal

View File

@@ -7,7 +7,7 @@ const myPages = {
sv: "/sv/webview/scandic-friends/mina-sidor",
}
export const overview = {
const overview = {
da: `${myPages.da}/oversigt`,
de: `${myPages.de}/uberblick`,
en: `${myPages.en}/overview`,

View File

@@ -38,15 +38,6 @@ export const partners: LangRoute = {
sv: `/${Lang.sv}/scandic-friends/partners`,
}
export const spendPoints: LangRoute = {
da: `/${Lang.da}/scandic-friends/brug-point`,
de: `/${Lang.de}/scandic-friends/ausgeben`,
en: `/${Lang.en}/scandic-friends/spend-points`,
fi: `/${Lang.fi}/scandic-friends/hyodynna`,
no: `/${Lang.no}/scandic-friends/bruk-poeng`,
sv: `/${Lang.sv}/scandic-friends/anvand-poang`,
}
export const offers: LangRoute = {
da: `/${Lang.da}/tilbud`,
de: `/${Lang.de}/angebote`,

View File

@@ -152,7 +152,7 @@ function filterPoints(ancillaries: Ancillaries, user: User | null) {
})
}
export function generateUniqueAncillaries(
function generateUniqueAncillaries(
ancillaries: Ancillaries
): Ancillary["ancillaryContent"] {
const uniqueAncillaries = new Map(

View File

@@ -7,7 +7,7 @@ import { logger } from "@scandic-hotels/common/logger"
const logged: Record<string, boolean> = {}
export type ClientIntlProviderProps = React.PropsWithChildren<
type ClientIntlProviderProps = React.PropsWithChildren<
Pick<IntlConfig, "defaultLocale" | "messages"> & { locale: Lang }
>

View File

@@ -20,7 +20,7 @@ type FailedWarmup = {
export type WarmupResult = BaseWarmup | FailedWarmup
export const warmupFunctions: Record<WarmupFunctionsKey, WarmupFunction> = {
const warmupFunctions: Record<WarmupFunctionsKey, WarmupFunction> = {
countries_en: warmupCountry(Lang.en),
countries_da: warmupCountry(Lang.da),
countries_de: warmupCountry(Lang.de),

View File

@@ -5,7 +5,7 @@ const langs = Object.keys(Lang) as Lang[]
/*
* Keys for warmup functions, the order of the keys is the order in which they will be executed
*/
export const warmupKeys = [
const warmupKeys = [
...langs.map((lang) => `countries_${lang}` as const),
"hotelsByCountry",
...langs.map((lang) => `hotelData_${lang}` as const),

View File

@@ -1,6 +1,6 @@
import { create } from "zustand"
export type SelectedMarker = {
type SelectedMarker = {
cityId: string
location: { lat: number; lng: number }
} | null

View File

@@ -30,7 +30,6 @@ export interface CityMarker {
}
export type CityMarkerProperties = Omit<CityMarker, "coordinates">
export type CitiesClusterMarkerProperties = CityMarkerProperties[]
export type CityMarkerGeojson = FeatureCollection<Point, CityMarkerProperties>
export type CityMarkerFeature = CityMarkerGeojson["features"][number]

View File

@@ -6,7 +6,3 @@ export type MembershipLevelIconProps = {
level: MembershipLevel
rows?: 1 | 2
} & LevelProps
export type CopyButtonProps = {
membershipNumber: string
}

View File

@@ -66,9 +66,3 @@ export interface StepsProps {
savedCreditCards: CreditCard[] | null
error: AncillaryErrorMessage | null
}
export interface ActionButtonsProps {
isPriceDetailsOpen: boolean
togglePriceDetails: () => void
isSubmitting: boolean
}

View File

@@ -1,8 +1,3 @@
import type { userQueryRouter } from "@scandic-hotels/trpc/routers/user/query"
import type { User } from "@scandic-hotels/trpc/types/user"
export type UserQueryRouter = typeof userQueryRouter
export interface UserProps {
user: User
}

View File

@@ -1,34 +1,5 @@
import type { Lang } from "@scandic-hotels/common/constants/language"
import type { PageContentTypeEnum } from "@scandic-hotels/trpc/enums/contentType"
export type NextSearchParams = { [key: string]: string | string[] | undefined }
export type SearchParams<S = object> = {
searchParams: Promise<S & { [key: string]: string }>
}
export type LangParams = {
lang: Lang
}
export type StatusParams = {
status: number
}
export type ContentTypeParams = {
contentType:
| PageContentTypeEnum.loyaltyPage
| PageContentTypeEnum.campaignOverviewPage
| PageContentTypeEnum.campaignPage
| PageContentTypeEnum.contentPage
| PageContentTypeEnum.hotelPage
| PageContentTypeEnum.collectionPage
| PageContentTypeEnum.destinationOverviewPage
| PageContentTypeEnum.destinationCountryPage
| PageContentTypeEnum.destinationCityPage
| PageContentTypeEnum.startPage
}
export type UIDParams = {
uid: string
}

View File

@@ -1,7 +1,7 @@
import type { Lang } from "@scandic-hotels/common/constants/language"
import type { SyncResult } from "contentstack"
export type ChangeFrequency =
type ChangeFrequency =
| "always"
| "hourly"
| "daily"
@@ -10,7 +10,7 @@ export type ChangeFrequency =
| "yearly"
| "never"
export interface SitemapEntry {
interface SitemapEntry {
url: string
lastModified: string
changeFrequency: ChangeFrequency
@@ -62,8 +62,3 @@ export interface SyncItem {
export interface SyncResponse extends Omit<SyncResult, "items"> {
items: SyncItem[]
}
export type SyncItemsByUid = {
mainEntry: SyncItem
alternates: SyncItem[]
}

View File

@@ -1,6 +1,6 @@
export const profilingConsentOpenEvent = "profiling-consent:open"
export const storageKey = (memberKey: string) =>
const storageKey = (memberKey: string) =>
`profiling-consent:dismissed:${memberKey}`
export function readDismissed(memberKey: string): boolean {
@@ -13,11 +13,6 @@ export function setDismissed(memberKey: string): void {
localStorage.setItem(storageKey(memberKey), "1")
}
export function clearDismissed(memberKey: string): void {
if (!memberKey || typeof window === "undefined") return
localStorage.removeItem(storageKey(memberKey))
}
export function requestOpen(): void {
if (typeof window === "undefined") return
window.dispatchEvent(new CustomEvent(profilingConsentOpenEvent))

View File

@@ -64,7 +64,7 @@ export async function getLastUpdated() {
return await store().get(lastUpdatedKey)
}
export async function getSitemapData() {
async function getSitemapData() {
const sitemapData: SitemapData | null = await store().get(sitemapDataKey, {
type: "json",
})

View File

@@ -11,7 +11,4 @@ export {
trackSocialMediaClick,
} from "@scandic-hotels/tracking/navigation"
export { trackPageViewStart } from "@scandic-hotels/tracking/pageview"
export {
trackPaymentEvent,
trackUpdatePaymentMethod,
} from "@scandic-hotels/tracking/payment"
export { trackUpdatePaymentMethod } from "@scandic-hotels/tracking/payment"

View File

@@ -6,7 +6,7 @@ import { webviews } from "@/constants/routes/webviews"
import type { Lang } from "@scandic-hotels/common/constants/language"
export async function webviewSearchParams() {
async function webviewSearchParams() {
const searchParams = new URLSearchParams()
const headersList = await headers()
const loginType = headersList.get("loginType")