58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import Link from "next/link"
|
|
|
|
import { Lang } from "@/constants/languages"
|
|
import { serverClient } from "@/lib/trpc/server"
|
|
|
|
import Header from "@/components/MyPages/Blocks/Header"
|
|
import CardGrid from "@/components/TempDesignSystem/CardGrid"
|
|
import Title from "@/components/TempDesignSystem/Title"
|
|
|
|
import levelsData from "../data"
|
|
|
|
import styles from "./current.module.css"
|
|
|
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
|
|
|
export default async function CurrentBenefitsBlock({
|
|
title,
|
|
subtitle,
|
|
link,
|
|
}: AccountPageComponentProps) {
|
|
const user = await serverClient().user.get()
|
|
// TODO: level should be fetched from the `user` object once available
|
|
// TAKE NOTE: we need clarification on how benefits stack from different levels
|
|
// in order to determine if a benefit is specific to a level or if it is a cumulative benefit
|
|
// we might have to add a new boolean property "exclusive" or similar
|
|
const userLevel = 1
|
|
|
|
const currentLevel = levelsData[Lang.en].levels.find(
|
|
(level) => level.tier === userLevel
|
|
)
|
|
if (!currentLevel) {
|
|
// TODO: handle this case?
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<section className={styles.container}>
|
|
<Header title={title} link={link} subtitle={subtitle} />
|
|
|
|
<CardGrid>
|
|
{currentLevel.benefits.map((benefit, idx) => (
|
|
<Link
|
|
href={benefit.href}
|
|
key={`${currentLevel}-${idx}`}
|
|
className={styles.card}
|
|
>
|
|
<Title as="h5" level="h3" className={styles.title}>
|
|
<span className={styles.value}>{benefit.value}</span>
|
|
{benefit.explaination ? ` ${benefit.explaination}` : ""}
|
|
</Title>
|
|
<p className={styles.cardSubtitle}>{benefit.description}</p>
|
|
</Link>
|
|
))}
|
|
</CardGrid>
|
|
</section>
|
|
)
|
|
}
|