Merged in feat/sw-2859-set-up-shared-trpc-package (pull request #2319)
feat(SW-2859): Create trpc package * Add isEdge, safeTry and dataCache to new common package * Add eslint and move prettier config * Clean up tests * Create trpc package and move initialization * Move errors and a few procedures * Move telemetry to common package * Move tokenManager to common package * Add Sentry to procedures * Clean up procedures * Fix self-referencing imports * Add exports to packages and lint rule to prevent relative imports * 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 * Fix lang imports Approved-by: Linus Flood
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
|
||||
@@ -12,7 +12,7 @@ import { TransferPointsFormClient } from "./TransferPointsFormClient"
|
||||
|
||||
import styles from "./transferPoints.module.css"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export async function TransferPointsForm({ lang }: { lang: Lang }) {
|
||||
const profile = await getProfileWithExtendedPartnerData()
|
||||
|
||||
@@ -26,8 +26,9 @@ import Button from "@/components/TempDesignSystem/Button"
|
||||
|
||||
import styles from "./transferPoints.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { LangParams } from "@/types/params"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
type TransferPointsFormClientProps = {
|
||||
sasPoints: number | null
|
||||
|
||||
@@ -4,7 +4,7 @@ import "dialogshift-webchat-sdk/bundles/dialogshift-webchat-sdk.min.css"
|
||||
|
||||
import { useEffect, useRef } from "react"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
interface DialogshiftWidgetClientProps {
|
||||
widgetId: string
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { IntlShape } from "react-intl"
|
||||
|
||||
import { HealthFacilitiesEnum } from "@/types/components/hotelPage/facilities"
|
||||
@@ -13,7 +14,6 @@ import {
|
||||
import { HotelHashValues } from "@/types/enums/hotelPage"
|
||||
import type { Hotel, HotelData } from "@/types/hotel"
|
||||
import type { HotelPage } from "@/types/trpc/routers/contentstack/hotelPage"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
export function getRoomNameAsParam(roomName: string) {
|
||||
return roomName
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable formatjs/no-literal-string-in-jsx */
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import styles from "./contact.module.css"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"use client"
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
|
||||
import { type Lang, languages } from "@/constants/languages"
|
||||
import { languages } from "@/constants/languages"
|
||||
import { env } from "@/env/client"
|
||||
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
@@ -11,6 +11,8 @@ import useLang from "@/hooks/useLang"
|
||||
|
||||
import styles from "./desktop.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { LanguageSwitcherProps } from "@/types/components/current/languageSwitcher"
|
||||
|
||||
export default function Desktop({ urls }: LanguageSwitcherProps) {
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
"use client"
|
||||
import { useState } from "react"
|
||||
|
||||
import { type Lang, languages } from "@/constants/languages"
|
||||
import { languages } from "@/constants/languages"
|
||||
import { env } from "@/env/client"
|
||||
|
||||
import useLang from "@/hooks/useLang"
|
||||
|
||||
import styles from "./mobile.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { LanguageSwitcherProps } from "@/types/components/current/languageSwitcher"
|
||||
|
||||
export default function Mobile({ urls }: LanguageSwitcherProps) {
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
import { headers } from "next/headers"
|
||||
|
||||
import { Lang, localeToLang } from "@/constants/languages"
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { localeToLang } from "@/constants/languages"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
type Texts = {
|
||||
title: string
|
||||
|
||||
@@ -4,11 +4,11 @@ import { useState } from "react"
|
||||
import { DayPicker } from "react-day-picker"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
|
||||
@@ -3,10 +3,10 @@ import { useEffect, useRef, useState } from "react"
|
||||
import { type DateRange, DayPicker } from "react-day-picker"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
|
||||
@@ -4,10 +4,10 @@ import { useState } from "react"
|
||||
import { DayPicker } from "react-day-picker"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import { DayPicker } from "react-day-picker"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { da, de, fi, nb, sv } from "date-fns/locale"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export const locales = {
|
||||
[Lang.da]: da,
|
||||
|
||||
@@ -5,11 +5,7 @@ import { useEffect, useState } from "react"
|
||||
import { FormProvider, useForm } from "react-hook-form"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import {
|
||||
getDefaultCountryFromLang,
|
||||
type Lang,
|
||||
langToApiLang,
|
||||
} from "@/constants/languages"
|
||||
import { getDefaultCountryFromLang, langToApiLang } from "@/constants/languages"
|
||||
import { logout } from "@/constants/routes/handleAuth"
|
||||
import { profile } from "@/constants/routes/myPages"
|
||||
import { trpc } from "@/lib/trpc/client"
|
||||
@@ -28,6 +24,8 @@ import { type EditProfileSchema, editProfileSchema } from "./schema"
|
||||
|
||||
import styles from "./form.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import {
|
||||
type EditFormProps,
|
||||
Status,
|
||||
|
||||
@@ -6,6 +6,8 @@ import { getSpecialRoomType } from "@/utils/specialRoomType"
|
||||
|
||||
import { invertedBedTypeMap } from "../../utils"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
@@ -20,7 +22,6 @@ import { RateEnum } from "@/types/enums/rate"
|
||||
import type { Room } from "@/types/stores/booking-confirmation"
|
||||
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
|
||||
import type { RateDefinition } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
function getRate(cancellationRule: RateDefinition["cancellationRule"] | null) {
|
||||
switch (cancellationRule) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// import { act, cleanup, render, screen, within } from "@testing-library/react"
|
||||
// import { type IntlConfig, IntlProvider } from "react-intl"
|
||||
|
||||
// import { Lang } from "@/constants/languages"
|
||||
// import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
// import {
|
||||
// bedType,
|
||||
|
||||
@@ -7,10 +7,11 @@ import { useSearchHistory } from "@/hooks/useSearchHistory"
|
||||
|
||||
import { getTracking } from "./tracking"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { DetailsBooking } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
import type { Hotel } from "@/types/hotel"
|
||||
import type { Room } from "@/types/providers/details/room"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
interface TrackingWrapperProps {
|
||||
booking: DetailsBooking
|
||||
|
||||
@@ -5,6 +5,8 @@ import { REDEMPTION } from "@/constants/booking"
|
||||
import { sumPackages } from "@/components/HotelReservation/utils"
|
||||
import { getSpecialRoomType } from "@/utils/specialRoomType"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import type { BreakfastPackages } from "@/types/components/hotelReservation/breakfast"
|
||||
import type { DetailsBooking } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
@@ -24,7 +26,6 @@ import type {
|
||||
PriceProduct,
|
||||
Product,
|
||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
export function getTracking(
|
||||
booking: DetailsBooking,
|
||||
|
||||
@@ -37,10 +37,11 @@ import { hotelCardVariants } from "./variants"
|
||||
|
||||
import styles from "./hotelCard.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { HotelCardListingTypeEnum } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
|
||||
import type { HotelCardProps } from "@/types/components/hotelReservation/selectHotel/hotelCardProps"
|
||||
import { SidePeekEnum } from "@/types/components/hotelReservation/sidePeek"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
function HotelCard({
|
||||
hotelData: { availability, hotel },
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
trackAncillarySuccess,
|
||||
} from "@/utils/tracking/myStay"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export default function GuaranteeAncillaryHandler({
|
||||
confirmationNumber,
|
||||
|
||||
@@ -16,7 +16,7 @@ import PriceAndDate from "./PriceAndDate"
|
||||
|
||||
import styles from "./confirmation.module.css"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
interface ConfirmationProps {
|
||||
checkInDate: string
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { differenceInCalendarDays, format, isWeekend } from "date-fns"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
type TrackingSDKHotelInfo,
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { ChildrenInRoom } from "@/utils/hotelSearchDetails"
|
||||
|
||||
export function getTracking(
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { differenceInCalendarDays, format, isWeekend } from "date-fns"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
type TrackingSDKHotelInfo,
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { ChildrenInRoom } from "@/utils/hotelSearchDetails"
|
||||
|
||||
export function getTracking(
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { differenceInCalendarDays, format, isWeekend } from "date-fns"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import type { Room } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
@@ -8,7 +10,6 @@ import {
|
||||
type TrackingSDKHotelInfo,
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { ChildrenInRoom } from "@/utils/hotelSearchDetails"
|
||||
|
||||
export function getTracking(
|
||||
|
||||
@@ -12,8 +12,9 @@ import FnFNotAllowedAlert from "../FnFNotAllowedAlert/FnFNotAllowedAlert"
|
||||
import AvailabilityError from "./AvailabilityError"
|
||||
import Tracking from "./Tracking"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { SelectRateBooking } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
export default async function SelectRatePage({
|
||||
lang,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useIntl } from "react-intl"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import { type Lang, languages } from "@/constants/languages"
|
||||
import { languages } from "@/constants/languages"
|
||||
import { env } from "@/env/client"
|
||||
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
@@ -17,6 +17,8 @@ import { replaceUrlPart } from "./utils"
|
||||
|
||||
import styles from "./languageSwitcherContent.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { LanguageSwitcherContentProps } from "@/types/components/languageSwitcher/languageSwitcher"
|
||||
|
||||
export default function LanguageSwitcherContent({
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import { countriesMap } from "@/constants/countries"
|
||||
import { Lang, languages } from "@/constants/languages"
|
||||
import { languages } from "@/constants/languages"
|
||||
import { profileEdit } from "@/constants/routes/myPages"
|
||||
import { getProfile } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import { render, screen } from "@testing-library/react"
|
||||
import { type UserEvent, userEvent } from "@testing-library/user-event"
|
||||
import { FormProvider, useForm } from "react-hook-form"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
import { getLocalizedMonthName } from "@/utils/dateFormatting"
|
||||
|
||||
Reference in New Issue
Block a user