Merged in feat/sw-2862-move-booking-router-to-trpc-package (pull request #2421)

feat(SW-2861): Move booking router to trpc package

* Use direct imports from trpc package

* Add lint-staged config to trpc

* Move lang enum to common

* Restructure trpc package folder structure

* WIP first step

* update internal imports in trpc

* Fix most errors in scandic-web

Just 100 left...

* Move Props type out of trpc

* Fix CategorizedFilters types

* Move more schemas in hotel router

* Fix deps

* fix getNonContentstackUrls

* Fix import error

* Fix entry error handling

* Fix generateMetadata metrics

* Fix alertType enum

* Fix duplicated types

* lint:fix

* Merge branch 'master' into feat/sw-2863-move-contentstack-router-to-trpc-package

* Fix broken imports

* Move booking router to trpc package

* Move partners router to trpc package

* Move autocomplete router to trpc package

* Move booking router to trpc package

* Merge branch 'master' into feat/sw-2862-move-booking-router-to-trpc-package


Approved-by: Linus Flood
This commit is contained in:
Anton Gunnarsson
2025-06-26 13:21:16 +00:00
parent ded9e1278f
commit e572d9e7e9
69 changed files with 179 additions and 178 deletions

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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"

View File

@@ -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"

View File

@@ -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,

View File

@@ -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,

View File

@@ -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

View File

@@ -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"]

View File

@@ -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<

View File

@@ -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)

View File

@@ -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", () => {

View File

@@ -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,

View File

@@ -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: {

View File

@@ -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"]

View File

@@ -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,

View File

@@ -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"]

View File

@@ -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()

View File

@@ -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<

View File

@@ -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

View File

@@ -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<string, Lang> = {
"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, ApiLangKey> = {
[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 },

View File

@@ -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"

View File

@@ -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,

View File

@@ -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"

View File

@@ -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

View File

@@ -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"

View File

@@ -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"

View File

@@ -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 {

View File

@@ -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<string | undefined> {
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,

View File

@@ -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,

View File

@@ -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<BookingConfirmation, "booking"> {}

View File

@@ -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

View File

@@ -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<BookingConfirmation, "booking" | "hotel"> {
mainRef: MutableRefObject<HTMLElement | null>

View File

@@ -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"]

View File

@@ -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<BookingConfirmation, "booking"> {}

View File

@@ -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<BookingConfirmation, "booking"> {

View File

@@ -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"]

View File

@@ -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 {

View File

@@ -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

View File

@@ -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

View File

@@ -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"],

View File

@@ -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<boolean> {
const session = await auth()

View File

@@ -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
) {

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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, ApiLangKey> = {
[Lang.da]: ApiLang.Da,
[Lang.de]: ApiLang.De,
[Lang.en]: ApiLang.En,
[Lang.fi]: ApiLang.Fi,
[Lang.no]: ApiLang.No,
[Lang.sv]: ApiLang.Sv,
}

View File

@@ -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",
}

View File

@@ -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<Context>().meta<Meta>().create()

View File

@@ -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[],

View File

@@ -1,5 +1,4 @@
import { mergeRouters } from "@scandic-hotels/trpc"
import { mergeRouters } from "../.."
import { bookingMutationRouter } from "./mutation"
import { bookingQueryRouter } from "./query"

View File

@@ -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(

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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"

View File

@@ -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,

View File

@@ -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<string | undefined> {
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,

View File

@@ -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<typeof bookingConfirmationSchema> {}

View File

@@ -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