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:
@@ -1,8 +1,9 @@
|
|||||||
|
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||||
|
|
||||||
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import { SASLevelUpgradeCheck } from "@/components/MyPages/SASLevelUpgradeCheck"
|
import { SASLevelUpgradeCheck } from "@/components/MyPages/SASLevelUpgradeCheck"
|
||||||
import Surprises from "@/components/MyPages/Surprises"
|
import Surprises from "@/components/MyPages/Surprises"
|
||||||
import { getEurobonusMembership } from "@/utils/user"
|
|
||||||
|
|
||||||
import styles from "./layout.module.css"
|
import styles from "./layout.module.css"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { headers } from "next/headers"
|
import { headers } from "next/headers"
|
||||||
import { notFound, redirect } from "next/navigation"
|
import { notFound, redirect } from "next/navigation"
|
||||||
|
|
||||||
import { overview } from "@/constants/routes/myPages"
|
import { overview } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
|
|
||||||
import { isSignupPage } from "@/constants/routes/signup"
|
import { isSignupPage } from "@/constants/routes/signup"
|
||||||
import { env } from "@/env/server"
|
import { env } from "@/env/server"
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { partnerSas } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { partnerSas } from "@/constants/routes/myPages"
|
|
||||||
|
|
||||||
import Button from "@/components/TempDesignSystem/Button"
|
import Button from "@/components/TempDesignSystem/Button"
|
||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
import { Link } from "react-aria-components"
|
import { Link } from "react-aria-components"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { profile } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { profile } from "@/constants/routes/myPages"
|
|
||||||
|
|
||||||
import Button from "@/components/TempDesignSystem/Button"
|
import Button from "@/components/TempDesignSystem/Button"
|
||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ArrowLeft } from "react-feather"
|
import { ArrowLeft } from "react-feather"
|
||||||
|
|
||||||
import { overview as profileOverview } from "@/constants/routes/myPages"
|
import { overview as profileOverview } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
|
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
@@ -13,12 +13,12 @@ import type { PropsWithChildren } from "react"
|
|||||||
|
|
||||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||||
|
|
||||||
export default async function SasXScandicLayout(props: PropsWithChildren<LayoutArgs<LangParams>>) {
|
export default async function SasXScandicLayout(
|
||||||
const params = await props.params;
|
props: PropsWithChildren<LayoutArgs<LangParams>>
|
||||||
|
) {
|
||||||
|
const params = await props.params
|
||||||
|
|
||||||
const {
|
const { children } = props
|
||||||
children
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import { useTransition } from "react"
|
|||||||
import { FormProvider, useForm } from "react-hook-form"
|
import { FormProvider, useForm } from "react-hook-form"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { profileEdit } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { profileEdit } from "@/constants/routes/myPages"
|
|
||||||
import { sasPartnershipTermsAndConditions } from "@/constants/webHrefs"
|
import { sasPartnershipTermsAndConditions } from "@/constants/webHrefs"
|
||||||
|
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { redirect } from "next/navigation"
|
import { redirect } from "next/navigation"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||||
|
|
||||||
import { getEurobonusMembership } from "@/utils/user"
|
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import { SASModal } from "../components/SASModal"
|
import { SASModal } from "../components/SASModal"
|
||||||
import { LinkAccountForm } from "./LinkAccountForm"
|
import { LinkAccountForm } from "./LinkAccountForm"
|
||||||
@@ -11,7 +11,7 @@ import { LinkAccountForm } from "./LinkAccountForm"
|
|||||||
import type { LangParams, PageArgs } from "@/types/params"
|
import type { LangParams, PageArgs } from "@/types/params"
|
||||||
|
|
||||||
export default async function SASxScandicLinkPage(props: PageArgs<LangParams>) {
|
export default async function SASxScandicLinkPage(props: PageArgs<LangParams>) {
|
||||||
const params = await props.params;
|
const params = await props.params
|
||||||
const profile = await getProfileSafely()
|
const profile = await getProfileSafely()
|
||||||
|
|
||||||
if (!profile || !profile.loyalty) return null
|
if (!profile || !profile.loyalty) return null
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
|
import { partnerSas } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { partnerSas } from "@/constants/routes/myPages"
|
|
||||||
|
|
||||||
import { Redirect } from "@/components/Redirect"
|
import { Redirect } from "@/components/Redirect"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ import { SASModal } from "../../components/SASModal"
|
|||||||
import type { LangParams, PageArgs } from "@/types/params"
|
import type { LangParams, PageArgs } from "@/types/params"
|
||||||
|
|
||||||
export default async function SASxScandicLinkPage(props: PageArgs<LangParams>) {
|
export default async function SASxScandicLinkPage(props: PageArgs<LangParams>) {
|
||||||
const params = await props.params;
|
const params = await props.params
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import { cookies } from "next/headers"
|
|||||||
import { redirect } from "next/navigation"
|
import { redirect } from "next/navigation"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import { myPages } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||||
import {
|
import {
|
||||||
SAS_TOKEN_STORAGE_KEY,
|
SAS_TOKEN_STORAGE_KEY,
|
||||||
SAS_TRANSFER_POINT_KEY,
|
SAS_TRANSFER_POINT_KEY,
|
||||||
} from "@scandic-hotels/trpc/constants/partnerSAS"
|
} from "@scandic-hotels/trpc/constants/partnerSAS"
|
||||||
|
|
||||||
import { myPages } from "@/constants/routes/myPages"
|
|
||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import React, { Suspense } from "react"
|
import React, { Suspense } from "react"
|
||||||
|
|
||||||
|
import { partnerSas } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { hotelreservation } from "@/constants/routes/hotelReservation"
|
import { hotelreservation } from "@/constants/routes/hotelReservation"
|
||||||
import { partnerSas } from "@/constants/routes/myPages"
|
|
||||||
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
|
import { overview } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { overview } from "@/constants/routes/myPages"
|
|
||||||
|
|
||||||
import { Redirect } from "@/components/Redirect"
|
import { Redirect } from "@/components/Redirect"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
|
|
||||||
@@ -12,8 +11,10 @@ import { SASModal } from "../../components/SASModal"
|
|||||||
|
|
||||||
import type { LangParams, PageArgs } from "@/types/params"
|
import type { LangParams, PageArgs } from "@/types/params"
|
||||||
|
|
||||||
export default async function SASxScandicUnlinkSuccessPage(props: PageArgs<LangParams>) {
|
export default async function SASxScandicUnlinkSuccessPage(
|
||||||
const params = await props.params;
|
props: PageArgs<LangParams>
|
||||||
|
) {
|
||||||
|
const params = await props.params
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||||
|
import { profile } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
|
|
||||||
import { profile } from "@/constants/routes/myPages"
|
|
||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
import { getPublicURL } from "@/server/utils"
|
import { getPublicURL } from "@/server/utils"
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { type NextRequest, NextResponse } from "next/server"
|
import { type NextRequest, NextResponse } from "next/server"
|
||||||
|
|
||||||
|
import { overview } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { isValidSession } from "@scandic-hotels/trpc/utils/session"
|
import { isValidSession } from "@scandic-hotels/trpc/utils/session"
|
||||||
|
|
||||||
import { DTMC_SUCCESS_BANNER_KEY } from "@/constants/dtmc"
|
import { DTMC_SUCCESS_BANNER_KEY } from "@/constants/dtmc"
|
||||||
import { linkEmploymentError } from "@/constants/routes/dtmc"
|
import { linkEmploymentError } from "@/constants/routes/dtmc"
|
||||||
import { overview } from "@/constants/routes/myPages"
|
|
||||||
import { internalServerError } from "@/server/errors/next"
|
import { internalServerError } from "@/server/errors/next"
|
||||||
import { getPublicURL } from "@/server/utils"
|
import { getPublicURL } from "@/server/utils"
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { type ReactNode, Suspense } from "react"
|
|||||||
import DiamondAddIcon from "@scandic-hotels/design-system/Icons/DiamondAddIcon"
|
import DiamondAddIcon from "@scandic-hotels/design-system/Icons/DiamondAddIcon"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SAS_EUROBONUS_TIER_TO_NAME_MAP,
|
SAS_EUROBONUS_TIER_TO_NAME_MAP,
|
||||||
@@ -17,7 +18,6 @@ import SectionHeader from "@/components/Section/Header"
|
|||||||
import SectionLink from "@/components/Section/Link"
|
import SectionLink from "@/components/Section/Link"
|
||||||
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
import { getEurobonusMembership } from "@/utils/user"
|
|
||||||
|
|
||||||
import { UnlinkSAS } from "./UnlinkSAS"
|
import { UnlinkSAS } from "./UnlinkSAS"
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||||
|
|
||||||
import { getProfileWithExtendedPartnerData } from "@/lib/trpc/memoizedRequests"
|
import { getProfileWithExtendedPartnerData } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
import { getEurobonusMembership } from "@/utils/user"
|
|
||||||
|
|
||||||
import { TransferPointsFormClient } from "./TransferPointsFormClient"
|
import { TransferPointsFormClient } from "./TransferPointsFormClient"
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { usePathname } from "next/navigation"
|
|||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { findMyBookingCurrentWebPath } from "@scandic-hotels/common/constants/routes/findMyBooking"
|
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 { logout } from "@/constants/routes/handleAuth"
|
||||||
import { myPages } from "@/constants/routes/myPages"
|
|
||||||
import { env } from "@/env/client"
|
import { env } from "@/env/client"
|
||||||
import useDropdownStore from "@/stores/main-menu"
|
import useDropdownStore from "@/stores/main-menu"
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { useIntl } from "react-intl"
|
|||||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||||
|
|
||||||
import { logout } from "@/constants/routes/handleAuth"
|
import { logout } from "@/constants/routes/handleAuth"
|
||||||
import { trpc } from "@/lib/trpc/client"
|
|
||||||
import useDropdownStore from "@/stores/main-menu"
|
import useDropdownStore from "@/stores/main-menu"
|
||||||
|
|
||||||
|
import { useMyPagesNavigation } from "@/components/Header/MainMenu/MyPagesMenuContent"
|
||||||
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
import Title from "@/components/TempDesignSystem/Text/Title"
|
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 { logout } from "@/constants/routes/handleAuth"
|
||||||
import { overview } from "@/constants/routes/myPages"
|
|
||||||
import { getName } from "@/lib/trpc/memoizedRequests"
|
import { getName } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import LoginButton from "@/components/LoginButton"
|
import LoginButton from "@/components/LoginButton"
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import { useEffect, useState } from "react"
|
|||||||
import { FormProvider, useForm } from "react-hook-form"
|
import { FormProvider, useForm } from "react-hook-form"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { profile } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { langToApiLang } from "@scandic-hotels/trpc/constants/apiLang"
|
import { langToApiLang } from "@scandic-hotels/trpc/constants/apiLang"
|
||||||
|
|
||||||
import { getDefaultCountryFromLang } from "@/constants/languages"
|
import { getDefaultCountryFromLang } from "@/constants/languages"
|
||||||
import { logout } from "@/constants/routes/handleAuth"
|
import { logout } from "@/constants/routes/handleAuth"
|
||||||
import { profile } from "@/constants/routes/myPages"
|
|
||||||
import { trpc } from "@/lib/trpc/client"
|
import { trpc } from "@/lib/trpc/client"
|
||||||
|
|
||||||
import { editProfile } from "@/actions/editProfile"
|
import { editProfile } from "@/actions/editProfile"
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import useLang from "@/hooks/useLang"
|
|||||||
|
|
||||||
import styles from "./myPagesMenuContent.module.css"
|
import styles from "./myPagesMenuContent.module.css"
|
||||||
|
|
||||||
|
import type { MyPagesLinkKey } from "@scandic-hotels/trpc/routers/navigation/mypages/MyPagesLink"
|
||||||
|
|
||||||
import type { MyPagesMenuProps } from "../MyPagesMenu"
|
import type { MyPagesMenuProps } from "../MyPagesMenu"
|
||||||
|
|
||||||
type Props = MyPagesMenuProps & { toggleOpenStateFn: () => void }
|
type Props = MyPagesMenuProps & { toggleOpenStateFn: () => void }
|
||||||
@@ -165,7 +167,51 @@ function SecondaryLinks({
|
|||||||
|
|
||||||
export const useMyPagesNavigation = () => {
|
export const useMyPagesNavigation = () => {
|
||||||
const lang = useLang()
|
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,
|
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 { FormProvider, useForm } from "react-hook-form"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { profileEdit } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { profileEdit } from "@/constants/routes/myPages"
|
|
||||||
import { isWebview } from "@/constants/routes/webviews"
|
import { isWebview } from "@/constants/routes/webviews"
|
||||||
import { trpc } from "@/lib/trpc/client"
|
import { trpc } from "@/lib/trpc/client"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
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 { isValidLang } from "@scandic-hotels/common/utils/languages"
|
||||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
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 { countriesMap } from "@scandic-hotels/trpc/constants/countries"
|
||||||
|
|
||||||
import { languages } from "@/constants/languages"
|
import { languages } from "@/constants/languages"
|
||||||
import { profileEdit } from "@/constants/routes/myPages"
|
|
||||||
import { getProfile } from "@/lib/trpc/memoizedRequests"
|
import { getProfile } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import ButtonLink from "@/components/ButtonLink"
|
import ButtonLink from "@/components/ButtonLink"
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import { usePathname, useRouter } from "next/navigation"
|
|||||||
import { useEffect, useRef } from "react"
|
import { useEffect, useRef } from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { partnerSas } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
|
|
||||||
import { TIER_TO_FRIEND_MAP } from "@/constants/membershipLevels"
|
import { TIER_TO_FRIEND_MAP } from "@/constants/membershipLevels"
|
||||||
import { partnerSas } from "@/constants/routes/myPages"
|
|
||||||
import { trpc } from "@/lib/trpc/client"
|
import { trpc } from "@/lib/trpc/client"
|
||||||
|
|
||||||
import { toast } from "@/components/TempDesignSystem/Toasts"
|
import { toast } from "@/components/TempDesignSystem/Toasts"
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import React, { useState } from "react"
|
|||||||
import { Dialog, Modal, ModalOverlay } from "react-aria-components"
|
import { Dialog, Modal, ModalOverlay } from "react-aria-components"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { benefits } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { benefits } from "@/constants/routes/myPages"
|
|
||||||
import {
|
import {
|
||||||
benefits as webviewBenefits,
|
benefits as webviewBenefits,
|
||||||
myPagesWebviews,
|
myPagesWebviews,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { headers } from "next/headers"
|
import { headers } from "next/headers"
|
||||||
import { redirect } from "next/navigation"
|
import { redirect } from "next/navigation"
|
||||||
|
|
||||||
|
import { overview } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { isValidSession } from "@scandic-hotels/trpc/utils/session"
|
import { isValidSession } from "@scandic-hotels/trpc/utils/session"
|
||||||
|
|
||||||
import { overview } from "@/constants/routes/myPages"
|
|
||||||
import { getProfile } from "@/lib/trpc/memoizedRequests"
|
import { getProfile } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import { auth } from "@/auth"
|
import { auth } from "@/auth"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
profile,
|
profile,
|
||||||
profileEdit,
|
profileEdit,
|
||||||
stays,
|
stays,
|
||||||
} from "./myPages"
|
} from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are routes in code we know requires auth
|
* These are routes in code we know requires auth
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { type NextMiddleware, NextResponse } from "next/server"
|
import { type NextMiddleware, NextResponse } from "next/server"
|
||||||
|
|
||||||
import { findLang } from "@scandic-hotels/common/utils/languages"
|
|
||||||
import { resolve as resolveEntry } from "@scandic-hotels/trpc/utils/entry"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
myPages,
|
myPages,
|
||||||
overview,
|
overview,
|
||||||
profile,
|
profile,
|
||||||
profileEdit,
|
profileEdit,
|
||||||
} from "@/constants/routes/myPages"
|
} from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
|
import { findLang } from "@scandic-hotels/common/utils/languages"
|
||||||
|
import { resolve as resolveEntry } from "@scandic-hotels/trpc/utils/entry"
|
||||||
|
|
||||||
import { internalServerError, notFound } from "@/server/errors/next"
|
import { internalServerError, notFound } from "@/server/errors/next"
|
||||||
import { getPublicNextURL } from "@/server/utils"
|
import { getPublicNextURL } from "@/server/utils"
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import * as Sentry from "@sentry/nextjs"
|
|||||||
import createJiti from "jiti"
|
import createJiti from "jiti"
|
||||||
|
|
||||||
import { findMyBooking } from "@scandic-hotels/common/constants/routes/findMyBooking"
|
import { findMyBooking } from "@scandic-hotels/common/constants/routes/findMyBooking"
|
||||||
|
import { myPages } from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import {
|
import {
|
||||||
myStay,
|
myStay,
|
||||||
preliminaryReceipt,
|
preliminaryReceipt,
|
||||||
} from "@scandic-hotels/common/constants/routes/myStay"
|
} from "@scandic-hotels/common/constants/routes/myStay"
|
||||||
|
|
||||||
import { login, logout } from "./constants/routes/handleAuth.js"
|
import { login, logout } from "./constants/routes/handleAuth.js"
|
||||||
import { myPages } from "./constants/routes/myPages.js"
|
|
||||||
import {
|
import {
|
||||||
myStay as myStayWebview,
|
myStay as myStayWebview,
|
||||||
preliminaryReceipt as preliminaryReceiptWebview,
|
preliminaryReceipt as preliminaryReceiptWebview,
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { autocompleteRouter } from "@scandic-hotels/trpc/routers/autocomplete"
|
|||||||
import { bookingRouter } from "@scandic-hotels/trpc/routers/booking"
|
import { bookingRouter } from "@scandic-hotels/trpc/routers/booking"
|
||||||
import { contentstackRouter } from "@scandic-hotels/trpc/routers/contentstack"
|
import { contentstackRouter } from "@scandic-hotels/trpc/routers/contentstack"
|
||||||
import { hotelsRouter } from "@scandic-hotels/trpc/routers/hotels"
|
import { hotelsRouter } from "@scandic-hotels/trpc/routers/hotels"
|
||||||
|
import { navigationRouter } from "@scandic-hotels/trpc/routers/navigation"
|
||||||
import { partnerRouter } from "@scandic-hotels/trpc/routers/partners"
|
import { partnerRouter } from "@scandic-hotels/trpc/routers/partners"
|
||||||
|
|
||||||
import { navigationRouter } from "./routers/navigation"
|
|
||||||
import { userRouter } from "./routers/user"
|
import { userRouter } from "./routers/user"
|
||||||
|
|
||||||
export const appRouter = router({
|
export const appRouter = router({
|
||||||
|
|||||||
@@ -4,22 +4,7 @@ import {
|
|||||||
} from "@scandic-hotels/common/constants/membershipLevels"
|
} from "@scandic-hotels/common/constants/membershipLevels"
|
||||||
import { scandicMembershipTypes } from "@scandic-hotels/trpc/routers/user/helpers"
|
import { scandicMembershipTypes } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||||
|
|
||||||
import type {
|
import type { User, UserLoyalty } from "@scandic-hotels/trpc/types/user"
|
||||||
EurobonusMembership,
|
|
||||||
Membership,
|
|
||||||
User,
|
|
||||||
UserLoyalty,
|
|
||||||
} from "@scandic-hotels/trpc/types/user"
|
|
||||||
|
|
||||||
function isEurobonusMembership(
|
|
||||||
membership: Membership
|
|
||||||
): membership is EurobonusMembership {
|
|
||||||
return membership.type === scandicMembershipTypes.SAS_EB
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getEurobonusMembership(loyalty: UserLoyalty) {
|
|
||||||
return loyalty.memberships?.find(isEurobonusMembership)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getMembershipCards(userLoyalty: UserLoyalty) {
|
export function getMembershipCards(userLoyalty: UserLoyalty) {
|
||||||
return userLoyalty.memberships
|
return userLoyalty.memberships
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
/**
|
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
|
||||||
* @file Due to these records being used in next.config.js, and that is required
|
|
||||||
* to be a js file, we use jsdoc to type these.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are routes that define code entries for My pages
|
* These are routes that define code entries for My pages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const scandicFriends: LangRoute = {
|
||||||
export const scandicFriends = {
|
|
||||||
da: "/da/scandic-friends",
|
da: "/da/scandic-friends",
|
||||||
de: "/de/scandic-friends",
|
de: "/de/scandic-friends",
|
||||||
en: "/en/scandic-friends",
|
en: "/en/scandic-friends",
|
||||||
@@ -17,8 +13,7 @@ export const scandicFriends = {
|
|||||||
sv: "/sv/scandic-friends",
|
sv: "/sv/scandic-friends",
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const myPages: LangRoute = {
|
||||||
export const myPages = {
|
|
||||||
da: `${scandicFriends.da}/mine-sider`,
|
da: `${scandicFriends.da}/mine-sider`,
|
||||||
de: `${scandicFriends.de}/mein-bereich`,
|
de: `${scandicFriends.de}/mein-bereich`,
|
||||||
en: `${scandicFriends.en}/my-pages`,
|
en: `${scandicFriends.en}/my-pages`,
|
||||||
@@ -27,8 +22,7 @@ export const myPages = {
|
|||||||
sv: `${scandicFriends.sv}/mina-sidor`,
|
sv: `${scandicFriends.sv}/mina-sidor`,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const overview: LangRoute = {
|
||||||
export const overview = {
|
|
||||||
da: `${myPages.da}/oversigt`,
|
da: `${myPages.da}/oversigt`,
|
||||||
de: `${myPages.de}/uberblick`,
|
de: `${myPages.de}/uberblick`,
|
||||||
en: `${myPages.en}/overview`,
|
en: `${myPages.en}/overview`,
|
||||||
@@ -38,8 +32,7 @@ export const overview = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** TODO: Update to relevant paths */
|
/** TODO: Update to relevant paths */
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const profile: LangRoute = {
|
||||||
export const profile = {
|
|
||||||
da: `${myPages.da}/profil`,
|
da: `${myPages.da}/profil`,
|
||||||
de: `${myPages.de}/profil`,
|
de: `${myPages.de}/profil`,
|
||||||
en: `${myPages.en}/profile`,
|
en: `${myPages.en}/profile`,
|
||||||
@@ -48,8 +41,7 @@ export const profile = {
|
|||||||
sv: `${myPages.sv}/profil`,
|
sv: `${myPages.sv}/profil`,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const profileEdit: LangRoute = {
|
||||||
export const profileEdit = {
|
|
||||||
da: `${profile.da}/rediger`,
|
da: `${profile.da}/rediger`,
|
||||||
de: `${profile.de}/bearbeiten`,
|
de: `${profile.de}/bearbeiten`,
|
||||||
en: `${profile.en}/edit`,
|
en: `${profile.en}/edit`,
|
||||||
@@ -58,8 +50,7 @@ export const profileEdit = {
|
|||||||
sv: `${profile.sv}/redigera`,
|
sv: `${profile.sv}/redigera`,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const points: LangRoute = {
|
||||||
export const points = {
|
|
||||||
da: `${myPages.da}/point`,
|
da: `${myPages.da}/point`,
|
||||||
de: `${myPages.de}/punkte`,
|
de: `${myPages.de}/punkte`,
|
||||||
en: `${myPages.en}/points`,
|
en: `${myPages.en}/points`,
|
||||||
@@ -68,8 +59,7 @@ export const points = {
|
|||||||
sv: `${myPages.sv}/poang`,
|
sv: `${myPages.sv}/poang`,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const benefits: LangRoute = {
|
||||||
export const benefits = {
|
|
||||||
da: `${myPages.da}/fordele`,
|
da: `${myPages.da}/fordele`,
|
||||||
de: `${myPages.de}/vorteile`,
|
de: `${myPages.de}/vorteile`,
|
||||||
en: `${myPages.en}/benefits`,
|
en: `${myPages.en}/benefits`,
|
||||||
@@ -78,8 +68,7 @@ export const benefits = {
|
|||||||
sv: `${myPages.sv}/formaner`,
|
sv: `${myPages.sv}/formaner`,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const stays: LangRoute = {
|
||||||
export const stays = {
|
|
||||||
da: `${myPages.da}/ophold`,
|
da: `${myPages.da}/ophold`,
|
||||||
de: `${myPages.de}/aufenthalte`,
|
de: `${myPages.de}/aufenthalte`,
|
||||||
en: `${myPages.en}/stays`,
|
en: `${myPages.en}/stays`,
|
||||||
@@ -88,8 +77,7 @@ export const stays = {
|
|||||||
sv: `${myPages.sv}/vistelser`,
|
sv: `${myPages.sv}/vistelser`,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
export const partnerSas: LangRoute = {
|
||||||
export const partnerSas = {
|
|
||||||
da: `${myPages.da}/sas-eurobonus`,
|
da: `${myPages.da}/sas-eurobonus`,
|
||||||
de: `${myPages.de}/sas-eurobonus`,
|
de: `${myPages.de}/sas-eurobonus`,
|
||||||
en: `${myPages.en}/sas-eurobonus`,
|
en: `${myPages.en}/sas-eurobonus`,
|
||||||
6
packages/trpc/env/server.ts
vendored
6
packages/trpc/env/server.ts
vendored
@@ -21,6 +21,11 @@ export const env = createEnv({
|
|||||||
SAS_AUTH_ENDPOINT: z.string().default(""),
|
SAS_AUTH_ENDPOINT: z.string().default(""),
|
||||||
SAS_OCP_APIM: z.string().default(""),
|
SAS_OCP_APIM: z.string().default(""),
|
||||||
SAS_AUTH_CLIENTID: z.string().default(""),
|
SAS_AUTH_CLIENTID: z.string().default(""),
|
||||||
|
SAS_ENABLED: z
|
||||||
|
.string()
|
||||||
|
.refine((s) => s === "1" || s === "0")
|
||||||
|
.transform((s) => s === "1")
|
||||||
|
.default("0"),
|
||||||
CACHE_TIME_HOTELS: z.coerce
|
CACHE_TIME_HOTELS: z.coerce
|
||||||
.number()
|
.number()
|
||||||
.default(TWENTYFOUR_HOURS)
|
.default(TWENTYFOUR_HOURS)
|
||||||
@@ -53,6 +58,7 @@ export const env = createEnv({
|
|||||||
SAS_AUTH_ENDPOINT: process.env.SAS_AUTH_ENDPOINT,
|
SAS_AUTH_ENDPOINT: process.env.SAS_AUTH_ENDPOINT,
|
||||||
SAS_OCP_APIM: process.env.SAS_OCP_APIM,
|
SAS_OCP_APIM: process.env.SAS_OCP_APIM,
|
||||||
SAS_AUTH_CLIENTID: process.env.SAS_AUTH_CLIENTID,
|
SAS_AUTH_CLIENTID: process.env.SAS_AUTH_CLIENTID,
|
||||||
|
SAS_ENABLED: process.env.SAS,
|
||||||
CACHE_TIME_HOTELS: process.env.CACHE_TIME_HOTELS,
|
CACHE_TIME_HOTELS: process.env.CACHE_TIME_HOTELS,
|
||||||
CACHE_TIME_CITY_SEARCH: process.env.CACHE_TIME_CITY_SEARCH,
|
CACHE_TIME_CITY_SEARCH: process.env.CACHE_TIME_CITY_SEARCH,
|
||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { router } from "@scandic-hotels/trpc"
|
import { router } from "../.."
|
||||||
|
|
||||||
import { myPagesNavigation } from "./mypages/index"
|
import { myPagesNavigation } from "./mypages/index"
|
||||||
|
|
||||||
export const navigationRouter = router({ myPages: myPagesNavigation })
|
export const navigationRouter = router({ myPages: myPagesNavigation })
|
||||||
@@ -1,6 +1,16 @@
|
|||||||
|
export type MyPagesLinkKey =
|
||||||
|
| "overview"
|
||||||
|
| "points"
|
||||||
|
| "stays"
|
||||||
|
| "benefits"
|
||||||
|
| "partnerSas"
|
||||||
|
| "teamMemberCard"
|
||||||
|
| "scandicFriends"
|
||||||
|
| "profile"
|
||||||
|
|
||||||
type BaseLink = {
|
type BaseLink = {
|
||||||
type: "link" | "withbadge"
|
type: "link" | "withbadge"
|
||||||
text: string
|
key: MyPagesLinkKey
|
||||||
href: string
|
href: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
import { cache } from "react"
|
import { cache } from "react"
|
||||||
|
|
||||||
|
import * as routes from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||||
|
|
||||||
import * as routes from "@/constants/routes/myPages"
|
import { env } from "../../../../env/server"
|
||||||
import { env } from "@/env/server"
|
import { getEurobonusMembership } from "../../user/helpers"
|
||||||
|
|
||||||
import { getIntl } from "@/i18n"
|
|
||||||
import { getEurobonusMembership } from "@/utils/user"
|
|
||||||
|
|
||||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||||
import type { UserLoyalty } from "@scandic-hotels/trpc/types/user"
|
import type { UserLoyalty } from "@scandic-hotels/trpc/types/user"
|
||||||
@@ -21,38 +19,28 @@ export const getPrimaryLinks = cache(
|
|||||||
lang: Lang
|
lang: Lang
|
||||||
userLoyalty?: UserLoyalty
|
userLoyalty?: UserLoyalty
|
||||||
}): Promise<MyPagesLink[]> => {
|
}): Promise<MyPagesLink[]> => {
|
||||||
const intl = await getIntl({ lang })
|
|
||||||
|
|
||||||
const showSASLink = userLoyalty ? isScandicXSASActive(userLoyalty) : false
|
const showSASLink = userLoyalty ? isScandicXSASActive(userLoyalty) : false
|
||||||
const [showTeamMemberLink] = await safeTry(showTeamMemberCard())
|
const [showTeamMemberLink] = await safeTry(showTeamMemberCard())
|
||||||
|
|
||||||
const menuItems: MyPagesLink[] = [
|
const menuItems: MyPagesLink[] = [
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "overview",
|
||||||
defaultMessage: "Overview",
|
|
||||||
}),
|
|
||||||
href: routes.overview[lang],
|
href: routes.overview[lang],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "points",
|
||||||
defaultMessage: "My points",
|
|
||||||
}),
|
|
||||||
href: routes.points[lang],
|
href: routes.points[lang],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "stays",
|
||||||
defaultMessage: "My stays",
|
|
||||||
}),
|
|
||||||
href: routes.stays[lang],
|
href: routes.stays[lang],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "benefits",
|
||||||
defaultMessage: "My benefits",
|
|
||||||
}),
|
|
||||||
href: routes.benefits[lang],
|
href: routes.benefits[lang],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -60,9 +48,7 @@ export const getPrimaryLinks = cache(
|
|||||||
if (showSASLink) {
|
if (showSASLink) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "partnerSas",
|
||||||
defaultMessage: "Scandic ♥ SAS",
|
|
||||||
}),
|
|
||||||
href: routes.partnerSas[lang],
|
href: routes.partnerSas[lang],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -70,9 +56,7 @@ export const getPrimaryLinks = cache(
|
|||||||
if (showTeamMemberLink) {
|
if (showTeamMemberLink) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "teamMemberCard",
|
||||||
defaultMessage: "Team Member Card",
|
|
||||||
}),
|
|
||||||
href: "#",
|
href: "#",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import * as routes from "@/constants/routes/myPages"
|
import * as routes from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
|
|
||||||
import { getIntl } from "@/i18n"
|
|
||||||
|
|
||||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||||
|
|
||||||
@@ -11,20 +9,15 @@ export async function getSecondaryLinks({
|
|||||||
}: {
|
}: {
|
||||||
lang: Lang
|
lang: Lang
|
||||||
}): Promise<MyPagesLink[]> {
|
}): Promise<MyPagesLink[]> {
|
||||||
const intl = await getIntl({ lang })
|
|
||||||
const menuItems: MyPagesLink[] = [
|
const menuItems: MyPagesLink[] = [
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "scandicFriends",
|
||||||
defaultMessage: "About Scandic Friends",
|
|
||||||
}),
|
|
||||||
href: routes.scandicFriends[lang],
|
href: routes.scandicFriends[lang],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
text: intl.formatMessage({
|
key: "profile",
|
||||||
defaultMessage: "My profile",
|
|
||||||
}),
|
|
||||||
href: routes.profile[lang],
|
href: routes.profile[lang],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -2,10 +2,10 @@ import { TRPCError } from "@trpc/server"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
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 "@scandic-hotels/trpc/utils/session"
|
|
||||||
|
|
||||||
|
import { safeProtectedProcedure } from "../../../procedures"
|
||||||
|
import { getVerifiedUser } from "../../../routers/user/utils"
|
||||||
|
import { isValidSession } from "../../../utils/session"
|
||||||
import { getPrimaryLinks } from "./getPrimaryLinks"
|
import { getPrimaryLinks } from "./getPrimaryLinks"
|
||||||
import { getSecondaryLinks } from "./getSecondaryLinks"
|
import { getSecondaryLinks } from "./getSecondaryLinks"
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
|
EurobonusMembership,
|
||||||
Membership,
|
Membership,
|
||||||
NativeFriendsMembership,
|
NativeFriendsMembership,
|
||||||
UserLoyalty,
|
UserLoyalty,
|
||||||
@@ -45,3 +46,13 @@ export function getFriendsMembership(userLoyalty: UserLoyalty) {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isEurobonusMembership(
|
||||||
|
membership: Membership
|
||||||
|
): membership is EurobonusMembership {
|
||||||
|
return membership.type === scandicMembershipTypes.SAS_EB
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getEurobonusMembership(loyalty: UserLoyalty) {
|
||||||
|
return loyalty.memberships?.find(isEurobonusMembership)
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"./routers/user/*": "./lib/routers/user/*.ts",
|
"./routers/user/*": "./lib/routers/user/*.ts",
|
||||||
"./routers/partners/*": "./lib/routers/partners/*.ts",
|
"./routers/partners/*": "./lib/routers/partners/*.ts",
|
||||||
"./routers/autocomplete/*": "./lib/routers/autocomplete/*.ts",
|
"./routers/autocomplete/*": "./lib/routers/autocomplete/*.ts",
|
||||||
|
"./routers/navigation/*": "./lib/routers/navigation/*.ts",
|
||||||
"./enums/*": "./lib/enums/*.ts",
|
"./enums/*": "./lib/enums/*.ts",
|
||||||
"./types/*": "./lib/types/*.ts",
|
"./types/*": "./lib/types/*.ts",
|
||||||
"./constants/*": "./lib/constants/*.ts",
|
"./constants/*": "./lib/constants/*.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user