Merged in feat/sw-2864-move-hotels-router-to-trpc-package (pull request #2410)
feat (SW-2864): Move booking router to trpc package * Add env to trpc package * Add eslint to trpc package * Apply lint rules * 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 * Merge branch 'master' into feat/sw-2864-move-hotels-router-to-trpc-package Approved-by: Linus Flood
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { countriesMap } from "@/constants/countries"
|
||||
import { countriesMap } from "@scandic-hotels/trpc/constants/countries"
|
||||
|
||||
export function isValidCountry(
|
||||
country: string
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { generateChildrenString } from "@scandic-hotels/trpc/routers/hotels/helpers"
|
||||
import {
|
||||
type HotelLocation,
|
||||
isHotelLocation,
|
||||
type Location,
|
||||
} from "@scandic-hotels/trpc/types/locations"
|
||||
|
||||
import { REDEMPTION } from "@/constants/booking"
|
||||
import { getLocations } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { generateChildrenString } from "@/components/HotelReservation/utils"
|
||||
import type { Child } from "@scandic-hotels/trpc/types/child"
|
||||
|
||||
import type { BookingSearchType } from "@/types/components/hotelReservation/booking"
|
||||
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
|
||||
export type ChildrenInRoom = (Child[] | null)[] | null
|
||||
export type ChildrenInRoomString = (string | null)[] | null
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
||||
import type { Packages } from "@/types/requests/packages"
|
||||
|
||||
import type { Packages } from "@scandic-hotels/trpc/types/packages"
|
||||
|
||||
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
|
||||
|
||||
export function getSpecialRoomType(
|
||||
|
||||
@@ -3,10 +3,11 @@ import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast"
|
||||
|
||||
import { trackEvent } from "./base"
|
||||
|
||||
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 { CreditCard } from "@/types/user"
|
||||
import type { BreakfastData } from "@/stores/my-stay/add-ancillary-flow"
|
||||
|
||||
export function trackCancelStay(hotelId: string, bnr: string) {
|
||||
|
||||
@@ -2,56 +2,14 @@ import {
|
||||
type MembershipLevel,
|
||||
MembershipLevelEnum,
|
||||
} from "@scandic-hotels/common/constants/membershipLevels"
|
||||
import { scandicMembershipTypes } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||
|
||||
import type {
|
||||
EurobonusMembership,
|
||||
Membership,
|
||||
NativeFriendsMembership,
|
||||
User,
|
||||
UserLoyalty,
|
||||
} from "@/types/user"
|
||||
|
||||
export enum scandicMembershipTypes {
|
||||
SCANDIC_NATIVE = "SCANDIC_NATIVE",
|
||||
SAS_EB = "SAS_EB",
|
||||
}
|
||||
|
||||
export function isScandicNativeMembership(
|
||||
membership: Membership
|
||||
): membership is NativeFriendsMembership {
|
||||
return membership.type === scandicMembershipTypes.SCANDIC_NATIVE
|
||||
}
|
||||
|
||||
export function getFriendsMembership(userLoyalty: UserLoyalty) {
|
||||
const { memberships, ...loyalty } = userLoyalty
|
||||
|
||||
const friendsMembership = memberships.find(isScandicNativeMembership)
|
||||
|
||||
if (!friendsMembership) return null
|
||||
|
||||
const pointExpiration = loyalty.pointExpirations
|
||||
.sort(
|
||||
(a, b) => new Date(a.expires).getTime() - new Date(b.expires).getTime()
|
||||
)
|
||||
.at(0)
|
||||
|
||||
// Map to the same format that was used with Profile V1 to avoid larger changes for now.
|
||||
const result = {
|
||||
membershipType: friendsMembership.type,
|
||||
membershipNumber: friendsMembership.membershipNumber,
|
||||
membershipLevel: loyalty.tier,
|
||||
nextLevel: friendsMembership.nextTier,
|
||||
currentPoints: loyalty.points.spendable,
|
||||
expirationDate: loyalty.tierExpires,
|
||||
nightsToTopTier: friendsMembership.nightsToTopTier,
|
||||
pointsRequiredToNextlevel: friendsMembership.pointsToNextTier,
|
||||
tierExpirationDate: loyalty.tierExpires,
|
||||
pointsExpiryDate: pointExpiration?.expires,
|
||||
pointsToExpire: pointExpiration?.points,
|
||||
memberSince: friendsMembership.memberSince,
|
||||
}
|
||||
return result
|
||||
}
|
||||
} from "@scandic-hotels/trpc/types/user"
|
||||
|
||||
function isEurobonusMembership(
|
||||
membership: Membership
|
||||
|
||||
Reference in New Issue
Block a user