Merged in fix/LOY-439-boosted-by-sas-bug (pull request #3047)

fix(LOY-439): fix "boosted by sas" issue

* fix(LOY-439): fix "boosted by sas" issue


Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
Matilda Landström
2025-11-04 09:09:30 +00:00
parent 20d1ba305a
commit 4970dfa2ed
5 changed files with 27 additions and 42 deletions

View File

@@ -2,37 +2,28 @@ import { dt } from "@scandic-hotels/common/dt"
import { Divider } from "@scandic-hotels/design-system/Divider"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import { getSasTierExpirationDate } from "@/utils/sas"
import styles from "./membershipOverviewCard.module.css"
import type { EurobonusMembership } from "@scandic-hotels/trpc/types/user"
import type { IntlShape } from "react-intl"
interface SasBoostStatusProps {
sasMembership: EurobonusMembership
intl: IntlShape
expiryDate: string
}
export default async function SasBoostStatus({
sasMembership,
intl,
expiryDate,
}: SasBoostStatusProps) {
const lang = await getLang()
const tierExpirationDate = getSasTierExpirationDate(sasMembership)
if (!tierExpirationDate || sasMembership.boostedByScandic) {
return null
}
const intl = await getIntl()
const sasBoostExpiryText = intl.formatMessage(
{
id: "membershipOverViewCard.sasBoostedUntilDate",
defaultMessage: "Linked with SAS until {date}",
defaultMessage: "Boosted by SAS until {date}",
},
{
date: dt(tierExpirationDate).locale(lang).format("D MMM YYYY"),
date: dt(expiryDate).locale(lang).format("D MMM YYYY"),
}
)
@@ -40,7 +31,7 @@ export default async function SasBoostStatus({
<>
<Divider variant="vertical" color="Border/Divider/Accent" />
<Typography variant="Label/xsRegular">
<span className={styles.sasBoostText}>{sasBoostExpiryText}</span>
<span className={styles.headingText}>{sasBoostExpiryText}</span>
</Typography>
</>
)

View File

@@ -2,13 +2,12 @@ import { MembershipLevelEnum } from "@scandic-hotels/common/constants/membership
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 { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
import { isBoostedBySas } from "@scandic-hotels/trpc/routers/user/helpers"
import { membershipLevels } from "@/constants/membershipLevels"
import MembershipLevelIcon from "@/components/Levels/Icon"
import { getIntl } from "@/i18n"
import { getSasTierExpirationDate } from "@/utils/sas"
import SasBoostStatus from "./SasBoostStatus"
@@ -34,23 +33,16 @@ export default async function MembershipOverviewCard({
? intl.formatNumber(user.membership.currentPoints)
: intl.formatMessage({ id: "common.NA", defaultMessage: "N/A" })
const sasMembership = user.loyalty
? getEurobonusMembership(user.loyalty)
: null
const showSasBoostIcon =
sasMembership &&
getSasTierExpirationDate(sasMembership) &&
!sasMembership.boostedByScandic
const boostedBySas = user.loyalty ? isBoostedBySas(user.loyalty) : null
return (
<section className={styles.card} aria-labelledby="membership-level">
<header className={styles.membershipHeader}>
{showSasBoostIcon && (
{boostedBySas ? (
<MaterialIcon icon="travel" size={20} color="Icon/Accent" />
)}
) : null}
<Typography variant="Title/Overline/sm">
<h2 className={styles.levelText} id="membership-level">
<h2 className={styles.headingText} id="membership-level">
{intl.formatMessage(
{
id: "common.membershipLevelWithValue",
@@ -60,9 +52,10 @@ export default async function MembershipOverviewCard({
)}
</h2>
</Typography>
{sasMembership && (
<SasBoostStatus sasMembership={sasMembership} intl={intl} />
)}
{user.loyalty && boostedBySas ? (
<SasBoostStatus expiryDate={user.loyalty?.tierExpires} />
) : null}
</header>
<MembershipLevelIcon
@@ -78,7 +71,7 @@ export default async function MembershipOverviewCard({
/>
<Typography variant="Title/Overline/sm">
<h3 className={styles.pointsLabel}>
<h3 className={styles.headingText}>
{intl.formatMessage({
id: "common.pointsToSpend",
defaultMessage: "Points to spend",

View File

@@ -16,16 +16,10 @@
margin-bottom: var(--Space-x05);
}
.levelText,
.sasBoostText,
.pointsLabel {
.headingText {
color: var(--Text-Brand-OnPrimary-3-Heading);
}
.levelText {
text-transform: uppercase;
}
.divider {
margin: var(--Space-x4) 0;
}

View File

@@ -5,7 +5,10 @@ import DiamondAddIcon from "@scandic-hotels/design-system/Icons/DiamondAddIcon"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import SkeletonShimmer from "@scandic-hotels/design-system/SkeletonShimmer"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
import {
getEurobonusMembership,
isBoostedBySas,
} from "@scandic-hotels/trpc/routers/user/helpers"
import {
SAS_EUROBONUS_TIER_TO_NAME_MAP,
@@ -346,7 +349,7 @@ function calculateMatchState(loyalty: UserLoyalty): MatchState {
if (eurobonusMembership?.boostedByScandic) return "boostedByScandic"
if (!loyalty.tierBoostedBy) return "noBoost"
if (loyalty.tierBoostedBy === "SAS_EB") return "boostedBySAS"
if (isBoostedBySas(loyalty)) return "boostedBySAS"
return "noBoost"
}

View File

@@ -48,6 +48,10 @@ export function getFriendsMembership(userLoyalty: UserLoyalty) {
return result
}
export function isBoostedBySas(loyalty: UserLoyalty) {
return loyalty.tierBoostedBy === scandicMembershipTypes.SAS_EB
}
function isEurobonusMembership(
membership: Membership
): membership is EurobonusMembership {