From 08804e867520c103b26d8886dfe7f4e0b2076698 Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Thu, 18 Sep 2025 15:33:00 +0000 Subject: [PATCH] Merged in chore/cleanup-scandic-web (pull request #2831) chore: Cleanup scandic-web * Remove unused files * Remove unused and add missing packages * Remove unused exports Approved-by: Linus Flood --- .../Rewards/RewardIcon/index.tsx | 2 +- .../scandic-web/components/Carousel/index.tsx | 1 - .../DestinationPage/Map/PageTypeProvider.tsx | 2 +- .../SidePeeks/MeetingsAndConferences/util.ts | 4 +- .../components/DeprecatedJsonToHtml/index.tsx | 20 - .../jsontohtml.module.css | 68 -- .../DeprecatedJsonToHtml/renderOptions.tsx | 687 ------------------ .../components/DeprecatedJsonToHtml/utils.tsx | 150 ---- .../BookingConfirmation/Tracking/index.tsx | 83 --- .../BookingConfirmation/Tracking/tracking.ts | 213 ------ .../MyStay/utils/hasBreakfastPackage.ts | 22 +- .../MyPages/Avatar/avatar.module.css | 27 - .../components/MyPages/Avatar/index.tsx | 22 - .../InnerCard/ProgressSection/index.tsx | 2 +- .../InnerCard/SuccessCard/index.tsx | 2 +- .../components/Section/Header/index.tsx | 2 +- .../SidePeeks/BookedRoomSidePeek/index.tsx | 2 +- .../Arrow/arrow.module.css | 0 .../{Popover => Breadcrumbs}/Arrow/arrow.ts | 0 .../{Popover => Breadcrumbs}/Arrow/index.tsx | 0 .../Arrow/variants.ts | 0 .../TempDesignSystem/Breadcrumbs/index.tsx | 2 +- .../TempDesignSystem/Grids/Dynamic/dynamic.ts | 6 +- .../TempDesignSystem/Popover/index.tsx | 51 -- .../Popover/popover.module.css | 28 - .../TempDesignSystem/Popover/popover.ts | 6 - .../TempDesignSystem/ProgressBar/index.tsx | 12 - .../ProgressBar/progressbar.module.css | 12 - .../ProgressBar/progressbar.ts | 3 - apps/scandic-web/constants/homeHrefs.ts | 26 - apps/scandic-web/constants/languages.ts | 42 +- apps/scandic-web/constants/routes/webviews.ts | 4 +- .../lib/trpc/memoizedRequests/index.ts | 42 -- apps/scandic-web/package.json | 6 +- .../providers/Details/RoomProvider.tsx | 0 .../stores/hotel-listing-data/helper.ts | 11 - .../stores/my-stay/add-ancillary-flow.ts | 5 +- .../scandic-web/stores/select-rate/helpers.ts | 136 ---- apps/scandic-web/types/Prettify.ts | 3 - .../types/components/ancillaryCard.ts | 6 - .../types/components/blocks/index.ts | 2 +- .../types/components/blocks/infoCard.ts | 8 - .../types/components/deprecatedjsontohtml.ts | 12 - .../types/components/dropdown/dropdown.ts | 2 - .../types/components/header/avatar.ts | 6 - .../types/components/hotelPage/facilities.ts | 14 - .../components/hotelPage/meetingRooms.ts | 2 +- .../hotelReservation/enterDetails/bedType.ts | 3 - .../hotelReservation/enterDetails/details.ts | 4 - .../hotelReservation/myStay/cancelStay.ts | 32 - .../hotelReservation/myStay/changeDates.ts | 26 - .../components/hotelReservation/price.ts | 19 +- .../hotelReservation/selectHotel/hotelData.ts | 11 - .../selectHotel/hotelFilters.ts | 20 - .../hotelReservation/selectHotel/map.ts | 36 - .../selectHotel/priceCardProps.ts | 19 - .../selectHotel/selectHotel.ts | 15 - .../selectRate/hotelInfoCard.ts | 7 - .../selectRate/rateSummary.ts | 7 - .../hotelReservation/selectRate/rates.ts | 14 - .../selectRate/roomListItem.ts | 13 - .../components/hotelReservation/summary.ts | 34 - .../languageSwitcher/languageSwitcher.ts | 3 +- .../components/myPages/myPage/earnAndBurn.ts | 23 +- .../components/myPages/myProfile/edit.ts | 24 - .../components/myPages/myStay/ancillaries.ts | 17 - .../components/myPages/stays/previous.ts | 6 +- .../components/myPages/stays/upcoming.ts | 6 +- apps/scandic-web/types/components/search.ts | 8 - .../sidePeeks/bookedRoomSidePeek.ts | 8 - .../types/components/sidebar/index.ts | 2 +- .../types/contexts/details/room.ts | 0 apps/scandic-web/types/enums/scriptedCard.ts | 9 - .../scandic-web/types/enums/signatureHotel.ts | 8 - apps/scandic-web/types/intl.d.ts | 16 - apps/scandic-web/types/intl.ts | 10 - apps/scandic-web/types/params.ts | 11 +- apps/scandic-web/types/providers/rates.ts | 12 - .../types/providers/select-rate/room.ts | 6 - .../types/requests/asides/contact.ts | 81 --- .../scandic-web/types/requests/asides/puff.ts | 5 - .../scandic-web/types/requests/blocks/list.ts | 49 -- .../scandic-web/types/requests/blocks/puff.ts | 9 - .../scandic-web/types/requests/blocks/text.ts | 13 - apps/scandic-web/types/requests/embeds.ts | 22 - apps/scandic-web/types/requests/hero.ts | 6 - .../types/requests/imageContainer.ts | 12 - apps/scandic-web/types/requests/preamble.ts | 11 - apps/scandic-web/types/requests/puff.ts | 22 - .../types/requests/trackingData.ts | 3 - apps/scandic-web/types/requests/utils/all.ts | 8 - .../scandic-web/types/requests/utils/asset.ts | 8 - .../types/requests/utils/embeds.ts | 11 - .../types/requests/utils/pageLink.ts | 17 - .../types/requests/utils/typename.ts | 19 - apps/scandic-web/types/rte/attrs.ts | 51 -- apps/scandic-web/types/rte/node.ts | 98 --- apps/scandic-web/types/rte/option.ts | 5 - apps/scandic-web/types/sidepeek.ts | 2 - .../types/stores/destination-data.ts | 6 - .../types/stores/hotel-listing-data.ts | 6 - apps/scandic-web/types/stores/my-stay.ts | 2 +- .../types/transitionTypes/jsontohtml.ts | 14 - .../types/transitionTypes/rte/attrs.ts | 45 -- .../types/transitionTypes/rte/enums.ts | 69 -- .../types/transitionTypes/rte/node.ts | 98 --- .../types/transitionTypes/rte/option.ts | 5 - .../trpc/routers/contentstack/sidebar.ts | 11 +- apps/scandic-web/utils/facilityCards.ts | 5 +- apps/scandic-web/utils/rewards.ts | 5 - apps/scandic-web/utils/tracking/booking.ts | 16 - apps/scandic-web/utils/tracking/index.ts | 11 +- yarn.lock | 6 +- 113 files changed, 45 insertions(+), 2891 deletions(-) delete mode 100644 apps/scandic-web/components/DeprecatedJsonToHtml/index.tsx delete mode 100644 apps/scandic-web/components/DeprecatedJsonToHtml/jsontohtml.module.css delete mode 100644 apps/scandic-web/components/DeprecatedJsonToHtml/renderOptions.tsx delete mode 100644 apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx delete mode 100644 apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx delete mode 100644 apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts delete mode 100644 apps/scandic-web/components/MyPages/Avatar/avatar.module.css delete mode 100644 apps/scandic-web/components/MyPages/Avatar/index.tsx rename apps/scandic-web/components/TempDesignSystem/{Popover => Breadcrumbs}/Arrow/arrow.module.css (100%) rename apps/scandic-web/components/TempDesignSystem/{Popover => Breadcrumbs}/Arrow/arrow.ts (100%) rename apps/scandic-web/components/TempDesignSystem/{Popover => Breadcrumbs}/Arrow/index.tsx (100%) rename apps/scandic-web/components/TempDesignSystem/{Popover => Breadcrumbs}/Arrow/variants.ts (100%) delete mode 100644 apps/scandic-web/components/TempDesignSystem/Popover/index.tsx delete mode 100644 apps/scandic-web/components/TempDesignSystem/Popover/popover.module.css delete mode 100644 apps/scandic-web/components/TempDesignSystem/Popover/popover.ts delete mode 100644 apps/scandic-web/components/TempDesignSystem/ProgressBar/index.tsx delete mode 100644 apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.module.css delete mode 100644 apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.ts delete mode 100644 apps/scandic-web/constants/homeHrefs.ts delete mode 100644 apps/scandic-web/providers/Details/RoomProvider.tsx delete mode 100644 apps/scandic-web/stores/select-rate/helpers.ts delete mode 100644 apps/scandic-web/types/Prettify.ts delete mode 100644 apps/scandic-web/types/components/deprecatedjsontohtml.ts delete mode 100644 apps/scandic-web/types/components/header/avatar.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/enterDetails/bedType.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectHotel/hotelData.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectHotel/hotelFilters.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectHotel/priceCardProps.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectHotel/selectHotel.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectRate/rateSummary.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectRate/rates.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectRate/roomListItem.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/summary.ts delete mode 100644 apps/scandic-web/types/components/search.ts delete mode 100644 apps/scandic-web/types/contexts/details/room.ts delete mode 100644 apps/scandic-web/types/enums/scriptedCard.ts delete mode 100644 apps/scandic-web/types/enums/signatureHotel.ts delete mode 100644 apps/scandic-web/types/intl.d.ts delete mode 100644 apps/scandic-web/types/intl.ts delete mode 100644 apps/scandic-web/types/providers/rates.ts delete mode 100644 apps/scandic-web/types/providers/select-rate/room.ts delete mode 100644 apps/scandic-web/types/requests/asides/contact.ts delete mode 100644 apps/scandic-web/types/requests/asides/puff.ts delete mode 100644 apps/scandic-web/types/requests/blocks/list.ts delete mode 100644 apps/scandic-web/types/requests/blocks/puff.ts delete mode 100644 apps/scandic-web/types/requests/blocks/text.ts delete mode 100644 apps/scandic-web/types/requests/embeds.ts delete mode 100644 apps/scandic-web/types/requests/hero.ts delete mode 100644 apps/scandic-web/types/requests/imageContainer.ts delete mode 100644 apps/scandic-web/types/requests/preamble.ts delete mode 100644 apps/scandic-web/types/requests/puff.ts delete mode 100644 apps/scandic-web/types/requests/trackingData.ts delete mode 100644 apps/scandic-web/types/requests/utils/all.ts delete mode 100644 apps/scandic-web/types/requests/utils/asset.ts delete mode 100644 apps/scandic-web/types/requests/utils/embeds.ts delete mode 100644 apps/scandic-web/types/requests/utils/pageLink.ts delete mode 100644 apps/scandic-web/types/rte/attrs.ts delete mode 100644 apps/scandic-web/types/rte/node.ts delete mode 100644 apps/scandic-web/types/rte/option.ts delete mode 100644 apps/scandic-web/types/transitionTypes/jsontohtml.ts delete mode 100644 apps/scandic-web/types/transitionTypes/rte/attrs.ts delete mode 100644 apps/scandic-web/types/transitionTypes/rte/enums.ts delete mode 100644 apps/scandic-web/types/transitionTypes/rte/node.ts delete mode 100644 apps/scandic-web/types/transitionTypes/rte/option.ts diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Rewards/RewardIcon/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Rewards/RewardIcon/index.tsx index c7ed90d2d..c50d1e9d3 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/Rewards/RewardIcon/index.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/Rewards/RewardIcon/index.tsx @@ -2,7 +2,7 @@ import { mapRewardToIcon } from "./data" import type { LogoAndIllustrationProps } from "@scandic-hotels/design-system/Icons" -export interface RewardIconProps extends LogoAndIllustrationProps { +interface RewardIconProps extends LogoAndIllustrationProps { rewardId: string iconSize?: "small" | "medium" | "large" } diff --git a/apps/scandic-web/components/Carousel/index.tsx b/apps/scandic-web/components/Carousel/index.tsx index e59bc26ef..b3939625a 100644 --- a/apps/scandic-web/components/Carousel/index.tsx +++ b/apps/scandic-web/components/Carousel/index.tsx @@ -119,4 +119,3 @@ Carousel.Previous = CarouselPrevious Carousel.Dots = CarouselDots export { Carousel } -export type { CarouselApi } diff --git a/apps/scandic-web/components/ContentType/DestinationPage/Map/PageTypeProvider.tsx b/apps/scandic-web/components/ContentType/DestinationPage/Map/PageTypeProvider.tsx index 434b11e73..3e7d72813 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/Map/PageTypeProvider.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/Map/PageTypeProvider.tsx @@ -13,7 +13,7 @@ export const usePageType = () => { return context } -export type PageTypeProviderProps = { +type PageTypeProviderProps = { value: "city" | "country" | "overview" | null } diff --git a/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/util.ts b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/util.ts index 5ccd5d0bc..8b43c4b05 100644 --- a/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/util.ts +++ b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/util.ts @@ -21,7 +21,7 @@ export async function getConferenceRoomTexts( return { seatingText, roomText } } -export async function getRoomText(roomSizes: number[]) { +async function getRoomText(roomSizes: number[]) { const largestRoom = Math.max(...roomSizes) const smallestRoom = Math.min(...roomSizes) const intl = await getIntl() @@ -47,7 +47,7 @@ export async function getRoomText(roomSizes: number[]) { return roomText } -export async function getSeatingText(roomSeating: number[]) { +async function getSeatingText(roomSeating: number[]) { const biggestSeating = Math.max(...roomSeating) const smallestSeating = Math.min(...roomSeating) const intl = await getIntl() diff --git a/apps/scandic-web/components/DeprecatedJsonToHtml/index.tsx b/apps/scandic-web/components/DeprecatedJsonToHtml/index.tsx deleted file mode 100644 index bcfd11119..000000000 --- a/apps/scandic-web/components/DeprecatedJsonToHtml/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { nodesToHtml } from "./utils" - -import styles from "./jsontohtml.module.css" - -import type { DeprecatedJsonToHtmlProps } from "@/types/components/deprecatedjsontohtml" - -export default function DeprecatedJsonToHtml({ - embeds, - nodes, - renderOptions = {}, -}: DeprecatedJsonToHtmlProps) { - if (!Array.isArray(nodes) || !nodes.length) { - return null - } - return ( -
- {nodesToHtml(nodes, embeds, renderOptions).filter(Boolean)} -
- ) -} diff --git a/apps/scandic-web/components/DeprecatedJsonToHtml/jsontohtml.module.css b/apps/scandic-web/components/DeprecatedJsonToHtml/jsontohtml.module.css deleted file mode 100644 index afc508078..000000000 --- a/apps/scandic-web/components/DeprecatedJsonToHtml/jsontohtml.module.css +++ /dev/null @@ -1,68 +0,0 @@ -.image { - max-width: 100%; - width: 100%; - height: 365px; - object-fit: cover; - border-radius: var(--Corner-radius-md); - margin: var(--Spacing-x1) var(--Spacing-x0); -} - -.ul, -.ol { - padding: var(--Spacing-x2) var(--Spacing-x0); - display: grid; - gap: var(--Spacing-x1); -} - -.ol > li::marker { - color: var(--Primary-Light-On-Surface-Accent); -} - -.li:has(.heart), -.li:has(.check) { - list-style: none; -} - -.li { - margin-left: var(--Spacing-x3); -} - -.li:has(.heart):before { - content: url("/_static/icons/heart.svg"); - position: relative; - height: 8px; - top: 3px; - margin-right: var(--Spacing-x1); - margin-left: calc(var(--Spacing-x3) * -1); -} - -.li:has(.check)::before { - content: url("/_static/icons/check-ring.svg"); - position: relative; - height: 8px; - top: 3px; - margin-right: var(--Spacing-x1); - margin-left: calc(var(--Spacing-x3) * -1); -} - -.container { - display: grid; - gap: var(--Spacing-x3); - max-width: 1197px; -} - -.li > p { - display: inline; -} - -.tableContainer { - max-width: 100%; - overflow-x: auto; -} -@media screen and (min-width: 768px) { - .ol:has(li:nth-last-child(n + 5)), - .ul:has(li:nth-last-child(n + 5)) { - grid-template-columns: 1fr 1fr; - grid-auto-flow: column; - } -} diff --git a/apps/scandic-web/components/DeprecatedJsonToHtml/renderOptions.tsx b/apps/scandic-web/components/DeprecatedJsonToHtml/renderOptions.tsx deleted file mode 100644 index 5326d2fe8..000000000 --- a/apps/scandic-web/components/DeprecatedJsonToHtml/renderOptions.tsx +++ /dev/null @@ -1,687 +0,0 @@ -import { - type DeprecatedImageVaultAssetResponse, - type ImageVaultAssetResponse, - mapImageVaultAssetResponseToImageVaultAsset, - mapInsertResponseToImageVaultAsset, -} from "@scandic-hotels/common/utils/imageVault" -import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url" -import Body from "@scandic-hotels/design-system/Body" -import Caption from "@scandic-hotels/design-system/Caption" -import { Divider } from "@scandic-hotels/design-system/Divider" -import Footnote from "@scandic-hotels/design-system/Footnote" -import Image from "@scandic-hotels/design-system/Image" -import ImageContainer from "@scandic-hotels/design-system/ImageContainer" -import Link from "@scandic-hotels/design-system/Link" -import Subtitle from "@scandic-hotels/design-system/Subtitle" -import Table from "@scandic-hotels/design-system/Table" -import Title from "@scandic-hotels/design-system/Title" -import { - AvailableParagraphFormatEnum, - RTEItemTypeEnum, - RTETypeEnum, -} from "@scandic-hotels/trpc/types/RTEenums" - -import BiroScript from "../TempDesignSystem/Text/BiroScript" -import { hasAvailableParagraphFormat, hasAvailableULFormat } from "./utils" - -import styles from "./jsontohtml.module.css" - -import type { EmbedByUid } from "@/types/components/deprecatedjsontohtml" -import { EmbedEnum } from "@/types/requests/utils/embeds" -import type { Attributes } from "@/types/rte/attrs" -import { - type RTEDefaultNode, - type RTEImageNode, - RTEMarkType, - type RTENext, - type RTENode, - type RTERegularNode, - type RTETextNode, -} from "@/types/rte/node" -import type { RenderOptions } from "@/types/rte/option" - -function extractPossibleAttributes(attrs: Attributes | undefined) { - if (!attrs) return {} - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const props: Record = {} - if (attrs.id) { - props.id = attrs.id - } - - if (attrs.class) { - props.className = attrs.class - } else if (attrs["class-name"]) { - props.className = attrs["class-name"] - } else if (attrs.classname) { - props.className = attrs.classname - } else if (attrs?.style?.["text-align"]) { - props.style = { - textAlign: attrs?.style?.["text-align"], - } - } - - return props -} - -export const renderOptions: RenderOptions = { - [RTETypeEnum.a]: ( - node: RTERegularNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - if (node.attrs.url) { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - } - return null - }, - - [RTETypeEnum.blockquote]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.code]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.embed]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - if (node.attrs.src) { - props.src = node.attrs.src - } - if (node.attrs.url) { - props.src = node.attrs.url - } - if (!props.src) { - return null - } - return ( - - ) - }, - - [RTETypeEnum.h1]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.h2]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.h3]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.h4]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.h5]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.hr]: () => { - return - }, - - [RTETypeEnum.li]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( -
  • - {next(node.children, embeds, fullRenderOptions)} -
  • - ) - }, - - [RTETypeEnum.ol]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - - // Set the number of rows dynamically to create even rows for each column. We want the li:s - // to flow with the column, so therefore this is needed. - let numberOfRows: number | undefined - if (node.children.length > 4) { - const half = node.children.length / 2 - numberOfRows = Math.ceil(half) - } - - return ( -
      - {next(node.children, embeds, fullRenderOptions)} -
    - ) - }, - - [RTETypeEnum.p]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - - const hasFormat = node.children.some((item) => - hasAvailableParagraphFormat((item as RTETextNode)?.classname) - ) - - // If a child node has an available format as className, we wrap it in a - // span and render the children with the correct component - if (hasFormat) { - return next(node.children, embeds, fullRenderOptions) - } - - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.reference]: ( - node: RTENode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - if ("attrs" in node) { - const type = node.attrs.type - if (type === RTEItemTypeEnum.asset) { - const image = embeds?.[node?.attrs?.["asset-uid"]] - if (image?.node.__typename === EmbedEnum.SysAsset) { - const alt = image?.node?.title ?? node.attrs.alt - const props = extractPossibleAttributes(node.attrs) - props.className = styles.image - return ( - {alt} - ) - } - } else if (type === RTEItemTypeEnum.entry) { - const entry = embeds?.[node?.attrs?.["entry-uid"]] - - if (entry?.node.__typename === EmbedEnum.ImageContainer) { - if (entry.node.image_left && entry.node.image_right) { - return ( - - ) - } - return null - } else if ( - entry?.node.__typename === EmbedEnum.LoyaltyPage || - entry?.node.__typename === EmbedEnum.ContentPage || - entry?.node.__typename === EmbedEnum.AccountPage - ) { - // If entry is not an ImageContainer, it is a page and we return it as a link - const props = extractPossibleAttributes(node.attrs) - let href = "" - if (entry?.node.__typename === EmbedEnum.AccountPage) { - href = removeMultipleSlashes( - `/${entry.node.system.locale}${entry.node.url}` - ) - } else { - href = - entry.node?.web?.original_url || - removeMultipleSlashes( - `/${entry.node.system.locale}${entry.node.url}` - ) - } - - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - } - } - } - - return null - }, - - [RTETypeEnum.ImageVault]: (node: RTEImageNode) => { - const type = node.type - if (!("attrs" in node) || type !== RTETypeEnum.ImageVault) { - return null - } - - let image = undefined - if ("imageVaultId" in node.attrs && "fileName" in node.attrs) { - image = mapImageVaultAssetResponseToImageVaultAsset( - node.attrs as unknown as ImageVaultAssetResponse - ) - } - - if ("Name" in node.attrs && "Id" in node.attrs) { - image = mapInsertResponseToImageVaultAsset( - node.attrs as unknown as DeprecatedImageVaultAssetResponse - ) - } - - if (!image) { - return null - } - const alt = image.meta.alt ?? image.title - const props = extractPossibleAttributes(node.attrs) - - return ( -
    - {alt} - {image.meta.caption} -
    - ) - - return null - }, - - [RTETypeEnum.table]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( -
    - - {next(node.children, embeds, fullRenderOptions)} -
    -
    - ) - }, - - [RTETypeEnum.thead]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - // Override the styling of p tags inside the thead tag - const theadChildPRenderOptions = { - ...fullRenderOptions, - [RTETypeEnum.p]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => ( - - {next(node.children, embeds, fullRenderOptions)} - - ), - } - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, theadChildPRenderOptions)} - - ) - }, - - [RTETypeEnum.tbody]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.tfoot]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.fragment]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - return <>{next(node.children, embeds, fullRenderOptions)} - }, - - [RTETypeEnum.tr]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.th]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.td]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - return ( - - {next(node.children, embeds, fullRenderOptions)} - - ) - }, - - [RTETypeEnum.ul]: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - const props = extractPossibleAttributes(node.attrs) - - // Set the number of rows dynamically to create even rows for each column. We want the li:s - // to flow with the column, so therefore this is needed. - let numberOfRows: number | undefined - if (node.children.length > 4) { - const half = node.children.length / 2 - numberOfRows = Math.ceil(half) - } - - return ( -
      - {next(node.children, embeds, fullRenderOptions)} -
    - ) - }, - - /** TextNode wrappers */ - [RTEMarkType.bold]: (children: React.ReactNode) => { - return {children} - }, - - [RTEMarkType.italic]: (children: React.ReactNode) => { - return {children} - }, - - [RTEMarkType.underline]: (children: React.ReactNode) => { - return {children} - }, - - [RTEMarkType.strikethrough]: (children: React.ReactNode) => { - return {children} - }, - - [RTEMarkType.inlineCode]: (children: React.ReactNode) => { - return {children} - }, - - [RTEMarkType.subscript]: (children: React.ReactNode) => { - return {children} - }, - - [RTEMarkType.superscript]: (children: React.ReactNode) => { - return {children} - }, - - [RTEMarkType.break]: (children: React.ReactNode) => { - return ( - <> -
    - {children} - - ) - }, - - [RTEMarkType.classnameOrId]: ( - children: React.ReactNode, - className?: string, - id?: string - ) => { - const props = { - className, - id, - } - if (!className) { - delete props.className - } - if (!id) { - delete props.id - } - - if (className) { - if (hasAvailableULFormat(className)) { - props.className = styles[className] - } - } - - if (className === AvailableParagraphFormatEnum.footnote) { - return ( - - {children} - - ) - } - - if (className === AvailableParagraphFormatEnum.caption) { - return ( - - {children} - - ) - } - - if (className === AvailableParagraphFormatEnum["script-1"]) { - return ( - - {children} - - ) - } - - if (className === AvailableParagraphFormatEnum["script-2"]) { - return ( - - {children} - - ) - } - - if (className === AvailableParagraphFormatEnum["subtitle-1"]) { - return ( - - {children} - - ) - } - if (className === AvailableParagraphFormatEnum["subtitle-2"]) { - return ( - - {children} - - ) - } - return ( - - {children} - - ) - }, - - /** - * Contentstack can return something called `default` as seen here in their - * own SDK (https://github.com/contentstack/contentstack-utils-javascript/blob/master/src/options/default-node-options.ts#L89) - */ - default: ( - node: RTEDefaultNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions - ) => { - return next(node.children, embeds, fullRenderOptions) - }, -} diff --git a/apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx b/apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx deleted file mode 100644 index f2456083a..000000000 --- a/apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx +++ /dev/null @@ -1,150 +0,0 @@ -import { cloneElement } from "react" - -import { - AvailableParagraphFormatEnum, - AvailableULFormatEnum, - RTETypeEnum, -} from "@scandic-hotels/trpc/types/RTEenums" - -import { renderOptions } from "./renderOptions" - -import type { Node } from "@scandic-hotels/trpc/types/edges" - -import type { EmbedByUid } from "@/types/components/deprecatedjsontohtml" -import type { Embeds } from "@/types/requests/embeds" -import { - RTEMarkType, - type RTENode, - type RTERenderMark, - type RTERenderOptionComponent, - type RTETextNode, -} from "@/types/rte/node" -import type { RenderOptions } from "@/types/rte/option" - -export function groupEmbedsByUid(embedsArray: Node[]) { - const embedsByUid = embedsArray.reduce((acc, embed) => { - if (embed.node.system?.uid) { - acc[embed.node.system.uid] = embed - } - return acc - }, {}) - - return embedsByUid -} - -export function nodeChildrenToHtml( - nodes: RTENode[], - embeds: EmbedByUid, - fullRenderOptions: RenderOptions - // eslint-disable-next-line @typescript-eslint/no-explicit-any -): any { - return nodes - .map((node, i) => { - // This function either returns a JSX element or null - const element = nodeToHtml(node, embeds, fullRenderOptions) - if (!element) { - return null - } - - return cloneElement(element, { - key: `child-rte-${i}`, - }) - }) - .filter(Boolean) -} - -export function textNodeToHtml( - node: RTETextNode, - fullRenderOptions: RenderOptions -) { - let text = <>{node.text} - - if (node.classname || node.id) { - text = (fullRenderOptions[RTEMarkType.classnameOrId] as RTERenderMark)( - text, - node.classname, - node.id - ) - } - if (node.break) { - text = (fullRenderOptions[RTEMarkType.break] as RTERenderMark)(text) - } - if (node.superscript) { - text = (fullRenderOptions[RTEMarkType.superscript] as RTERenderMark)(text) - } - if (node.subscript) { - text = (fullRenderOptions[RTEMarkType.subscript] as RTERenderMark)(text) - } - if (node.inlineCode) { - text = (fullRenderOptions[RTEMarkType.inlineCode] as RTERenderMark)(text) - } - if (node.strikethrough) { - text = (fullRenderOptions[RTEMarkType.strikethrough] as RTERenderMark)(text) - } - if (node.underline) { - text = (fullRenderOptions[RTEMarkType.underline] as RTERenderMark)(text) - } - if (node.italic) { - text = (fullRenderOptions[RTEMarkType.italic] as RTERenderMark)(text) - } - if (node.bold) { - text = (fullRenderOptions[RTEMarkType.bold] as RTERenderMark)(text) - } - return text -} - -function next( - nodes: RTENode[], - embeds: EmbedByUid, - fullRenderOptions: RenderOptions -) { - return nodeChildrenToHtml(nodes, embeds, fullRenderOptions) -} - -export function hasAvailableParagraphFormat(className?: string) { - if (!className) { - return false - } - return Object.keys(AvailableParagraphFormatEnum).includes(className) -} - -export function hasAvailableULFormat(className?: string) { - if (!className) { - return false - } - return Object.keys(AvailableULFormatEnum).includes(className) -} - -export function nodeToHtml( - node: RTENode, - embeds: EmbedByUid, - fullRenderOptions: RenderOptions -) { - if ("type" in node === false) { - return textNodeToHtml(node, fullRenderOptions) - } else { - if (fullRenderOptions[node.type] !== undefined) { - if (node.type === RTETypeEnum.doc) { - return null - } - return (fullRenderOptions[node.type] as RTERenderOptionComponent)( - node, - embeds, - next, - fullRenderOptions - ) - } else { - return next(node.children, embeds, fullRenderOptions) - } - } -} - -export function nodesToHtml( - nodes: RTENode[], - embedsArray: Node[], - overrideRenderOptions: RenderOptions -) { - const embeds = groupEmbedsByUid(embedsArray) - const fullRenderOptions = { ...renderOptions, ...overrideRenderOptions } - return nodes.map((node) => nodeToHtml(node, embeds, fullRenderOptions)) -} diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx deleted file mode 100644 index 9a05b8d4e..000000000 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx +++ /dev/null @@ -1,83 +0,0 @@ -"use client" - -import { useEffect, useState } from "react" - -import { clearPaymentInfoSessionStorage } from "@scandic-hotels/booking-flow/components/EnterDetails/Payment/helpers" -import { useSearchHistory } from "@scandic-hotels/booking-flow/hooks/useSearchHistory" -import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" -import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK" - -import useLang from "@/hooks/useLang" - -import { getTracking } from "./tracking" - -import type { Room } from "@scandic-hotels/booking-flow/types/stores/booking-confirmation" -import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" - -export default function Tracking({ - bookingConfirmation, - refId, -}: { - bookingConfirmation: BookingConfirmation - refId: string -}) { - const lang = useLang() - const bookingRooms = useBookingConfirmationStore((state) => state.rooms) - - const [loadedBookingConfirmationRefId] = useState(() => { - if (typeof window !== "undefined") { - return sessionStorage.getItem("loadedBookingConfirmationRefId") - } - return null - }) - - useEffect(() => { - sessionStorage.setItem("loadedBookingConfirmationRefId", refId) - }, [refId]) - - const searchHistory = useSearchHistory() - const searchTerm = searchHistory.searchHistory[0]?.name - - let trackingData = null - - if (bookingRooms.every(Boolean)) { - const rooms = bookingRooms.filter((room): room is Room => !!room) - trackingData = getTracking( - lang, - bookingConfirmation.booking, - bookingConfirmation.hotel, - rooms, - searchTerm - ) - } - - useEffect(() => { - if (trackingData?.paymentInfo) { - clearPaymentInfoSessionStorage() - } - }, [trackingData]) - - if (!trackingData) { - return null - } - - const { hotelsTrackingData, pageTrackingData, paymentInfo, ancillaries } = - trackingData - - return ( - - ) -} diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts deleted file mode 100644 index 97682845c..000000000 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts +++ /dev/null @@ -1,213 +0,0 @@ -import { createHash } from "crypto" -import { differenceInCalendarDays, format, isWeekend } from "date-fns" - -import { readPaymentInfoFromSessionStorage } from "@scandic-hotels/booking-flow/components/EnterDetails/Payment/helpers" -import { invertedBedTypeMap } from "@scandic-hotels/booking-flow/utils/SelectRate" -import { getSpecialRoomType } from "@scandic-hotels/booking-flow/utils/specialRoomType" -import { CancellationRuleEnum } from "@scandic-hotels/common/constants/booking" -import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" -import { RateEnum } from "@scandic-hotels/common/constants/rate" -import { - TrackingChannelEnum, - type TrackingSDKAncillaries, - type TrackingSDKHotelInfo, - type TrackingSDKPageData, - type TrackingSDKPaymentInfo, -} from "@scandic-hotels/tracking/types" -import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" -import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter" - -import type { Room } from "@scandic-hotels/booking-flow/types/stores/booking-confirmation" -import type { Lang } from "@scandic-hotels/common/constants/language" -import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" -import type { RateDefinition } from "@scandic-hotels/trpc/types/roomAvailability" - -function getRate(cancellationRule: RateDefinition["cancellationRule"] | null) { - switch (cancellationRule) { - case "CancellableBefore6PM": - return RateEnum.flex - case "Changeable": - return RateEnum.change - case "NotCancellable": - return RateEnum.save - default: - return "" - } -} - -function mapAncillaryPackage( - ancillaryPackage: BookingConfirmation["booking"]["packages"][number], - operaId: string -) { - const isPoints = ancillaryPackage.currency === CurrencyEnum.POINTS - return { - hotelid: operaId, - productCategory: "", // TODO: Add category - productId: ancillaryPackage.code, - productName: ancillaryPackage.description, - productPoints: isPoints ? ancillaryPackage.totalPrice : 0, - productPrice: isPoints ? 0 : ancillaryPackage.totalPrice, - productType: - ancillaryPackage.code === BreakfastPackageEnum.REGULAR_BREAKFAST - ? "food" - : "room preference", - productUnits: ancillaryPackage.totalUnit, - productDeliveryTime: "", - } -} - -export function getTracking( - lang: Lang, - booking: BookingConfirmation["booking"], - hotel: BookingConfirmation["hotel"], - rooms: Room[], - searchTerm?: string -) { - const arrivalDate = new Date(booking.checkInDate) - const departureDate = new Date(booking.checkOutDate) - const paymentInfoSessionData = readPaymentInfoFromSessionStorage() - - const pageTrackingData: TrackingSDKPageData = { - channel: TrackingChannelEnum.hotelreservation, - domainLanguage: lang, - pageId: "booking-confirmation", - pageName: `hotelreservation|confirmation`, - pageType: "confirmation", - siteSections: `hotelreservation|confirmation`, - siteVersion: "new-web", - } - - const noOfAdults = rooms.map((r) => r.adults).join(",") - const noOfChildren = rooms.map((r) => r.childrenAges?.length ?? 0).join(",") - const noOfRooms = rooms.length - const isFlexBooking = - booking.rateDefinition.cancellationRule === - CancellationRuleEnum.CancellableBefore6PM - const isGuaranteedFlexBooking = booking.guaranteeInfo && isFlexBooking - - const ancillaries: TrackingSDKAncillaries = rooms - .flatMap((r) => r.packages) - .filter( - (p) => - p.code === RoomPackageCodeEnum.PET_ROOM || - p.code === BreakfastPackageEnum.REGULAR_BREAKFAST - ) - .map((pkg) => mapAncillaryPackage(pkg, hotel.operaId)) - - const hotelsTrackingData: TrackingSDKHotelInfo = { - ageOfChildren: rooms.map((r) => r.childrenAges?.join(",") ?? "").join("|"), - analyticsRateCode: rooms - .map((r) => getRate(r.rateDefinition.cancellationRule)) - .join("|"), - arrivalDate: format(arrivalDate, "yyyy-MM-dd"), - bedType: rooms - .map((r) => r.bedType) - .join(",") - .toLowerCase(), - bnr: rooms.map((r) => r.confirmationNumber).join(","), - bookingCode: rooms.map((room) => room.bookingCode ?? "n/a").join(", "), - bookingCodeAvailability: booking.bookingCode - ? rooms.map((room) => (room.bookingCode ? "true" : "false")).join(", ") - : undefined, - bookingTypeofDay: isWeekend(arrivalDate) ? "weekend" : "weekday", - breakfastOption: rooms - .map((r) => { - if (r.breakfastIncluded || r.breakfast) { - return "breakfast buffet" - } - return "no breakfast" - }) - .join(","), - childBedPreference: rooms - .map( - (r) => - r.childBedPreferences - .map((cbp) => - Array(cbp.quantity).fill(invertedBedTypeMap[cbp.bedType]) - ) - .join(",") ?? "" - ) - .join("|"), - country: hotel?.address.country, - departureDate: format(departureDate, "yyyy-MM-dd"), - duration: differenceInCalendarDays(departureDate, arrivalDate), - hotelID: hotel.operaId, - leadTime: differenceInCalendarDays(arrivalDate, new Date()), - noOfAdults, - noOfChildren, - noOfRooms, - rateCode: rooms.map((r) => r.rateDefinition.rateCode).join(","), - rateCodeCancellationRule: rooms - .map((r) => r.rateDefinition.cancellationRule) - .join(",") - .toLowerCase(), - rateCodeName: rooms.map(constructRateCodeName).join(","), - rateCodeType: rooms.map((r) => r.rateCodeType?.toLowerCase()).join(","), - region: hotel?.address.city, - revenueCurrencyCode: [...new Set(rooms.map((r) => r.currencyCode))].join( - "," - ), - rewardNight: booking.roomPoints > 0 ? "yes" : "no", - rewardNightAvailability: booking.roomPoints > 0 ? "true" : "false", - points: booking.roomPoints > 0 ? booking.roomPoints : undefined, - roomPrice: rooms.reduce((total, room) => total + room.roomPrice, 0), - roomTypeCode: rooms.map((r) => r.roomTypeCode ?? "").join(","), - searchTerm, - searchType: "hotel", - specialRoomType: rooms - .map((room) => getSpecialRoomType(room.packages)) - .join(","), - totalPrice: rooms.reduce((total, room) => total + room.totalPrice, 0), - lateArrivalGuarantee: booking.rateDefinition.mustBeGuaranteed - ? "mandatory" - : isFlexBooking - ? booking.guaranteeInfo - ? "yes" - : "no" - : "na", - guaranteedProduct: isGuaranteedFlexBooking ? "room" : "na", - emailId: getSHAHash(booking.guest.email), - mobileNumber: getSHAHash(booking.guest.phoneNumber), - } - - const paymentInfo: TrackingSDKPaymentInfo = { - paymentStatus: isGuaranteedFlexBooking - ? "glacardsaveconfirmed" - : "confirmed", - type: - booking.guaranteeInfo?.cardType ?? paymentInfoSessionData?.paymentMethod, - } - - return { - hotelsTrackingData, - pageTrackingData, - paymentInfo, - ancillaries, - } -} - -function constructRateCodeName(room: Room) { - if (room.cheques) { - return "corporate cheque" - } else if (room.vouchers) { - return "voucher" - } else if (room.roomPoints) { - return "redemption" - } - - const rate = getRate(room.rateDefinition.cancellationRule) - - const bookingCodeStr = room.bookingCode ? room.bookingCode.toUpperCase() : "" - - const breakfastIncludedStr = room.breakfastIncluded - ? "incl. breakfast" - : "excl. breakfast" - - return [bookingCodeStr, rate, breakfastIncludedStr] - .filter(Boolean) - .join(" - ") -} - -function getSHAHash(key: string) { - return createHash("sha256").update(key).digest("hex") -} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/utils/hasBreakfastPackage.ts b/apps/scandic-web/components/HotelReservation/MyStay/utils/hasBreakfastPackage.ts index 950b9df70..5e9395ac9 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/utils/hasBreakfastPackage.ts +++ b/apps/scandic-web/components/HotelReservation/MyStay/utils/hasBreakfastPackage.ts @@ -1,6 +1,6 @@ import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" -export function hasBreakfastPackageFromBookingFlow( +function hasBreakfastPackageFromBookingFlow( packages: { code: string }[] @@ -13,26 +13,6 @@ export function hasBreakfastPackageFromBookingFlow( ) } -export function getBreakfastPackagesFromBookingFlow( - packages: T[] -): T[] | undefined { - // Since `FREE_CHILD_BREAKFAST` has the same code when breakfast is added - // in the booking flow and as ancillary we can't just do a simple filter on the codes. - // So we shortcircuit if there are no booking flow specific packages. - if (!packages || !hasBreakfastPackageFromBookingFlow(packages)) { - return undefined - } - - return packages.filter( - (p) => - p.code === BreakfastPackageEnum.REGULAR_BREAKFAST || - p.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST || - p.code === BreakfastPackageEnum.CHILD_PAYING_BREAKFAST || - p.code === BreakfastPackageEnum.FREE_CHILD_BREAKFAST || - p.code === BreakfastPackageEnum.SPECIAL_PACKAGE_BREAKFAST - ) -} - export function getBreakfastPackagesFromAncillaryFlow< T extends { code: string }, >(packages: T[]): T[] | undefined { diff --git a/apps/scandic-web/components/MyPages/Avatar/avatar.module.css b/apps/scandic-web/components/MyPages/Avatar/avatar.module.css deleted file mode 100644 index 5898e3f58..000000000 --- a/apps/scandic-web/components/MyPages/Avatar/avatar.module.css +++ /dev/null @@ -1,27 +0,0 @@ -.avatar { - display: inline-flex; - align-items: center; - justify-content: center; - vertical-align: middle; - overflow: hidden; - cursor: pointer; - width: 35px; - height: 35px; - border-radius: 100%; - background-color: rgba(0, 0, 0, 0.05); -} - -.avatarInitialsText { - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - background-color: var(--Primary-Dark-Surface-Normal); - color: var(--Primary-Dark-On-Surface-Text); - font-size: var(--typography-Caption-Bold-fontSize); - font-family: var(--typography-Body-Regular-fontFamily); - font-weight: var(--typography-Caption-Bold-fontWeight); - line-height: 150%; - letter-spacing: 0.096px; -} diff --git a/apps/scandic-web/components/MyPages/Avatar/index.tsx b/apps/scandic-web/components/MyPages/Avatar/index.tsx deleted file mode 100644 index 63f0060c8..000000000 --- a/apps/scandic-web/components/MyPages/Avatar/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { getInitials } from "@/utils/user" - -import styles from "./avatar.module.css" - -import type { User } from "@scandic-hotels/trpc/types/user" - -export default function Avatar({ - firstName, - lastName, -}: { - firstName: User["firstName"] - lastName: User["lastName"] -}) { - const initials = getInitials(firstName, lastName) - return ( - - - {initials} - - - ) -} diff --git a/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/ProgressSection/index.tsx b/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/ProgressSection/index.tsx index 6b8d2bf6a..3a49715f8 100644 --- a/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/ProgressSection/index.tsx +++ b/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/ProgressSection/index.tsx @@ -10,7 +10,7 @@ import styles from "./progressSection.module.css" import type { ProgressCalculation } from "../../types" -export interface ProgressSectionProps { +interface ProgressSectionProps { earned: number progress: ProgressCalculation toKeepCurrent?: number diff --git a/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/SuccessCard/index.tsx b/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/SuccessCard/index.tsx index ec9eb8b7f..9bdd3a7f4 100644 --- a/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/SuccessCard/index.tsx +++ b/apps/scandic-web/components/MyPages/LevelProgressCard/InnerCard/SuccessCard/index.tsx @@ -5,7 +5,7 @@ import { getIntl } from "@/i18n" import styles from "./successCard.module.css" -export interface SuccessCardProps { +interface SuccessCardProps { pointsEarned?: number | null } diff --git a/apps/scandic-web/components/Section/Header/index.tsx b/apps/scandic-web/components/Section/Header/index.tsx index ad04baee1..00f5098ff 100644 --- a/apps/scandic-web/components/Section/Header/index.tsx +++ b/apps/scandic-web/components/Section/Header/index.tsx @@ -5,7 +5,7 @@ import SectionLink from "../Link" import styles from "./header.module.css" -export type HeaderProps = { +type HeaderProps = { link?: { href: string text: string diff --git a/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx b/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx index 4c511f870..4c544c8f5 100644 --- a/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx +++ b/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx @@ -40,7 +40,7 @@ type PartialHotelRoom = Pick< "descriptions" | "images" | "name" | "roomFacilities" | "roomTypes" > -export type Room = Pick< +type Room = Pick< BookingConfirmationSchema, | "adults" | "bookingCode" diff --git a/apps/scandic-web/components/TempDesignSystem/Popover/Arrow/arrow.module.css b/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/arrow.module.css similarity index 100% rename from apps/scandic-web/components/TempDesignSystem/Popover/Arrow/arrow.module.css rename to apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/arrow.module.css diff --git a/apps/scandic-web/components/TempDesignSystem/Popover/Arrow/arrow.ts b/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/arrow.ts similarity index 100% rename from apps/scandic-web/components/TempDesignSystem/Popover/Arrow/arrow.ts rename to apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/arrow.ts diff --git a/apps/scandic-web/components/TempDesignSystem/Popover/Arrow/index.tsx b/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/index.tsx similarity index 100% rename from apps/scandic-web/components/TempDesignSystem/Popover/Arrow/index.tsx rename to apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/index.tsx diff --git a/apps/scandic-web/components/TempDesignSystem/Popover/Arrow/variants.ts b/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/variants.ts similarity index 100% rename from apps/scandic-web/components/TempDesignSystem/Popover/Arrow/variants.ts rename to apps/scandic-web/components/TempDesignSystem/Breadcrumbs/Arrow/variants.ts diff --git a/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/index.tsx b/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/index.tsx index 9bcc16ceb..6677ec075 100644 --- a/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/index.tsx +++ b/apps/scandic-web/components/TempDesignSystem/Breadcrumbs/index.tsx @@ -17,7 +17,7 @@ import { debounce } from "@scandic-hotels/common/utils/debounce" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" -import { Arrow } from "../Popover/Arrow" +import { Arrow } from "./Arrow" import { Breadcrumb } from "./Breadcrumb" import { splitBreadcrumbs } from "./utils" import { breadcrumbsVariants } from "./variants" diff --git a/apps/scandic-web/components/TempDesignSystem/Grids/Dynamic/dynamic.ts b/apps/scandic-web/components/TempDesignSystem/Grids/Dynamic/dynamic.ts index 48c418452..a32750453 100644 --- a/apps/scandic-web/components/TempDesignSystem/Grids/Dynamic/dynamic.ts +++ b/apps/scandic-web/components/TempDesignSystem/Grids/Dynamic/dynamic.ts @@ -4,11 +4,11 @@ import type { TypenameInterface } from "@/types/requests/utils/typename" export type Order = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 -export type ColSpan = 2 | 3 | 4 | 6 | 8 +type ColSpan = 2 | 3 | 4 | 6 | 8 export type RowSpan = 1 | 2 | 3 | 6 // TODO: Extend query and fix type accordingly -export interface Row extends TypenameInterface<"Card"> { +interface Row extends TypenameInterface<"Card"> { title: string } @@ -19,7 +19,7 @@ type Column = { }[] } -export interface Grid { +interface Grid { columns: Column[] } diff --git a/apps/scandic-web/components/TempDesignSystem/Popover/index.tsx b/apps/scandic-web/components/TempDesignSystem/Popover/index.tsx deleted file mode 100644 index 5445b6cdc..000000000 --- a/apps/scandic-web/components/TempDesignSystem/Popover/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { - Button, - Dialog, - DialogTrigger, - OverlayArrow, - Popover as RAPopover, -} from "react-aria-components" - -import useSetOverFlowVisibleOnRA from "@scandic-hotels/common/hooks/useSetOverflowVisibleOnRA" -import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" - -import { Arrow } from "./Arrow" - -import styles from "./popover.module.css" - -import type { PopoverProps } from "./popover" - -export default function Popover({ - triggerContent, - children, - ...props -}: PopoverProps) { - const setOverflowVisible = useSetOverFlowVisibleOnRA() - - return ( - - - - - - - - - {({ close }) => ( - <> - - {children} - - )} - - - - ) -} diff --git a/apps/scandic-web/components/TempDesignSystem/Popover/popover.module.css b/apps/scandic-web/components/TempDesignSystem/Popover/popover.module.css deleted file mode 100644 index d48a11172..000000000 --- a/apps/scandic-web/components/TempDesignSystem/Popover/popover.module.css +++ /dev/null @@ -1,28 +0,0 @@ -.root { - background-color: var(--Base-Surface-Primary-light-Normal); - border-radius: var(--Corner-radius-md); - box-shadow: var(--popup-box-shadow); - padding: var(--Spacing-x2); - max-width: calc(360px + var(--Spacing-x2) * 2); - overflow-y: auto; -} - -.root section:focus-visible { - outline: none; -} - -.trigger { - background: none; - border: none; - padding: 0; - cursor: pointer; -} -.closeButton { - position: absolute; - top: 8px; - right: 8px; - background: none; - border: none; - cursor: pointer; - padding: 0; -} diff --git a/apps/scandic-web/components/TempDesignSystem/Popover/popover.ts b/apps/scandic-web/components/TempDesignSystem/Popover/popover.ts deleted file mode 100644 index c774ca398..000000000 --- a/apps/scandic-web/components/TempDesignSystem/Popover/popover.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { PopoverProps as RAPopoverProps } from "react-aria-components" - -export interface PopoverProps extends Omit { - triggerContent: React.ReactNode - children: React.ReactNode -} diff --git a/apps/scandic-web/components/TempDesignSystem/ProgressBar/index.tsx b/apps/scandic-web/components/TempDesignSystem/ProgressBar/index.tsx deleted file mode 100644 index e14dc391c..000000000 --- a/apps/scandic-web/components/TempDesignSystem/ProgressBar/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import styles from "./progressbar.module.css" - -import type { ProgressbarProps } from "./progressbar" - -export default function ProgressBar({ className, progress }: ProgressbarProps) { - className = className ?? "" - return ( -
    -
    -
    - ) -} diff --git a/apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.module.css b/apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.module.css deleted file mode 100644 index 5561eb587..000000000 --- a/apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.module.css +++ /dev/null @@ -1,12 +0,0 @@ -.bar { - background-color: var(--Main-Grey-White); - border-radius: 40px; - height: 20px; - width: 100%; -} - -.progress { - background-color: var(--UI-Opacity-Almost-Black-100); - border-radius: 40px; - height: 20px; -} diff --git a/apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.ts b/apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.ts deleted file mode 100644 index acd637f64..000000000 --- a/apps/scandic-web/components/TempDesignSystem/ProgressBar/progressbar.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface ProgressbarProps extends React.HTMLAttributes { - progress: number -} diff --git a/apps/scandic-web/constants/homeHrefs.ts b/apps/scandic-web/constants/homeHrefs.ts deleted file mode 100644 index 00bf00156..000000000 --- a/apps/scandic-web/constants/homeHrefs.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const homeHrefs = { - development: { - da: "https://stage.scandichotels.dk", - de: "https://stage.scandichotels.de", - en: "https://stage.scandichotels.com", - fi: "https://stage.scandichotels.fi", - no: "https://stage.scandichotels.no", - sv: "https://stage.scandichotels.se", - }, - production: { - da: "https://www.scandichotels.dk", - de: "https://www.scandichotels.de", - en: "https://www.scandichotels.com", - fi: "https://www.scandichotels.fi", - no: "https://www.scandichotels.no", - sv: "https://www.scandichotels.se", - }, - test: { - da: "https://test.scandichotels.dk", - de: "https://test.scandichotels.de", - en: "https://test.scandichotels.com", - fi: "https://test.scandichotels.fi", - no: "https://test.scandichotels.no", - sv: "https://test.scandichotels.se", - }, -} diff --git a/apps/scandic-web/constants/languages.ts b/apps/scandic-web/constants/languages.ts index 5398ee075..729a1e3b9 100644 --- a/apps/scandic-web/constants/languages.ts +++ b/apps/scandic-web/constants/languages.ts @@ -10,47 +10,7 @@ export const languages: Record = { [Lang.sv]: "Svenska", } -export const localeToLang: Record = { - en: Lang.en, - "en-US": Lang.en, - "en-GB": Lang.en, - "en-DE": Lang.en, - "en-DK": Lang.en, - "en-SE": Lang.en, - "en-FI": Lang.en, - - sv: Lang.sv, - "se-SE": Lang.sv, - "sv-SE": Lang.sv, - "sv-FI": Lang.sv, - - fi: Lang.fi, - "fi-FI": Lang.fi, - "se-FI": Lang.fi, - "smn-FI": Lang.fi, - - dk: Lang.da, - da: Lang.da, - "da-DK": Lang.da, - "fo-DK": Lang.da, - - de: Lang.de, - "de-DE": Lang.de, - "dsb-DE": Lang.de, - "ksh-DE": Lang.de, - "nds-DE": Lang.de, - "hsb-DE": Lang.de, - "de-CH": Lang.de, - "de-AU": Lang.de, - - no: Lang.no, - nb: Lang.no, - "nb-NO": Lang.no, - "nn-NO": Lang.no, - "se-NO": Lang.no, -} as const - -export const languageSelect = [ +const languageSelect = [ { label: "Danish", value: ApiLang.Da }, { label: "German", value: ApiLang.De }, { label: "English", value: ApiLang.En }, diff --git a/apps/scandic-web/constants/routes/webviews.ts b/apps/scandic-web/constants/routes/webviews.ts index 9391df443..67a0ceab7 100644 --- a/apps/scandic-web/constants/routes/webviews.ts +++ b/apps/scandic-web/constants/routes/webviews.ts @@ -25,7 +25,7 @@ export const benefits = { sv: `${myPages.sv}/formaner`, } -export const points = { +const points = { da: `${myPages.da}/point`, de: `${myPages.de}/punkte`, en: `${myPages.en}/points`, @@ -34,7 +34,7 @@ export const points = { sv: `${myPages.sv}/poang`, } -export const programOverview = { +const programOverview = { da: `/da/webview/scandic-friends`, de: `/de/webview/scandic-friends`, en: `/en/webview/scandic-friends`, diff --git a/apps/scandic-web/lib/trpc/memoizedRequests/index.ts b/apps/scandic-web/lib/trpc/memoizedRequests/index.ts index 977e4215d..084272f58 100644 --- a/apps/scandic-web/lib/trpc/memoizedRequests/index.ts +++ b/apps/scandic-web/lib/trpc/memoizedRequests/index.ts @@ -1,5 +1,3 @@ -import { redirect } from "next/navigation" - import { cache } from "@/utils/cache" import { serverClient } from "../server" @@ -7,7 +5,6 @@ import { serverClient } from "../server" import type { Lang } from "@scandic-hotels/common/constants/language" import type { GetHotelsByCSFilterInput } from "@scandic-hotels/trpc/routers/hotels/input" import type { GetSavedPaymentCardsInput } from "@scandic-hotels/trpc/routers/user/input" -import type { RoomsAvailabilityExtendedInputSchema } from "@scandic-hotels/trpc/types/availability" import type { Country } from "@scandic-hotels/trpc/types/country" import type { HotelInput } from "@scandic-hotels/trpc/types/hotel" import type { @@ -96,13 +93,6 @@ export const getHeader = cache(async function getMemoizedHeader() { return caller.contentstack.base.header() }) -export const getSiteConfig = cache(async function getMemoizedSiteConfig( - lang: Lang -) { - const caller = await serverClient() - return caller.contentstack.base.siteConfig({ lang }) -}) - export const getAncillaryPackages = cache( async function getMemoizedAncillaryPackages(input: AncillaryPackagesInput) { const caller = await serverClient() @@ -165,16 +155,6 @@ export const getMeetingRooms = cache( } ) -export const getAdditionalData = cache( - async function getMemoizedAdditionalData(input: { - hotelId: string - language: Lang - }) { - const caller = await serverClient() - return caller.hotel.additionalData(input) - } -) - export const getDestinationOverviewPage = cache( async function getMemoizedDestinationOverviewPage() { const caller = await serverClient() @@ -236,33 +216,11 @@ export const getStartPage = cache(async function getMemoizedStartPage() { return caller.contentstack.startPage.get() }) -export const getPageSettings = cache(async function getMemoizedPageSettings( - lang: Lang -) { - const caller = await serverClient() - return caller.contentstack.pageSettings.get({ lang }) -}) - export const getJobylonFeed = cache(async function getMemoizedJobylonFeed() { const caller = await serverClient() return caller.partner.jobylon.feed.get() }) -export const getSelectedRoomsAvailabilityEnterDetails = cache( - async function getMemoizedSelectedRoomsAvailability( - input: RoomsAvailabilityExtendedInputSchema - ) { - const caller = await serverClient() - const result = await caller.hotel.availability.enterDetails(input) - - if (typeof result === "string") { - redirect(result) - } - - return result - } -) - export const getCampaignPage = cache(async function getMemoizedCampaignPage() { const caller = await serverClient() return caller.contentstack.campaignPage.get() diff --git a/apps/scandic-web/package.json b/apps/scandic-web/package.json index d12b04917..0c7278763 100644 --- a/apps/scandic-web/package.json +++ b/apps/scandic-web/package.json @@ -52,22 +52,19 @@ "@tanstack/react-table": "^8.21.3", "@testing-library/dom": "^10.4.0", "@trpc/client": "^11.1.2", - "@trpc/react-query": "^11.1.2", "@trpc/server": "^11.1.2", "@tsparticles/confetti": "^3.8.1", "@types/geojson": "^7946.0.16", "@types/supercluster": "^7.1.3", "@vis.gl/react-google-maps": "^1.5.2", "class-variance-authority": "^0.7.1", + "client-only": "^0.0.1", "contentstack": "^3.25.3", "date-fns": "^4.1.0", "dayjs": "^1.11.13", - "deepmerge": "^4.3.1", "dialogshift-webchat-sdk": "^2.10.1", - "downshift": "^9.0.9", "embla-carousel": "^8.6.0", "embla-carousel-react": "^8.6.0", - "fast-deep-equal": "^3.1.3", "flat": "^6.0.1", "graphql-tag": "^2.12.6", "html-react-parser": "^5.2.3", @@ -76,7 +73,6 @@ "input-otp": "^1.4.2", "json-stable-stringify-without-jsonify": "^1.0.1", "jsonwebtoken": "^9.0.2", - "libphonenumber-js": "^1.12.7", "lodash-es": "^4.17.21", "md5": "^2.3.0", "motion": "^12.10.0", diff --git a/apps/scandic-web/providers/Details/RoomProvider.tsx b/apps/scandic-web/providers/Details/RoomProvider.tsx deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/scandic-web/stores/hotel-listing-data/helper.ts b/apps/scandic-web/stores/hotel-listing-data/helper.ts index 8867bbd4b..9900dae1e 100644 --- a/apps/scandic-web/stores/hotel-listing-data/helper.ts +++ b/apps/scandic-web/stores/hotel-listing-data/helper.ts @@ -51,14 +51,3 @@ export function isValidSortOption( ): value is HotelSortOption { return sortItems.map((item) => item.value).includes(value as HotelSortOption) } - -export function getBasePathNameWithoutFilters( - pathname: string, - filterSlugs: string[] -) { - const pathSegments = pathname.split("/") - const filteredSegments = pathSegments.filter( - (segment) => !filterSlugs.includes(segment) - ) - return filteredSegments.join("/") -} diff --git a/apps/scandic-web/stores/my-stay/add-ancillary-flow.ts b/apps/scandic-web/stores/my-stay/add-ancillary-flow.ts index 9aef7bedc..ad7ac1eed 100644 --- a/apps/scandic-web/stores/my-stay/add-ancillary-flow.ts +++ b/apps/scandic-web/stores/my-stay/add-ancillary-flow.ts @@ -2,6 +2,8 @@ import { produce } from "immer" import { useContext } from "react" import { create, useStore } from "zustand" +import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" + import { clearAncillarySessionData } from "@/components/HotelReservation/MyStay/utils/ancillaries" import { AddAncillaryContext } from "@/contexts/AddAncillary" @@ -10,7 +12,6 @@ import type { Ancillary, SelectedAncillary, } from "@/types/components/myPages/myStay/ancillaries" -import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" import type { Room } from "@/types/stores/my-stay" export enum AncillaryStepEnum { @@ -40,7 +41,7 @@ export type BreakfastData = { currency: string } -export interface AddAncillaryState { +interface AddAncillaryState { currentStep: number steps: Steps booking: Room diff --git a/apps/scandic-web/stores/select-rate/helpers.ts b/apps/scandic-web/stores/select-rate/helpers.ts deleted file mode 100644 index 1ddc582ea..000000000 --- a/apps/scandic-web/stores/select-rate/helpers.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" - -import type { AvailabilityError } from "@scandic-hotels/booking-flow/types/stores/rates" -import type { - Product, - RoomConfiguration, - RoomsAvailability, -} from "@scandic-hotels/trpc/types/roomAvailability" - -export function findProduct( - rateCode: string, - product: Product, - counterRateCode = "" -) { - if ("corporateCheque" in product) { - return product.corporateCheque.rateCode === rateCode - } - - if ("redemption" in product) { - return product.redemption.rateCode === rateCode - } - - if ("voucher" in product) { - return product.voucher.rateCode === rateCode - } - - const memberExists = "member" in product - const publicExists = "public" in product - const isRegularRate = memberExists && publicExists - if (isRegularRate) { - let isProduct = false - if (product.member) { - isProduct = - product.member.rateCode === rateCode || - product.member.rateCode === counterRateCode - } - if (product.public) { - isProduct = - product.public.rateCode === rateCode || - product.public.rateCode === counterRateCode - } - return isProduct - } - - return null -} - -export function findProductInRoom( - rateCode: string | undefined | null, - room: RoomConfiguration, - counterRateCode: string | undefined | null -) { - if (!rateCode) { - return null - } - - if (room.campaign.length) { - const campaignProduct = room.campaign.find((product) => - findProduct(rateCode, product, counterRateCode || "") - ) - if (campaignProduct) { - return campaignProduct - } - } - if (room.code.length) { - const codeProduct = room.code.find((product) => - findProduct(rateCode, product, counterRateCode || "") - ) - if (codeProduct) { - return codeProduct - } - } - if (room.redemptions.length) { - const redemptionProduct = room.redemptions.find((product) => - findProduct(rateCode, product) - ) - if (redemptionProduct) { - return redemptionProduct - } - } - if (room.regular.length) { - const regularProduct = room.regular.find((product) => - findProduct(rateCode, product, counterRateCode || "") - ) - if (regularProduct) { - return regularProduct - } - } -} - -export function findSelectedRate( - rateCode: string | undefined | null, - counterRateCode: string | undefined | null, - roomTypeCode: string | undefined | null, - rooms: RoomConfiguration[] | AvailabilityError -) { - if (!Array.isArray(rooms)) { - return null - } - - if (!rateCode) { - return null - } - - return rooms.find((room) => { - if (room.roomTypeCode !== roomTypeCode) { - return false - } - return findProductInRoom(rateCode, room, counterRateCode) - }) -} - -export function findDefaultCurrency( - roomsAvailability: (RoomsAvailability | AvailabilityError)[] | undefined -) { - if (!roomsAvailability || !roomsAvailability.length) { - return CurrencyEnum.Unknown - } - - const availability = roomsAvailability.filter( - (room): room is RoomsAvailability => { - if ("error" in room) { - return false - } - return true - } - )[0] - - const pkg = availability?.packages.find((pkg) => pkg.localPrice.currency) - if (!pkg) { - return CurrencyEnum.Unknown - } - - const defaultCurrency = pkg.localPrice.currency - return defaultCurrency -} diff --git a/apps/scandic-web/types/Prettify.ts b/apps/scandic-web/types/Prettify.ts deleted file mode 100644 index 7ebc71ea5..000000000 --- a/apps/scandic-web/types/Prettify.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type Prettify = { - [K in keyof T]: T[K] -} & {} diff --git a/apps/scandic-web/types/components/ancillaryCard.ts b/apps/scandic-web/types/components/ancillaryCard.ts index b1b9b3177..7e0c4c903 100644 --- a/apps/scandic-web/types/components/ancillaryCard.ts +++ b/apps/scandic-web/types/components/ancillaryCard.ts @@ -13,9 +13,3 @@ export interface AncillaryCardProps { description?: string } } - -export interface AncillaryChoiceCardProps extends AncillaryCardProps { - name: string - id?: string - value: string -} diff --git a/apps/scandic-web/types/components/blocks/index.ts b/apps/scandic-web/types/components/blocks/index.ts index 79104db20..976348abb 100644 --- a/apps/scandic-web/types/components/blocks/index.ts +++ b/apps/scandic-web/types/components/blocks/index.ts @@ -9,7 +9,7 @@ import type { Block as DestinationCountryPageBlock } from "@scandic-hotels/trpc/ import type { Block as DestinationOverviewPageBlock } from "@scandic-hotels/trpc/types/destinationOverviewPage" import type { Block as LoyaltyPageBlock } from "@scandic-hotels/trpc/types/loyaltyPage" -export type Blocks = +type Blocks = | AccountPageBlock | CampaignPageBlock | CampaignOverviewPageBlock diff --git a/apps/scandic-web/types/components/blocks/infoCard.ts b/apps/scandic-web/types/components/blocks/infoCard.ts index e001e5ff9..2dabd265c 100644 --- a/apps/scandic-web/types/components/blocks/infoCard.ts +++ b/apps/scandic-web/types/components/blocks/infoCard.ts @@ -9,14 +9,6 @@ type CardTheme = Exclude< "image" > -export const INFO_CARD_THEMES = [ - "one", - "two", - "three", - "primaryInverted", - "primaryStrong", -] as const satisfies readonly CardTheme[] - export interface InfoCardProps { scriptedTopTitle?: string heading: string diff --git a/apps/scandic-web/types/components/deprecatedjsontohtml.ts b/apps/scandic-web/types/components/deprecatedjsontohtml.ts deleted file mode 100644 index 2f1b71f40..000000000 --- a/apps/scandic-web/types/components/deprecatedjsontohtml.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { Embeds } from "@/types/requests/embeds" -import type { Node } from "@scandic-hotels/trpc/types/edges" -import type { RTENode } from "../rte/node" -import type { RenderOptions } from "../rte/option" - -export type DeprecatedJsonToHtmlProps = { - embeds: Node[] - nodes: RTENode[] - renderOptions?: RenderOptions -} - -export type EmbedByUid = Record> diff --git a/apps/scandic-web/types/components/dropdown/dropdown.ts b/apps/scandic-web/types/components/dropdown/dropdown.ts index 368ffcc43..b6d2f9bbc 100644 --- a/apps/scandic-web/types/components/dropdown/dropdown.ts +++ b/apps/scandic-web/types/components/dropdown/dropdown.ts @@ -18,5 +18,3 @@ export enum DropdownTypeEnum { HeaderLanguageSwitcherMobile = "headerLanguageSwitcherMobile", FooterLanguageSwitcher = "footerLanguageSwitcher", } - -export type DropdownType = `${DropdownTypeEnum}` diff --git a/apps/scandic-web/types/components/header/avatar.ts b/apps/scandic-web/types/components/header/avatar.ts deleted file mode 100644 index a06a4d2f8..000000000 --- a/apps/scandic-web/types/components/header/avatar.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { ImageProps } from "next/image" - -export interface AvatarProps { - image?: ImageProps - initials?: string | null -} diff --git a/apps/scandic-web/types/components/hotelPage/facilities.ts b/apps/scandic-web/types/components/hotelPage/facilities.ts index b0e28c4d9..c1d476e90 100644 --- a/apps/scandic-web/types/components/hotelPage/facilities.ts +++ b/apps/scandic-web/types/components/hotelPage/facilities.ts @@ -68,11 +68,6 @@ export enum MeetingsHeading { Default = "Great minds meet here", } -export type HeadingEnum = - | RestaurantHeadings - | WellnessHeadings - | MeetingsHeading - export enum HealthFacilitiesEnum { Jacuzzi = "Jacuzzi", Gym = "Gym", @@ -101,15 +96,6 @@ export enum IndoorPoolDetails { DepthFrom = "DepthFrom", } -export enum OutdoorPoolDetails { - Length = "Length", - Width = "Width", - DepthTo = "DepthTo", - DepthFrom = "DepthFrom", - OpenMonthFrom = "OpenMonthFrom", - OpenMonthTo = "OpenMonthTo", -} - export enum SaunaDetails { SeparateMenAndWomen = "SeparateMenAndWomen", } diff --git a/apps/scandic-web/types/components/hotelPage/meetingRooms.ts b/apps/scandic-web/types/components/hotelPage/meetingRooms.ts index 3402c7400..a5bb5a646 100644 --- a/apps/scandic-web/types/components/hotelPage/meetingRooms.ts +++ b/apps/scandic-web/types/components/hotelPage/meetingRooms.ts @@ -1,6 +1,6 @@ import type { meetingRoomsSchema } from "@scandic-hotels/trpc/routers/hotels/schemas/meetingRoom" import type { z } from "zod" -export type MeetingRoomData = z.output +type MeetingRoomData = z.output export type MeetingRooms = MeetingRoomData["data"] export type MeetingRoom = MeetingRooms[number]["attributes"] diff --git a/apps/scandic-web/types/components/hotelReservation/enterDetails/bedType.ts b/apps/scandic-web/types/components/hotelReservation/enterDetails/bedType.ts deleted file mode 100644 index 71a0ba4db..000000000 --- a/apps/scandic-web/types/components/hotelReservation/enterDetails/bedType.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type BedTypeInfoProps = { - hasMultipleBedTypes: boolean -} diff --git a/apps/scandic-web/types/components/hotelReservation/enterDetails/details.ts b/apps/scandic-web/types/components/hotelReservation/enterDetails/details.ts index fa13894d2..df803ef48 100644 --- a/apps/scandic-web/types/components/hotelReservation/enterDetails/details.ts +++ b/apps/scandic-web/types/components/hotelReservation/enterDetails/details.ts @@ -1,10 +1,6 @@ -import type { Product } from "@scandic-hotels/trpc/types/roomAvailability" - import type { Price } from "../price" export interface RoomPrice { perNight: Price perStay: Price } - -export type RoomRate = Product diff --git a/apps/scandic-web/types/components/hotelReservation/myStay/cancelStay.ts b/apps/scandic-web/types/components/hotelReservation/myStay/cancelStay.ts index 53c1a4b30..04e3ae3dc 100644 --- a/apps/scandic-web/types/components/hotelReservation/myStay/cancelStay.ts +++ b/apps/scandic-web/types/components/hotelReservation/myStay/cancelStay.ts @@ -1,7 +1,5 @@ import { z } from "zod" -import type { Hotel } from "@scandic-hotels/trpc/types/hotel" - export const cancelStaySchema = z.object({ rooms: z.array( z.object({ @@ -11,34 +9,4 @@ export const cancelStaySchema = z.object({ ), }) -export interface CancelStayProps { - handleCloseModal: () => void - hotel: Hotel -} - export type CancelStayFormValues = z.output - -export interface RoomDetails { - id: string - roomName: string - roomTypeCode: string - rateDefinition: { - breakfastIncluded: boolean - cancellationRule: string | null - cancellationText: string | null - generalTerms: string[] - isMemberRate: boolean - mustBeGuaranteed: boolean - rateCode: string - title: string | null - } - isMainBooking?: boolean -} - -export interface StayDetails { - checkInDate: string - checkOutDate: string - nightsText: string - adultsText: string - childrenText: string -} diff --git a/apps/scandic-web/types/components/hotelReservation/myStay/changeDates.ts b/apps/scandic-web/types/components/hotelReservation/myStay/changeDates.ts index 1afa37add..c8e388e86 100644 --- a/apps/scandic-web/types/components/hotelReservation/myStay/changeDates.ts +++ b/apps/scandic-web/types/components/hotelReservation/myStay/changeDates.ts @@ -1,7 +1,5 @@ import { z } from "zod" -import { Lang } from "@scandic-hotels/common/constants/language" - export const changeDatesSchema = z.object({ checkInDate: z.string(), checkOutDate: z.string(), @@ -9,30 +7,6 @@ export const changeDatesSchema = z.object({ export type ChangeDatesSchema = z.output -export interface QueryInput { - hotelId: string - roomStayStartDate: string - roomStayEndDate: string - adults: number - children: string - bookingCode: string - rateCode: string - roomTypeCode: string - lang: Lang -} - -export const DEFAULT_QUERY_INPUT: QueryInput = { - hotelId: "", - roomStayStartDate: "", - roomStayEndDate: "", - adults: 1, - children: "", - bookingCode: "", - rateCode: "", - roomTypeCode: "", - lang: Lang.en, -} - export interface ChangeDatesStepsProps { closeModal: () => void } diff --git a/apps/scandic-web/types/components/hotelReservation/price.ts b/apps/scandic-web/types/components/hotelReservation/price.ts index 9b13c710b..8ad792728 100644 --- a/apps/scandic-web/types/components/hotelReservation/price.ts +++ b/apps/scandic-web/types/components/hotelReservation/price.ts @@ -1,6 +1,4 @@ -import { z } from "zod" - -import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" +import type { CurrencyEnum } from "@scandic-hotels/common/constants/currency" interface TPrice { additionalPrice?: number @@ -14,18 +12,3 @@ export interface Price { requested?: TPrice local: TPrice } - -export const PointsPriceSchema = z - .object({ - localPrice: z.object({ - currency: z.nativeEnum(CurrencyEnum), - price: z.number(), - additionalPrice: z.number().optional(), - additionalPriceCurrency: z.nativeEnum(CurrencyEnum).optional(), - }), - }) - .transform((data) => ({ - local: { - ...data.localPrice, - }, - })) diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelData.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelData.ts deleted file mode 100644 index 2bcf33267..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelData.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ProductType } from "@scandic-hotels/trpc/types/availability" -import type { Hotel } from "@scandic-hotels/trpc/types/hotel" - -export type HotelData = { - hotelData: Hotel - price: ProductType -} - -export interface NullableHotelData extends Omit { - hotelData: HotelData["hotelData"] | null -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelFilters.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelFilters.ts deleted file mode 100644 index f34ce61a4..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelFilters.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Hotel } from "@scandic-hotels/trpc/types/hotel" - -export type HotelFilter = Hotel["detailedFacilities"][number] & { - hotelId: string - hotelIds: string[] -} - -export type CategorizedHotelFilters = { - facilityFilters: HotelFilter[] - surroundingsFilters: HotelFilter[] -} - -export type HotelFiltersProps = { - filters: CategorizedHotelFilters - className?: string -} - -export type HotelFilterModalProps = { - filters: CategorizedHotelFilters -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts deleted file mode 100644 index 24a38191d..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { ProductTypeCheque } from "@scandic-hotels/trpc/types/availability" -import type { Amenities } from "@scandic-hotels/trpc/types/hotel" - -import type { Coordinates } from "@/types/components/maps/coordinates" - -export type HotelPin = { - bookingCode?: string | null - name: string - coordinates: Coordinates - chequePrice: ProductTypeCheque["localPrice"] | null - publicPrice: number | null - memberPrice: number | null - redemptionPrice: number | null - voucherPrice: number | null - rateType: string | null - currency: string - images: { - src: string - altText: string - altText_En: string - title: string - title_En: string - }[] - amenities: Amenities - ratings: number | null - operaId: string - facilityIds: number[] - hasEnoughPoints: boolean -} - -export interface HotelCardDialogProps { - type?: "listing" | "standalone" - isOpen: boolean - data: HotelPin - handleClose: (event: { stopPropagation: () => void }) => void -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/priceCardProps.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/priceCardProps.ts deleted file mode 100644 index 41e4c5ee8..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/priceCardProps.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { - ProductTypeCheque, - ProductTypePrices, - ProductTypeVoucher, -} from "@scandic-hotels/trpc/types/availability" - -export type PriceCardProps = { - productTypePrices: ProductTypePrices - isMemberPrice?: boolean - className?: string -} - -export type VoucherCardProps = { - productTypeVoucher: ProductTypeVoucher -} - -export type BonusChequeCardProps = { - productTypeVoucher: ProductTypeCheque -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/selectHotel.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/selectHotel.ts deleted file mode 100644 index d56e1ad04..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/selectHotel.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { BookingSearchType } from "@scandic-hotels/booking-flow/searchType" -import type { Child } from "@scandic-hotels/trpc/types/child" - -export type SelectHotelBooking = { - hotelId?: string - city?: string - fromDate: string - toDate: string - rooms: { - adults: number - childrenInRoom?: Child[] - }[] - bookingCode?: string - searchType?: BookingSearchType -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts deleted file mode 100644 index d4f708527..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { SelectRateBooking } from "@scandic-hotels/booking-flow/types/components/selectRate/selectRate" -import type { Hotel } from "@scandic-hotels/trpc/types/hotel" - -export interface HotelInfoCardProps { - booking: SelectRateBooking - hotel: Hotel -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/rateSummary.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/rateSummary.ts deleted file mode 100644 index 2c8a370d0..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectRate/rateSummary.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { Price } from "../price" - -export interface MobileSummaryProps { - isAllRoomsSelected: boolean - isUserLoggedIn: boolean - totalPriceToShow: Price -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/rates.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/rates.ts deleted file mode 100644 index 9025efb05..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectRate/rates.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { - Product, - RoomConfiguration, -} from "@scandic-hotels/trpc/types/roomAvailability" - -export interface RatesProps { - roomConfiguration: RoomConfiguration -} - -export interface SharedRateCardProps - extends Pick { - handleSelectRate: (product: Product) => void - nights: number -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/roomListItem.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/roomListItem.ts deleted file mode 100644 index f79c0aa7c..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectRate/roomListItem.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Package } from "@scandic-hotels/trpc/types/packages" -import type { RoomConfiguration } from "@scandic-hotels/trpc/types/roomAvailability" - -export type RoomListItemProps = { - roomConfiguration: RoomConfiguration -} - -export type RoomListItemImageProps = Pick< - RoomConfiguration, - "roomType" | "roomTypeCode" | "roomsLeft" -> & { - roomPackages: Package[] -} diff --git a/apps/scandic-web/types/components/hotelReservation/summary.ts b/apps/scandic-web/types/components/hotelReservation/summary.ts deleted file mode 100644 index ab398f16e..000000000 --- a/apps/scandic-web/types/components/hotelReservation/summary.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { SelectRateBooking } from "@scandic-hotels/booking-flow/types/components/selectRate/selectRate" -import type { Child } from "@scandic-hotels/trpc/types/child" -import type { Packages } from "@scandic-hotels/trpc/types/packages" - -import type { RoomPrice, RoomRate } from "./enterDetails/details" -import type { Price } from "./price" - -export type RoomsData = { - rateDetails: string[] | undefined - roomType: string - cancellationText: string - roomPrice: RoomPrice - adults: number - children?: Child[] - packages: Packages | null -} - -export interface SelectRateSummaryProps { - booking: SelectRateBooking - isMember: boolean - totalPrice: Price - vat: number - rooms: Array<{ - adults: number - childrenInRoom: Child[] | undefined - roomType: string - roomPrice: RoomPrice - roomRate: RoomRate - rateDetails: string[] | undefined - cancellationText: string - packages?: Packages - } | null> - toggleSummaryOpen: () => void -} diff --git a/apps/scandic-web/types/components/languageSwitcher/languageSwitcher.ts b/apps/scandic-web/types/components/languageSwitcher/languageSwitcher.ts index 49aac80fb..0be8a005d 100644 --- a/apps/scandic-web/types/components/languageSwitcher/languageSwitcher.ts +++ b/apps/scandic-web/types/components/languageSwitcher/languageSwitcher.ts @@ -7,7 +7,7 @@ export enum LanguageSwitcherTypesEnum { Footer = "footer", } -export type LanguageSwitcherTypes = `${LanguageSwitcherTypesEnum}` +type LanguageSwitcherTypes = `${LanguageSwitcherTypesEnum}` export interface LanguageSwitcherProps { type: LanguageSwitcherTypes @@ -20,5 +20,6 @@ export interface LanguageSwitcherContentProps { export interface LanguageSwitcherContainerProps { type: LanguageSwitcherTypes + // eslint-disable-next-line @typescript-eslint/no-explicit-any children: ReactElement } diff --git a/apps/scandic-web/types/components/myPages/myPage/earnAndBurn.ts b/apps/scandic-web/types/components/myPages/myPage/earnAndBurn.ts index ccd53fb62..2766c0587 100644 --- a/apps/scandic-web/types/components/myPages/myPage/earnAndBurn.ts +++ b/apps/scandic-web/types/components/myPages/myPage/earnAndBurn.ts @@ -1,27 +1,17 @@ -import type { Lang } from "@scandic-hotels/common/constants/language" import type { VariantProps } from "class-variance-authority" import type { awardPointsVariants } from "@/components/Blocks/DynamicContent/Points/EarnAndBurn/AwardPoints/awardPointsVariants" import type { UserQueryRouter } from "../user" -export type TransactionResponse = Awaited< +type TransactionResponse = Awaited< ReturnType > -export type TransactionsNonNullResponseObject = NonNullable -export type Transactions = +type TransactionsNonNullResponseObject = NonNullable +type Transactions = NonNullable["data"]["transactions"] -export type Transaction = +type Transaction = NonNullable["data"]["transactions"][number] -export type ClientEarnAndBurnProps = { - initialData: TransactionsNonNullResponseObject - lang: Lang -} - -export type EarnAndBurnProps = { - lang: Lang -} - export interface ClientTableProps { transactions: Transactions } @@ -30,7 +20,4 @@ export interface RowProps { transaction: Transaction } -export interface AwardPointsProps extends Pick {} - -export interface AwardPointsVariantProps - extends VariantProps {} +export type AwardPointsVariantProps = VariantProps diff --git a/apps/scandic-web/types/components/myPages/myProfile/edit.ts b/apps/scandic-web/types/components/myPages/myProfile/edit.ts index 5350984d3..2c3cca54c 100644 --- a/apps/scandic-web/types/components/myPages/myProfile/edit.ts +++ b/apps/scandic-web/types/components/myPages/myProfile/edit.ts @@ -8,27 +8,3 @@ export const enum Status { error = "error", success = "success", } - -type Data = Record< - string, - string | undefined | Record -> - -type Issue = { - field: string - message: string -} - -export type State = { - data: Data - message: string -} & ( - | { - issues: never - status: Status.success - } - | { - issues: Issue[] - status: Status.error - } -) diff --git a/apps/scandic-web/types/components/myPages/myStay/ancillaries.ts b/apps/scandic-web/types/components/myPages/myStay/ancillaries.ts index b8011ca89..5bc241b5f 100644 --- a/apps/scandic-web/types/components/myPages/myStay/ancillaries.ts +++ b/apps/scandic-web/types/components/myPages/myStay/ancillaries.ts @@ -24,15 +24,6 @@ export interface AddedAncillariesProps { booking: Room } -export interface AncillaryProps { - ancillary: Ancillary["ancillaryContent"][number] -} - -export interface AncillaryGridModalProps { - ancillaries: Ancillaries - user: User | null -} - export interface AddAncillaryFlowModalProps { booking: Room packages: Packages | null @@ -40,14 +31,6 @@ export interface AddAncillaryFlowModalProps { savedCreditCards: CreditCard[] | null } -export type DeliveryTimeOption = { - label: string - value: string -} -export interface DeliveryMethodStepProps { - deliveryTimeOptions: DeliveryTimeOption[] -} - export interface SelectQuantityStepProps { user: User | null } diff --git a/apps/scandic-web/types/components/myPages/stays/previous.ts b/apps/scandic-web/types/components/myPages/stays/previous.ts index d236f55eb..f0d8b5b7c 100644 --- a/apps/scandic-web/types/components/myPages/stays/previous.ts +++ b/apps/scandic-web/types/components/myPages/stays/previous.ts @@ -1,14 +1,10 @@ import type { UserQueryRouter } from "../user" -export type PreviousStaysResponse = Awaited< +type PreviousStaysResponse = Awaited< ReturnType > export type PreviousStaysNonNullResponseObject = NonNullable -export type PreviousStays = - NonNullable["data"] -export type PreviousStay = - NonNullable["data"][number] export interface PreviousStaysClientProps { initialPreviousStays: PreviousStaysNonNullResponseObject diff --git a/apps/scandic-web/types/components/myPages/stays/upcoming.ts b/apps/scandic-web/types/components/myPages/stays/upcoming.ts index 829c201b1..573212951 100644 --- a/apps/scandic-web/types/components/myPages/stays/upcoming.ts +++ b/apps/scandic-web/types/components/myPages/stays/upcoming.ts @@ -1,14 +1,10 @@ import type { UserQueryRouter } from "../user" -export type UpcomingStaysResponse = Awaited< +type UpcomingStaysResponse = Awaited< ReturnType > export type UpcomingStaysNonNullResponseObject = NonNullable -export type UpcomingStays = - NonNullable["data"] -export type UpcomingStay = - NonNullable["data"][number] export interface UpcomingStaysClientProps { initialUpcomingStays: UpcomingStaysNonNullResponseObject diff --git a/apps/scandic-web/types/components/search.ts b/apps/scandic-web/types/components/search.ts deleted file mode 100644 index 356e93ff4..000000000 --- a/apps/scandic-web/types/components/search.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface SearchProps { - handlePressEnter: () => void -} - -export type SearchHistoryItem = { - type: "cities" | "hotels" - id: string -} diff --git a/apps/scandic-web/types/components/sidePeeks/bookedRoomSidePeek.ts b/apps/scandic-web/types/components/sidePeeks/bookedRoomSidePeek.ts index 129ddd031..0dfacc018 100644 --- a/apps/scandic-web/types/components/sidePeeks/bookedRoomSidePeek.ts +++ b/apps/scandic-web/types/components/sidePeeks/bookedRoomSidePeek.ts @@ -1,12 +1,4 @@ import type { Room } from "@scandic-hotels/trpc/types/hotel" -import type { SafeUser } from "@/types/user" - -export type BookedRoomSidePeekProps = { - close: () => void - confirmationNumber: string - room: Room - user: SafeUser -} export type RoomDetailsProps = { roomDescription: string diff --git a/apps/scandic-web/types/components/sidebar/index.ts b/apps/scandic-web/types/components/sidebar/index.ts index 7de515372..aba4f94ae 100644 --- a/apps/scandic-web/types/components/sidebar/index.ts +++ b/apps/scandic-web/types/components/sidebar/index.ts @@ -1,7 +1,7 @@ import type { SidebarBlock as ContentPageSidebarBlock } from "@scandic-hotels/trpc/types/contentPage" import type { SidebarBlock as LoyaltyPageSidebarBlock } from "@scandic-hotels/trpc/types/loyaltyPage" -export type Blocks = ContentPageSidebarBlock | LoyaltyPageSidebarBlock +type Blocks = ContentPageSidebarBlock | LoyaltyPageSidebarBlock export interface SidebarProps { blocks: Blocks[] diff --git a/apps/scandic-web/types/contexts/details/room.ts b/apps/scandic-web/types/contexts/details/room.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/scandic-web/types/enums/scriptedCard.ts b/apps/scandic-web/types/enums/scriptedCard.ts deleted file mode 100644 index 658a84621..000000000 --- a/apps/scandic-web/types/enums/scriptedCard.ts +++ /dev/null @@ -1,9 +0,0 @@ -export enum scriptedCardThemeEnum { - one = "one", - two = "two", - three = "three", - primaryDim = "primaryDim", - primaryDark = "primaryDark", - primaryInverted = "primaryInverted", - primaryStrong = "primaryStrong", -} diff --git a/apps/scandic-web/types/enums/signatureHotel.ts b/apps/scandic-web/types/enums/signatureHotel.ts deleted file mode 100644 index 1ea37e868..000000000 --- a/apps/scandic-web/types/enums/signatureHotel.ts +++ /dev/null @@ -1,8 +0,0 @@ -export enum SignatureHotelEnum { - DowntownCamper = "879", - GrandHotelOslo = "340", - Haymarket = "890", - HotelNorge = "785", - Marski = "605", - TheDock = "796", -} diff --git a/apps/scandic-web/types/intl.d.ts b/apps/scandic-web/types/intl.d.ts deleted file mode 100644 index 36ded9ced..000000000 --- a/apps/scandic-web/types/intl.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// import type { MessageDescriptor } from "@formatjs/intl" - -// Module augmentation -declare module "@formatjs/intl" { - // We are unable to override description field on MessageDescriptor from formatjs. - // Module augmentation does not allow for that. But we leave it here for reference. - // Instead we export our own LokaliseMessageDescriptor and use that where we control the code. - // For example in our custom formatter in i18n/formatter.ts - // interface MessageDescriptor { - // description?: { - // context?: string - // limit?: number - // tags?: string[] - // } - // } -} diff --git a/apps/scandic-web/types/intl.ts b/apps/scandic-web/types/intl.ts deleted file mode 100644 index a34e0cb4c..000000000 --- a/apps/scandic-web/types/intl.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { MessageDescriptor } from "@formatjs/intl" - -export interface LokaliseMessageDescriptor - extends Omit { - description: { - context?: string - limit?: number - tags?: string - } -} diff --git a/apps/scandic-web/types/params.ts b/apps/scandic-web/types/params.ts index 562ccbbc2..bdeec993a 100644 --- a/apps/scandic-web/types/params.ts +++ b/apps/scandic-web/types/params.ts @@ -7,7 +7,7 @@ export type SearchParams = { searchParams: Promise } -export type Params

    = { +type Params

    = { params: Promise

    } @@ -41,15 +41,6 @@ export type UIDParams = { uid: string } -export type UriParams = { - uri: string | string[] -} - -export type PreviewParams = { - uri?: string - live_preview?: string -} - export type LayoutArgs

    = P extends undefined ? unknown : Params

    diff --git a/apps/scandic-web/types/providers/rates.ts b/apps/scandic-web/types/providers/rates.ts deleted file mode 100644 index 6e9a27e46..000000000 --- a/apps/scandic-web/types/providers/rates.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { SelectRateBooking } from "@scandic-hotels/booking-flow/types/components/selectRate/selectRate" -import type { AvailabilityError } from "@scandic-hotels/booking-flow/types/stores/rates" -import type { Room } from "@scandic-hotels/trpc/types/hotel" -import type { RoomsAvailability } from "@scandic-hotels/trpc/types/roomAvailability" - -export interface RatesProviderProps extends React.PropsWithChildren { - booking: SelectRateBooking - hotelType: string | undefined - roomCategories: Room[] - roomsAvailability: (RoomsAvailability | AvailabilityError)[] | undefined - vat: number -} diff --git a/apps/scandic-web/types/providers/select-rate/room.ts b/apps/scandic-web/types/providers/select-rate/room.ts deleted file mode 100644 index 32e8ebf91..000000000 --- a/apps/scandic-web/types/providers/select-rate/room.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { SelectedRoom } from "@scandic-hotels/booking-flow/types/stores/rates" - -export interface RoomProviderProps extends React.PropsWithChildren { - idx: number - room: SelectedRoom -} diff --git a/apps/scandic-web/types/requests/asides/contact.ts b/apps/scandic-web/types/requests/asides/contact.ts deleted file mode 100644 index 272763321..000000000 --- a/apps/scandic-web/types/requests/asides/contact.ts +++ /dev/null @@ -1,81 +0,0 @@ -import type { Lang } from "@scandic-hotels/common/constants/language" -import type { EdgesWithTotalCount } from "@scandic-hotels/trpc/types/edges" - -import type { Typename } from "../utils/typename" - -export enum Section { - ContactBlockSectionsExtraInfo = "ContactBlockSectionsExtraInfo", - ContactBlockSectionsMailingAddress = "ContactBlockSectionsMailingAddress", - ContactBlockSectionsPhone = "ContactBlockSectionsPhone", - ContactBlockSectionsTitle = "ContactBlockSectionsTitle", - ContactBlockSectionsVisitingAddress = "ContactBlockSectionsVisitingAddress", -} - -type ExtraInfo = Typename< - { - extra_info: { - text: string[] - } - }, - Section.ContactBlockSectionsExtraInfo -> - -type MailingAddress = Typename< - { - mailing_address: { - city: string - country: string - name: string - street: string - zip: string - } - }, - Section.ContactBlockSectionsMailingAddress -> - -type Phone = Typename< - { - phone: { - number: number - title: string - } - }, - Section.ContactBlockSectionsPhone -> - -type Title = Typename< - { - title: { - text: string - } - }, - Section.ContactBlockSectionsTitle -> - -type VisitingAddress = Typename< - { - visiting_address: { - city: string - country: string - street: string - zip: string - } - }, - Section.ContactBlockSectionsVisitingAddress -> - -type Sections = ExtraInfo | MailingAddress | Phone | Title | VisitingAddress - -export type ContactNode = { - sections: Sections[] - system: { - locale: Lang - uid: string - } -} - -export type Contact = { - contact: { - contactConnection: EdgesWithTotalCount - } -} diff --git a/apps/scandic-web/types/requests/asides/puff.ts b/apps/scandic-web/types/requests/asides/puff.ts deleted file mode 100644 index b1930aa6f..000000000 --- a/apps/scandic-web/types/requests/asides/puff.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { Puff } from "../puff" - -export type PuffAside = { - puff: Puff -} diff --git a/apps/scandic-web/types/requests/blocks/list.ts b/apps/scandic-web/types/requests/blocks/list.ts deleted file mode 100644 index 64a57032c..000000000 --- a/apps/scandic-web/types/requests/blocks/list.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { Typename } from "../utils/typename" - -enum ListItemStyleEnum { - checkmark = "checkmark", - default = "default", -} - -type ListItemStyle = keyof typeof ListItemStyleEnum - -export enum BlockListItemsEnum { - CurrentBlocksPageBlocksListBlockListItemsListItem = "CurrentBlocksPageBlocksListBlockListItemsListItem", - CurrentBlocksPageBlocksListBlockListItemsListItemExternalLink = "CurrentBlocksPageBlocksListBlockListItemsListItemExternalLink", -} - -type ExternalLinkListItem = Typename< - { - list_item_external_link: { - link: { - href: string - title: string - } - list_item_style: ListItemStyle - subtitle?: string - } - }, - BlockListItemsEnum.CurrentBlocksPageBlocksListBlockListItemsListItemExternalLink -> - -type RegularListItem = Typename< - { - list_item: { - list_item_style: ListItemStyle - subtitle?: string - title: string - } - }, - BlockListItemsEnum.CurrentBlocksPageBlocksListBlockListItemsListItem -> - -export type ListItem = ExternalLinkListItem | RegularListItem - -export type List = { - list: { - title?: string - list_items: ListItem[] - } -} - -export type ListProps = List diff --git a/apps/scandic-web/types/requests/blocks/puff.ts b/apps/scandic-web/types/requests/blocks/puff.ts deleted file mode 100644 index 912050393..000000000 --- a/apps/scandic-web/types/requests/blocks/puff.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Puff } from "../puff" - -export type PuffBlock = { - puffs: { - puffs: { - puff: Puff - }[] - } -} diff --git a/apps/scandic-web/types/requests/blocks/text.ts b/apps/scandic-web/types/requests/blocks/text.ts deleted file mode 100644 index 6d6dfe9d5..000000000 --- a/apps/scandic-web/types/requests/blocks/text.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { EdgesWithTotalCount } from "@scandic-hotels/trpc/types/edges" - -import type { RTEDocument } from "@/types/rte/node" -import type { Embeds } from "../embeds" - -export type Text = { - text: { - content: { - embedded_itemsConnection: EdgesWithTotalCount - json: RTEDocument - } - } -} diff --git a/apps/scandic-web/types/requests/embeds.ts b/apps/scandic-web/types/requests/embeds.ts deleted file mode 100644 index e4f82d9a7..000000000 --- a/apps/scandic-web/types/requests/embeds.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { ImageContainer } from "./imageContainer" -import type { SysAsset } from "./utils/asset" -import type { EmbedEnum } from "./utils/embeds" -import type { PageLink, PageLinkWithOriginalUrl } from "./utils/pageLink" -import type { TypenameInterface } from "./utils/typename" - -interface AccountPage - extends TypenameInterface, - PageLink {} -interface ContentPage - extends TypenameInterface, - PageLinkWithOriginalUrl {} -interface LoyaltyPage - extends TypenameInterface, - PageLinkWithOriginalUrl {} - -export type Embeds = - | AccountPage - | ContentPage - | ImageContainer - | LoyaltyPage - | SysAsset diff --git a/apps/scandic-web/types/requests/hero.ts b/apps/scandic-web/types/requests/hero.ts deleted file mode 100644 index 18b537942..000000000 --- a/apps/scandic-web/types/requests/hero.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { EdgesWithTotalCount } from "@scandic-hotels/trpc/types/edges" -import type { Image } from "@scandic-hotels/trpc/types/image" - -export type Hero = { - imagesConnection: EdgesWithTotalCount -} diff --git a/apps/scandic-web/types/requests/imageContainer.ts b/apps/scandic-web/types/requests/imageContainer.ts deleted file mode 100644 index 68ac08b30..000000000 --- a/apps/scandic-web/types/requests/imageContainer.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { ImageVaultAsset } from "@scandic-hotels/common/utils/imageVault" -import type { System } from "@scandic-hotels/trpc/routers/contentstack/schemas/system" - -import type { EmbedEnum } from "./utils/embeds" -import type { TypenameInterface } from "./utils/typename" - -export interface ImageContainer - extends TypenameInterface, - System { - image_left?: ImageVaultAsset - image_right?: ImageVaultAsset -} diff --git a/apps/scandic-web/types/requests/preamble.ts b/apps/scandic-web/types/requests/preamble.ts deleted file mode 100644 index ee3b21e18..000000000 --- a/apps/scandic-web/types/requests/preamble.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { EdgesWithTotalCount } from "@scandic-hotels/trpc/types/edges" - -import type { RTEDocument } from "../rte/node" -import type { Embeds } from "./embeds" - -export type Preamble = { - text: { - embedded_itemsConnection: EdgesWithTotalCount - json: RTEDocument - } -} diff --git a/apps/scandic-web/types/requests/puff.ts b/apps/scandic-web/types/requests/puff.ts deleted file mode 100644 index 9038687cc..000000000 --- a/apps/scandic-web/types/requests/puff.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { EdgesWithTotalCount } from "@scandic-hotels/trpc/types/edges" -import type { Image } from "@scandic-hotels/trpc/types/image" - -import type { RTEDocument } from "../rte/node" - -export enum PuffStyleEnum { - button = "button", - default = "default", -} - -export type Puff = { - imageConnection: EdgesWithTotalCount - link: { - href: string - title?: string - } - puff_style: PuffStyleEnum - text: { - json: RTEDocument - } - title: string -} diff --git a/apps/scandic-web/types/requests/trackingData.ts b/apps/scandic-web/types/requests/trackingData.ts deleted file mode 100644 index 74d000ceb..000000000 --- a/apps/scandic-web/types/requests/trackingData.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type TrackingData = { - current_blocks_page: { url: string; title: string } -} diff --git a/apps/scandic-web/types/requests/utils/all.ts b/apps/scandic-web/types/requests/utils/all.ts deleted file mode 100644 index 9d5238c56..000000000 --- a/apps/scandic-web/types/requests/utils/all.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface AllRequestResponse { - items: T[] -} - -export interface AllRequestResponseWithTotal { - items: T[] - total: number -} diff --git a/apps/scandic-web/types/requests/utils/asset.ts b/apps/scandic-web/types/requests/utils/asset.ts deleted file mode 100644 index cb95d5fa4..000000000 --- a/apps/scandic-web/types/requests/utils/asset.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Image } from "@scandic-hotels/trpc/types/image" - -import type { EmbedEnum } from "./embeds" -import type { TypenameInterface } from "./typename" - -export interface SysAsset - extends TypenameInterface, - Image {} diff --git a/apps/scandic-web/types/requests/utils/embeds.ts b/apps/scandic-web/types/requests/utils/embeds.ts deleted file mode 100644 index 0fe39ddbd..000000000 --- a/apps/scandic-web/types/requests/utils/embeds.ts +++ /dev/null @@ -1,11 +0,0 @@ -export enum EmbedEnum { - CurrentBlocksPage = "CurrentBlocksPage", - SysAsset = "SysAsset", - ImageContainer = "ImageContainer", - LoyaltyPage = "LoyaltyPage", - AccountPage = "AccountPage", - ContentPage = "ContentPage", - HotelPage = "HotelPage", -} - -export type Embed = keyof typeof EmbedEnum diff --git a/apps/scandic-web/types/requests/utils/pageLink.ts b/apps/scandic-web/types/requests/utils/pageLink.ts deleted file mode 100644 index 1278ef309..000000000 --- a/apps/scandic-web/types/requests/utils/pageLink.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { z } from "zod" - -import type { - extendedPageLinkSchema, - pageLinkSchema, -} from "@scandic-hotels/trpc/routers/contentstack/schemas/pageLinks" -import type { EmbedEnum } from "./embeds" -import type { TypenameInterface } from "./typename" - -export interface PageLink extends z.output {} - -export interface PageLinkWithOriginalUrl - extends z.output {} - -export interface PageLinkType - extends TypenameInterface, - PageLink {} diff --git a/apps/scandic-web/types/requests/utils/typename.ts b/apps/scandic-web/types/requests/utils/typename.ts index 5b76303a3..e7815c690 100644 --- a/apps/scandic-web/types/requests/utils/typename.ts +++ b/apps/scandic-web/types/requests/utils/typename.ts @@ -1,22 +1,3 @@ -export enum AsideTypenameEnum { - CurrentBlocksPageAsideContact = "CurrentBlocksPageAsideContact", - CurrentBlocksPageAsidePuff = "CurrentBlocksPageAsidePuff", -} - -export type AsideTypename = keyof typeof AsideTypenameEnum - -export enum BlocksTypenameEnum { - CurrentBlocksPageBlocksList = "CurrentBlocksPageBlocksList", - CurrentBlocksPageBlocksPuffs = "CurrentBlocksPageBlocksPuffs", - CurrentBlocksPageBlocksText = "CurrentBlocksPageBlocksText", -} - -export type BlocksTypename = keyof typeof BlocksTypenameEnum - -export type Typename = T & { - __typename: K -} - export interface TypenameInterface { __typename: K } diff --git a/apps/scandic-web/types/rte/attrs.ts b/apps/scandic-web/types/rte/attrs.ts deleted file mode 100644 index 4f7253d39..000000000 --- a/apps/scandic-web/types/rte/attrs.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { Lang } from "@scandic-hotels/common/constants/language" -import type { - ImageVaultAsset, - ImageVaultAssetResponse, -} from "@scandic-hotels/common/utils/imageVault" -import type { - EmbedTypesEnum, - RTEItemType, - RTEItemTypeEnum, -} from "@scandic-hotels/trpc/types/RTEenums" - -export interface Attributes { - [key: string]: any - "class-name"?: string - type: RTEItemType -} - -export interface RTEAssetAttrs extends Attributes { - alt: string - "asset-alt": string - "asset-link": string - "asset-name": string - "asset-type": "image/png" | "image/jpg" | "image/jpeg" - "asset-uid": string - "display-type": EmbedTypesEnum.display - "content-type-uid": "sys_assets" - inline: false - type: RTEItemTypeEnum.asset -} - -export interface RTEAnchorAttrs extends Attributes { - target: string - url: string -} - -export interface RTELinkAttrs extends Attributes { - "display-type": EmbedTypesEnum.link - "class-name": string - "content-type-uid": string - "entry-uid": string - locale: Lang - href: string - target: HTMLAnchorElement["target"] - type: RTEItemTypeEnum.entry -} - -export type RTEImageVaultAttrs = Attributes & { - height: string - style: string[] - width: string -} & (ImageVaultAssetResponse | ImageVaultAsset) diff --git a/apps/scandic-web/types/rte/node.ts b/apps/scandic-web/types/rte/node.ts deleted file mode 100644 index d9e13ff65..000000000 --- a/apps/scandic-web/types/rte/node.ts +++ /dev/null @@ -1,98 +0,0 @@ -import type { RTETypeEnum } from "@scandic-hotels/trpc/types/RTEenums" -import type { JSX } from "react" - -import type { EmbedByUid } from "../components/deprecatedjsontohtml" -import type { - Attributes, - RTEAnchorAttrs, - RTEAssetAttrs, - RTEImageVaultAttrs, - RTELinkAttrs, -} from "./attrs" -import type { RenderOptions } from "./option" - -export interface RTEDefaultNode { - attrs: Attributes - children: RTENode[] - type: RTETypeEnum - uid: string -} - -export interface RTELinkNode { - attrs: Attributes - children: RTENode[] - type: RTETypeEnum - uid: string -} - -export interface RTEReferenceAssetNode extends RTEDefaultNode { - attrs: RTEAssetAttrs -} - -export interface RTEAnchorNode extends RTEDefaultNode { - attrs: RTEAnchorAttrs - type: RTETypeEnum.a -} - -export interface RTEReferenceLinkNode extends RTEDefaultNode { - attrs: RTELinkAttrs -} - -export interface RTEImageVaultNode extends RTEDefaultNode { - attrs: RTEImageVaultAttrs - type: RTETypeEnum.ImageVault -} - -export enum RTEMarkType { - bold = "bold", - break = "break", - classnameOrId = "classnameOrId", - inlineCode = "inlineCode", - italic = "italic", - strikethrough = "strikethrough", - subscript = "subscript", - superscript = "superscript", - underline = "underline", -} - -type RTETextNodeOptionalKeys = { - [key in RTEMarkType]?: boolean -} - -export type RTETextNode = RTETextNodeOptionalKeys & { - classname?: string - id?: string - text: string -} - -export type RTERegularNode = RTEDefaultNode | RTEAnchorNode | RTEImageVaultNode - -export type RTEImageNode = RTEDefaultNode | RTEImageVaultNode - -export type RTEReferenceNode = RTEAnchorNode - -export type RTENode = RTERegularNode | RTEReferenceNode | RTETextNode - -export type RTERenderMark = ( - children: React.ReactNode, - classname?: string, - id?: string -) => JSX.Element - -export interface RTEDocument extends RTEDefaultNode { - type: RTETypeEnum.doc - _version: number -} - -export type RTERenderOptionComponent = ( - node: RTERegularNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions -) => React.ReactNode - -export type RTENext = ( - nodes: RTENode[], - embeds: EmbedByUid, - fullRenderOptions: RenderOptions -) => string diff --git a/apps/scandic-web/types/rte/option.ts b/apps/scandic-web/types/rte/option.ts deleted file mode 100644 index 126a5aeec..000000000 --- a/apps/scandic-web/types/rte/option.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { RTERenderMark, RTERenderOptionComponent } from "./node" - -export type RenderOptions = { - [type: string]: RTERenderOptionComponent | RTERenderMark -} diff --git a/apps/scandic-web/types/sidepeek.ts b/apps/scandic-web/types/sidepeek.ts index bc9aa8029..70c20018f 100644 --- a/apps/scandic-web/types/sidepeek.ts +++ b/apps/scandic-web/types/sidepeek.ts @@ -1,5 +1,3 @@ export enum SidePeekEnum { - hotelDetails = "hotel-detail-side-peek", - roomDetails = "room-detail-side-peek", bookedRoomDetails = "booked-room-detail-side-peek", } diff --git a/apps/scandic-web/types/stores/destination-data.ts b/apps/scandic-web/types/stores/destination-data.ts index 58e9f3830..f0e6f1c24 100644 --- a/apps/scandic-web/types/stores/destination-data.ts +++ b/apps/scandic-web/types/stores/destination-data.ts @@ -20,12 +20,6 @@ interface Actions { setIsLoading: (isLoading: boolean) => void } -export interface SubmitCallbackData { - sort: HotelSortOption - defaultSort: HotelSortOption - filters: string[] - basePath: string -} export interface DestinationDataState { actions: Actions allCities: DestinationCityListItem[] diff --git a/apps/scandic-web/types/stores/hotel-listing-data.ts b/apps/scandic-web/types/stores/hotel-listing-data.ts index 8dbd5c7eb..b640774b1 100644 --- a/apps/scandic-web/types/stores/hotel-listing-data.ts +++ b/apps/scandic-web/types/stores/hotel-listing-data.ts @@ -15,12 +15,6 @@ interface Actions { setIsLoading: (isLoading: boolean) => void } -export interface SubmitCallbackData { - sort: HotelSortOption - defaultSort: HotelSortOption - filters: string[] - basePath: string -} export interface HotelListingDataState { actions: Actions allHotels: HotelListingHotelData[] diff --git a/apps/scandic-web/types/stores/my-stay.ts b/apps/scandic-web/types/stores/my-stay.ts index 4da6e3b1e..5c07c49d9 100644 --- a/apps/scandic-web/types/stores/my-stay.ts +++ b/apps/scandic-web/types/stores/my-stay.ts @@ -36,7 +36,7 @@ export type Room = Omit< terms: string | null } -export type BookingRoom = BookingConfirmation["booking"] +type BookingRoom = BookingConfirmation["booking"] interface Actions { closeManageStay: () => void diff --git a/apps/scandic-web/types/transitionTypes/jsontohtml.ts b/apps/scandic-web/types/transitionTypes/jsontohtml.ts deleted file mode 100644 index 8683990b0..000000000 --- a/apps/scandic-web/types/transitionTypes/jsontohtml.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { Node } from "@scandic-hotels/trpc/types/edges" -import type { Embeds } from "@scandic-hotels/trpc/types/embeds" - -import type { RTENode } from "./rte/node" -import type { RenderOptions } from "./rte/option" - -export type JsonToHtmlProps = { - embeds: Node[] - nodes: RTENode[] - renderOptions?: RenderOptions - className?: string -} - -export type EmbedByUid = Record> diff --git a/apps/scandic-web/types/transitionTypes/rte/attrs.ts b/apps/scandic-web/types/transitionTypes/rte/attrs.ts deleted file mode 100644 index 5791d9907..000000000 --- a/apps/scandic-web/types/transitionTypes/rte/attrs.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type { Lang } from "@scandic-hotels/common/constants/language" -import type { ImageVaultAsset } from "@scandic-hotels/common/utils/imageVault" - -import type { EmbedTypesEnum, RTEItemType, RTEItemTypeEnum } from "./enums" - -export interface Attributes { - [key: string]: any - "class-name"?: string - type: RTEItemType -} - -export interface RTEAssetAttrs extends Attributes { - alt: string - "asset-alt": string - "asset-link": string - "asset-name": string - "asset-type": "image/png" | "image/jpg" | "image/jpeg" - "asset-uid": string - "display-type": EmbedTypesEnum.display - "content-type-uid": "sys_assets" - inline: false - type: RTEItemTypeEnum.asset -} - -export interface RTEAnchorAttrs extends Attributes { - target: string - url: string -} - -export interface RTELinkAttrs extends Attributes { - "display-type": EmbedTypesEnum.link - "class-name": string - "content-type-uid": string - "entry-uid": string - locale: Lang - href: string - target: HTMLAnchorElement["target"] - type: RTEItemTypeEnum.entry -} - -export interface RTEImageVaultAttrs extends Attributes, ImageVaultAsset { - height: string - style: string[] - width: string -} diff --git a/apps/scandic-web/types/transitionTypes/rte/enums.ts b/apps/scandic-web/types/transitionTypes/rte/enums.ts deleted file mode 100644 index 11af3edb8..000000000 --- a/apps/scandic-web/types/transitionTypes/rte/enums.ts +++ /dev/null @@ -1,69 +0,0 @@ -export enum EmbedTypesEnum { - block = "block", - display = "display", - download = "download", - inline = "inline", - link = "link", -} - -export type EmbedTypes = keyof typeof EmbedTypesEnum - -/** Copied from https://github.com/contentstack/contentstack-utils-javascript/blob/master/src/nodes/node-type.ts */ -export enum RTETypeEnum { - a = "a", - blockquote = "blockquote", - code = "code", - doc = "doc", - embed = "embed", - h1 = "h1", - h2 = "h2", - h3 = "h3", - h4 = "h4", - h5 = "h5", - h6 = "h6", - hr = "hr", - img = "img", - li = "li", - ol = "ol", - p = "p", - reference = "reference", - span = "span", - /** - * Included for compatibility when copying RTE from other sources e.g. epi - */ - div = "div", - table = "table", - tbody = "tbody", - td = "td", - text = "text", - tfoot = "tfoot", - th = "th", - thead = "thead", - tr = "tr", - ul = "ul", - ImageVault = "ImageVault", - fragment = "fragment", -} - -export type RTEType = keyof typeof RTETypeEnum - -export enum RTEItemTypeEnum { - asset = "asset", - entry = "entry", -} - -export type RTEItemType = keyof typeof RTEItemTypeEnum - -export enum AvailableParagraphFormatEnum { - "script-1" = "script-1", - "script-2" = "script-2", - "footnote" = "footnote", - "caption" = "caption", - "subtitle-1" = "subtitle-1", - "subtitle-2" = "subtitle-2", -} - -export enum AvailableULFormatEnum { - "heart" = "heart", - "check" = "check", -} diff --git a/apps/scandic-web/types/transitionTypes/rte/node.ts b/apps/scandic-web/types/transitionTypes/rte/node.ts deleted file mode 100644 index c9d02af61..000000000 --- a/apps/scandic-web/types/transitionTypes/rte/node.ts +++ /dev/null @@ -1,98 +0,0 @@ -import type { JSX } from "react" - -import type { EmbedByUid } from "../jsontohtml" -import type { - Attributes, - RTEAnchorAttrs, - RTEAssetAttrs, - RTEImageVaultAttrs, - RTELinkAttrs, -} from "./attrs" -import type { RTETypeEnum } from "./enums" -import type { RenderOptions } from "./option" - -export interface RTEDefaultNode { - attrs: Attributes - children: RTENode[] - type: RTETypeEnum - uid: string -} - -export interface RTELinkNode { - attrs: Attributes - children: RTENode[] - type: RTETypeEnum - uid: string -} - -export interface RTEReferenceAssetNode extends RTEDefaultNode { - attrs: RTEAssetAttrs -} - -export interface RTEAnchorNode extends RTEDefaultNode { - attrs: RTEAnchorAttrs - type: RTETypeEnum.a -} - -export interface RTEReferenceLinkNode extends RTEDefaultNode { - attrs: RTELinkAttrs -} - -export interface RTEImageVaultNode extends RTEDefaultNode { - attrs: RTEImageVaultAttrs - type: RTETypeEnum.ImageVault -} - -export enum RTEMarkType { - bold = "bold", - break = "break", - classnameOrId = "classnameOrId", - inlineCode = "inlineCode", - italic = "italic", - strikethrough = "strikethrough", - subscript = "subscript", - superscript = "superscript", - underline = "underline", -} - -type RTETextNodeOptionalKeys = { - [key in RTEMarkType]?: boolean -} - -export type RTETextNode = RTETextNodeOptionalKeys & { - classname?: string - id?: string - text: string -} - -export type RTERegularNode = RTEDefaultNode | RTEAnchorNode | RTEImageVaultNode - -export type RTEImageNode = RTEDefaultNode | RTEImageVaultNode - -export type RTEReferenceNode = RTEAnchorNode - -export type RTENode = RTERegularNode | RTEReferenceNode | RTETextNode - -export type RTERenderMark = ( - children: React.ReactNode, - classname?: string, - id?: string -) => JSX.Element - -export interface RTEDocument extends RTEDefaultNode { - type: RTETypeEnum.doc - _version: number -} - -export type RTERenderOptionComponent = ( - node: RTERegularNode, - embeds: EmbedByUid, - next: RTENext, - fullRenderOptions: RenderOptions -) => React.ReactNode - -export type RTENext = ( - nodes: RTENode[], - embeds: EmbedByUid, - fullRenderOptions: RenderOptions -) => string diff --git a/apps/scandic-web/types/transitionTypes/rte/option.ts b/apps/scandic-web/types/transitionTypes/rte/option.ts deleted file mode 100644 index 126a5aeec..000000000 --- a/apps/scandic-web/types/transitionTypes/rte/option.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { RTERenderMark, RTERenderOptionComponent } from "./node" - -export type RenderOptions = { - [type: string]: RTERenderOptionComponent | RTERenderMark -} diff --git a/apps/scandic-web/types/trpc/routers/contentstack/sidebar.ts b/apps/scandic-web/types/trpc/routers/contentstack/sidebar.ts index 5ad46ab56..e30b35c1b 100644 --- a/apps/scandic-web/types/trpc/routers/contentstack/sidebar.ts +++ b/apps/scandic-web/types/trpc/routers/contentstack/sidebar.ts @@ -1,12 +1,9 @@ -import type { z } from "zod" - import type { joinLoyaltyContactSidebarSchema } from "@scandic-hotels/trpc/routers/contentstack/loyaltyPage/output" import type { contactSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/sidebar/joinLoyaltyContact" +import type { z } from "zod" -export interface JoinLoyaltyContact - extends z.output {} +export type JoinLoyaltyContact = z.output< + typeof joinLoyaltyContactSidebarSchema +> type ContactsSchema = z.output export type Contacts = ContactsSchema["contact"] -export interface Contact { - contact: NonNullable -} diff --git a/apps/scandic-web/utils/facilityCards.ts b/apps/scandic-web/utils/facilityCards.ts index bc495657f..59a7fee3f 100644 --- a/apps/scandic-web/utils/facilityCards.ts +++ b/apps/scandic-web/utils/facilityCards.ts @@ -149,6 +149,7 @@ export function setFacilityCardGrids( SidepeekSlugs.wellness, wellnessTitle ) + // eslint-disable-next-line @typescript-eslint/no-unused-expressions facilities.findIndex((f) => f === facility) % 2 === 0 ? grid.unshift(card) : grid.push(card) @@ -164,6 +165,7 @@ export function setFacilityCardGrids( SidepeekSlugs.meetings, MeetingsHeading.Default ) + // eslint-disable-next-line @typescript-eslint/no-unused-expressions facilities.findIndex((f) => f === facility) % 2 === 0 ? grid.unshift(card) : grid.push(card) @@ -179,6 +181,7 @@ export function setFacilityCardGrids( SidepeekSlugs.restaurant, restaurantTitle ) + // eslint-disable-next-line @typescript-eslint/no-unused-expressions facilities.findIndex((f) => f === facility) % 2 === 0 ? grid.unshift(card) : grid.push(card) @@ -214,7 +217,7 @@ function getRestaurantHeading(amenities: Amenities): RestaurantHeadings { return RestaurantHeadings.breakfastRestaurant } -export function getWellnessHeading( +function getWellnessHeading( healthFacilities: HealthFacilities ): WellnessHeadings | undefined { // For now return a generic message for all diff --git a/apps/scandic-web/utils/rewards.ts b/apps/scandic-web/utils/rewards.ts index 37393a6ed..3605c1dba 100644 --- a/apps/scandic-web/utils/rewards.ts +++ b/apps/scandic-web/utils/rewards.ts @@ -17,13 +17,8 @@ import type { Dayjs } from "dayjs" export { getEarliestExpirationDate, getFirstRedeemableCoupon, - getReedemableCoupons, - isOnSiteTierReward, isRestaurantOnSiteTierReward, - isRestaurantReward, - isTierType, isValidRewardId, - redeemLocationIsOnSite, } function isValidRewardId(id: string): id is RewardId { diff --git a/apps/scandic-web/utils/tracking/booking.ts b/apps/scandic-web/utils/tracking/booking.ts index 1c93977d8..0666f5b98 100644 --- a/apps/scandic-web/utils/tracking/booking.ts +++ b/apps/scandic-web/utils/tracking/booking.ts @@ -2,24 +2,8 @@ import { trackEvent } from "@scandic-hotels/tracking/base" -import type { LowestRoomPriceEvent } from "@scandic-hotels/tracking/types" import type { BreakfastPackages } from "@scandic-hotels/trpc/routers/hotels/output" -export function trackLowestRoomPrice(event: LowestRoomPriceEvent) { - trackEvent({ - event: "lowestRoomPrice", - hotelInfo: { - hotelId: event.hotelId, - arrivalDate: event.arrivalDate, - departureDate: event.departureDate, - }, - viewItemInfo: { - lowestPrice: event.lowestPrice, - currency: event.currency, - }, - }) -} - // Tracking for sections of booking flow enter-details page export function trackBedSelection(bedType: string) { trackEvent({ diff --git a/apps/scandic-web/utils/tracking/index.ts b/apps/scandic-web/utils/tracking/index.ts index 67f2e5628..e8fceb980 100644 --- a/apps/scandic-web/utils/tracking/index.ts +++ b/apps/scandic-web/utils/tracking/index.ts @@ -1,8 +1,3 @@ -export { - trackBedSelection, - trackBreakfastSelection, - trackLowestRoomPrice, -} from "./booking" export { trackAccordionClick, trackOpenSidePeekEvent } from "./componentEvents" export { trackHotelMapClick, trackHotelTabClick } from "./hotelPage" export { trackCancelStay, trackMyStayPageLink } from "./myStay" @@ -13,8 +8,4 @@ export { } from "./navigation" export { trackPaymentEvent, trackUpdatePaymentMethod } from "./payment" export { trackClick } from "@scandic-hotels/tracking/base" -export { - createSDKPageObject, - trackPageView, - trackPageViewStart, -} from "@scandic-hotels/tracking/pageview" +export { trackPageViewStart } from "@scandic-hotels/tracking/pageview" diff --git a/yarn.lock b/yarn.lock index 47bd9ca10..611675fbe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6138,7 +6138,6 @@ __metadata: "@testing-library/react": "npm:^16.3.0" "@testing-library/user-event": "npm:^14.6.1" "@trpc/client": "npm:^11.1.2" - "@trpc/react-query": "npm:^11.1.2" "@trpc/server": "npm:^11.1.2" "@tsparticles/confetti": "npm:^3.8.1" "@types/adm-zip": "npm:^0.5.7" @@ -6157,14 +6156,13 @@ __metadata: adm-zip: "npm:^0.5.16" babel-plugin-formatjs: "npm:^10.5.39" class-variance-authority: "npm:^0.7.1" + client-only: "npm:^0.0.1" contentstack: "npm:^3.25.3" cypress: "npm:^14.3.3" date-fns: "npm:^4.1.0" dayjs: "npm:^1.11.13" - deepmerge: "npm:^4.3.1" dialogshift-webchat-sdk: "npm:^2.10.1" dotenv: "npm:^16.5.0" - downshift: "npm:^9.0.9" embla-carousel: "npm:^8.6.0" embla-carousel-react: "npm:^8.6.0" eslint: "npm:^9" @@ -6172,7 +6170,6 @@ __metadata: eslint-plugin-formatjs: "npm:^5.3.1" eslint-plugin-import: "npm:^2.31.0" eslint-plugin-simple-import-sort: "npm:^12.1.1" - fast-deep-equal: "npm:^3.1.3" flat: "npm:^6.0.1" graphql-tag: "npm:^2.12.6" html-react-parser: "npm:^5.2.3" @@ -6184,7 +6181,6 @@ __metadata: json-sort-cli: "npm:^4.0.9" json-stable-stringify-without-jsonify: "npm:^1.0.1" jsonwebtoken: "npm:^9.0.2" - libphonenumber-js: "npm:^1.12.7" lint-staged: "npm:^15.5.2" lodash-es: "npm:^4.17.21" md5: "npm:^2.3.0"