From 7e97b74c186f3cac84b42bb5a60d73a8e2369f08 Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Fri, 30 May 2025 12:41:18 +0000 Subject: [PATCH] Merged in chore/remove-unused-code (pull request #2229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unused code * Remove unused scandic-web files * Remove unused exports Approved-by: Joakim Jäderberg --- .../(standard)/select-hotel/utils.ts | 77 -- .../components/FailedAttemptsError.tsx | 35 - .../emptyPreviousStays.module.css | 10 - .../Previous/EmptyPreviousStays/index.tsx | 17 - .../SidebarContentWrapperSkeleton.tsx | 21 - .../SidebarContentWrapper/index.tsx | 25 - .../sidebarContentWrapper.module.css | 12 - .../SidebarContentWrapper/utils.ts | 41 -- .../OverviewMapContainer/InputForm/index.tsx | 19 - .../InputForm/inputFrom.module.css | 14 - .../EnterDetails/Breakfast/schema.ts | 6 - .../ChangeDates/Steps/Form/Alerts/Error.tsx | 21 - .../Rooms/MultiRoom/MultiRoomSkeleton.tsx | 45 -- .../MobileSummary/PriceDetailsTable/index.tsx | 236 ------- .../RoomListItem/Rates/getRateDefinition.ts | 34 - .../Levels/Level/DoubleRow/ScandicFamily.tsx | 189 ----- .../Levels/Level/SingleRow/ScandicFamily.tsx | 189 ----- .../Levels/Level/SingleRow/ScandicFriends.tsx | 205 ------ apps/scandic-web/components/Levels/index.tsx | 3 - apps/scandic-web/components/Loading/index.tsx | 46 -- .../components/Loading/loading.module.css | 43 -- .../components/Modal/motionVariants.ts | 13 - .../Profile/DeleteCreditCardButton/index.tsx | 45 -- .../Form/FilterChip/Checkbox.tsx | 7 - .../Form/FilterChip/_Chip/chip.module.css | 40 -- .../Form/FilterChip/_Chip/index.tsx | 70 -- .../TempDesignSystem/SidePeek/types.ts | 11 - .../SidePeekSelfControlled/types.ts | 11 - apps/scandic-web/constants/myBooking.ts | 27 - apps/scandic-web/constants/poiCategories.ts | 19 - .../hooks/booking/usePaymentFailedToast.ts | 63 -- .../hooks/booking/useScrollToActiveSection.ts | 62 -- apps/scandic-web/hooks/useHandleKeyPress.ts | 11 - .../contentstack/destinationCityPage/input.ts | 5 - .../routers/contentstack/hotelPage/utils.ts | 98 +-- .../routers/hotels/schemas/hotelFilter.ts | 7 - .../routers/hotels/schemas/location/urls.ts | 68 -- .../routers/hotels/schemas/restaurants.ts | 81 --- .../server/routers/hotels/schemas/room.ts | 122 ---- .../routers/hotels/schemas/specialAlerts.ts | 39 -- .../dataCache/DistributedCache/endpoints.ts | 10 - .../DistributedCache/shouldHaveFullTtl.ts | 5 - .../MemoryCache/InMemoryCache/deleteAll.ts | 9 - .../_useEnterDetailsStore.testing.tsx | 657 ------------------ .../stores/enter-details/helpers.ts | 68 -- .../scandic-web/stores/select-rate/helpers.ts | 9 - .../types/components/current/asides/puffs.ts | 6 - .../types/components/current/header.ts | 3 - .../destinationOverviewPage/jumpTo/client.ts | 8 - .../destinationOverviewPage/jumpTo/index.ts | 49 -- .../jumpTo/resolver.ts | 5 - .../destinationOverviewPage/jumpTo/results.ts | 7 - .../types/components/form/filterChip.ts | 17 - .../types/components/header/logo.ts | 6 - .../types/components/header/topMenuButton.ts | 2 - .../components/hotelPage/map/dynamicMap.ts | 10 - .../hotelPage/map/mapWithCardWrapper.ts | 8 - .../hotelReservation/enterDetails/room.ts | 8 - .../selectHotel/hotePriceListProps.ts | 6 - .../selectRate/hotelSelectionHeader.ts | 5 - .../selectRate/imageGallery.ts | 3 - .../selectRate/roomSelection.ts | 12 - .../types/components/myPages/header.ts | 12 - .../components/myPages/myProfile/layout.ts | 6 - .../types/components/myPages/stays/page.ts | 6 - apps/scandic-web/types/enums/hotelListing.ts | 6 - apps/scandic-web/types/next/error.ts | 8 - .../types/requests/myPages/breadcrumbs.ts | 61 -- apps/scandic-web/types/requests/pageLinks.ts | 5 - apps/scandic-web/types/requests/rte.ts | 6 - .../types/trpc/routers/hotel/filter.ts | 5 - apps/scandic-web/utils/dateFormatting.ts | 10 - apps/scandic-web/utils/generateTag.ts | 10 - apps/scandic-web/utils/isBrowser.ts | 1 - apps/scandic-web/utils/safeTry.ts | 8 - apps/scandic-web/utils/tabbable.ts | 67 -- 76 files changed, 1 insertion(+), 3210 deletions(-) delete mode 100644 apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts delete mode 100644 apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/components/FailedAttemptsError.tsx delete mode 100644 apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css delete mode 100644 apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/index.tsx delete mode 100644 apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/SidebarContentWrapperSkeleton.tsx delete mode 100644 apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/index.tsx delete mode 100644 apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/sidebarContentWrapper.module.css delete mode 100644 apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/utils.ts delete mode 100644 apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/index.tsx delete mode 100644 apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/inputFrom.module.css delete mode 100644 apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/Error.tsx delete mode 100644 apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/MultiRoomSkeleton.tsx delete mode 100644 apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/PriceDetailsTable/index.tsx delete mode 100644 apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsList/RoomListItem/Rates/getRateDefinition.ts delete mode 100644 apps/scandic-web/components/Levels/Level/DoubleRow/ScandicFamily.tsx delete mode 100644 apps/scandic-web/components/Levels/Level/SingleRow/ScandicFamily.tsx delete mode 100644 apps/scandic-web/components/Levels/Level/SingleRow/ScandicFriends.tsx delete mode 100644 apps/scandic-web/components/Loading/index.tsx delete mode 100644 apps/scandic-web/components/Loading/loading.module.css delete mode 100644 apps/scandic-web/components/Profile/DeleteCreditCardButton/index.tsx delete mode 100644 apps/scandic-web/components/TempDesignSystem/Form/FilterChip/Checkbox.tsx delete mode 100644 apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/chip.module.css delete mode 100644 apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/index.tsx delete mode 100644 apps/scandic-web/components/TempDesignSystem/SidePeek/types.ts delete mode 100644 apps/scandic-web/components/TempDesignSystem/SidePeekSelfControlled/types.ts delete mode 100644 apps/scandic-web/constants/poiCategories.ts delete mode 100644 apps/scandic-web/hooks/booking/usePaymentFailedToast.ts delete mode 100644 apps/scandic-web/hooks/booking/useScrollToActiveSection.ts delete mode 100644 apps/scandic-web/hooks/useHandleKeyPress.ts delete mode 100644 apps/scandic-web/server/routers/contentstack/destinationCityPage/input.ts delete mode 100644 apps/scandic-web/server/routers/hotels/schemas/hotelFilter.ts delete mode 100644 apps/scandic-web/server/routers/hotels/schemas/location/urls.ts delete mode 100644 apps/scandic-web/server/routers/hotels/schemas/restaurants.ts delete mode 100644 apps/scandic-web/server/routers/hotels/schemas/room.ts delete mode 100644 apps/scandic-web/server/routers/hotels/schemas/specialAlerts.ts delete mode 100644 apps/scandic-web/services/dataCache/DistributedCache/shouldHaveFullTtl.ts delete mode 100644 apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/deleteAll.ts delete mode 100644 apps/scandic-web/stores/enter-details/_useEnterDetailsStore.testing.tsx delete mode 100644 apps/scandic-web/types/components/current/asides/puffs.ts delete mode 100644 apps/scandic-web/types/components/current/header.ts delete mode 100644 apps/scandic-web/types/components/destinationOverviewPage/jumpTo/client.ts delete mode 100644 apps/scandic-web/types/components/destinationOverviewPage/jumpTo/index.ts delete mode 100644 apps/scandic-web/types/components/destinationOverviewPage/jumpTo/resolver.ts delete mode 100644 apps/scandic-web/types/components/destinationOverviewPage/jumpTo/results.ts delete mode 100644 apps/scandic-web/types/components/form/filterChip.ts delete mode 100644 apps/scandic-web/types/components/header/logo.ts delete mode 100644 apps/scandic-web/types/components/header/topMenuButton.ts delete mode 100644 apps/scandic-web/types/components/hotelPage/map/dynamicMap.ts delete mode 100644 apps/scandic-web/types/components/hotelPage/map/mapWithCardWrapper.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/enterDetails/room.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectHotel/hotePriceListProps.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectRate/hotelSelectionHeader.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectRate/imageGallery.ts delete mode 100644 apps/scandic-web/types/components/hotelReservation/selectRate/roomSelection.ts delete mode 100644 apps/scandic-web/types/components/myPages/header.ts delete mode 100644 apps/scandic-web/types/components/myPages/myProfile/layout.ts delete mode 100644 apps/scandic-web/types/components/myPages/stays/page.ts delete mode 100644 apps/scandic-web/types/enums/hotelListing.ts delete mode 100644 apps/scandic-web/types/next/error.ts delete mode 100644 apps/scandic-web/types/requests/myPages/breadcrumbs.ts delete mode 100644 apps/scandic-web/types/requests/pageLinks.ts delete mode 100644 apps/scandic-web/types/requests/rte.ts delete mode 100644 apps/scandic-web/types/trpc/routers/hotel/filter.ts delete mode 100644 apps/scandic-web/utils/isBrowser.ts delete mode 100644 apps/scandic-web/utils/tabbable.ts diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts deleted file mode 100644 index 37e79043f..000000000 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { getHotel } from "@/lib/trpc/memoizedRequests" -import { serverClient } from "@/lib/trpc/server" - -import { getLang } from "@/i18n/serverContext" - -import type { - AlternativeHotelsAvailabilityInput, - AvailabilityInput, -} from "@/types/components/hotelReservation/selectHotel/availabilityInput" -import type { NullableHotelData } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps" -import type { HotelsAvailabilityItem } from "@/types/trpc/routers/hotel/availability" - -export async function fetchAvailableHotels( - input: AvailabilityInput -): Promise { - const availableHotels = - await serverClient().hotel.availability.hotelsByCity(input) - - if (!availableHotels) return [] - - return enhanceHotels(availableHotels) -} - -export async function fetchBookingCodeAvailableHotels( - input: AvailabilityInput -): Promise { - const availableHotels = - await serverClient().hotel.availability.hotelsByCityWithBookingCode(input) - - if (!availableHotels) return [] - - return enhanceHotels(availableHotels) -} - -export async function fetchAlternativeHotels( - hotelId: string, - input: AlternativeHotelsAvailabilityInput -): Promise { - const alternativeHotelIds = await serverClient().hotel.nearbyHotelIds({ - hotelId, - }) - - if (!alternativeHotelIds) return [] - - const availableHotels = - await serverClient().hotel.availability.hotelsByHotelIds({ - ...input, - hotelIds: alternativeHotelIds, - }) - - if (!availableHotels) return [] - - return enhanceHotels(availableHotels) -} - -async function enhanceHotels(hotels: { - availability: HotelsAvailabilityItem[] -}) { - const language = getLang() - - const hotelFetchers = hotels.availability.map(async (hotel) => { - const hotelData = await getHotel({ - hotelId: hotel.hotelId.toString(), - isCardOnlyPayment: false, - language, - }) - - if (!hotelData) return { hotelData: null, price: hotel.productType } - - return { - hotelData: hotelData.hotel, - price: hotel.productType, - } - }) - - return await Promise.all(hotelFetchers) -} diff --git a/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/components/FailedAttemptsError.tsx b/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/components/FailedAttemptsError.tsx deleted file mode 100644 index 99a157fda..000000000 --- a/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/components/FailedAttemptsError.tsx +++ /dev/null @@ -1,35 +0,0 @@ -"use client" - -import { useIntl } from "react-intl" - -import { Typography } from "@scandic-hotels/design-system/Typography" - -import Button from "@/components/TempDesignSystem/Button" - -import { GenericError } from "./GenericError" - -export function FailedAttemptsError() { - const intl = useIntl() - - return ( - - -

- {intl.formatMessage({ - defaultMessage: "Please wait 1 hour before trying again.", - })} -

-
- -
- ) -} diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css deleted file mode 100644 index 7e31321b6..000000000 --- a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css +++ /dev/null @@ -1,10 +0,0 @@ -.container { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - background-color: var(--Scandic-Brand-Pale-Peach); - border-radius: var(--Corner-radius-md); - margin-bottom: var(--Spacing-x-half); - height: 200px; -} diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/index.tsx deleted file mode 100644 index 10adeec8e..000000000 --- a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/EmptyPreviousStays/index.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import Title from "@/components/TempDesignSystem/Text/Title" -import { getIntl } from "@/i18n" - -import styles from "./emptyPreviousStays.module.css" - -export default async function EmptyPreviousStaysBlock() { - const intl = await getIntl() - return ( -
- - {intl.formatMessage({ - defaultMessage: "You have no previous stays.", - })} - -
- ) -} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/SidebarContentWrapperSkeleton.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/SidebarContentWrapperSkeleton.tsx deleted file mode 100644 index 333cc28d7..000000000 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/SidebarContentWrapperSkeleton.tsx +++ /dev/null @@ -1,21 +0,0 @@ -"use client" - -import React from "react" - -import SkeletonShimmer from "@/components/SkeletonShimmer" - -import styles from "./sidebarContentWrapper.module.css" - -export default function SidebarContentWrapperSkeleton({ - children, -}: React.PropsWithChildren) { - return ( -
-
- - -
- {children} -
- ) -} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/index.tsx deleted file mode 100644 index 15ef68571..000000000 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -"use client" - -import { useRef } from "react" - -import { StickyElementNameEnum } from "@/stores/sticky-position" - -import useStickyPosition from "@/hooks/useStickyPosition" - -import styles from "./sidebarContentWrapper.module.css" - -export default function SidebarContentWrapper({ - children, -}: React.PropsWithChildren) { - const sidebarRef = useRef(null) - useStickyPosition({ - ref: sidebarRef, - name: StickyElementNameEnum.DESTINATION_SIDEBAR, - }) - - return ( -
- {children} -
- ) -} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/sidebarContentWrapper.module.css b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/sidebarContentWrapper.module.css deleted file mode 100644 index f41dc74be..000000000 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/sidebarContentWrapper.module.css +++ /dev/null @@ -1,12 +0,0 @@ -.sidebarContent { - display: grid; - align-content: start; - gap: var(--Spacing-x2); - padding: var(--Spacing-x4); -} - -@media screen and (min-width: 1367px) { - .sidebarContent { - position: sticky; - } -} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/utils.ts b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/utils.ts deleted file mode 100644 index 57eaa5e61..000000000 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/SidebarContentWrapper/utils.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { IntlShape } from "react-intl" - -import type { CategorizedFilters } from "@/types/components/destinationFilterAndSort" - -export function getHeadingText( - intl: IntlShape, - location: string, - allFilters: CategorizedFilters, - filter?: string -) { - if (filter) { - const facilityFilter = allFilters.facilityFilters.find( - (f) => f.slug === filter - ) - const surroudingsFilter = allFilters.surroundingsFilters.find( - (f) => f.slug === filter - ) - - if (facilityFilter) { - return intl.formatMessage( - { - defaultMessage: "Hotels with {filter} in {location}", - }, - { location, filter: facilityFilter.name } - ) - } else if (surroudingsFilter) { - return intl.formatMessage( - { - defaultMessage: "Hotels near {filter} in {location}", - }, - { location, filter: surroudingsFilter.name } - ) - } - } - return intl.formatMessage( - { - defaultMessage: "Hotels in {location}", - }, - { location } - ) -} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/index.tsx deleted file mode 100644 index 7677fb992..000000000 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -"use client" -import { useIntl } from "react-intl" - -import styles from "./inputFrom.module.css" - -export default function InputForm() { - const intl = useIntl() - return ( -
- -
- ) -} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/inputFrom.module.css b/apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/inputFrom.module.css deleted file mode 100644 index 08a74aa86..000000000 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationOverviewPage/OverviewMapContainer/InputForm/inputFrom.module.css +++ /dev/null @@ -1,14 +0,0 @@ -.form { - position: absolute; - top: 25px; - left: 50%; - transform: translateX(-50%); - z-index: 1; - background-color: var(--Base-Background-Primary-Normal); -} - -.formInput { - padding: var(--Spacing-x-one-and-half); - border: none; - width: 250px; -} diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Breakfast/schema.ts b/apps/scandic-web/components/HotelReservation/EnterDetails/Breakfast/schema.ts index 43bc8bc8f..d8008d2c6 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Breakfast/schema.ts +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Breakfast/schema.ts @@ -1,11 +1,5 @@ import { z } from "zod" -import { breakfastPackageSchema } from "@/server/routers/hotels/schemas/packages" - -export const breakfastStoreSchema = z.object({ - breakfast: breakfastPackageSchema.or(z.literal(false)), -}) - export const breakfastFormSchema = z.object({ breakfast: z.string().or(z.literal("false")), }) diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/Error.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/Error.tsx deleted file mode 100644 index 0a37d635d..000000000 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/Error.tsx +++ /dev/null @@ -1,21 +0,0 @@ -"use client" -import { useIntl } from "react-intl" - -import Alert from "@/components/TempDesignSystem/Alert" - -import { AlertTypeEnum } from "@/types/enums/alert" - -export default function Error() { - const intl = useIntl() - return ( - - ) -} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/MultiRoomSkeleton.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/MultiRoomSkeleton.tsx deleted file mode 100644 index fa055dbab..000000000 --- a/apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/MultiRoomSkeleton.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import SkeletonShimmer from "@/components/SkeletonShimmer" -import Divider from "@/components/TempDesignSystem/Divider" - -import styles from "./multiRoom.module.css" - -export default function MultiRoomSkeleton() { - return ( -
-
- -
-
- -
-
-
- -
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
- - -
-
-
-
- ) -} diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/PriceDetailsTable/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/PriceDetailsTable/index.tsx deleted file mode 100644 index f71c40db0..000000000 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/PriceDetailsTable/index.tsx +++ /dev/null @@ -1,236 +0,0 @@ -"use client" - -import { Fragment } from "react" -import { useIntl } from "react-intl" - -import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" - -import { dt } from "@/lib/dt" - -import Body from "@/components/TempDesignSystem/Text/Body" -import Caption from "@/components/TempDesignSystem/Text/Caption" -import useLang from "@/hooks/useLang" -import { formatPrice } from "@/utils/numberFormatting" - -import styles from "./priceDetailsTable.module.css" - -import type { Price } from "@/types/components/hotelReservation/price" -import type { SelectRateSummaryProps } from "@/types/components/hotelReservation/summary" - -function Row({ - label, - value, - bold, -}: { - label: string - value: string - bold?: boolean -}) { - return ( - - - {label} - - - {value} - - - ) -} - -function TableSection({ children }: React.PropsWithChildren) { - return {children} -} - -function TableSectionHeader({ - title, - subtitle, -}: { - title: string - subtitle?: string -}) { - return ( - - - {title} - {subtitle ? {subtitle} : null} - - - ) -} - -export interface PriceDetailsTableProps { - bookingCode?: string - fromDate: string - isMember: boolean - rooms: SelectRateSummaryProps["rooms"] - toDate: string - totalPrice: Price - vat: number -} - -export default function PriceDetailsTable({ - bookingCode, - fromDate, - isMember, - rooms, - toDate, - totalPrice, - vat, -}: PriceDetailsTableProps) { - const intl = useIntl() - const lang = useLang() - - const diff = dt(toDate).diff(fromDate, "days") - const nights = intl.formatMessage( - { - defaultMessage: "{totalNights, plural, one {# night} other {# nights}}", - }, - { totalNights: diff } - ) - const vatPercentage = vat / 100 - const vatAmount = totalPrice.local.price * vatPercentage - - const priceExclVat = totalPrice.local.price - vatAmount - - const duration = ` ${dt(fromDate).locale(lang).format("ddd, D MMM")} - - - ${dt(toDate).locale(lang).format("ddd, D MMM")} (${nights})` - return ( - - {rooms.map((room, idx) => { - const isMainRoom = idx === 0 - const getMemberRate = isMainRoom && isMember - - if (!room) { - return null - } - - let price - if ( - getMemberRate && - "member" in room.roomRate && - room.roomRate.member - ) { - price = room.roomRate.member - } else if ("public" in room.roomRate && room.roomRate.public) { - price = room.roomRate.public - } - if (!price) { - return null - } - return ( - - - {rooms.length > 1 && ( - - {intl.formatMessage({ - defaultMessage: "Room", - })} - {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} - {` ${idx + 1}`} - - )} - - - {room.packages?.map((pkg) => ( - - ))} - - - - ) - })} - - - - - - - - - {totalPrice.local.regularPrice && ( - - - - - - )} - {bookingCode && totalPrice.local.regularPrice && ( - - - - - )} - -
- - {intl.formatMessage({ - defaultMessage: "Price including VAT", - })} - - - - {formatPrice( - intl, - totalPrice.local.price, - totalPrice.local.currency - )} - -
-
- {formatPrice( - intl, - totalPrice.local.regularPrice, - totalPrice.local.currency - )} -
- - {bookingCode} -
- ) -} diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsList/RoomListItem/Rates/getRateDefinition.ts b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsList/RoomListItem/Rates/getRateDefinition.ts deleted file mode 100644 index e89b65a84..000000000 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsList/RoomListItem/Rates/getRateDefinition.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { - Product, - RateDefinition, -} from "@/types/trpc/routers/hotel/roomAvailability" - -/** - * Get terms and rate title from the rate definitions when booking code rate - * or public promotion is in play. Returns undefined when product is not available - * - * @param product - Either public or member product type - * @param rateDefinitions - List of rate definitions - * @returns RateDefinition | undefined - */ -export function getRateDefinition( - product: Product, - rateDefinitions: RateDefinition[], - isUserLoggedIn: boolean, - isMainRoom: boolean -) { - return rateDefinitions.find((rateDefinition) => { - if ("member" in product && product.member && isUserLoggedIn && isMainRoom) { - return rateDefinition.rateCode === product.member.rateCode - } - if ("corporateCheque" in product) { - return rateDefinition.rateCode === product.corporateCheque.rateCode - } - if ("voucher" in product) { - return rateDefinition.rateCode === product.voucher.rateCode - } - if ("public" in product && product.public) { - return rateDefinition.rateCode === product.public.rateCode - } - }) -} diff --git a/apps/scandic-web/components/Levels/Level/DoubleRow/ScandicFamily.tsx b/apps/scandic-web/components/Levels/Level/DoubleRow/ScandicFamily.tsx deleted file mode 100644 index 05d1ab10d..000000000 --- a/apps/scandic-web/components/Levels/Level/DoubleRow/ScandicFamily.tsx +++ /dev/null @@ -1,189 +0,0 @@ -import { levelVariants } from "../../variants" - -import type { LevelProps } from "../../levels" - -export default function ScandicFamily({ className, color }: LevelProps) { - const classNames = levelVariants({ - className, - color, - }) - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ) -} diff --git a/apps/scandic-web/components/Levels/Level/SingleRow/ScandicFamily.tsx b/apps/scandic-web/components/Levels/Level/SingleRow/ScandicFamily.tsx deleted file mode 100644 index 3bcedaf5e..000000000 --- a/apps/scandic-web/components/Levels/Level/SingleRow/ScandicFamily.tsx +++ /dev/null @@ -1,189 +0,0 @@ -import { levelVariants } from "../../variants" - -import type { LevelProps } from "../../levels" - -export default function ScandicFamily({ className, color }: LevelProps) { - const classNames = levelVariants({ - className, - color, - }) - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ) -} diff --git a/apps/scandic-web/components/Levels/Level/SingleRow/ScandicFriends.tsx b/apps/scandic-web/components/Levels/Level/SingleRow/ScandicFriends.tsx deleted file mode 100644 index d3fdf2d19..000000000 --- a/apps/scandic-web/components/Levels/Level/SingleRow/ScandicFriends.tsx +++ /dev/null @@ -1,205 +0,0 @@ -import { levelVariants } from "../../variants" - -import type { LevelProps } from "../../levels" - -export default function ScandicFriends({ className, color }: LevelProps) { - const classNames = levelVariants({ - className, - color, - }) - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ) -} diff --git a/apps/scandic-web/components/Levels/index.tsx b/apps/scandic-web/components/Levels/index.tsx index dfc81a470..669376234 100644 --- a/apps/scandic-web/components/Levels/index.tsx +++ b/apps/scandic-web/components/Levels/index.tsx @@ -4,7 +4,6 @@ export { default as DearFriend } from "./Level/DoubleRow/DearFriend" export { default as GoodFriend } from "./Level/DoubleRow/GoodFriend" export { default as LoyalFriend } from "./Level/DoubleRow/LoyalFriend" export { default as NewFriend } from "./Level/DoubleRow/NewFriend" -export { default as ScandicFamily } from "./Level/DoubleRow/ScandicFamily" export { default as ScandicFriends } from "./Level/DoubleRow/ScandicFriends" export { default as TrueFriend } from "./Level/DoubleRow/TrueFriend" export { default as BestFriendSingle } from "./Level/SingleRow/BestFriend" @@ -13,6 +12,4 @@ export { default as DearFriendSingle } from "./Level/SingleRow/DearFriend" export { default as GoodFriendSingle } from "./Level/SingleRow/GoodFriend" export { default as LoyalFriendSingle } from "./Level/SingleRow/LoyalFriend" export { default as NewFriendSingle } from "./Level/SingleRow/NewFriend" -export { default as ScandicFamilySingle } from "./Level/SingleRow/ScandicFamily" -export { default as ScandicFriendsSingle } from "./Level/SingleRow/ScandicFriends" export { default as TrueFriendSingle } from "./Level/SingleRow/TrueFriend" diff --git a/apps/scandic-web/components/Loading/index.tsx b/apps/scandic-web/components/Loading/index.tsx deleted file mode 100644 index fbf6c35e4..000000000 --- a/apps/scandic-web/components/Loading/index.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import styles from "./loading.module.css" - -type Size = "small" | "medium" | "large" -type Color = "white" | "burgundy" -type Props = { - size?: Size - color?: Color - className?: string -} - -export function Loading({ - size = "medium", - color = "burgundy", - className, -}: Props) { - return ( - - - - - - - - - - - ) -} - -const colors: { [color in Color]: string } = { - white: "#fff", - burgundy: "var(--Scandic-Brand-Burgundy)", -} - -const sizes: { [size in Size]: number } = { - small: 16, - medium: 20, - large: 24, -} diff --git a/apps/scandic-web/components/Loading/loading.module.css b/apps/scandic-web/components/Loading/loading.module.css deleted file mode 100644 index 2b6e93081..000000000 --- a/apps/scandic-web/components/Loading/loading.module.css +++ /dev/null @@ -1,43 +0,0 @@ -.loading { - --animationDuration: 0.8s; - --delayPerItem: calc(var(--animationDuration) / 8); - - & circle { - animation: fadeInOut var(--animationDuration) infinite linear both; - transform-origin: center; - - &:nth-child(2) { - animation-delay: calc(var(--delayPerItem) * -7); - } - &:nth-child(3) { - animation-delay: calc(var(--delayPerItem) * -6); - } - &:nth-child(4) { - animation-delay: calc(var(--delayPerItem) * -5); - } - &:nth-child(5) { - animation-delay: calc(var(--delayPerItem) * -4); - } - &:nth-child(6) { - animation-delay: calc(var(--delayPerItem) * -3); - } - &:nth-child(7) { - animation-delay: calc(var(--delayPerItem) * -2); - } - &:nth-child(8) { - animation-delay: calc(var(--delayPerItem) * -1); - } - } -} - -@keyframes fadeInOut { - 0%, - 20%, - 80%, - 100% { - opacity: 0.3; - } - 50% { - opacity: 1; - } -} diff --git a/apps/scandic-web/components/Modal/motionVariants.ts b/apps/scandic-web/components/Modal/motionVariants.ts index 511b14ddf..e24932152 100644 --- a/apps/scandic-web/components/Modal/motionVariants.ts +++ b/apps/scandic-web/components/Modal/motionVariants.ts @@ -21,16 +21,3 @@ export const slideInOut = { transition: { duration: 0.4, ease: "easeInOut" }, }, } - -export const slideFromTop = { - hidden: { - opacity: 0, - y: -32, - transition: { duration: 0.4, ease: "easeInOut" }, - }, - visible: { - opacity: 1, - y: 0, - transition: { duration: 0.4, ease: "easeInOut" }, - }, -} diff --git a/apps/scandic-web/components/Profile/DeleteCreditCardButton/index.tsx b/apps/scandic-web/components/Profile/DeleteCreditCardButton/index.tsx deleted file mode 100644 index 03a30eb06..000000000 --- a/apps/scandic-web/components/Profile/DeleteCreditCardButton/index.tsx +++ /dev/null @@ -1,45 +0,0 @@ -"use client" -import { useIntl } from "react-intl" - -import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" - -import { trpc } from "@/lib/trpc/client" - -import Button from "@/components/TempDesignSystem/Button" -import { toast } from "@/components/TempDesignSystem/Toasts" - -export default function DeleteCreditCardButton({ - creditCardId, -}: { - creditCardId: string -}) { - const intl = useIntl() - const trpcUtils = trpc.useUtils() - - const deleteCreditCardMutation = trpc.user.creditCard.delete.useMutation({ - onSuccess() { - trpcUtils.user.creditCards.invalidate() - toast.success( - intl.formatMessage({ - defaultMessage: "Credit card deleted successfully", - }) - ) - }, - onError() { - toast.error( - intl.formatMessage({ - defaultMessage: - "Failed to delete credit card, please try again later.", - }) - ) - }, - }) - async function handleDelete() { - deleteCreditCardMutation.mutate({ creditCardId }) - } - return ( - - ) -} diff --git a/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/Checkbox.tsx b/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/Checkbox.tsx deleted file mode 100644 index c2697d560..000000000 --- a/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/Checkbox.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import Chip from "./_Chip" - -import type { FilterChipCheckboxProps } from "@/types/components/form/filterChip" - -export default function CheckboxChip(props: FilterChipCheckboxProps) { - return -} diff --git a/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/chip.module.css b/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/chip.module.css deleted file mode 100644 index 31cf9c26a..000000000 --- a/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/chip.module.css +++ /dev/null @@ -1,40 +0,0 @@ -.label { - display: flex; - align-items: center; - gap: var(--Spacing-x-half); - padding: calc(var(--Spacing-x1) - 2px) var(--Spacing-x-one-and-half); - border: 1px solid var(--Base-Border-Subtle); - border-radius: var(--Corner-radius-sm); - background-color: var(--Base-Surface-Secondary-light-Normal); - cursor: pointer; - height: 32px; - background-color: var(--Base-Surface-Secondary-light-Normal); -} - -.label[data-selected="true"], -.label[data-selected="true"]:hover { - background-color: var(--Primary-Light-Surface-Normal); - border-color: var(--Base-Border-Hover); -} - -.label:hover { - background-color: var(--Base-Surface-Primary-light-Hover-alt); - border-color: var(--Base-Border-Subtle); -} - -.label[data-disabled="true"] { - background-color: var(--UI-Input-Controls-Surface-Disabled); - border-color: var(--UI-Input-Controls-Border-Disabled); - color: var(--Base-Text-Disabled); - cursor: not-allowed; -} - -.caption { - display: none; -} - -@media (min-width: 768px) { - .caption { - display: block; - } -} diff --git a/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/index.tsx b/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/index.tsx deleted file mode 100644 index d0ff244b6..000000000 --- a/apps/scandic-web/components/TempDesignSystem/Form/FilterChip/_Chip/index.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { useMemo } from "react" -import { useFormContext } from "react-hook-form" - -import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" - -import Caption from "@/components/TempDesignSystem/Text/Caption" - -import styles from "./chip.module.css" - -import type { FilterChipProps } from "@/types/components/form/filterChip" - -export default function FilterChip({ - Icon = () => , - iconHeight = 20, - iconWidth = 20, - id, - name, - label, - type, - value, - selected, - disabled, - hasTooltip, -}: FilterChipProps) { - const { register } = useFormContext() - - const captionColor = useMemo(() => { - if (selected) return "burgundy" - if (disabled) return "disabled" - return "uiTextPlaceholder" - }, [selected, disabled]) - - const iconColor = useMemo(() => { - if (selected) return "Icon/Interactive/Default" - if (disabled) return "Icon/Interactive/Disabled" - return "Icon/Interactive/Placeholder" - }, [selected, disabled]) - - return ( - - ) -} diff --git a/apps/scandic-web/components/TempDesignSystem/SidePeek/types.ts b/apps/scandic-web/components/TempDesignSystem/SidePeek/types.ts deleted file mode 100644 index e37554aff..000000000 --- a/apps/scandic-web/components/TempDesignSystem/SidePeek/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type SidePeekProps = { - activeContent: string | null - onClose: (isOpen: boolean) => void -} - -export type SidePeekContentProps = { - title?: string - contentKey: string - isActive?: boolean - onClose?: () => void -} diff --git a/apps/scandic-web/components/TempDesignSystem/SidePeekSelfControlled/types.ts b/apps/scandic-web/components/TempDesignSystem/SidePeekSelfControlled/types.ts deleted file mode 100644 index e37554aff..000000000 --- a/apps/scandic-web/components/TempDesignSystem/SidePeekSelfControlled/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type SidePeekProps = { - activeContent: string | null - onClose: (isOpen: boolean) => void -} - -export type SidePeekContentProps = { - title?: string - contentKey: string - isActive?: boolean - onClose?: () => void -} diff --git a/apps/scandic-web/constants/myBooking.ts b/apps/scandic-web/constants/myBooking.ts index 8fd98945d..093a891e6 100644 --- a/apps/scandic-web/constants/myBooking.ts +++ b/apps/scandic-web/constants/myBooking.ts @@ -8,30 +8,3 @@ export const myBookingPath: LangRoute = { no: "/hotelreservation/my-booking", sv: "/hotelreservation/din-bokning", } - -export const myBooking = { - development: { - da: `https://stage.scandichotels.dk${myBookingPath.da}`, - de: `https://stage.scandichotels.de${myBookingPath.de}`, - en: `https://stage.scandichotels.com${myBookingPath.en}`, - fi: `https://stage.scandichotels.fi${myBookingPath.fi}`, - no: `https://stage.scandichotels.no${myBookingPath.no}`, - sv: `https://stage.scandichotels.se${myBookingPath.sv}`, - }, - production: { - da: `https://www.scandichotels.dk${myBookingPath.da}`, - de: `https://www.scandichotels.de${myBookingPath.de}`, - en: `https://www.scandichotels.com${myBookingPath.en}`, - fi: `https://www.scandichotels.fi${myBookingPath.fi}`, - no: `https://www.scandichotels.no${myBookingPath.no}`, - sv: `https://www.scandichotels.se${myBookingPath.sv}`, - }, - test: { - da: `https://test.scandichotels.dk${myBookingPath.da}`, - de: `https://test.scandichotels.de${myBookingPath.de}`, - en: `https://test.scandichotels.com${myBookingPath.en}`, - fi: `https://test.scandichotels.fi${myBookingPath.fi}`, - no: `https://test.scandichotels.no${myBookingPath.no}`, - sv: `https://test.scandichotels.se${myBookingPath.sv}`, - }, -} diff --git a/apps/scandic-web/constants/poiCategories.ts b/apps/scandic-web/constants/poiCategories.ts deleted file mode 100644 index 6153414e7..000000000 --- a/apps/scandic-web/constants/poiCategories.ts +++ /dev/null @@ -1,19 +0,0 @@ -export enum PoiCategories { - "Airport" = "airport", - "Amusement park" = "amusementPark", - "Bus terminal" = "busTerminal", - "Fair" = "fair", - "Hospital" = "hospital", - "Hotel" = "hotel", - "Marketing city" = "marketingCity", - "Museum" = "museum", - "Nearby companies" = "nearbyCompanies", - "Parking / Garage" = "parkingGarage", - "Restaurant" = "restaurant", - "Shopping" = "shopping", - "Sports" = "sports", - "Theatre" = "theatre", - "Tourist" = "tourist", - "Transportations" = "transportations", - "Zoo" = "zoo", -} diff --git a/apps/scandic-web/hooks/booking/usePaymentFailedToast.ts b/apps/scandic-web/hooks/booking/usePaymentFailedToast.ts deleted file mode 100644 index 18076f48f..000000000 --- a/apps/scandic-web/hooks/booking/usePaymentFailedToast.ts +++ /dev/null @@ -1,63 +0,0 @@ -"use client" - -import { usePathname, useRouter, useSearchParams } from "next/navigation" -import { useCallback, useEffect } from "react" -import { useIntl } from "react-intl" - -import { BookingErrorCodeEnum } from "@/constants/booking" -import { useEnterDetailsStore } from "@/stores/enter-details" - -import { toast } from "@/components/TempDesignSystem/Toasts" - -export function usePaymentFailedToast() { - const updateSearchParams = useEnterDetailsStore( - (state) => state.actions.updateSeachParamString - ) - const intl = useIntl() - const searchParams = useSearchParams() - const pathname = usePathname() - const router = useRouter() - - const getErrorMessage = useCallback( - (errorCode: string | null) => { - switch (errorCode) { - case BookingErrorCodeEnum.TransactionCancelled: - return intl.formatMessage({ - defaultMessage: "You have now cancelled your payment.", - }) - default: - return intl.formatMessage({ - defaultMessage: - "We had an issue processing your booking. Please try again. No charges have been made.", - }) - } - }, - [intl] - ) - - const errorCode = searchParams.get("errorCode") - const errorMessage = getErrorMessage(errorCode) - - useEffect(() => { - if (!errorCode) return - - const toastType = - errorCode === BookingErrorCodeEnum.TransactionCancelled - ? "warning" - : "error" - toast[toastType](errorMessage) - - const queryParams = new URLSearchParams(searchParams.toString()) - queryParams.delete("errorCode") - - updateSearchParams(queryParams.toString()) - router.push(`${pathname}?${queryParams.toString()}`) - }, [ - searchParams, - pathname, - errorCode, - errorMessage, - router, - updateSearchParams, - ]) -} diff --git a/apps/scandic-web/hooks/booking/useScrollToActiveSection.ts b/apps/scandic-web/hooks/booking/useScrollToActiveSection.ts deleted file mode 100644 index 853bbfbcb..000000000 --- a/apps/scandic-web/hooks/booking/useScrollToActiveSection.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { useCallback, useEffect } from "react" -import { useMediaQuery } from "usehooks-ts" - -import type { StepEnum } from "@/types/enums/step" - -export default function useScrollToActiveSection( - step: StepEnum, - steps: StepEnum[], - isActive: boolean -) { - const isMobile = useMediaQuery("(max-width: 767px)") - - const handleScroll = useCallback(() => { - if (!isMobile) { - return - } - - const currentElement = document.querySelector( - `[data-step="${step}"]` - ) - const prevOpenElement = - document.querySelector(`[data-open="true"]`) - - const currentStepIndex = steps.indexOf(step) - const prevStep = prevOpenElement - ? (Number(prevOpenElement?.dataset.step) as StepEnum) - : null - const prevStepIndex = prevStep ? steps.indexOf(prevStep) : null - - if (currentElement) { - const BOOKING_WIDGET_OFFSET = 71 - - const prevElementContent = prevOpenElement?.querySelector("header + div") - - let collapsedSpace = 0 - if ( - prevElementContent && - prevStepIndex && - prevStepIndex < currentStepIndex - ) { - collapsedSpace = prevElementContent.clientHeight - } - - const currentElementTop = - currentElement.getBoundingClientRect().top + window.scrollY - - const scrollTarget = Math.round( - currentElementTop - BOOKING_WIDGET_OFFSET - collapsedSpace - ) - - window.scrollTo({ - top: scrollTarget, - behavior: "smooth", - }) - } - }, [step, steps, isMobile]) - - useEffect(() => { - if (!isActive) return - handleScroll() - }, [isActive, handleScroll]) -} diff --git a/apps/scandic-web/hooks/useHandleKeyPress.ts b/apps/scandic-web/hooks/useHandleKeyPress.ts deleted file mode 100644 index b240650d1..000000000 --- a/apps/scandic-web/hooks/useHandleKeyPress.ts +++ /dev/null @@ -1,11 +0,0 @@ -"use client" -import { useEffect } from "react" - -export function useHandleKeyPress(callback: (event: KeyboardEvent) => void) { - useEffect(() => { - window.addEventListener("keydown", callback) - return () => { - window.removeEventListener("keydown", callback) - } - }, [callback]) -} diff --git a/apps/scandic-web/server/routers/contentstack/destinationCityPage/input.ts b/apps/scandic-web/server/routers/contentstack/destinationCityPage/input.ts deleted file mode 100644 index 5856a3a66..000000000 --- a/apps/scandic-web/server/routers/contentstack/destinationCityPage/input.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { z } from "zod" - -export const getHotelListDataInput = z.object({ - cityIdentifier: z.string(), -}) diff --git a/apps/scandic-web/server/routers/contentstack/hotelPage/utils.ts b/apps/scandic-web/server/routers/contentstack/hotelPage/utils.ts index b90205408..4c4d91ec9 100644 --- a/apps/scandic-web/server/routers/contentstack/hotelPage/utils.ts +++ b/apps/scandic-web/server/routers/contentstack/hotelPage/utils.ts @@ -1,112 +1,16 @@ -import { GetHotelPageRefs } from "@/lib/graphql/Query/HotelPage/HotelPage.graphql" import { GetHotelPageCount } from "@/lib/graphql/Query/HotelPage/HotelPageCount.graphql" import { GetHotelPageUrls } from "@/lib/graphql/Query/HotelPage/HotelPageUrl.graphql" import { request } from "@/lib/graphql/request" -import { notFound } from "@/server/errors/trpc" import { createCounter } from "@/server/telemetry" -import { - generateRefsResponseTag, - generateTag, - generateTagsFromSystem, -} from "@/utils/generateTag" +import { batchedHotelPageUrlsSchema, hotelPageCountSchema } from "./output" -import { - batchedHotelPageUrlsSchema, - hotelPageCountSchema, - hotelPageRefsSchema, -} from "./output" - -import { HotelPageEnum } from "@/types/enums/hotelPage" -import type { System } from "@/types/requests/system" import type { GetHotelPageCountData, - GetHotelPageRefsSchema, GetHotelPageUrlsData, - HotelPageRefs, } from "@/types/trpc/routers/contentstack/hotelPage" import type { Lang } from "@/constants/languages" -export async function fetchHotelPageRefs(lang: Lang, uid: string) { - const getHotelPageRefsCounter = createCounter( - "trpc.contentstack", - "hotelPage.get.refs" - ) - const metricsGetHotelPageRefs = getHotelPageRefsCounter.init({ lang, uid }) - - metricsGetHotelPageRefs.start() - - const refsResponse = await request( - GetHotelPageRefs, - { locale: lang, uid }, - { - key: generateRefsResponseTag(lang, uid), - ttl: "max", - } - ) - if (!refsResponse.data) { - const notFoundError = notFound(refsResponse) - metricsGetHotelPageRefs.noDataError() - throw notFoundError - } - - return refsResponse.data -} - -export function validateHotelPageRefs( - data: GetHotelPageRefsSchema, - lang: Lang, - uid: string -) { - const getHotelPageRefsCounter = createCounter( - "trpc.contentstack", - "hotelPage.get.refs" - ) - const metricsGetHotelPageRefs = getHotelPageRefsCounter.init({ lang, uid }) - - const validatedData = hotelPageRefsSchema.safeParse(data) - - if (!validatedData.success) { - metricsGetHotelPageRefs.validationError(validatedData.error) - return null - } - - metricsGetHotelPageRefs.success() - - return validatedData.data -} - -export function generatePageTags( - validatedData: HotelPageRefs, - lang: Lang -): string[] { - const connections = getConnections(validatedData) - return [ - generateTagsFromSystem(lang, connections), - generateTag(lang, validatedData.hotel_page.system.uid), - ].flat() -} - -export function getConnections({ hotel_page }: HotelPageRefs) { - const connections: System["system"][] = [hotel_page.system] - if (hotel_page.content) { - hotel_page.content.forEach((block) => { - switch (block.__typename) { - case HotelPageEnum.ContentStack.blocks.ActivitiesCard: { - if (block.upcoming_activities_card.length) { - connections.push(...block.upcoming_activities_card) - } - break - } - } - if (hotel_page.faq) { - connections.push(...hotel_page.faq) - } - }) - } - return connections -} - export async function getHotelPageCount(lang: Lang) { const getHotelPageCountCounter = createCounter( "trpc.contentstack", diff --git a/apps/scandic-web/server/routers/hotels/schemas/hotelFilter.ts b/apps/scandic-web/server/routers/hotels/schemas/hotelFilter.ts deleted file mode 100644 index 5abd664df..000000000 --- a/apps/scandic-web/server/routers/hotels/schemas/hotelFilter.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { z } from "zod" - -export const hotelFilterSchema = z.object({ - hotelFacilities: z.array(z.string()), - hotelSurroundings: z.array(z.string()), - roomFacilities: z.array(z.string()), -}) diff --git a/apps/scandic-web/server/routers/hotels/schemas/location/urls.ts b/apps/scandic-web/server/routers/hotels/schemas/location/urls.ts deleted file mode 100644 index 908adc9bd..000000000 --- a/apps/scandic-web/server/routers/hotels/schemas/location/urls.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { z } from "zod" - -import { isDefined } from "@/server/utils" - -export const locationsUrlsSchema = z.object({ - hotels: z - .object({ - items: z.array( - z.object({ - id: z.string(), - url: z.string(), - }) - ), - }) - .transform((data) => { - return data.items - }), - cities: z - .object({ - items: z - .array( - z - .object({ - id: z - .object({ - da: z.string().nullish(), - de: z.string().nullish(), - en: z.string().nullish(), - fi: z.string().nullish(), - no: z.string().nullish(), - pl: z.string().nullish(), - sv: z.string().nullish(), - }) - .transform( - (data) => - data.da || - data.de || - data.en || - data.fi || - data.no || - data.pl || - data.sv - ), - url: z.string().nullish(), - }) - .partial() - .transform((data) => { - if (!data.id || !data.url) { - return null - } - - return { - id: data.id, - url: data.url, - } - }) - ) - .transform((data) => { - return data.filter(isDefined) - }), - }) - .transform((data) => { - return data.items - }), -}) - -export type GetLocationsUrlsData = z.input -export type LocationsUrls = z.output diff --git a/apps/scandic-web/server/routers/hotels/schemas/restaurants.ts b/apps/scandic-web/server/routers/hotels/schemas/restaurants.ts deleted file mode 100644 index 707de8f23..000000000 --- a/apps/scandic-web/server/routers/hotels/schemas/restaurants.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { z } from "zod" - -import { imageSchema } from "./image" -import { specialAlertsSchema } from "./specialAlerts" - -const restaurantPriceSchema = z.object({ - currency: z.string(), - amount: z.number(), -}) -export const restaurantDaySchema = z.object({ - sortOrder: z.number(), - alwaysOpen: z.boolean(), - isClosed: z.boolean(), - openingTime: z.string(), - closingTime: z.string(), -}) -export const restaurantOpeningHoursSchema = z.object({ - isActive: z.boolean(), - name: z.string().optional(), - monday: restaurantDaySchema.optional(), - tuesday: restaurantDaySchema.optional(), - wednesday: restaurantDaySchema.optional(), - thursday: restaurantDaySchema.optional(), - friday: restaurantDaySchema.optional(), - saturday: restaurantDaySchema.optional(), - sunday: restaurantDaySchema.optional(), -}) - -const restaurantOpeningDetailSchema = z.object({ - openingHours: restaurantOpeningHoursSchema, - alternateOpeningHours: restaurantOpeningHoursSchema.optional(), -}) - -export const restaurantSchema = z - .object({ - attributes: z.object({ - name: z.string(), - isPublished: z.boolean().default(false), - restaurantPage: z.boolean(), - email: z.string().optional(), - phoneNumber: z.string().optional(), - externalBreakfast: z - .object({ - isAvailable: z.boolean(), - localPriceForExternalGuests: restaurantPriceSchema.optional(), - requestedPriceForExternalGuests: restaurantPriceSchema.optional(), - }) - .optional(), - menus: z - .array( - z.object({ - name: z.string(), - url: z.string(), - }) - ) - .default([]), - openingDetails: z.array(restaurantOpeningDetailSchema).default([]), - content: z.object({ - images: z.array(imageSchema), - texts: z.object({ - descriptions: z.object({ - short: z.string().default(""), - medium: z.string().default(""), - }), - }), - bookTableUrl: z.string().optional(), - specialAlerts: specialAlertsSchema, - }), - }), - id: z.string(), - type: z.literal("restaurants"), - }) - .transform(({ attributes, id, type }) => ({ ...attributes, id, type })) - -export const getRestaurantsSchema = z - .object({ - data: z.array(restaurantSchema), - }) - .transform(({ data }) => { - return data.filter((item) => !!item.isPublished) - }) diff --git a/apps/scandic-web/server/routers/hotels/schemas/room.ts b/apps/scandic-web/server/routers/hotels/schemas/room.ts deleted file mode 100644 index caf6317a0..000000000 --- a/apps/scandic-web/server/routers/hotels/schemas/room.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { z } from "zod" - -import { BedTypeEnum, ExtraBedTypeEnum } from "@/constants/booking" - -import { imageSchema } from "./image" - -const roomContentSchema = z.object({ - images: z.array(imageSchema), - texts: z.object({ - descriptions: z.object({ - short: z.string().optional(), - medium: z.string().optional(), - }), - }), -}) - -const roomTypesSchema = z.object({ - name: z.string(), - description: z.string(), - code: z.string(), - roomCount: z.number(), - mainBed: z - .object({ - type: z.string(), - description: z.string(), - widthRange: z.object({ - min: z.number(), - max: z.number(), - }), - }) - .transform((data) => ({ - type: - data.type in BedTypeEnum - ? (data.type as BedTypeEnum) - : BedTypeEnum.Other, - description: data.description, - widthRange: data.widthRange, - })), - fixedExtraBed: z - .object({ - type: z.string(), - description: z.string().optional(), - widthRange: z.object({ - min: z.number(), - max: z.number(), - }), - }) - .transform((data) => { - return data.type in ExtraBedTypeEnum - ? { - type: data.type as ExtraBedTypeEnum, - description: data.description, - } - : undefined - }), - roomSize: z.object({ - min: z.number(), - max: z.number(), - }), - occupancy: z.object({ - total: z.number(), - adults: z.number(), - children: z.number(), - }), - isLackingCribs: z.boolean(), - isLackingExtraBeds: z.boolean(), -}) - -const roomFacilitiesSchema = z.object({ - availableInAllRooms: z.boolean(), - name: z.string(), - isUniqueSellingPoint: z.boolean(), - sortOrder: z.number(), - icon: z.string().optional(), -}) - -export const roomSchema = z - .object({ - attributes: z.object({ - name: z.string(), - sortOrder: z.number(), - content: roomContentSchema, - roomTypes: z.array(roomTypesSchema), - roomFacilities: z.array(roomFacilitiesSchema), - occupancy: z.object({ - min: z.number(), - max: z.number(), - }), - roomSize: z.object({ - min: z.number(), - max: z.number(), - }), - }), - id: z.string(), - type: z.literal("roomcategories"), - }) - .transform((data) => { - return { - descriptions: data.attributes.content.texts.descriptions, - id: data.id, - images: data.attributes.content.images, - name: data.attributes.name, - occupancy: data.attributes.occupancy, - totalOccupancy: - data.attributes.occupancy.min === data.attributes.occupancy.max - ? { - max: data.attributes.occupancy.max, - range: `${data.attributes.occupancy.max}`, - } - : { - max: data.attributes.occupancy.max, - range: `${data.attributes.occupancy.min}-${data.attributes.occupancy.max}`, - }, - roomSize: data.attributes.roomSize, - roomTypes: data.attributes.roomTypes, - sortOrder: data.attributes.sortOrder, - type: data.type, - roomFacilities: data.attributes.roomFacilities, - } - }) - -export type RoomType = Pick, "roomTypes" | "name"> diff --git a/apps/scandic-web/server/routers/hotels/schemas/specialAlerts.ts b/apps/scandic-web/server/routers/hotels/schemas/specialAlerts.ts deleted file mode 100644 index 6acd8407a..000000000 --- a/apps/scandic-web/server/routers/hotels/schemas/specialAlerts.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { z } from "zod" - -import { dt } from "@/lib/dt" - -import { AlertTypeEnum } from "@/types/enums/alert" - -const specialAlertSchema = z.object({ - type: z.string(), - title: z.string().optional(), - description: z.string().optional(), - displayInBookingFlow: z.boolean(), - startDate: z.string().optional(), - endDate: z.string().optional(), -}) - -export const specialAlertsSchema = z - .array(specialAlertSchema) - .transform((data) => { - const now = dt().utc().format("YYYY-MM-DD") - const filteredAlerts = data.filter((alert) => { - let shouldShowNow = true - - if (alert.startDate && alert.startDate > now) { - shouldShowNow = false - } - if (alert.endDate && alert.endDate < now) { - shouldShowNow = false - } - const hasText = alert.description || alert.title - return shouldShowNow && hasText - }) - return filteredAlerts.map((alert, idx) => ({ - id: `alert-${alert.type}-${idx}`, - type: AlertTypeEnum.Info, - heading: alert.title || null, - text: alert.description || null, - })) - }) - .default([]) diff --git a/apps/scandic-web/services/dataCache/DistributedCache/endpoints.ts b/apps/scandic-web/services/dataCache/DistributedCache/endpoints.ts index e737f9b38..0705dccc1 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/endpoints.ts +++ b/apps/scandic-web/services/dataCache/DistributedCache/endpoints.ts @@ -10,13 +10,3 @@ export function getCacheEndpoint(key: string) { return url } - -export function getClearCacheEndpoint() { - if (!env.REDIS_API_HOST) { - throw new Error("REDIS_API_HOST is not set") - } - - const url = new URL(`/api/cache/clear`, env.REDIS_API_HOST) - - return url -} diff --git a/apps/scandic-web/services/dataCache/DistributedCache/shouldHaveFullTtl.ts b/apps/scandic-web/services/dataCache/DistributedCache/shouldHaveFullTtl.ts deleted file mode 100644 index dae6a5338..000000000 --- a/apps/scandic-web/services/dataCache/DistributedCache/shouldHaveFullTtl.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { env } from "@/env/server" - -export function shouldHaveFullTtl() { - return env.BRANCH === "release" -} diff --git a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/deleteAll.ts b/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/deleteAll.ts deleted file mode 100644 index 3a6466356..000000000 --- a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/deleteAll.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { cacheLogger } from "@/services/dataCache/logger" - -import { cacheMap } from "./cacheMap" - -export async function deleteAll() { - cacheLogger.debug("Deleting all keys") - - cacheMap.clear() -} diff --git a/apps/scandic-web/stores/enter-details/_useEnterDetailsStore.testing.tsx b/apps/scandic-web/stores/enter-details/_useEnterDetailsStore.testing.tsx deleted file mode 100644 index f0b8a7860..000000000 --- a/apps/scandic-web/stores/enter-details/_useEnterDetailsStore.testing.tsx +++ /dev/null @@ -1,657 +0,0 @@ -// import { describe, expect, test } from "@jest/globals" -// import { act, renderHook, waitFor } from "@testing-library/react" -// import { type PropsWithChildren } from "react" - -// import { BedTypeEnum } from "@/constants/booking" -// import { Lang } from "@/constants/languages" - -// import { -// bedType, -// booking, -// breakfastPackage, -// guestDetailsMember, -// guestDetailsNonMember, -// roomPrice, -// roomRate, -// } from "@/__mocks__/hotelReservation" -// import EnterDetailsProvider from "@/providers/EnterDetailsProvider" - -// import { detailsStorageName, useEnterDetailsStore } from "." - -// import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType" -// import type { BreakfastPackages } from "@/types/components/hotelReservation/enterDetails/breakfast" -// import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate" -// import { PackageTypeEnum } from "@/types/enums/packages" -// import { StepEnum } from "@/types/enums/step" -// import type { PersistedState } from "@/types/stores/enter-details" - -// jest.mock("react", () => ({ -// ...jest.requireActual("react"), -// cache: jest.fn(), -// })) - -// jest.mock("@/server/utils", () => ({ -// toLang: () => Lang.en, -// })) - -// jest.mock("@/lib/api", () => ({ -// fetchRetry: jest.fn((fn) => fn), -// })) - -// interface CreateWrapperParams { -// bedTypes?: BedTypeSelection[] -// bookingParams?: SelectRateSearchParams -// breakfastIncluded?: boolean -// breakfastPackages?: BreakfastPackages | null -// mustBeGuaranteed?: boolean -// } - -// function createWrapper(params: Partial = {}) { -// const { -// breakfastIncluded = false, -// breakfastPackages = null, -// mustBeGuaranteed = false, -// bookingParams = booking, -// bedTypes = [bedType.king, bedType.queen], -// } = params - -// return function Wrapper({ children }: PropsWithChildren) { -// return ( -// -// {children} -// -// ) -// } -// } - -// describe("Enter Details Store", () => { -// beforeEach(() => { -// window.sessionStorage.clear() -// }) - -// describe("initial state", () => { -// test("initialize with correct default values", () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) -// const state = result.current - -// expect(state.booking).toEqual(booking) - -// // room 1 -// const room1 = result.current.rooms[0] - -// expect(room1.currentStep).toBe(StepEnum.selectBed) - -// expect(room1.room.roomPrice.perNight.local.price).toEqual( -// roomRate.publicRate.localPrice.pricePerNight -// ) -// expect(room1.room.bedType).toEqual(undefined) -// expect(Object.values(room1.room.guest).every((value) => value === "")) - -// // room 2 -// const room2 = result.current.rooms[1] - -// expect(room2.currentStep).toBe(null) -// expect(room2.room.roomPrice.perNight.local.price).toEqual( -// room2.room.roomRate.publicRate.localPrice.pricePerNight -// ) -// expect(room2.room.bedType).toEqual(undefined) -// expect(Object.values(room2.room.guest).every((value) => value === "")) -// }) - -// test("initialize with correct values from session storage", () => { -// const storage: PersistedState = { -// activeRoom: 0, -// booking: booking, -// rooms: [ -// { -// currentStep: StepEnum.selectBed, -// isComplete: false, -// room: { -// adults: 1, -// bedType: { -// description: bedType.king.description, -// roomTypeCode: bedType.king.value, -// }, -// bedTypes: [ -// { -// description: bedType.king.description, -// extraBed: undefined, -// size: { -// min: 100, -// max: 120, -// }, -// type: BedTypeEnum.King, -// value: bedType.king.value, -// }, -// ], -// breakfastIncluded: false, -// breakfast: breakfastPackage, -// cancellationText: "Non-refundable", -// childrenInRoom: [], -// guest: guestDetailsNonMember, -// rateDetails: [], -// roomFeatures: null, -// roomPrice: roomPrice, -// roomRate: roomRate, -// roomType: "Classic Double", -// roomTypeCode: "QS", -// }, -// steps: { -// [StepEnum.selectBed]: { -// step: StepEnum.selectBed, -// isValid: true, -// }, -// [StepEnum.breakfast]: { -// step: StepEnum.breakfast, -// isValid: true, -// }, -// [StepEnum.details]: { -// step: StepEnum.details, -// isValid: true, -// }, -// }, -// }, -// ], -// } - -// window.sessionStorage.setItem(detailsStorageName, JSON.stringify(storage)) - -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) - -// expect(result.current.booking).toEqual(storage.booking) -// expect(result.current.rooms[0]).toEqual(storage.rooms[0]) -// }) -// }) - -// test("add bedtype and proceed to next step", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) - -// let room1 = result.current.rooms[0] -// expect(room1.currentStep).toEqual(StepEnum.selectBed) - -// const selectedBedType = { -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// } - -// await act(async () => { -// result.current.actions.updateBedType(0)(selectedBedType) -// }) - -// room1 = result.current.rooms[0] - -// expect(room1.steps[StepEnum.selectBed].isValid).toEqual(true) -// expect(room1.room.bedType).toEqual(selectedBedType) - -// expect(room1.currentStep).toEqual(StepEnum.breakfast) -// }) - -// test("complete step and navigate to next step", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) - -// // Room 1 -// expect(result.current.activeRoom).toEqual(0) - -// let room1 = result.current.rooms[0] -// expect(room1.currentStep).toEqual(StepEnum.selectBed) - -// await act(async () => { -// result.current.actions.updateBedType(0)({ -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// }) -// }) - -// room1 = result.current.rooms[0] -// expect(room1.steps[StepEnum.selectBed].isValid).toEqual(true) -// expect(room1.currentStep).toEqual(StepEnum.breakfast) - -// await act(async () => { -// result.current.actions.updateBreakfast(0)(breakfastPackage) -// }) - -// room1 = result.current.rooms[0] -// expect(room1.steps[StepEnum.breakfast]?.isValid).toEqual(true) -// expect(room1.currentStep).toEqual(StepEnum.details) - -// await act(async () => { -// result.current.actions.updateDetails(0)(guestDetailsNonMember) -// }) - -// expect(result.current.canProceedToPayment).toBe(false) - -// // Room 2 -// expect(result.current.activeRoom).toEqual(1) - -// let room2 = result.current.rooms[1] -// expect(room2.currentStep).toEqual(StepEnum.selectBed) - -// await act(async () => { -// const selectedBedType = { -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// } -// result.current.actions.updateBedType(1)(selectedBedType) -// }) - -// room2 = result.current.rooms[1] -// expect(room2.steps[StepEnum.selectBed].isValid).toEqual(true) -// expect(room2.currentStep).toEqual(StepEnum.breakfast) - -// await act(async () => { -// result.current.actions.updateBreakfast(1)(breakfastPackage) -// }) - -// room2 = result.current.rooms[1] -// expect(room2.steps[StepEnum.breakfast]?.isValid).toEqual(true) -// expect(room2.currentStep).toEqual(StepEnum.details) - -// await act(async () => { -// result.current.actions.updateDetails(1)(guestDetailsNonMember) -// }) - -// expect(result.current.canProceedToPayment).toBe(true) -// }) - -// test("all steps needs to be completed before going to next room", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) - -// await act(async () => { -// result.current.actions.updateDetails(0)(guestDetailsNonMember) -// }) - -// expect(result.current.activeRoom).toEqual(1) - -// await act(async () => { -// result.current.actions.setStep(StepEnum.breakfast) -// }) - -// expect(result.current.activeRoom).toEqual(1) -// }) - -// test("can go back and modify room 1 after completion", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) - -// await act(async () => { -// result.current.actions.updateBedType(0)({ -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// }) -// result.current.actions.updateBreakfast(0)(breakfastPackage) -// result.current.actions.updateDetails(0)(guestDetailsNonMember) -// }) - -// // now we are at room 2 -// expect(result.current.activeRoom).toEqual(1) - -// await act(async () => { -// result.current.actions.setStep(StepEnum.breakfast) // click "modify" -// }) - -// expect(result.current.activeRoom).toEqual(1) - -// await act(async () => { -// result.current.actions.updateBreakfast(1)(breakfastPackage) -// }) - -// // going back to room 2 -// expect(result.current.activeRoom).toEqual(1) -// }) - -// test("breakfast step should be hidden when breakfast is included", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper({ breakfastPackages: null }), -// } -// ) - -// const room1 = result.current.rooms[0] -// expect(Object.keys(room1.steps)).not.toContain(StepEnum.breakfast) - -// const room2 = result.current.rooms[1] -// expect(Object.keys(room2.steps)).not.toContain(StepEnum.breakfast) -// }) - -// test("select bed step should be skipped when there is only one bedtype", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper({ -// bedTypes: [bedType.queen], -// breakfastPackages: [ -// { -// code: "TEST", -// description: "Description", -// localPrice: { -// currency: "SEK", -// price: "100", -// totalPrice: "100", -// }, -// requestedPrice: { -// currency: "SEK", -// price: "100", -// totalPrice: "100", -// }, -// packageType: PackageTypeEnum.BreakfastAdult, -// }, -// ], -// }), -// } -// ) - -// const room1 = result.current.rooms[0] -// expect(room1.steps[StepEnum.selectBed].isValid).toEqual(true) -// expect(room1.currentStep).toEqual(StepEnum.breakfast) - -// const room2 = result.current.rooms[1] -// expect(room2.steps[StepEnum.selectBed].isValid).toEqual(true) -// expect(room2.currentStep).toEqual(null) -// }) - -// describe("price calculation", () => { -// test("total price should be set properly", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) - -// const publicRate = roomRate.publicRate.localPrice.pricePerStay -// const memberRate = roomRate.memberRate?.localPrice.pricePerStay ?? 0 - -// const initialTotalPrice = publicRate * result.current.rooms.length -// expect(result.current.totalPrice.local.price).toEqual(initialTotalPrice) - -// // room 1 -// await act(async () => { -// result.current.actions.updateBedType(0)({ -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// }) -// result.current.actions.updateBreakfast(0)(breakfastPackage) -// }) - -// let expectedTotalPrice = -// initialTotalPrice + Number(breakfastPackage.localPrice.price) -// expect(result.current.totalPrice.local.price).toEqual(expectedTotalPrice) - -// await act(async () => { -// result.current.actions.updateDetails(0)(guestDetailsMember) -// }) - -// expectedTotalPrice = -// memberRate + publicRate + Number(breakfastPackage.localPrice.price) -// expect(result.current.totalPrice.local.price).toEqual(expectedTotalPrice) - -// // room 2 -// await act(async () => { -// result.current.actions.updateBedType(1)({ -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// }) -// result.current.actions.updateBreakfast(1)(breakfastPackage) -// }) - -// expectedTotalPrice = -// memberRate + publicRate + Number(breakfastPackage.localPrice.price) * 2 -// expect(result.current.totalPrice.local.price).toEqual(expectedTotalPrice) - -// await act(async () => { -// result.current.actions.updateDetails(1)(guestDetailsNonMember) -// }) - -// expect(result.current.totalPrice.local.price).toEqual(expectedTotalPrice) -// }) - -// test("room price should be set properly", async () => { -// const { result } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper(), -// } -// ) - -// const publicRate = roomRate.publicRate.localPrice.pricePerStay -// const memberRate = roomRate.memberRate?.localPrice.pricePerStay ?? 0 - -// let room1 = result.current.rooms[0] -// expect(room1.room.roomPrice.perStay.local.price).toEqual(publicRate) - -// let room2 = result.current.rooms[0] -// expect(room2.room.roomPrice.perStay.local.price).toEqual(publicRate) - -// await act(async () => { -// result.current.actions.updateDetails(0)(guestDetailsMember) -// }) - -// room1 = result.current.rooms[0] -// expect(room1.room.roomPrice.perStay.local.price).toEqual(memberRate) -// }) -// }) - -// describe("change room", () => { -// test("changing to room with new bedtypes requires selecting bed again", async () => { -// const { result: firstRun } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper({ bedTypes: [bedType.king, bedType.queen] }), -// } -// ) - -// const selectedBedType = { -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// } - -// // add bedtype -// await act(async () => { -// firstRun.current.actions.updateBedType(0)(selectedBedType) -// }) - -// await act(async () => { -// firstRun.current.actions.updateBreakfast(0)(false) // 'no breakfast' selected -// }) - -// await act(async () => { -// firstRun.current.actions.updateDetails(0)(guestDetailsNonMember) -// }) - -// const updatedBooking = { -// ...booking, -// rooms: booking.rooms.map((r) => ({ -// ...r, -// roomTypeCode: "NEW", -// })), -// } - -// // render again to change the bedtypes -// const { result: secondRun } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper({ -// bookingParams: updatedBooking, -// bedTypes: [bedType.single, bedType.queen], -// }), -// } -// ) - -// await waitFor(() => { -// const secondRunRoom = secondRun.current.rooms[0] - -// // bed type should be unset since the bed types have changed -// expect(secondRunRoom.room.bedType).toEqual(undefined) - -// // bed step should be unselected -// expect(secondRunRoom.currentStep).toBe(StepEnum.selectBed) -// expect(secondRunRoom.steps[StepEnum.selectBed].isValid).toBe(false) - -// // other steps should still be selected -// expect(secondRunRoom.room.breakfast).toBe(false) -// expect(secondRunRoom.steps[StepEnum.breakfast]?.isValid).toBe(true) -// expect(secondRunRoom.room.guest).toEqual(guestDetailsNonMember) -// expect(secondRunRoom.steps[StepEnum.details].isValid).toBe(true) -// }) -// }) - -// test("changing to room with single bedtype option should skip step", async () => { -// const { result: firstRun } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper({ bedTypes: [bedType.king, bedType.queen] }), -// } -// ) - -// const selectedBedType = { -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// } - -// // add bedtype -// await act(async () => { -// firstRun.current.actions.updateBedType(0)(selectedBedType) -// }) - -// await act(async () => { -// firstRun.current.actions.updateBreakfast(0)(breakfastPackage) -// }) - -// const updatedBooking = { -// ...booking, -// rooms: booking.rooms.map((r) => ({ -// ...r, -// roomTypeCode: "NEW", -// })), -// } - -// // render again to change the bedtypes -// const { result: secondRun } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper({ -// bookingParams: updatedBooking, -// bedTypes: [bedType.queen], -// }), -// } -// ) - -// await waitFor(() => { -// const secondRunRoom = secondRun.current.rooms[0] - -// expect(secondRunRoom.room.bedType).toEqual({ -// roomTypeCode: bedType.queen.value, -// description: bedType.queen.description, -// }) - -// expect(secondRunRoom.steps[StepEnum.selectBed].isValid).toBe(true) -// expect(secondRunRoom.steps[StepEnum.breakfast]?.isValid).toBe(true) - -// expect(secondRunRoom.steps[StepEnum.details].isValid).toBe(false) -// expect(secondRunRoom.currentStep).toBe(StepEnum.details) -// }) -// }) - -// test("if booking has changed, stored values should be discarded", async () => { -// const { result: firstRun } = renderHook( -// () => useEnterDetailsStore((state) => state), -// { -// wrapper: createWrapper({ bedTypes: [bedType.king, bedType.queen] }), -// } -// ) - -// const selectedBedType = { -// roomTypeCode: bedType.king.value, -// description: bedType.king.description, -// } - -// // add bedtype -// await act(async () => { -// firstRun.current.actions.updateBedType(0)(selectedBedType) -// }) - -// await act(async () => { -// firstRun.current.actions.updateBreakfast(0)(breakfastPackage) -// }) - -// const updatedBooking = { -// ...booking, -// hotelId: "0001", -// fromDate: "2030-01-01", -// toDate: "2030-01-02", -// } - -// renderHook(() => useEnterDetailsStore((state) => state), { -// wrapper: createWrapper({ -// bookingParams: updatedBooking, -// bedTypes: [bedType.queen], -// }), -// }) - -// await waitFor(() => { -// const storageItem = window.sessionStorage.getItem(detailsStorageName) -// expect(storageItem).toBe(null) -// }) -// }) -// }) -// }) diff --git a/apps/scandic-web/stores/enter-details/helpers.ts b/apps/scandic-web/stores/enter-details/helpers.ts index 8fbfbed52..84e7e60b7 100644 --- a/apps/scandic-web/stores/enter-details/helpers.ts +++ b/apps/scandic-web/stores/enter-details/helpers.ts @@ -11,7 +11,6 @@ import { type RoomRate } from "@/types/components/hotelReservation/enterDetails/ import type { Price } from "@/types/components/hotelReservation/price" import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate" import { CurrencyEnum } from "@/types/enums/currency" -import { StepEnum } from "@/types/enums/step" import type { Package } from "@/types/requests/packages" import type { PersistedState, RoomState } from "@/types/stores/enter-details" import type { SafeUser } from "@/types/user" @@ -65,56 +64,6 @@ export function add(...nums: (number | string | undefined)[]) { }, 0) } -export function subtract(...nums: (number | string | undefined)[]) { - return nums.reduce((total: number, num, idx) => { - if (typeof num === "undefined") { - num = 0 - } - if (idx === 0) { - return parseInt(`${num}`) - } - total = total - parseInt(`${num}`) - if (total < 0) { - return 0 - } - return total - }, 0) -} - -export function getCurrency(roomRate: RoomRate) { - if ("corporateCheque" in roomRate) { - return { - localCurrency: CurrencyEnum.CC, - requestedCurrency: CurrencyEnum.CC, - } - } else if ("redemption" in roomRate) { - return { - localCurrency: CurrencyEnum.POINTS, - requestedCurrency: CurrencyEnum.POINTS, - } - } else if ("voucher" in roomRate) { - return { - localCurrency: CurrencyEnum.Voucher, - requestedCurrency: CurrencyEnum.Voucher, - } - } else if ("public" in roomRate && roomRate.public) { - return { - localCurrency: roomRate.public.localPrice.currency, - requestedCurrency: roomRate.public.requestedPrice?.currency, - } - } else if ("member" in roomRate && roomRate.member) { - return { - localCurrency: roomRate.member.localPrice.currency, - requestedCurrency: roomRate.member.requestedPrice?.currency, - } - } - - return { - localCurrency: CurrencyEnum.Unknown, - requestedCurrency: CurrencyEnum.Unknown, - } -} - export function getRoomPrice(roomRate: RoomRate, isMember: boolean) { if (isMember && "member" in roomRate && roomRate.member) { return { @@ -596,23 +545,6 @@ export function calcTotalPrice( ) } -export function getFirstInteractiveStepOfRoom(room: RoomState["room"]) { - if (!room.bedType) { - return StepEnum.selectBed - } - if (room.breakfast !== false) { - return StepEnum.breakfast - } - return StepEnum.details -} - -export function findNextInvalidStep(roomState: RoomState) { - return ( - Object.values(roomState.steps).find((stp) => !stp.isValid)?.step ?? - getFirstInteractiveStepOfRoom(roomState.room) - ) -} - export const checkRoomProgress = (steps: RoomState["steps"]) => { return Object.values(steps) .filter(Boolean) diff --git a/apps/scandic-web/stores/select-rate/helpers.ts b/apps/scandic-web/stores/select-rate/helpers.ts index 82c78853a..78e94efb5 100644 --- a/apps/scandic-web/stores/select-rate/helpers.ts +++ b/apps/scandic-web/stores/select-rate/helpers.ts @@ -1,4 +1,3 @@ -import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter" import { CurrencyEnum } from "@/types/enums/currency" import type { AvailabilityError } from "@/types/stores/rates" import type { @@ -101,14 +100,6 @@ export function findSelectedRate( }) } -export function isRoomPackageCode( - code: string | null -): code is RoomPackageCodeEnum { - return Object.values(RoomPackageCodeEnum).includes( - code as RoomPackageCodeEnum - ) -} - export function clearRoomSelectionFromUrl( roomIdx: number, searchParams: URLSearchParams diff --git a/apps/scandic-web/types/components/current/asides/puffs.ts b/apps/scandic-web/types/components/current/asides/puffs.ts deleted file mode 100644 index 07198d912..000000000 --- a/apps/scandic-web/types/components/current/asides/puffs.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Puff } from "@/types/requests/puff" -import type { Node } from "@/types/requests/utils/edges" - -export type PuffsProps = { - puffs: Node[] -} diff --git a/apps/scandic-web/types/components/current/header.ts b/apps/scandic-web/types/components/current/header.ts deleted file mode 100644 index 598ae1f04..000000000 --- a/apps/scandic-web/types/components/current/header.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type HeaderProps = { - uid: string -} diff --git a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/client.ts b/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/client.ts deleted file mode 100644 index fdfc6be78..000000000 --- a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/client.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { JumpToData, JumpToProps, LocationMatchResultsState } from "./" - -export type ClientProps = { - results: LocationMatchResultsState - latest: NonNullable - setFilterString: (filter: string | null) => void - onAction: JumpToProps["onAction"] -} diff --git a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/index.ts b/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/index.ts deleted file mode 100644 index 1c27dd852..000000000 --- a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { ReactNode } from "react" -import type { Key } from "react-aria-components" - -export type JumpToDataItem = { - id: Key - displayName: string - type: "hotels" | "cities" - description: string - url: string - rankingNames: string[] - rankingKeywords: string[] -} - -export type JumpToData = JumpToDataItem[] - -export type JumpToHistory = { - id: JumpToDataItem["id"] - type: JumpToDataItem["type"] -}[] - -export type JumpToProps = { - data: T - history: JumpToHistory - onAction: (id: T[number]["id"]) => void - onClearHistory: () => void -} - -export type LocationMatch = { - id: Key - displayName: string - type: string - description?: string - url?: string - closesModal?: boolean - icon?: ReactNode -} - -export type ScoringMatch = LocationMatch & { - score: number -} - -export type LocationMatchResult = { - id: Key - name: string - children: LocationMatch[] -} - -export type LocationMatchResults = LocationMatchResult[] -export type LocationMatchResultsState = LocationMatchResults | null diff --git a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/resolver.ts b/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/resolver.ts deleted file mode 100644 index 93909f7bf..000000000 --- a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/resolver.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { getJumpToData } from "@/lib/trpc/memoizedRequests" - -export type JumpToResolverProps = { - dataPromise: ReturnType -} diff --git a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/results.ts b/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/results.ts deleted file mode 100644 index 0f6259910..000000000 --- a/apps/scandic-web/types/components/destinationOverviewPage/jumpTo/results.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { ClientProps } from "./client" - -export type ResultsProps = Pick & { - results: NonNullable - "aria-label": string - renderEmptyState?: boolean -} diff --git a/apps/scandic-web/types/components/form/filterChip.ts b/apps/scandic-web/types/components/form/filterChip.ts deleted file mode 100644 index 062d398f4..000000000 --- a/apps/scandic-web/types/components/form/filterChip.ts +++ /dev/null @@ -1,17 +0,0 @@ -type FilterChipType = "checkbox" | "radio" - -export interface FilterChipProps { - Icon?: React.ElementType - iconHeight?: number - iconWidth?: number - id?: string - label: string - name: string - type: FilterChipType - value?: string - selected?: boolean - disabled?: boolean - hasTooltip?: boolean -} - -export type FilterChipCheckboxProps = Omit diff --git a/apps/scandic-web/types/components/header/logo.ts b/apps/scandic-web/types/components/header/logo.ts deleted file mode 100644 index d44edfb21..000000000 --- a/apps/scandic-web/types/components/header/logo.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type LogoProps = { - height: number - src: string - title: string - width: number -} diff --git a/apps/scandic-web/types/components/header/topMenuButton.ts b/apps/scandic-web/types/components/header/topMenuButton.ts deleted file mode 100644 index 20589bc4c..000000000 --- a/apps/scandic-web/types/components/header/topMenuButton.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface TopMenuButtonProps - extends React.ButtonHTMLAttributes {} diff --git a/apps/scandic-web/types/components/hotelPage/map/dynamicMap.ts b/apps/scandic-web/types/components/hotelPage/map/dynamicMap.ts deleted file mode 100644 index 7b8595cc9..000000000 --- a/apps/scandic-web/types/components/hotelPage/map/dynamicMap.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { PointOfInterest } from "@/types/hotel" -import type { Coordinates } from "../../maps/coordinates" - -export interface DynamicMapProps { - apiKey: string - hotelName: string - coordinates: Coordinates - pointsOfInterest: PointOfInterest[] - mapId: string -} diff --git a/apps/scandic-web/types/components/hotelPage/map/mapWithCardWrapper.ts b/apps/scandic-web/types/components/hotelPage/map/mapWithCardWrapper.ts deleted file mode 100644 index 326c6b0f9..000000000 --- a/apps/scandic-web/types/components/hotelPage/map/mapWithCardWrapper.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Coordinates } from "@/types/components/maps/coordinates" -import type { PointOfInterest } from "@/types/hotel" - -export interface MapWithCardWrapperProps { - coordinates: Coordinates - hotelName: string - topThreePois: PointOfInterest[] -} diff --git a/apps/scandic-web/types/components/hotelReservation/enterDetails/room.ts b/apps/scandic-web/types/components/hotelReservation/enterDetails/room.ts deleted file mode 100644 index 87bbf459d..000000000 --- a/apps/scandic-web/types/components/hotelReservation/enterDetails/room.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface SelectedRoomProps { - hotelId: string - roomType: string - roomTypeCode: string - rateDescription: string - roomIndex: number - searchParamsStr: string -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotePriceListProps.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/hotePriceListProps.ts deleted file mode 100644 index 769edf97f..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotePriceListProps.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { ProductType } from "@/types/trpc/routers/hotel/availability" - -export type HotelPriceListProps = { - hotelId: string - price: ProductType -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/hotelSelectionHeader.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/hotelSelectionHeader.ts deleted file mode 100644 index 5384723d9..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectRate/hotelSelectionHeader.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { Hotel } from "@/types/hotel" - -export type HotelSelectionHeaderProps = { - hotel: Hotel -} diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/imageGallery.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/imageGallery.ts deleted file mode 100644 index 576326374..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectRate/imageGallery.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { ApiImage } from "@/types/hotel" - -export type ImageGalleryProps = { images?: ApiImage[]; title: string } diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/roomSelection.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/roomSelection.ts deleted file mode 100644 index 3f854bbfe..000000000 --- a/apps/scandic-web/types/components/hotelReservation/selectRate/roomSelection.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { Room } from "@/types/hotel" -import type { RoomsAvailability } from "@/types/trpc/routers/hotel/roomAvailability" -import type { RoomPackageCodes, RoomPackages } from "./roomFilter" - -export interface SelectRateProps { - availablePackages: RoomPackages - hotelType: string | undefined - isUserLoggedIn: boolean - roomsAvailability: RoomsAvailability | null - roomCategories: Room[] - vat: number -} diff --git a/apps/scandic-web/types/components/myPages/header.ts b/apps/scandic-web/types/components/myPages/header.ts deleted file mode 100644 index 1af4abf21..000000000 --- a/apps/scandic-web/types/components/myPages/header.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { HeadingProps } from "@/components/TempDesignSystem/Text/Title/title" - -export type HeaderProps = { - link?: { - href: string - text: string - } - preamble?: string | null - textTransform?: HeadingProps["textTransform"] - title?: string | null - topTitle?: boolean -} diff --git a/apps/scandic-web/types/components/myPages/myProfile/layout.ts b/apps/scandic-web/types/components/myPages/myProfile/layout.ts deleted file mode 100644 index 3042210f1..000000000 --- a/apps/scandic-web/types/components/myPages/myProfile/layout.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type ProfileLayoutProps = { - communication: React.ReactNode - creditCards: React.ReactNode - membershipCards: React.ReactNode - profile: React.ReactNode -} diff --git a/apps/scandic-web/types/components/myPages/stays/page.ts b/apps/scandic-web/types/components/myPages/stays/page.ts deleted file mode 100644 index b4e997f2e..000000000 --- a/apps/scandic-web/types/components/myPages/stays/page.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Stay } from "@/server/routers/user/output" - -export type Page = { - data: Stay[] - nextCursor?: string -} diff --git a/apps/scandic-web/types/enums/hotelListing.ts b/apps/scandic-web/types/enums/hotelListing.ts deleted file mode 100644 index 5c16a2c19..000000000 --- a/apps/scandic-web/types/enums/hotelListing.ts +++ /dev/null @@ -1,6 +0,0 @@ -export namespace HotelListingEnum { - export const enum RatePlanSet { - PUBLIC = "PUBLIC", - MEMBER = "MEMBER", - } -} diff --git a/apps/scandic-web/types/next/error.ts b/apps/scandic-web/types/next/error.ts deleted file mode 100644 index 6694d1357..000000000 --- a/apps/scandic-web/types/next/error.ts +++ /dev/null @@ -1,8 +0,0 @@ -interface NextError extends Error { - digest?: string -} - -export interface ErrorPage { - error: NextError - reset: () => void -} diff --git a/apps/scandic-web/types/requests/myPages/breadcrumbs.ts b/apps/scandic-web/types/requests/myPages/breadcrumbs.ts deleted file mode 100644 index b24500e40..000000000 --- a/apps/scandic-web/types/requests/myPages/breadcrumbs.ts +++ /dev/null @@ -1,61 +0,0 @@ -import type { Lang } from "@/constants/languages" -import type { System } from "../system" -import type { AllRequestResponse } from "../utils/all" -import type { Edges } from "../utils/edges" - -interface MyPagesBreadcrumbs { - web?: { - breadcrumbs?: { - title: string - parentsConnection: Edges<{ - web: { - breadcrumbs: { - title: string - } - system: { - locale: Lang - uid: string - } - } - url: string - }> - } - system: { - uid: string - } - } -} - -interface AllPageResponse extends AllRequestResponse {} - -export interface GetMyPagesBreadcrumbsData { - all_account_page: AllPageResponse -} - -export interface GetLoyaltyPageBreadcrumbsData { - all_loyalty_page: AllPageResponse -} - -export interface GetBreadcrumbsItems { - items: MyPagesBreadcrumbRefs[] -} - -interface MyPagesBreadcrumbRefs extends System { - web?: { - breadcrumbs?: { - parentsConnection: Edges - title: string - } - } -} - -interface AllPageRefsResponse - extends AllRequestResponse {} - -export interface GetMyPagesBreadcrumbsRefsData { - all_account_page: AllPageRefsResponse -} - -export interface GetLoyaltyPageBreadcrumbsRefsData { - all_loyalty_page: AllPageRefsResponse -} diff --git a/apps/scandic-web/types/requests/pageLinks.ts b/apps/scandic-web/types/requests/pageLinks.ts deleted file mode 100644 index 1e40320f3..000000000 --- a/apps/scandic-web/types/requests/pageLinks.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum PageLinkEnum { - AccountPage = "AccountPage", - ContentPage = "ContentPage", - LoyaltyPage = "LoyaltyPage", -} diff --git a/apps/scandic-web/types/requests/rte.ts b/apps/scandic-web/types/requests/rte.ts deleted file mode 100644 index f6e18b41a..000000000 --- a/apps/scandic-web/types/requests/rte.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum RTEEmbedsEnum { - AccountPage = "AccountPage", - ContentPage = "ContentPage", - LoyaltyPage = "LoyaltyPage", - ImageContainer = "ImageContainer", -} diff --git a/apps/scandic-web/types/trpc/routers/hotel/filter.ts b/apps/scandic-web/types/trpc/routers/hotel/filter.ts deleted file mode 100644 index 5f4108b68..000000000 --- a/apps/scandic-web/types/trpc/routers/hotel/filter.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { z } from "zod" - -import type { hotelFilterSchema } from "@/server/routers/hotels/schemas/hotelFilter" - -export type HotelFilter = z.output diff --git a/apps/scandic-web/utils/dateFormatting.ts b/apps/scandic-web/utils/dateFormatting.ts index d1549335f..3a7d48bfc 100644 --- a/apps/scandic-web/utils/dateFormatting.ts +++ b/apps/scandic-web/utils/dateFormatting.ts @@ -16,16 +16,6 @@ export function getLocalizedMonthName(monthIndex: number, lang: Lang) { return monthName.charAt(0).toUpperCase() + monthName.slice(1) } -export function getNights(start: string, end: string) { - const range = [] - let current = d(start) - while (current.isBefore(end)) { - range.push(current) - current = current.add(1, "days") - } - return range -} - export function getNumberOfNights(startDate: Date, endDate: Date) { return d(endDate).diff(startDate, "day") } diff --git a/apps/scandic-web/utils/generateTag.ts b/apps/scandic-web/utils/generateTag.ts index a0055d421..f85fe72fc 100644 --- a/apps/scandic-web/utils/generateTag.ts +++ b/apps/scandic-web/utils/generateTag.ts @@ -100,16 +100,6 @@ export function generateLoyaltyConfigTag( return `${lang}:loyalty_config:${contentTypeUid}:${id}` } -/** - * Function to generate tags for service tokens - * - * @param serviceTokenScope scope of service token - * @returns string - */ -export function generateServiceTokenTag(scopes: string[]) { - return `service_token:${scopes.join("-")}` -} - /** * Function to generate tags for hotel page urls * diff --git a/apps/scandic-web/utils/isBrowser.ts b/apps/scandic-web/utils/isBrowser.ts deleted file mode 100644 index c6e4fac54..000000000 --- a/apps/scandic-web/utils/isBrowser.ts +++ /dev/null @@ -1 +0,0 @@ -export const isBrowser = typeof window !== "undefined" && !("Deno" in window) diff --git a/apps/scandic-web/utils/safeTry.ts b/apps/scandic-web/utils/safeTry.ts index 9b986a17f..d3bb81596 100644 --- a/apps/scandic-web/utils/safeTry.ts +++ b/apps/scandic-web/utils/safeTry.ts @@ -9,11 +9,3 @@ export async function safeTry(func: Promise): SafeTryResult { return [undefined, err] } } - -export function safeTrySync(func: () => T): Awaited> { - try { - return [func(), undefined] - } catch (err) { - return [undefined, err] - } -} diff --git a/apps/scandic-web/utils/tabbable.ts b/apps/scandic-web/utils/tabbable.ts deleted file mode 100644 index 93c49de4e..000000000 --- a/apps/scandic-web/utils/tabbable.ts +++ /dev/null @@ -1,67 +0,0 @@ -/*! - * Adapted from jQuery UI core - * - * http://jqueryui.com - * - * Copyright 2014 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/ui-core/ - */ - -const tabbableNode = /input|select|textarea|button|object/ - -function hidesContents(element: HTMLElement) { - const zeroSize = element.offsetWidth <= 0 && element.offsetHeight <= 0 - - // If the node is empty, this is good enough - if (zeroSize && !element.innerHTML) return true - - // Otherwise we need to check some styles - const style = window.getComputedStyle(element) - return ( - style.getPropertyValue("display") === "none" || - (zeroSize && style.getPropertyValue("overflow") !== "visible") - ) -} - -function visible(element: any) { - let parentElement = element - while (parentElement) { - if (parentElement === document.body) break - if (hidesContents(parentElement)) return false - parentElement = parentElement.parentNode - } - return true -} - -export function focusable(element: HTMLElement, isTabIndexNotNaN: boolean) { - const nodeName = element.nodeName.toLowerCase() - const res = - //@ts-ignore - (tabbableNode.test(nodeName) && !element.disabled) || - //@ts-ignore - (nodeName === "a" ? element.href || isTabIndexNotNaN : isTabIndexNotNaN) - return res && visible(element) -} - -export function tabbable(element: HTMLElement) { - const tabIndexAttr = element.getAttribute("tabindex") - const tabIndex = tabIndexAttr !== null ? Number(tabIndexAttr) : undefined - const isTabIndexNaN = tabIndex === undefined || isNaN(tabIndex) - - return (isTabIndexNaN || tabIndex >= 0) && focusable(element, !isTabIndexNaN) -} - -export default function findTabbableDescendants( - element: HTMLElement | null | undefined -): HTMLElement[] { - if (!(element instanceof HTMLElement)) { - return [] - } - - return Array.from(element.querySelectorAll("*")) - .filter((el): el is HTMLElement => el instanceof HTMLElement) - .filter(tabbable) -}