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
201 lines
6.0 KiB
TypeScript
201 lines
6.0 KiB
TypeScript
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 { TransferPointsFormClient } from "./TransferPointsFormClient"
|
|
|
|
import styles from "./transferPoints.module.css"
|
|
|
|
import type { Lang } from "@scandic-hotels/common/constants/language"
|
|
|
|
export async function TransferPointsForm({ lang }: { lang: Lang }) {
|
|
const profile = await getProfileWithExtendedPartnerData()
|
|
if (!profile || !profile.loyalty) return null
|
|
|
|
const eurobonusMembership = getEurobonusMembership(profile?.loyalty)
|
|
if (!eurobonusMembership) return null
|
|
|
|
const scandicPoints = profile?.membership?.currentPoints ?? 0
|
|
const sasPoints = eurobonusMembership.spendablePoints || 0
|
|
|
|
// TODO get from api
|
|
const exchangeRate = 2
|
|
|
|
return (
|
|
<TransferPointsFormContent
|
|
sasPoints={sasPoints}
|
|
scandicPoints={scandicPoints}
|
|
exchangeRate={exchangeRate}
|
|
lang={lang}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export async function TransferPointsFormSkeleton({ lang }: { lang: Lang }) {
|
|
return (
|
|
<TransferPointsFormContent
|
|
sasPoints={null}
|
|
scandicPoints={null}
|
|
exchangeRate={null}
|
|
lang={lang}
|
|
/>
|
|
)
|
|
}
|
|
|
|
async function TransferPointsFormContent({
|
|
sasPoints,
|
|
scandicPoints,
|
|
exchangeRate,
|
|
lang,
|
|
}: {
|
|
sasPoints: number | null
|
|
scandicPoints: number | null
|
|
exchangeRate: number | null
|
|
lang: Lang
|
|
}) {
|
|
const intl = await getIntl()
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
<section className={styles.card}>
|
|
<div className={styles.highFive}>
|
|
<Image
|
|
src="/_static/img/scandic-high-five.svg"
|
|
alt=""
|
|
width="111"
|
|
height="139"
|
|
sizes="100vw"
|
|
/>
|
|
</div>
|
|
<div className={styles.transferContainer}>
|
|
<div className={styles.transferFrom}>
|
|
<div>
|
|
<div className={styles.labelWithIcon}>
|
|
<Typography variant="Tag/sm">
|
|
<p>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Transfer from",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
<MaterialIcon icon="upload" />
|
|
</div>
|
|
<Typography variant="Title/Subtitle/md">
|
|
<p>
|
|
{intl.formatMessage({
|
|
defaultMessage: "SAS EuroBonus",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
</div>
|
|
<div>
|
|
<Typography variant="Tag/sm">
|
|
<p className={styles.balanceLabel}>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Balance",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
{sasPoints === null ? (
|
|
<SkeletonShimmer
|
|
width="10ch"
|
|
height="20px"
|
|
display="inline-block"
|
|
/>
|
|
) : (
|
|
<Typography variant="Body/Paragraph/mdRegular">
|
|
<p>
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{points, number} p",
|
|
},
|
|
{ points: sasPoints }
|
|
)}
|
|
</p>
|
|
</Typography>
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className={styles.noPointsWarning}>
|
|
{sasPoints === 0 && (
|
|
<Typography variant="Body/Paragraph/mdRegular">
|
|
<p>
|
|
{intl.formatMessage({
|
|
defaultMessage: "You have no points to transfer.",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
)}
|
|
</div>
|
|
<div className={styles.transferTo}>
|
|
<div>
|
|
<div className={styles.labelWithIcon}>
|
|
<MaterialIcon icon="download" />
|
|
<Typography variant="Tag/sm">
|
|
<p>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Transfer to",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
</div>
|
|
<Typography variant="Title/Subtitle/md">
|
|
<p>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Scandic Friends",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
</div>
|
|
<div>
|
|
<Typography variant="Tag/sm">
|
|
<p className={styles.balanceLabel}>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Balance",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
{scandicPoints === null ? (
|
|
<SkeletonShimmer
|
|
width="10ch"
|
|
height="20px"
|
|
display="inline-block"
|
|
/>
|
|
) : (
|
|
<Typography variant="Body/Paragraph/mdRegular">
|
|
<p>
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{points, number} p",
|
|
},
|
|
{ points: scandicPoints }
|
|
)}
|
|
</p>
|
|
</Typography>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<TransferPointsFormClient
|
|
sasPoints={sasPoints}
|
|
exchangeRate={exchangeRate}
|
|
lang={lang}
|
|
/>
|
|
</section>
|
|
<Typography variant="Body/Supporting text (caption)/smRegular">
|
|
<p style={{ color: "var(--Text-Tertiary)" }}>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Transferred points will not be level qualifying",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
</div>
|
|
)
|
|
}
|