Files
web/components/MyPages/Blocks/Benefits/NextLevel/index.tsx
Matilda Landström bb422f804d Merged in feat/card-grid-ui (pull request #332)
Feat/card grid ui

Approved-by: Simon.Emanuelsson
2024-07-09 11:16:44 +00:00

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 Body from "@/components/TempDesignSystem/Text/Body"
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 columns={2}>
{nextLevel.benefits.map((benefit) => (
<article key={benefit.title} className={styles.card}>
<Chip>
<Lock height={16} />
{formatMessage({ id: "Level up to unlock" })}
</Chip>
<div>
<Body color="peach50" textAlign="center">
{formatMessage({ id: "As our" })} {nextLevel.name}
</Body>{" "}
<Subtitle
color="pale"
textAlign="center"
textTransform="uppercase"
>
{benefit.title}
</Subtitle>
</div>
</article>
))}
</Grids.Stackable>
<SectionLink link={link} variant="mobile" />
</SectionContainer>
)
}