From c53e6ef1872f867084bced0e687adc3f3e04beda Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Tue, 26 Aug 2025 11:48:54 +0000 Subject: [PATCH] Merged in chore/move-use-scroll-to-top (pull request #2705) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit chore: Move useScrollToTop to common package * Move useScrollToTop to common package Approved-by: Joakim Jäderberg --- .../ContentType/DestinationPage/CityListing/index.tsx | 2 +- .../ContentType/DestinationPage/HotelListing/index.tsx | 2 +- .../components/ContentType/DestinationPage/Map/index.tsx | 2 +- .../components/HotelReservation/HotelCardListing/index.tsx | 2 +- .../SelectHotelMap/SelectHotelMapContent/index.tsx | 2 +- .../Rooms/RoomsHeader/BookingCodeFilter/index.tsx | 2 +- .../BookingWidget/GuestsRoomsPicker/Counter/index.tsx | 4 ++-- .../lib/components/BookingWidget/GuestsRoomsPicker/Form.tsx | 2 +- packages/booking-flow/lib/components/Contact/index.tsx | 2 +- {apps/scandic-web => packages/common}/hooks/useScrollToTop.ts | 0 packages/trpc/lib/routers/hotels/output.ts | 2 +- packages/trpc/lib/routers/hotels/query.ts | 2 +- packages/trpc/lib/routers/hotels/schemas/productTypePrice.ts | 3 +-- 13 files changed, 13 insertions(+), 14 deletions(-) rename {apps/scandic-web => packages/common}/hooks/useScrollToTop.ts (100%) diff --git a/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx index 8a5716879..b9c8d9f60 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx @@ -4,6 +4,7 @@ import { useRef } from "react" import { useIntl } from "react-intl" import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert" +import { useScrollToTop } from "@scandic-hotels/common/hooks/useScrollToTop" import { Alert } from "@scandic-hotels/design-system/Alert" import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton" import { Typography } from "@scandic-hotels/design-system/Typography" @@ -11,7 +12,6 @@ import { Typography } from "@scandic-hotels/design-system/Typography" import { useDestinationDataStore } from "@/stores/destination-data" import DestinationFilterAndSort from "@/components/DestinationFilterAndSort" -import { useScrollToTop } from "@/hooks/useScrollToTop" import CityListingItem from "./CityListingItem" import CityListingSkeleton from "./CityListingSkeleton" diff --git a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx index 42fbaadae..daf4e8430 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx @@ -6,6 +6,7 @@ import { useEffect, useRef, useState } from "react" import { useIntl } from "react-intl" import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert" +import { useScrollToTop } from "@scandic-hotels/common/hooks/useScrollToTop" import { Alert } from "@scandic-hotels/design-system/Alert" import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" @@ -15,7 +16,6 @@ import { Typography } from "@scandic-hotels/design-system/Typography" import { useDestinationDataStore } from "@/stores/destination-data" import DestinationFilterAndSort from "@/components/DestinationFilterAndSort" -import { useScrollToTop } from "@/hooks/useScrollToTop" import HotelListingItem from "./HotelListingItem" import HotelListingSkeleton from "./HotelListingSkeleton" diff --git a/apps/scandic-web/components/ContentType/DestinationPage/Map/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/Map/index.tsx index 3690ef34e..396c1611d 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/Map/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/Map/index.tsx @@ -11,6 +11,7 @@ import { } from "react" import { useIntl } from "react-intl" +import { useScrollToTop } from "@scandic-hotels/common/hooks/useScrollToTop" import { debounce } from "@scandic-hotels/common/utils/debounce" import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" @@ -20,7 +21,6 @@ import { useDestinationDataStore } from "@/stores/destination-data" import { useDestinationPageHotelsMapStore } from "@/stores/destination-page-hotels-map" import DestinationFilterAndSort from "@/components/DestinationFilterAndSort" -import { useScrollToTop } from "@/hooks/useScrollToTop" import DynamicMap from "./DynamicMap" import MapContent from "./MapContent" diff --git a/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx b/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx index d6a66d3a2..0702def35 100644 --- a/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx +++ b/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx @@ -13,6 +13,7 @@ import { alternativeHotelsMap, selectHotelMap, } from "@scandic-hotels/common/constants/routes/hotelReservation" +import { useScrollToTop } from "@scandic-hotels/common/hooks/useScrollToTop" import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton" import { HotelCard } from "@scandic-hotels/design-system/HotelCard" @@ -21,7 +22,6 @@ import { useHotelsMapStore } from "@/stores/hotels-map" import HotelDetailsSidePeek from "@/components/SidePeeks/HotelDetailsSidePeek" import useLang from "@/hooks/useLang" -import { useScrollToTop } from "@/hooks/useScrollToTop" import { isValidClientSession } from "@/utils/clientSession" import { mapApiImagesToGalleryImages } from "@/utils/imageGallery" diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx index 4d668d557..c1a332820 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx @@ -14,6 +14,7 @@ import { alternativeHotels, selectHotel, } from "@scandic-hotels/common/constants/routes/hotelReservation" +import { useScrollToTop } from "@scandic-hotels/common/hooks/useScrollToTop" import { debounce } from "@scandic-hotels/common/utils/debounce" import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton" import { Button } from "@scandic-hotels/design-system/Button" @@ -28,7 +29,6 @@ import { useHotelsMapStore } from "@/stores/hotels-map" import { RoomCardSkeleton } from "@/components/HotelReservation/RoomCardSkeleton/RoomCardSkeleton" import { useIsUserLoggedIn } from "@/hooks/useIsUserLoggedIn" import useLang from "@/hooks/useLang" -import { useScrollToTop } from "@/hooks/useScrollToTop" import { mapApiImagesToGalleryImages } from "@/utils/imageGallery" import { trackEvent } from "@/utils/tracking/base" diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsHeader/BookingCodeFilter/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsHeader/BookingCodeFilter/index.tsx index 914af78cb..f94d0e923 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsHeader/BookingCodeFilter/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomsHeader/BookingCodeFilter/index.tsx @@ -13,11 +13,11 @@ import { import { useIntl } from "react-intl" import { BookingCodeFilterEnum } from "@scandic-hotels/booking-flow/stores/bookingCode-filter" +import { RateTypeEnum } from "@scandic-hotels/common/constants/rateType" import { ChipButton } from "@scandic-hotels/design-system/ChipButton" import { IconButton } from "@scandic-hotels/design-system/IconButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" -import { RateTypeEnum } from "@scandic-hotels/common/constants/rateType" import { useSelectRateContext } from "@/contexts/SelectRate/SelectRateContext" import { useBreakpoint } from "@/hooks/useBreakpoint" diff --git a/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Counter/index.tsx b/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Counter/index.tsx index 8bca160c2..73c71ae2c 100644 --- a/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Counter/index.tsx +++ b/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Counter/index.tsx @@ -1,10 +1,10 @@ "use client" +import { IconButton } from "@scandic-hotels/design-system/IconButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" +import { Typography } from "@scandic-hotels/design-system/Typography" import styles from "./counter.module.css" -import { IconButton } from "@scandic-hotels/design-system/IconButton" -import { Typography } from "@scandic-hotels/design-system/Typography" type CounterProps = { count: number diff --git a/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Form.tsx b/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Form.tsx index d7978eb0a..6894bfec4 100644 --- a/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Form.tsx +++ b/packages/booking-flow/lib/components/BookingWidget/GuestsRoomsPicker/Form.tsx @@ -4,6 +4,7 @@ import { useCallback, useEffect } from "react" import { useFormContext, useWatch } from "react-hook-form" import { useIntl } from "react-intl" +import { Button } from "@scandic-hotels/design-system/Button" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Tooltip } from "@scandic-hotels/design-system/Tooltip" import { Typography } from "@scandic-hotels/design-system/Typography" @@ -15,7 +16,6 @@ import styles from "./guests-rooms-picker.module.css" import type { GuestsRoom as TGuestsRoom } from ".." import type { BookingWidgetSchema } from "../Client" -import { Button } from "@scandic-hotels/design-system/Button" const MAX_ROOMS = 4 diff --git a/packages/booking-flow/lib/components/Contact/index.tsx b/packages/booking-flow/lib/components/Contact/index.tsx index 9878b1bb7..66f9e2680 100644 --- a/packages/booking-flow/lib/components/Contact/index.tsx +++ b/packages/booking-flow/lib/components/Contact/index.tsx @@ -6,13 +6,13 @@ import FacebookIcon from "@scandic-hotels/design-system/Icons/FacebookIcon" import InstagramIcon from "@scandic-hotels/design-system/Icons/InstagramIcon" import Image from "@scandic-hotels/design-system/Image" import Link from "@scandic-hotels/design-system/Link" +import { Typography } from "@scandic-hotels/design-system/Typography" import useLang from "../../hooks/useLang" import styles from "./contact.module.css" import type { Hotel } from "@scandic-hotels/trpc/types/hotel" -import { Typography } from "@scandic-hotels/design-system/Typography" interface ContactProps { hotel: Hotel diff --git a/apps/scandic-web/hooks/useScrollToTop.ts b/packages/common/hooks/useScrollToTop.ts similarity index 100% rename from apps/scandic-web/hooks/useScrollToTop.ts rename to packages/common/hooks/useScrollToTop.ts diff --git a/packages/trpc/lib/routers/hotels/output.ts b/packages/trpc/lib/routers/hotels/output.ts index dd56ea3ed..f412ef2e9 100644 --- a/packages/trpc/lib/routers/hotels/output.ts +++ b/packages/trpc/lib/routers/hotels/output.ts @@ -1,11 +1,11 @@ import { z } from "zod" +import { RateTypeEnum } from "@scandic-hotels/common/constants/rateType" import { logger } from "@scandic-hotels/common/logger" import { toLang } from "@scandic-hotels/common/utils/languages" import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator" import { RateEnum } from "../../enums/rate" -import { RateTypeEnum } from "../../../../common/constants/rateType" import { RoomPackageCodeEnum } from "../../enums/roomFilter" import { AvailabilityEnum } from "../../enums/selectHotel" import { diff --git a/packages/trpc/lib/routers/hotels/query.ts b/packages/trpc/lib/routers/hotels/query.ts index b95836316..67381757e 100644 --- a/packages/trpc/lib/routers/hotels/query.ts +++ b/packages/trpc/lib/routers/hotels/query.ts @@ -1,4 +1,5 @@ import { Lang } from "@scandic-hotels/common/constants/language" +import { RateTypeEnum } from "@scandic-hotels/common/constants/rateType" import { getCacheClient } from "@scandic-hotels/common/dataCache" import { dt } from "@scandic-hotels/common/dt" import { createLogger } from "@scandic-hotels/common/logger/createLogger" @@ -10,7 +11,6 @@ import * as api from "../../api" import { SEARCH_TYPE_REDEMPTION } from "../../constants/booking" import { BreakfastPackageEnum } from "../../enums/breakfast" import { RateEnum } from "../../enums/rate" -import { RateTypeEnum } from "../../../../common/constants/rateType" import { AvailabilityEnum } from "../../enums/selectHotel" import { badRequestError, unauthorizedError } from "../../errors" import { diff --git a/packages/trpc/lib/routers/hotels/schemas/productTypePrice.ts b/packages/trpc/lib/routers/hotels/schemas/productTypePrice.ts index 6a805314f..cad95b1be 100644 --- a/packages/trpc/lib/routers/hotels/schemas/productTypePrice.ts +++ b/packages/trpc/lib/routers/hotels/schemas/productTypePrice.ts @@ -1,11 +1,10 @@ import { z } from "zod" import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" +import { RateTypeEnum } from "@scandic-hotels/common/constants/rateType" import { nullableNumberValidator } from "@scandic-hotels/common/utils/zod/numberValidator" import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator" -import { RateTypeEnum } from "../../../../../common/constants/rateType" - export const corporateChequeSchema = z .object({ additionalPricePerStay: nullableNumberValidator,