Merged in feat/3614-basicInfo (pull request #3427)
feat(SW-3614): use new loyalty prop in basicProfile * feat(SW-3614): use new loyalty prop in basicProfile * PR fixes Approved-by: Matilda Landström
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
|
||||
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||
import {
|
||||
getEurobonusMembership,
|
||||
scandicMembershipTypes,
|
||||
} from "@scandic-hotels/trpc/routers/user/helpers"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
import {
|
||||
getBasicProfileSafely,
|
||||
getProfileSafely,
|
||||
getProfilingConsent,
|
||||
} from "@/lib/trpc/memoizedRequests"
|
||||
@@ -85,10 +89,10 @@ async function MyPagesLayoutBase({
|
||||
breadcrumbs,
|
||||
children,
|
||||
}: MyPagesLayoutProps) {
|
||||
const profile = await getProfileSafely()
|
||||
const eurobonusMembership = profile?.loyalty
|
||||
? getEurobonusMembership(profile.loyalty)
|
||||
: null
|
||||
const profile = await getBasicProfileSafely()
|
||||
const eurobonusMembership = profile?.loyalty?.memberships?.find(
|
||||
(m) => m.membershipType === scandicMembershipTypes.SAS_EB
|
||||
)
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { redirect } from "next/navigation"
|
||||
import React from "react"
|
||||
|
||||
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||
import { scandicMembershipTypes } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||
|
||||
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||
import { getBasicProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { SASModal } from "../components/SASModal"
|
||||
import { LinkAccountForm } from "./LinkAccountForm"
|
||||
@@ -12,11 +12,13 @@ export default async function SASxScandicLinkPage(
|
||||
props: PageProps<"/[lang]/sas-x-scandic/link">
|
||||
) {
|
||||
const params = await props.params
|
||||
const profile = await getProfileSafely()
|
||||
const profile = await getBasicProfileSafely()
|
||||
|
||||
if (!profile || !profile.loyalty) return null
|
||||
|
||||
const eurobonusMembership = getEurobonusMembership(profile.loyalty)
|
||||
const eurobonusMembership = profile.loyalty.memberships?.some(
|
||||
(m) => m.membershipType === scandicMembershipTypes.SAS_EB
|
||||
)
|
||||
|
||||
if (eurobonusMembership) {
|
||||
redirect(`/${params.lang}/sas-x-scandic/error?errorCode=alreadyLinked`)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import ButtonLink from "@scandic-hotels/design-system/ButtonLink"
|
||||
import Image from "@scandic-hotels/design-system/Image"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||
import { scandicMembershipTypes } from "@scandic-hotels/trpc/routers/user/helpers"
|
||||
|
||||
import { getProfile } from "@/lib/trpc/memoizedRequests"
|
||||
import { getBasicProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getIntl } from "@/i18n"
|
||||
import desktopBackground from "@/public/_static/img/sas/sas-scandic-link-account-banner-desktop.png"
|
||||
@@ -17,12 +17,14 @@ export default async function SASLinkAccountBanner(
|
||||
props: DynamicContentProps["dynamic_content"]
|
||||
) {
|
||||
const intl = await getIntl()
|
||||
const user = await getProfile()
|
||||
const user = await getBasicProfileSafely()
|
||||
|
||||
if (!user || "error" in user || !user.loyalty) {
|
||||
return null
|
||||
}
|
||||
const sasMembership = getEurobonusMembership(user.loyalty)
|
||||
const sasMembership = user.loyalty.memberships?.some(
|
||||
(m) => m.membershipType === scandicMembershipTypes.SAS_EB
|
||||
)
|
||||
if (sasMembership) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -22,6 +22,17 @@ export const getBasicProfile = cache(async function getMemoizedBasicProfile() {
|
||||
return caller.user.getBasic()
|
||||
})
|
||||
|
||||
export const getBasicProfileSafely = cache(
|
||||
async function getMemoizedBasicProfile() {
|
||||
try {
|
||||
const caller = await serverClient()
|
||||
return caller.user.getBasic()
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
export const getProfileSafely = cache(
|
||||
async function getMemoizedProfileSafely() {
|
||||
const caller = await serverClient()
|
||||
@@ -59,13 +70,6 @@ export const getMembershipLevelSafely = cache(
|
||||
}
|
||||
)
|
||||
|
||||
export const getMembershipCards = cache(
|
||||
async function getMemoizedMembershipCards() {
|
||||
const caller = await serverClient()
|
||||
return caller.user.membershipCards()
|
||||
}
|
||||
)
|
||||
|
||||
export const getHotelsByCSFilter = cache(async function getMemoizedHotels(
|
||||
input: GetHotelsByCSFilterInput
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user