Merged in feat/sw-2865-move-navigation-router-to-trpc-package (pull request #2427)

feat(SW-2862): Move navigation router to trpc package

* 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

* Remove translations from My Pages navigation trpc procedure

* Move navigation router to trpc package

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

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

* Merge branch 'master' into feat/sw-2865-move-navigation-router-to-trpc-package

* Merge branch 'master' into feat/sw-2865-move-navigation-router-to-trpc-package

* Merge branch 'master' into feat/sw-2865-move-navigation-router-to-trpc-package


Approved-by: Linus Flood
This commit is contained in:
Anton Gunnarsson
2025-06-27 06:54:49 +00:00
parent 39250e21e3
commit 00bcdaaa28
39 changed files with 150 additions and 130 deletions
@@ -4,6 +4,7 @@ import { type ReactNode, Suspense } from "react"
import DiamondAddIcon from "@scandic-hotels/design-system/Icons/DiamondAddIcon"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
import {
SAS_EUROBONUS_TIER_TO_NAME_MAP,
@@ -17,7 +18,6 @@ import SectionHeader from "@/components/Section/Header"
import SectionLink from "@/components/Section/Link"
import SkeletonShimmer from "@/components/SkeletonShimmer"
import { getIntl } from "@/i18n"
import { getEurobonusMembership } from "@/utils/user"
import { UnlinkSAS } from "./UnlinkSAS"
@@ -1,12 +1,12 @@
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
import { getProfileWithExtendedPartnerData } from "@/lib/trpc/memoizedRequests"
import Image from "@/components/Image"
import SkeletonShimmer from "@/components/SkeletonShimmer"
import { getIntl } from "@/i18n"
import { getEurobonusMembership } from "@/utils/user"
import { TransferPointsFormClient } from "./TransferPointsFormClient"
@@ -5,9 +5,9 @@ import { usePathname } from "next/navigation"
import { useIntl } from "react-intl"
import { findMyBookingCurrentWebPath } from "@scandic-hotels/common/constants/routes/findMyBooking"
import { myPages } from "@scandic-hotels/common/constants/routes/myPages"
import { logout } from "@/constants/routes/handleAuth"
import { myPages } from "@/constants/routes/myPages"
import { env } from "@/env/client"
import useDropdownStore from "@/stores/main-menu"
@@ -5,9 +5,9 @@ import { useIntl } from "react-intl"
import { Divider } from "@scandic-hotels/design-system/Divider"
import { logout } from "@/constants/routes/handleAuth"
import { trpc } from "@/lib/trpc/client"
import useDropdownStore from "@/stores/main-menu"
import { useMyPagesNavigation } from "@/components/Header/MainMenu/MyPagesMenuContent"
import SkeletonShimmer from "@/components/SkeletonShimmer"
import Link from "@/components/TempDesignSystem/Link"
import Title from "@/components/TempDesignSystem/Text/Title"
@@ -143,8 +143,3 @@ function Skeletons({ count }: { count: number }) {
</>
)
}
function useMyPagesNavigation() {
const lang = useLang()
return trpc.navigation.myPages.useQuery({ lang })
}
@@ -1,5 +1,6 @@
import { overview } from "@scandic-hotels/common/constants/routes/myPages"
import { logout } from "@/constants/routes/handleAuth"
import { overview } from "@/constants/routes/myPages"
import { getName } from "@/lib/trpc/memoizedRequests"
import LoginButton from "@/components/LoginButton"
@@ -5,11 +5,11 @@ import { useEffect, useState } from "react"
import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl"
import { profile } from "@scandic-hotels/common/constants/routes/myPages"
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"
import { editProfile } from "@/actions/editProfile"
@@ -16,6 +16,8 @@ import useLang from "@/hooks/useLang"
import styles from "./myPagesMenuContent.module.css"
import type { MyPagesLinkKey } from "@scandic-hotels/trpc/routers/navigation/mypages/MyPagesLink"
import type { MyPagesMenuProps } from "../MyPagesMenu"
type Props = MyPagesMenuProps & { toggleOpenStateFn: () => void }
@@ -165,7 +167,51 @@ function SecondaryLinks({
export const useMyPagesNavigation = () => {
const lang = useLang()
return trpc.navigation.myPages.useQuery({
const intl = useIntl()
const MyPagesLinkTranslationMap: Record<MyPagesLinkKey, string> = {
overview: intl.formatMessage({
defaultMessage: "Overview",
}),
points: intl.formatMessage({
defaultMessage: "My points",
}),
stays: intl.formatMessage({
defaultMessage: "My stays",
}),
benefits: intl.formatMessage({
defaultMessage: "My benefits",
}),
partnerSas: intl.formatMessage({
defaultMessage: "Scandic ♥ SAS",
}),
teamMemberCard: intl.formatMessage({
defaultMessage: "Team Member Card",
}),
scandicFriends: intl.formatMessage({
defaultMessage: "About Scandic Friends",
}),
profile: intl.formatMessage({
defaultMessage: "My profile",
}),
}
const result = trpc.navigation.myPages.useQuery({
lang: lang,
})
if (result.data) {
const primaryLinks = result.data.primaryLinks.map((link) => ({
...link,
text: MyPagesLinkTranslationMap[link.key],
}))
const secondaryLinks = result.data.secondaryLinks.map((link) => ({
...link,
text: MyPagesLinkTranslationMap[link.key],
}))
return { ...result, data: { primaryLinks, secondaryLinks } }
}
return { ...result, data: null }
}
@@ -6,10 +6,10 @@ import { Dialog } from "react-aria-components"
import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl"
import { profileEdit } from "@scandic-hotels/common/constants/routes/myPages"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { profileEdit } from "@/constants/routes/myPages"
import { isWebview } from "@/constants/routes/webviews"
import { trpc } from "@/lib/trpc/client"
@@ -1,4 +1,5 @@
import { Lang } from "@scandic-hotels/common/constants/language"
import { profileEdit } from "@scandic-hotels/common/constants/routes/myPages"
import { isValidLang } from "@scandic-hotels/common/utils/languages"
import { Divider } from "@scandic-hotels/design-system/Divider"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
@@ -6,7 +7,6 @@ import { Typography } from "@scandic-hotels/design-system/Typography"
import { countriesMap } from "@scandic-hotels/trpc/constants/countries"
import { languages } from "@/constants/languages"
import { profileEdit } from "@/constants/routes/myPages"
import { getProfile } from "@/lib/trpc/memoizedRequests"
import ButtonLink from "@/components/ButtonLink"
@@ -4,8 +4,9 @@ import { usePathname, useRouter } from "next/navigation"
import { useEffect, useRef } from "react"
import { useIntl } from "react-intl"
import { partnerSas } from "@scandic-hotels/common/constants/routes/myPages"
import { TIER_TO_FRIEND_MAP } from "@/constants/membershipLevels"
import { partnerSas } from "@/constants/routes/myPages"
import { trpc } from "@/lib/trpc/client"
import { toast } from "@/components/TempDesignSystem/Toasts"
@@ -6,9 +6,9 @@ import React, { useState } from "react"
import { Dialog, Modal, ModalOverlay } from "react-aria-components"
import { useIntl } from "react-intl"
import { benefits } from "@scandic-hotels/common/constants/routes/myPages"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { benefits } from "@/constants/routes/myPages"
import {
benefits as webviewBenefits,
myPagesWebviews,
@@ -1,9 +1,9 @@
import { headers } from "next/headers"
import { redirect } from "next/navigation"
import { overview } from "@scandic-hotels/common/constants/routes/myPages"
import { isValidSession } from "@scandic-hotels/trpc/utils/session"
import { overview } from "@/constants/routes/myPages"
import { getProfile } from "@/lib/trpc/memoizedRequests"
import { auth } from "@/auth"