diff --git a/apps/scandic-web/actions/editProfile.ts b/apps/scandic-web/actions/editProfile.ts index a220c36f2..548a263f8 100644 --- a/apps/scandic-web/actions/editProfile.ts +++ b/apps/scandic-web/actions/editProfile.ts @@ -3,9 +3,9 @@ import { z } from "zod" import * as api from "@scandic-hotels/trpc/api" +import { ApiLang } from "@scandic-hotels/trpc/constants/apiLang" import { countriesMap } from "@scandic-hotels/trpc/constants/countries" -import { ApiLang } from "@/constants/languages" import { getProfile } from "@/lib/trpc/memoizedRequests" import { protectedServerActionProcedure } from "@/server/trpc" diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(confirmation)/booking-confirmation/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(confirmation)/booking-confirmation/page.tsx index 51b60cacc..a2235cded 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(confirmation)/booking-confirmation/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(confirmation)/booking-confirmation/page.tsx @@ -1,11 +1,12 @@ import { cookies } from "next/headers" import { notFound, redirect } from "next/navigation" +import { decrypt } from "@scandic-hotels/trpc/utils/encryption" + import { MEMBERSHIP_FAILED_ERROR } from "@/constants/booking" import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests" import BookingConfirmation from "@/components/HotelReservation/BookingConfirmation" -import { decrypt } from "@/utils/encryption" import type { LangParams, PageArgs } from "@/types/params" diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx index 32c8793f4..39d0b0d27 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx @@ -2,6 +2,9 @@ import { notFound } from "next/navigation" import { getServiceToken } from "@scandic-hotels/common/tokenManager" import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode" +import { getBooking } from "@scandic-hotels/trpc/routers/booking/utils" +import { encrypt } from "@scandic-hotels/trpc/utils/encryption" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" import { PaymentCallbackStatusEnum } from "@/constants/booking" import { @@ -9,13 +12,10 @@ import { details, } from "@/constants/routes/hotelReservation" import { serverClient } from "@/lib/trpc/server" -import { getBooking } from "@/server/routers/booking/utils" import { auth } from "@/auth" import HandleErrorCallback from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleErrorCallback" import HandleSuccessCallback from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleSuccessCallback" -import { encrypt } from "@/utils/encryption" -import { isValidSession } from "@/utils/session" import type { LangParams, PageArgs } from "@/types/params" diff --git a/apps/scandic-web/app/api/web/auth/dtmc/route.ts b/apps/scandic-web/app/api/web/auth/dtmc/route.ts index 5bddd4015..c0b7a1c79 100644 --- a/apps/scandic-web/app/api/web/auth/dtmc/route.ts +++ b/apps/scandic-web/app/api/web/auth/dtmc/route.ts @@ -1,5 +1,7 @@ import { type NextRequest, NextResponse } from "next/server" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" + import { DTMC_SUCCESS_BANNER_KEY } from "@/constants/dtmc" import { linkEmploymentError } from "@/constants/routes/dtmc" import { overview } from "@/constants/routes/myPages" @@ -9,7 +11,6 @@ import { getPublicURL } from "@/server/utils" import { auth } from "@/auth" import { auth as dtmcAuth } from "@/auth.dtmc" import { getLang } from "@/i18n/serverContext" -import { isValidSession } from "@/utils/session" async function linkEmployeeToUser(employeeId: string) { try { diff --git a/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/CallToActions/index.tsx b/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/CallToActions/index.tsx index 28a5e88ea..090acb092 100644 --- a/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/CallToActions/index.tsx +++ b/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/CallToActions/index.tsx @@ -1,6 +1,7 @@ import React from "react" import { Typography } from "@scandic-hotels/design-system/Typography" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" import { dtmcLogin } from "@/constants/routes/dtmc" import { login } from "@/constants/routes/handleAuth" @@ -10,7 +11,6 @@ import { auth } from "@/auth" import ButtonLink from "@/components/ButtonLink" import { getIntl } from "@/i18n" import { getLang } from "@/i18n/serverContext" -import { isValidSession } from "@/utils/session" import styles from "./callToActions.module.css" diff --git a/apps/scandic-web/components/Forms/Edit/Profile/index.tsx b/apps/scandic-web/components/Forms/Edit/Profile/index.tsx index 14edc6cf3..7ed321c24 100644 --- a/apps/scandic-web/components/Forms/Edit/Profile/index.tsx +++ b/apps/scandic-web/components/Forms/Edit/Profile/index.tsx @@ -5,7 +5,9 @@ import { useEffect, useState } from "react" import { FormProvider, useForm } from "react-hook-form" import { useIntl } from "react-intl" -import { getDefaultCountryFromLang, langToApiLang } from "@/constants/languages" +import { langToApiLang } from "@scandic-hotels/trpc/constants/apiLang" + +import { getDefaultCountryFromLang } from "@/constants/languages" import { logout } from "@/constants/routes/handleAuth" import { profile } from "@/constants/routes/myPages" import { trpc } from "@/lib/trpc/client" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/Breakfast/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/Breakfast/index.tsx index 3f8ebc77d..15ae79126 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/Breakfast/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/Breakfast/index.tsx @@ -7,7 +7,7 @@ import { formatPrice } from "@/utils/numberFormatting" import styles from "./breakfast.module.css" -import type { PackageSchema } from "@/types/trpc/routers/booking/confirmation" +import type { PackageSchema } from "@scandic-hotels/trpc/types/bookingConfirmation" interface BreakfastProps { breakfast: PackageSchema | false | undefined diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/RoomDetailsSidePeek/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/RoomDetailsSidePeek/index.tsx index c1b72ed59..ffd23c0ab 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/RoomDetailsSidePeek/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/RoomDetailsSidePeek/index.tsx @@ -5,12 +5,12 @@ import { useIntl } from "react-intl" import { Button } from "@scandic-hotels/design-system/Button" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" +import { getBookedHotelRoom } from "@scandic-hotels/trpc/routers/booking/helpers" import { useBookingConfirmationStore } from "@/stores/booking-confirmation" import { RoomSidePeekContent } from "@/components/SidePeeks/RoomSidePeek/RoomSidePeekContent" import SidePeekSelfControlled from "@/components/TempDesignSystem/SidePeekSelfControlled" -import { getBookedHotelRoom } from "@/utils/booking" interface RoomDetailsSidePeekProps { roomTypeCode: string diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx index 6a4c4e548..5484648a0 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx @@ -11,8 +11,9 @@ import { useSearchHistory } from "@/hooks/useSearchHistory" import { clearPaymentInfoSessionStorage } from "../../EnterDetails/Payment/helpers" import { getTracking } from "./tracking" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" + import type { Room } from "@/types/stores/booking-confirmation" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" export default function Tracking({ bookingConfirmation, diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts index d9e6c30df..b37829f11 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts @@ -13,6 +13,7 @@ import { getSpecialRoomType } from "@/utils/specialRoomType" import { invertedBedTypeMap } from "../../utils" import type { Lang } from "@scandic-hotels/common/constants/language" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { RateDefinition } from "@scandic-hotels/trpc/types/roomAvailability" import { @@ -23,7 +24,6 @@ import { type TrackingSDKPaymentInfo, } from "@/types/components/tracking" import type { Room } from "@/types/stores/booking-confirmation" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" function getRate(cancellationRule: RateDefinition["cancellationRule"] | null) { switch (cancellationRule) { diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts index 5bc11e6f2..f9a8b176d 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts @@ -1,15 +1,16 @@ +import { type IntlShape } from "react-intl" + import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" import { formatPrice } from "@/utils/numberFormatting" -import type { IntlShape } from "react-intl" - -import type { BookingConfirmationRoom } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation" import type { BookingConfirmationSchema, PackageSchema, -} from "@/types/trpc/routers/booking/confirmation" +} from "@scandic-hotels/trpc/types/bookingConfirmation" + +import type { BookingConfirmationRoom } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation" export function mapRoomState( booking: BookingConfirmationSchema, diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleSuccessCallback.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleSuccessCallback.tsx index 96d3808e2..2391037a0 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleSuccessCallback.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleSuccessCallback.tsx @@ -3,7 +3,9 @@ import { useRouter } from "next/navigation" import { useEffect } from "react" -import { BookingStatusEnum, MEMBERSHIP_FAILED_ERROR } from "@/constants/booking" +import { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus" + +import { MEMBERSHIP_FAILED_ERROR } from "@/constants/booking" import LoadingSpinner from "@/components/LoadingSpinner" import { useHandleBookingStatus } from "@/hooks/booking/useHandleBookingStatus" diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx index 5cd879cd5..ff2dab9c5 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx @@ -14,9 +14,10 @@ import { Button } from "@scandic-hotels/design-system/Button" import { Typography } from "@scandic-hotels/design-system/Typography" import { bedTypeMap } from "@scandic-hotels/trpc/constants/bedTypeMap" import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking" +import { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus" import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter" -import { BookingStatusEnum, PAYMENT_METHOD_TITLES } from "@/constants/booking" +import { PAYMENT_METHOD_TITLES } from "@/constants/booking" import { bookingConfirmation } from "@/constants/routes/hotelReservation" import { env } from "@/env/client" import { trpc } from "@/lib/trpc/client" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/RemoveButton.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/RemoveButton.tsx index fce6930fa..0b2356553 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/RemoveButton.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/RemoveButton.tsx @@ -11,8 +11,9 @@ import { toast } from "@/components/TempDesignSystem/Toasts" import useLang from "@/hooks/useLang" import { trackRemoveAncillary } from "@/utils/tracking/myStay" +import type { PackageSchema } from "@scandic-hotels/trpc/types/bookingConfirmation" + import type { Room } from "@/types/stores/my-stay" -import type { PackageSchema } from "@/types/trpc/routers/booking/confirmation" export default function RemoveButton({ refId, diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx index 9636c71b2..2f1512781 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx @@ -16,9 +16,10 @@ import RemoveButton from "./RemoveButton" import styles from "./addedAncillaries.module.css" +import type { PackageSchema } from "@scandic-hotels/trpc/types/bookingConfirmation" + import type { AddedAncillariesProps } from "@/types/components/myPages/myStay/ancillaries" import type { Room } from "@/types/stores/my-stay" -import type { PackageSchema } from "@/types/trpc/routers/booking/confirmation" export function AddedAncillaries({ ancillaries, diff --git a/apps/scandic-web/components/HotelReservation/MyStay/GuestDetails/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/GuestDetails/index.tsx index 7aad76df2..f4277974d 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/GuestDetails/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/GuestDetails/index.tsx @@ -24,13 +24,14 @@ import ModifyContact from "../ModifyContact" import styles from "./guestDetails.module.css" +import type { Guest } from "@scandic-hotels/trpc/routers/booking/output" + import { type ModifyContactSchema, modifyContactSchema, } from "@/types/components/hotelReservation/myStay/modifyContact" import { MODAL_STEPS } from "@/types/components/hotelReservation/myStay/myStay" import type { SafeUser } from "@/types/user" -import type { Guest } from "@/server/routers/booking/output" interface GuestDetailsProps { refId: string diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ModifyContact/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ModifyContact/index.tsx index 8cfaddcc5..151d1d196 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ModifyContact/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ModifyContact/index.tsx @@ -10,7 +10,7 @@ import Body from "@/components/TempDesignSystem/Text/Body" import styles from "./modifyContact.module.css" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" interface ModifyContactProps { guest: BookingConfirmation["booking"]["guest"] diff --git a/apps/scandic-web/components/HotelReservation/MyStay/PriceType/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/PriceType/index.tsx index 053395b22..826233e09 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/PriceType/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/PriceType/index.tsx @@ -5,8 +5,9 @@ import Points from "./Points" import Price from "./Price" import Vouchers from "./Vouchers" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" + import { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" interface PriceTypeProps extends Pick< diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Receipt/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Receipt/index.tsx index 4417f3fc5..3db661b20 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Receipt/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Receipt/index.tsx @@ -5,6 +5,7 @@ import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import { dt } from "@scandic-hotels/common/dt" import ScandicLogoIcon from "@scandic-hotels/design-system/Icons/ScandicLogoIcon" import { Typography } from "@scandic-hotels/design-system/Typography" +import { parseRefId } from "@scandic-hotels/trpc/utils/refId" import { findBooking, @@ -16,7 +17,6 @@ import { import { getIntl } from "@/i18n" import { isLoggedInUser } from "@/utils/isLoggedInUser" import * as maskValue from "@/utils/maskValue" -import { parseRefId } from "@/utils/refId" import AdditionalInfoForm from "../../FindMyBooking/AdditionalInfoForm" import accessBooking, { @@ -31,7 +31,7 @@ import Tracking from "./tracking" import styles from "./receipt.module.css" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" export async function Receipt({ refId }: { refId: string }) { const { confirmationNumber, lastName } = parseRefId(refId) diff --git a/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.test.ts b/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.test.ts index 1ca1b0df2..a8253d79c 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.test.ts +++ b/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.test.ts @@ -8,8 +8,9 @@ import accessBooking, { ERROR_UNAUTHORIZED, } from "./accessBooking" +import type { Guest } from "@scandic-hotels/trpc/routers/booking/output" + import type { SafeUser } from "@/types/user" -import type { Guest } from "@/server/routers/booking/output" describe("Access booking", () => { describe("for logged in booking", () => { diff --git a/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.ts b/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.ts index 0076ba447..9eb71defd 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.ts +++ b/apps/scandic-web/components/HotelReservation/MyStay/accessBooking.ts @@ -1,5 +1,6 @@ +import type { Guest } from "@scandic-hotels/trpc/routers/booking/output" + import type { SafeUser } from "@/types/user" -import type { Guest } from "@/server/routers/booking/output" export { ACCESS_GRANTED, diff --git a/apps/scandic-web/components/HotelReservation/MyStay/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/index.tsx index b7627299d..b47394e1e 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/index.tsx @@ -4,6 +4,7 @@ import { notFound } from "next/navigation" import { dt } from "@scandic-hotels/common/dt" import { Typography } from "@scandic-hotels/design-system/Typography" import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" +import { parseRefId } from "@scandic-hotels/trpc/utils/refId" import { env } from "@/env/server" import { @@ -35,14 +36,13 @@ import { getIntl } from "@/i18n" import MyStayProvider from "@/providers/MyStay" import { isLoggedInUser } from "@/utils/isLoggedInUser" import * as maskValue from "@/utils/maskValue" -import { parseRefId } from "@/utils/refId" import { getCurrentWebUrl } from "@/utils/url" import styles from "./index.module.css" import type { Lang } from "@scandic-hotels/common/constants/language" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" import type { SafeUser } from "@/types/user" export default async function MyStay(props: { diff --git a/apps/scandic-web/components/HotelReservation/MyStay/utils/mapRoomDetails.ts b/apps/scandic-web/components/HotelReservation/MyStay/utils/mapRoomDetails.ts index c644d1b70..3e6bd896b 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/utils/mapRoomDetails.ts +++ b/apps/scandic-web/components/HotelReservation/MyStay/utils/mapRoomDetails.ts @@ -1,20 +1,21 @@ import { dt } from "@scandic-hotels/common/dt" +import { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus" import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" import { PackageTypeEnum } from "@scandic-hotels/trpc/enums/packages" import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter" -import { BookingStatusEnum, CancellationRuleEnum } from "@/constants/booking" +import { CancellationRuleEnum } from "@/constants/booking" import { convertToChildType } from "../../utils/convertToChildType" import { getPriceType } from "../../utils/getPriceType" import { formatChildBedPreferences } from "../utils" import type { RateEnum } from "@scandic-hotels/trpc/enums/rate" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { Room } from "@scandic-hotels/trpc/types/hotel" import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast" import type { Room as MyStayRoom } from "@/types/stores/my-stay" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" interface MapRoomDetailsParams { booking: BookingConfirmation["booking"] diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts b/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts index 85a1d149a..d418738d3 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts @@ -1,13 +1,5 @@ import { AvailabilityEnum } from "@scandic-hotels/trpc/enums/selectHotel" import { generateChildrenString } from "@scandic-hotels/trpc/routers/hotels/helpers" -import { - type AdditionalData, - type Hotel, -} from "@scandic-hotels/trpc/types/hotel" -import { - type HotelLocation, - type Location, -} from "@scandic-hotels/trpc/types/locations" import { getHotel } from "@/lib/trpc/memoizedRequests" import { serverClient } from "@/lib/trpc/server" @@ -16,6 +8,11 @@ import { getLang } from "@/i18n/serverContext" import type { HotelsAvailabilityItem } from "@scandic-hotels/trpc/types/availability" import type { Child } from "@scandic-hotels/trpc/types/child" +import type { AdditionalData, Hotel } from "@scandic-hotels/trpc/types/hotel" +import type { + HotelLocation, + Location, +} from "@scandic-hotels/trpc/types/locations" import type { AlternativeHotelsAvailabilityInput, diff --git a/apps/scandic-web/components/HotelReservation/utils/convertToChildType.ts b/apps/scandic-web/components/HotelReservation/utils/convertToChildType.ts index 9783f072d..2d5153640 100644 --- a/apps/scandic-web/components/HotelReservation/utils/convertToChildType.ts +++ b/apps/scandic-web/components/HotelReservation/utils/convertToChildType.ts @@ -1,9 +1,8 @@ import { ChildBedMapEnum } from "@scandic-hotels/trpc/enums/childBedMapEnum" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { Child } from "@scandic-hotels/trpc/types/child" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" - export function convertToChildType( childrenAges: number[], childBedPreferences: BookingConfirmation["booking"]["childBedPreferences"] diff --git a/apps/scandic-web/components/ProtectedLayout.tsx b/apps/scandic-web/components/ProtectedLayout.tsx index 15ebffc35..495cb271e 100644 --- a/apps/scandic-web/components/ProtectedLayout.tsx +++ b/apps/scandic-web/components/ProtectedLayout.tsx @@ -1,13 +1,14 @@ import { headers } from "next/headers" import { redirect } from "next/navigation" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" + import { overview } from "@/constants/routes/myPages" import { getProfile } from "@/lib/trpc/memoizedRequests" import { auth } from "@/auth" import { getIntl } from "@/i18n" import { getLang } from "@/i18n/serverContext" -import { isValidSession } from "@/utils/session" export async function ProtectedLayout({ children }: React.PropsWithChildren) { const intl = await getIntl() diff --git a/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx b/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx index 14d0ed0e2..5d5ea9065 100644 --- a/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx +++ b/apps/scandic-web/components/SidePeeks/BookedRoomSidePeek/index.tsx @@ -25,6 +25,7 @@ import RoomDetails from "./RoomDetails" import styles from "./bookedRoomSidePeek.module.css" +import type { BookingConfirmationSchema } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { Child } from "@scandic-hotels/trpc/types/child" import type { Room as HotelRoom } from "@scandic-hotels/trpc/types/hotel" import type { Packages } from "@scandic-hotels/trpc/types/packages" @@ -32,7 +33,6 @@ import type { Packages } from "@scandic-hotels/trpc/types/packages" import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast" import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType" import type { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay" -import type { BookingConfirmationSchema } from "@/types/trpc/routers/booking/confirmation" import type { SafeUser } from "@/types/user" type PartialHotelRoom = Pick< diff --git a/apps/scandic-web/constants/booking.ts b/apps/scandic-web/constants/booking.ts index c52ccf8b0..22c382993 100644 --- a/apps/scandic-web/constants/booking.ts +++ b/apps/scandic-web/constants/booking.ts @@ -17,23 +17,6 @@ import type { } from "@scandic-hotels/trpc/enums/bedType" import type { JSX } from "react" -export enum BookingStatusEnum { - BookingCompleted = "BookingCompleted", - Cancelled = "Cancelled", - CheckedOut = "CheckedOut", - ConfirmedInScorpio = "ConfirmedInScorpio", - CreatedInOhip = "CreatedInOhip", - PaymentAuthorized = "PaymentAuthorized", - PaymentCancelled = "PaymentCancelled", - PaymentError = "PaymentError", - PaymentFailed = "PaymentFailed", - PaymentRegistered = "PaymentRegistered", - PaymentSucceeded = "PaymentSucceeded", - PendingAcceptPriceChange = "PendingAcceptPriceChange", - PendingGuarantee = "PendingGuarantee", - PendingPayment = "PendingPayment", -} - export const FamilyAndFriendsCodes = ["D000029555", "D000029271", "D000029195"] export const bookingSearchTypes = [REDEMPTION] as const diff --git a/apps/scandic-web/constants/languages.ts b/apps/scandic-web/constants/languages.ts index fe398fdf7..5628926a8 100644 --- a/apps/scandic-web/constants/languages.ts +++ b/apps/scandic-web/constants/languages.ts @@ -1,4 +1,5 @@ import { Lang } from "@scandic-hotels/common/constants/language" +import { ApiLang } from "@scandic-hotels/trpc/constants/apiLang" import type { LowerCaseCountryCode } from "@/types/components/form/phone" @@ -51,27 +52,6 @@ export const localeToLang: Record = { "se-NO": Lang.no, } as const -export enum ApiLang { - Da = "Da", - De = "De", - En = "En", - Fi = "Fi", - No = "No", - Sv = "Sv", - Unknown = "Unknown", -} - -type ApiLangKey = keyof typeof ApiLang - -export const langToApiLang: Record = { - [Lang.da]: ApiLang.Da, - [Lang.de]: ApiLang.De, - [Lang.en]: ApiLang.En, - [Lang.fi]: ApiLang.Fi, - [Lang.no]: ApiLang.No, - [Lang.sv]: ApiLang.Sv, -} - export const languageSelect = [ { label: "Danish", value: ApiLang.Da }, { label: "German", value: ApiLang.De }, diff --git a/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts b/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts index 37f0aa1e6..6f4167742 100644 --- a/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts +++ b/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts @@ -2,7 +2,8 @@ import { useRouter } from "next/navigation" import { useCallback, useEffect, useState } from "react" import { useIntl } from "react-intl" -import { BookingStatusEnum } from "@/constants/booking" +import { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus" + import { trpc } from "@/lib/trpc/client" import { toast } from "@/components/TempDesignSystem/Toasts" diff --git a/apps/scandic-web/hooks/booking/useHandleBookingStatus.ts b/apps/scandic-web/hooks/booking/useHandleBookingStatus.ts index 4b340e552..d38f0ae4d 100644 --- a/apps/scandic-web/hooks/booking/useHandleBookingStatus.ts +++ b/apps/scandic-web/hooks/booking/useHandleBookingStatus.ts @@ -6,7 +6,7 @@ import { trpc } from "@/lib/trpc/client" import useLang from "@/hooks/useLang" -import type { BookingStatusEnum } from "@/constants/booking" +import type { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus" export function useHandleBookingStatus({ refId, diff --git a/apps/scandic-web/middlewares/bookingFlow.ts b/apps/scandic-web/middlewares/bookingFlow.ts index e6b2634e6..bd42abaff 100644 --- a/apps/scandic-web/middlewares/bookingFlow.ts +++ b/apps/scandic-web/middlewares/bookingFlow.ts @@ -2,13 +2,13 @@ import { type NextMiddleware, NextResponse } from "next/server" import { findLang } from "@scandic-hotels/common/utils/languages" import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" import { SEARCHTYPE } from "@/constants/booking" import { login } from "@/constants/routes/handleAuth" import { getPublicNextURL } from "@/server/utils" import { auth } from "@/auth" -import { isValidSession } from "@/utils/session" import { getDefaultRequestHeaders } from "./utils" diff --git a/apps/scandic-web/providers/MyStay.tsx b/apps/scandic-web/providers/MyStay.tsx index 5ecae1c7a..cf2b1458b 100644 --- a/apps/scandic-web/providers/MyStay.tsx +++ b/apps/scandic-web/providers/MyStay.tsx @@ -3,8 +3,6 @@ import { notFound } from "next/navigation" import { use, useRef } from "react" import { useIntl } from "react-intl" -import { type RoomCategories } from "@scandic-hotels/trpc/types/hotel" - import { trpc } from "@/lib/trpc/client" import { createMyStayStore } from "@/stores/my-stay" @@ -12,14 +10,15 @@ import { MyStaySkeleton } from "@/components/HotelReservation/MyStay/myStaySkele import { MyStayContext } from "@/contexts/MyStay" import type { Lang } from "@scandic-hotels/common/constants/language" +import type { + BookingConfirmation, + BookingConfirmationSchema, +} from "@scandic-hotels/trpc/types/bookingConfirmation" +import type { RoomCategories } from "@scandic-hotels/trpc/types/hotel" import type { CreditCard } from "@scandic-hotels/trpc/types/user" import type { Packages } from "@/types/components/myPages/myStay/ancillaries" import type { MyStayStore } from "@/types/contexts/my-stay" -import type { - BookingConfirmation, - BookingConfirmationSchema, -} from "@/types/trpc/routers/booking/confirmation" interface MyStayProviderProps { bookingConfirmation: BookingConfirmation diff --git a/apps/scandic-web/server/index.ts b/apps/scandic-web/server/index.ts index ffa5be05c..e87620d44 100644 --- a/apps/scandic-web/server/index.ts +++ b/apps/scandic-web/server/index.ts @@ -1,11 +1,11 @@ /** Routers */ import { router } from "@scandic-hotels/trpc" import { autocompleteRouter } from "@scandic-hotels/trpc/routers/autocomplete" +import { bookingRouter } from "@scandic-hotels/trpc/routers/booking" import { contentstackRouter } from "@scandic-hotels/trpc/routers/contentstack" import { hotelsRouter } from "@scandic-hotels/trpc/routers/hotels" import { partnerRouter } from "@scandic-hotels/trpc/routers/partners" -import { bookingRouter } from "./routers/booking" import { navigationRouter } from "./routers/navigation" import { userRouter } from "./routers/user" diff --git a/apps/scandic-web/server/routers/navigation/mypages/index.ts b/apps/scandic-web/server/routers/navigation/mypages/index.ts index 2f8e5dcb8..4629f2e03 100644 --- a/apps/scandic-web/server/routers/navigation/mypages/index.ts +++ b/apps/scandic-web/server/routers/navigation/mypages/index.ts @@ -4,8 +4,7 @@ import { z } from "zod" import { Lang } from "@scandic-hotels/common/constants/language" import { safeProtectedProcedure } from "@scandic-hotels/trpc/procedures" import { getVerifiedUser } from "@scandic-hotels/trpc/routers/user/utils" - -import { isValidSession } from "@/utils/session" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" import { getPrimaryLinks } from "./getPrimaryLinks" import { getSecondaryLinks } from "./getSecondaryLinks" diff --git a/apps/scandic-web/server/routers/user/query.ts b/apps/scandic-web/server/routers/user/query.ts index 68608182b..d732d1e12 100644 --- a/apps/scandic-web/server/routers/user/query.ts +++ b/apps/scandic-web/server/routers/user/query.ts @@ -9,8 +9,8 @@ import { import { getFriendsMembership } from "@scandic-hotels/trpc/routers/user/helpers" import { getVerifiedUser } from "@scandic-hotels/trpc/routers/user/utils" import { toApiLang } from "@scandic-hotels/trpc/utils" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" -import { isValidSession } from "@/utils/session" import { getMembershipCards } from "@/utils/user" import { diff --git a/apps/scandic-web/server/routers/user/utils.ts b/apps/scandic-web/server/routers/user/utils.ts index 8c3c914c0..d350be58d 100644 --- a/apps/scandic-web/server/routers/user/utils.ts +++ b/apps/scandic-web/server/routers/user/utils.ts @@ -7,14 +7,13 @@ import { getFriendsMembership } from "@scandic-hotels/trpc/routers/user/helpers" import { creditCardsSchema } from "@scandic-hotels/trpc/routers/user/output" import { getVerifiedUser } from "@scandic-hotels/trpc/routers/user/utils" import { toApiLang } from "@scandic-hotels/trpc/utils" +import { encrypt } from "@scandic-hotels/trpc/utils/encryption" import { myBookingPath } from "@/constants/myBooking" import { env } from "@/env/server" import { cache } from "@/utils/cache" -import { encrypt } from "@/utils/encryption" import * as maskValue from "@/utils/maskValue" -import { isValidSession } from "@/utils/session" import { getCurrentWebUrl } from "@/utils/url" import { type FriendTransaction, getStaysSchema, type Stay } from "./output" @@ -23,19 +22,6 @@ import type { Lang } from "@scandic-hotels/common/constants/language" import type { User } from "@scandic-hotels/trpc/types/user" import type { Session } from "next-auth" -export async function getMembershipNumber( - session: Session | null -): Promise { - if (!isValidSession(session)) return undefined - - const verifiedUser = await getVerifiedUser({ session }) - if (!verifiedUser || "error" in verifiedUser) { - return undefined - } - - return verifiedUser.data.membershipNumber -} - export async function getPreviousStays( accessToken: string, limit: number = 10, diff --git a/apps/scandic-web/stores/my-stay/index.ts b/apps/scandic-web/stores/my-stay/index.ts index 80fe957b8..a6531e558 100644 --- a/apps/scandic-web/stores/my-stay/index.ts +++ b/apps/scandic-web/stores/my-stay/index.ts @@ -3,9 +3,10 @@ import { produce } from "immer" import { useContext } from "react" import { create, useStore } from "zustand" +import { getBookedHotelRoom } from "@scandic-hotels/trpc/routers/booking/helpers" + import { mapRoomDetails } from "@/components/HotelReservation/MyStay/utils/mapRoomDetails" import { MyStayContext } from "@/contexts/MyStay" -import { getBookedHotelRoom } from "@/utils/booking" import { calculateTotalPoints, diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/actions/manageBooking.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/actions/manageBooking.ts index fe9acbdcd..de67dae78 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/actions/manageBooking.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/actions/manageBooking.ts @@ -1,4 +1,4 @@ -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" export interface ManageBookingProps extends Pick {} diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/bookingConfirmation.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/bookingConfirmation.ts index 078e1aa68..74868e909 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/bookingConfirmation.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/bookingConfirmation.ts @@ -1,8 +1,8 @@ -import type { Room } from "@scandic-hotels/trpc/types/hotel" import type { BookingConfirmation, BookingConfirmationSchema, -} from "@/types/trpc/routers/booking/confirmation" +} from "@scandic-hotels/trpc/types/bookingConfirmation" +import type { Room } from "@scandic-hotels/trpc/types/hotel" export interface BookingConfirmationProps { refId: string diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/header.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/header.ts index 629bcf4f1..34cb5ab13 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/header.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/header.ts @@ -1,7 +1,6 @@ +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { MutableRefObject } from "react" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" - export interface BookingConfirmationHeaderProps extends Pick { mainRef: MutableRefObject diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/hotelDetails.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/hotelDetails.ts index f121e0aba..1e8400055 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/hotelDetails.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/hotelDetails.ts @@ -1,4 +1,4 @@ -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" export interface BookingConfirmationHotelDetailsProps { hotel: BookingConfirmation["hotel"] diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/promos.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/promos.ts index fd860744c..4ba292c82 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/promos.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/promos.ts @@ -1,3 +1,3 @@ -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" export interface PromosProps extends Pick {} diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms.ts index a9996abbb..b4298504a 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms.ts @@ -1,5 +1,5 @@ +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { Room } from "@scandic-hotels/trpc/types/hotel" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" export interface BookingConfirmationRoomsProps extends Pick { diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms/room.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms/room.ts index bc2ce6b9a..2f1b5679e 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms/room.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/rooms/room.ts @@ -1,4 +1,4 @@ -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" export interface RoomProps { booking: BookingConfirmation["booking"] diff --git a/apps/scandic-web/types/components/hotelReservation/myStay/receipt.ts b/apps/scandic-web/types/components/hotelReservation/myStay/receipt.ts index e8d798794..ca84779a2 100644 --- a/apps/scandic-web/types/components/hotelReservation/myStay/receipt.ts +++ b/apps/scandic-web/types/components/hotelReservation/myStay/receipt.ts @@ -1,5 +1,6 @@ +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { Room } from "@scandic-hotels/trpc/types/hotel" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" + import type { Ancillaries } from "../../myPages/myStay/ancillaries" export interface SpecificationProps { diff --git a/apps/scandic-web/types/components/search.ts b/apps/scandic-web/types/components/search.ts index 82da8fd30..c18a888ce 100644 --- a/apps/scandic-web/types/components/search.ts +++ b/apps/scandic-web/types/components/search.ts @@ -3,7 +3,6 @@ import type { VariantProps } from "class-variance-authority" import type { PropGetters } from "downshift" import type { dialogVariants } from "@/components/Forms/BookingWidget/FormContent/Search/SearchList/Dialog/variants" -// import type { AutoCompleteLocation } from "@/server/routers/autocomplete/schema" export interface SearchProps { handlePressEnter: () => void diff --git a/apps/scandic-web/types/stores/booking-confirmation.ts b/apps/scandic-web/types/stores/booking-confirmation.ts index c7a125bbf..031bf7d43 100644 --- a/apps/scandic-web/types/stores/booking-confirmation.ts +++ b/apps/scandic-web/types/stores/booking-confirmation.ts @@ -1,11 +1,10 @@ import type { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import type { ChildBedTypeEnum } from "@scandic-hotels/trpc/enums/childBedTypeEnum" -import type { RoomCategories } from "@scandic-hotels/trpc/types/hotel" - import type { BookingConfirmation, PackageSchema, -} from "../trpc/routers/booking/confirmation" +} from "@scandic-hotels/trpc/types/bookingConfirmation" +import type { RoomCategories } from "@scandic-hotels/trpc/types/hotel" export interface ChildBedPreference { quantity: number diff --git a/apps/scandic-web/types/stores/my-stay.ts b/apps/scandic-web/types/stores/my-stay.ts index 97b340371..a87b13f35 100644 --- a/apps/scandic-web/types/stores/my-stay.ts +++ b/apps/scandic-web/types/stores/my-stay.ts @@ -1,3 +1,4 @@ +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { Child } from "@scandic-hotels/trpc/types/child" import type { Hotel, @@ -12,7 +13,6 @@ import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDet import type { RoomPrice } from "@/types/components/hotelReservation/enterDetails/details" import type { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay" import type { Packages } from "@/types/components/myPages/myStay/ancillaries" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" export type Room = Omit< BookingConfirmation["booking"], diff --git a/apps/scandic-web/utils/isLoggedInUser.ts b/apps/scandic-web/utils/isLoggedInUser.ts index d3b705205..c7103ee97 100644 --- a/apps/scandic-web/utils/isLoggedInUser.ts +++ b/apps/scandic-web/utils/isLoggedInUser.ts @@ -2,9 +2,9 @@ import "server-only" import { cookies } from "next/headers" -import { auth } from "@/auth" +import { isValidSession } from "@scandic-hotels/trpc/utils/session" -import { isValidSession } from "./session" +import { auth } from "@/auth" export async function isLoggedInUser(): Promise { const session = await auth() diff --git a/apps/scandic-web/utils/specialRoomType.ts b/apps/scandic-web/utils/specialRoomType.ts index 041397bc1..f22b51381 100644 --- a/apps/scandic-web/utils/specialRoomType.ts +++ b/apps/scandic-web/utils/specialRoomType.ts @@ -1,9 +1,8 @@ import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter" +import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { Packages } from "@scandic-hotels/trpc/types/packages" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" - export function getSpecialRoomType( packages: BookingConfirmation["booking"]["packages"] | Packages | null ) { diff --git a/apps/scandic-web/utils/tracking/myStay.ts b/apps/scandic-web/utils/tracking/myStay.ts index c731cff2a..643855842 100644 --- a/apps/scandic-web/utils/tracking/myStay.ts +++ b/apps/scandic-web/utils/tracking/myStay.ts @@ -3,11 +3,11 @@ import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" import { trackEvent } from "./base" +import type { PackageSchema } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { CreditCard } from "@scandic-hotels/trpc/types/user" import type { SelectedAncillary } from "@/types/components/myPages/myStay/ancillaries" import type { Room } from "@/types/stores/my-stay" -import type { PackageSchema } from "@/types/trpc/routers/booking/confirmation" import type { BreakfastData } from "@/stores/my-stay/add-ancillary-flow" export function trackCancelStay(hotelId: string, bnr: string) { diff --git a/packages/trpc/env/server.ts b/packages/trpc/env/server.ts index 1463b1d61..9c732bec3 100644 --- a/packages/trpc/env/server.ts +++ b/packages/trpc/env/server.ts @@ -16,6 +16,7 @@ export const env = createEnv({ isServer: typeof window === "undefined" || "Deno" in window, server: { API_BASEURL: z.string(), + BOOKING_ENCRYPTION_KEY: z.string(), SAS_API_ENDPOINT: z.string().default(""), SAS_AUTH_ENDPOINT: z.string().default(""), SAS_OCP_APIM: z.string().default(""), @@ -47,6 +48,7 @@ export const env = createEnv({ emptyStringAsUndefined: true, runtimeEnv: { API_BASEURL: process.env.API_BASEURL, + BOOKING_ENCRYPTION_KEY: process.env.BOOKING_ENCRYPTION_KEY, SAS_API_ENDPOINT: process.env.SAS_API_ENDPOINT, SAS_AUTH_ENDPOINT: process.env.SAS_AUTH_ENDPOINT, SAS_OCP_APIM: process.env.SAS_OCP_APIM, diff --git a/packages/trpc/lib/constants/apiLang.ts b/packages/trpc/lib/constants/apiLang.ts new file mode 100644 index 000000000..f1f3f826a --- /dev/null +++ b/packages/trpc/lib/constants/apiLang.ts @@ -0,0 +1,22 @@ +import { Lang } from "@scandic-hotels/common/constants/language" + +export enum ApiLang { + Da = "Da", + De = "De", + En = "En", + Fi = "Fi", + No = "No", + Sv = "Sv", + Unknown = "Unknown", +} + +type ApiLangKey = keyof typeof ApiLang + +export const langToApiLang: Record = { + [Lang.da]: ApiLang.Da, + [Lang.de]: ApiLang.De, + [Lang.en]: ApiLang.En, + [Lang.fi]: ApiLang.Fi, + [Lang.no]: ApiLang.No, + [Lang.sv]: ApiLang.Sv, +} diff --git a/packages/trpc/lib/enums/bookingStatus.ts b/packages/trpc/lib/enums/bookingStatus.ts new file mode 100644 index 000000000..67bcebc6f --- /dev/null +++ b/packages/trpc/lib/enums/bookingStatus.ts @@ -0,0 +1,16 @@ +export enum BookingStatusEnum { + BookingCompleted = "BookingCompleted", + Cancelled = "Cancelled", + CheckedOut = "CheckedOut", + ConfirmedInScorpio = "ConfirmedInScorpio", + CreatedInOhip = "CreatedInOhip", + PaymentAuthorized = "PaymentAuthorized", + PaymentCancelled = "PaymentCancelled", + PaymentError = "PaymentError", + PaymentFailed = "PaymentFailed", + PaymentRegistered = "PaymentRegistered", + PaymentSucceeded = "PaymentSucceeded", + PendingAcceptPriceChange = "PendingAcceptPriceChange", + PendingGuarantee = "PendingGuarantee", + PendingPayment = "PendingPayment", +} diff --git a/apps/scandic-web/server/plugins/refIdToConfirmationNumber.ts b/packages/trpc/lib/plugins/refIdToConfirmationNumber.ts similarity index 86% rename from apps/scandic-web/server/plugins/refIdToConfirmationNumber.ts rename to packages/trpc/lib/plugins/refIdToConfirmationNumber.ts index af1b90f97..b7571cd0b 100644 --- a/apps/scandic-web/server/plugins/refIdToConfirmationNumber.ts +++ b/packages/trpc/lib/plugins/refIdToConfirmationNumber.ts @@ -1,10 +1,10 @@ import { initTRPC } from "@trpc/server" import { z } from "zod" -import { parseRefId } from "@/utils/refId" +import { parseRefId } from "../utils/refId" -import type { Meta } from "@scandic-hotels/trpc" -import type { Context } from "@scandic-hotels/trpc/context" +import type { Meta } from ".." +import type { Context } from "../context" export function createRefIdPlugin() { const t = initTRPC.context().meta().create() diff --git a/apps/scandic-web/utils/booking.ts b/packages/trpc/lib/routers/booking/helpers.ts similarity index 77% rename from apps/scandic-web/utils/booking.ts rename to packages/trpc/lib/routers/booking/helpers.ts index 3214bcab1..5144d35e6 100644 --- a/apps/scandic-web/utils/booking.ts +++ b/packages/trpc/lib/routers/booking/helpers.ts @@ -1,5 +1,5 @@ -import type { Room } from "@scandic-hotels/trpc/types/hotel" -import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { BookingConfirmation } from "../../types/bookingConfirmation" +import type { Room } from "../../types/hotel" export function getBookedHotelRoom( rooms: Room[], diff --git a/apps/scandic-web/server/routers/booking/index.ts b/packages/trpc/lib/routers/booking/index.ts similarity index 78% rename from apps/scandic-web/server/routers/booking/index.ts rename to packages/trpc/lib/routers/booking/index.ts index 18fe6b208..2d2f459a9 100644 --- a/apps/scandic-web/server/routers/booking/index.ts +++ b/packages/trpc/lib/routers/booking/index.ts @@ -1,5 +1,4 @@ -import { mergeRouters } from "@scandic-hotels/trpc" - +import { mergeRouters } from "../.." import { bookingMutationRouter } from "./mutation" import { bookingQueryRouter } from "./query" diff --git a/apps/scandic-web/server/routers/booking/input.ts b/packages/trpc/lib/routers/booking/input.ts similarity index 97% rename from apps/scandic-web/server/routers/booking/input.ts rename to packages/trpc/lib/routers/booking/input.ts index 52218c45f..42e291290 100644 --- a/apps/scandic-web/server/routers/booking/input.ts +++ b/packages/trpc/lib/routers/booking/input.ts @@ -1,9 +1,9 @@ import { z } from "zod" import { Lang } from "@scandic-hotels/common/constants/language" -import { ChildBedTypeEnum } from "@scandic-hotels/trpc/enums/childBedTypeEnum" -import { langToApiLang } from "@/constants/languages" +import { langToApiLang } from "../../constants/apiLang" +import { ChildBedTypeEnum } from "../../enums/childBedTypeEnum" const roomsSchema = z .array( diff --git a/apps/scandic-web/server/routers/booking/mutation.ts b/packages/trpc/lib/routers/booking/mutation.ts similarity index 96% rename from apps/scandic-web/server/routers/booking/mutation.ts rename to packages/trpc/lib/routers/booking/mutation.ts index 1150d32e6..f71ee762d 100644 --- a/apps/scandic-web/server/routers/booking/mutation.ts +++ b/packages/trpc/lib/routers/booking/mutation.ts @@ -1,14 +1,12 @@ import { createCounter } from "@scandic-hotels/common/telemetry" -import { router } from "@scandic-hotels/trpc" -import * as api from "@scandic-hotels/trpc/api" -import { safeProtectedServiceProcedure } from "@scandic-hotels/trpc/procedures" - -import { createRefIdPlugin } from "@/server/plugins/refIdToConfirmationNumber" -import { getMembershipNumber } from "@/server/routers/user/utils" - -import { encrypt } from "@/utils/encryption" -import { isValidSession } from "@/utils/session" +import { router } from "../.." +import * as api from "../../api" +import { createRefIdPlugin } from "../../plugins/refIdToConfirmationNumber" +import { safeProtectedServiceProcedure } from "../../procedures" +import { encrypt } from "../../utils/encryption" +import { isValidSession } from "../../utils/session" +import { getMembershipNumber } from "../user/utils" import { addPackageInput, cancelBookingsInput, diff --git a/apps/scandic-web/server/routers/booking/output.ts b/packages/trpc/lib/routers/booking/output.ts similarity index 97% rename from apps/scandic-web/server/routers/booking/output.ts rename to packages/trpc/lib/routers/booking/output.ts index d75b117de..386fcffe1 100644 --- a/apps/scandic-web/server/routers/booking/output.ts +++ b/packages/trpc/lib/routers/booking/output.ts @@ -7,12 +7,11 @@ import { nullableStringEmailValidator, nullableStringValidator, } from "@scandic-hotels/common/utils/zod/stringValidator" -import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast" -import { ChildBedTypeEnum } from "@scandic-hotels/trpc/enums/childBedTypeEnum" -import { BookingStatusEnum } from "@/constants/booking" - -import { calculateRefId } from "@/utils/refId" +import { BookingStatusEnum } from "../../enums/bookingStatus" +import { BreakfastPackageEnum } from "../../enums/breakfast" +import { ChildBedTypeEnum } from "../../enums/childBedTypeEnum" +import { calculateRefId } from "../../utils/refId" const guestSchema = z.object({ email: nullableStringEmailValidator, diff --git a/apps/scandic-web/server/routers/booking/query.ts b/packages/trpc/lib/routers/booking/query.ts similarity index 92% rename from apps/scandic-web/server/routers/booking/query.ts rename to packages/trpc/lib/routers/booking/query.ts index 68a6c8351..931b74e26 100644 --- a/apps/scandic-web/server/routers/booking/query.ts +++ b/packages/trpc/lib/routers/booking/query.ts @@ -1,22 +1,17 @@ import { createCounter } from "@scandic-hotels/common/telemetry" -import { router } from "@scandic-hotels/trpc" -import * as api from "@scandic-hotels/trpc/api" -import { - badRequestError, - serverErrorByStatus, -} from "@scandic-hotels/trpc/errors" + +import { router } from "../.." +import * as api from "../../api" +import { badRequestError, serverErrorByStatus } from "../../errors" +import { createRefIdPlugin } from "../../plugins/refIdToConfirmationNumber" import { safeProtectedServiceProcedure, serviceProcedure, -} from "@scandic-hotels/trpc/procedures" -import { getHotel } from "@scandic-hotels/trpc/routers/hotels/utils" -import { toApiLang } from "@scandic-hotels/trpc/utils" - -import { createRefIdPlugin } from "@/server/plugins/refIdToConfirmationNumber" - -import { getBookedHotelRoom } from "@/utils/booking" - -import { encrypt } from "../../../utils/encryption" +} from "../../procedures" +import { getHotel } from "../../routers/hotels/utils" +import { toApiLang } from "../../utils" +import { encrypt } from "../../utils/encryption" +import { getBookedHotelRoom } from "./helpers" import { createRefIdInput, findBookingInput, diff --git a/apps/scandic-web/server/routers/booking/utils.ts b/packages/trpc/lib/routers/booking/utils.ts similarity index 95% rename from apps/scandic-web/server/routers/booking/utils.ts rename to packages/trpc/lib/routers/booking/utils.ts index 82076cebd..7c6b4a5d5 100644 --- a/apps/scandic-web/server/routers/booking/utils.ts +++ b/packages/trpc/lib/routers/booking/utils.ts @@ -1,11 +1,8 @@ import { createCounter } from "@scandic-hotels/common/telemetry" -import * as api from "@scandic-hotels/trpc/api" -import { - badRequestError, - serverErrorByStatus, -} from "@scandic-hotels/trpc/errors" -import { toApiLang } from "@scandic-hotels/trpc/utils" +import * as api from "../../api" +import { badRequestError, serverErrorByStatus } from "../../errors" +import { toApiLang } from "../../utils" import { bookingConfirmationSchema, createBookingSchema } from "./output" import type { Lang } from "@scandic-hotels/common/constants/language" diff --git a/packages/trpc/lib/routers/hotels/query.ts b/packages/trpc/lib/routers/hotels/query.ts index 5295a2323..0cd0ba641 100644 --- a/packages/trpc/lib/routers/hotels/query.ts +++ b/packages/trpc/lib/routers/hotels/query.ts @@ -47,9 +47,9 @@ import { breakfastPackagesSchema, getNearbyHotelIdsSchema, } from "../../routers/hotels/output" -import { additionalDataSchema } from "../../routers/hotels/schemas/hotel/include/additionalData" import { toApiLang } from "../../utils" import { getVerifiedUser } from "../user/utils" +import { additionalDataSchema } from "./schemas/hotel/include/additionalData" import { meetingRoomsSchema } from "./schemas/meetingRoom" import { getCitiesByCountry, diff --git a/packages/trpc/lib/routers/user/utils.ts b/packages/trpc/lib/routers/user/utils.ts index 3e6abc25c..36dd3dd7e 100644 --- a/packages/trpc/lib/routers/user/utils.ts +++ b/packages/trpc/lib/routers/user/utils.ts @@ -2,10 +2,24 @@ import { createCounter } from "@scandic-hotels/common/telemetry" import * as api from "../../api" import { cache } from "../../DUPLICATED/cache" +import { isValidSession } from "../../utils/session" import { getUserSchema } from "./output" import type { Session } from "next-auth" +export async function getMembershipNumber( + session: Session | null +): Promise { + if (!isValidSession(session)) return undefined + + const verifiedUser = await getVerifiedUser({ session }) + if (!verifiedUser || "error" in verifiedUser) { + return undefined + } + + return verifiedUser.data.membershipNumber +} + export const getVerifiedUser = cache( async ({ session, diff --git a/apps/scandic-web/types/trpc/routers/booking/confirmation.ts b/packages/trpc/lib/types/bookingConfirmation.ts similarity index 79% rename from apps/scandic-web/types/trpc/routers/booking/confirmation.ts rename to packages/trpc/lib/types/bookingConfirmation.ts index e014a6b07..637bd6074 100644 --- a/apps/scandic-web/types/trpc/routers/booking/confirmation.ts +++ b/packages/trpc/lib/types/bookingConfirmation.ts @@ -1,10 +1,10 @@ -import type { HotelData, Room } from "@scandic-hotels/trpc/types/hotel" import type { z } from "zod" import type { bookingConfirmationSchema, packageSchema, -} from "@/server/routers/booking/output" +} from "../routers/booking/output" +import type { HotelData, Room } from "./hotel" export interface BookingConfirmationSchema extends z.output {} diff --git a/apps/scandic-web/utils/encryption.ts b/packages/trpc/lib/utils/encryption.ts similarity index 97% rename from apps/scandic-web/utils/encryption.ts rename to packages/trpc/lib/utils/encryption.ts index e4ea3d6d2..2c6322ba9 100644 --- a/apps/scandic-web/utils/encryption.ts +++ b/packages/trpc/lib/utils/encryption.ts @@ -2,7 +2,7 @@ import "server-only" import crypto from "crypto" -import { env } from "@/env/server" +import { env } from "../../env/server" const algorithm = "DES-ECB" const encryptionKey = env.BOOKING_ENCRYPTION_KEY diff --git a/apps/scandic-web/utils/refId.ts b/packages/trpc/lib/utils/refId.ts similarity index 100% rename from apps/scandic-web/utils/refId.ts rename to packages/trpc/lib/utils/refId.ts diff --git a/apps/scandic-web/utils/session.ts b/packages/trpc/lib/utils/session.ts similarity index 100% rename from apps/scandic-web/utils/session.ts rename to packages/trpc/lib/utils/session.ts