Feat(WEB-359): Update section link for mobile Approved-by: Chuma Mcphoy (We Ahead) Approved-by: Arvid Norlin
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { Lock } from "react-feather"
|
|
|
|
import { MembershipLevelEnum } from "@/constants/membershipLevels"
|
|
import { serverClient } from "@/lib/trpc/server"
|
|
|
|
import SectionContainer from "@/components/Section/Container"
|
|
import SectionHeader from "@/components/Section/Header"
|
|
import SectionLink from "@/components/Section/Link"
|
|
import Chip from "@/components/TempDesignSystem/Chip"
|
|
import Grids from "@/components/TempDesignSystem/Grids"
|
|
import BiroScript from "@/components/TempDesignSystem/Text/BiroScript"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
import { getIntl } from "@/i18n"
|
|
import { getMembershipLevelObject } from "@/utils/membershipLevel"
|
|
|
|
import styles from "./next.module.css"
|
|
|
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
|
|
|
export default async function NextLevelBenefitsBlock({
|
|
title,
|
|
subtitle,
|
|
lang,
|
|
link,
|
|
}: AccountPageComponentProps) {
|
|
const { formatMessage } = await getIntl()
|
|
const user = await serverClient().user.get()
|
|
if (!user) {
|
|
return null
|
|
}
|
|
const nextLevel = getMembershipLevelObject(
|
|
user.memberships[0].membershipLevel as MembershipLevelEnum,
|
|
lang,
|
|
"nextLevel"
|
|
)
|
|
if (!nextLevel) {
|
|
// TODO: handle this case, when missing or when user is top level?
|
|
return null
|
|
}
|
|
// TODO: how to handle different count of unlockable benefits?
|
|
return (
|
|
<SectionContainer>
|
|
<SectionHeader title={title} subtitle={subtitle} link={link} />
|
|
<Grids.Stackable>
|
|
{nextLevel.benefits.map((benefit) => (
|
|
<article key={benefit.title} className={styles.card}>
|
|
<Chip>
|
|
<Lock height={16} />
|
|
{formatMessage({ id: "Level up to unlock" })}
|
|
</Chip>
|
|
<div>
|
|
<BiroScript
|
|
className={styles.level}
|
|
color="primaryLightOnSurfaceAccent"
|
|
textAlign="center"
|
|
type="two"
|
|
>
|
|
{formatMessage({ id: "As our" })} {nextLevel.name}
|
|
</BiroScript>{" "}
|
|
<Subtitle color="pale" textAlign="center">
|
|
{benefit.title}
|
|
</Subtitle>
|
|
</div>
|
|
</article>
|
|
))}
|
|
</Grids.Stackable>
|
|
<SectionLink link={link} variant="mobile" />
|
|
</SectionContainer>
|
|
)
|
|
}
|