Feat(WEB-307) Display correct membership information * fix: fix typo * chore: update fetch of user membership * chore: update components to use api data * chore: remove lang as static value * fix: adapt to dev updates * fix: adapt to code from dev * fix: break out MembershipLevel into its a React component * fix: add enum to zod validation * refactor: rename tier to level * refactor: remove unnecessary casts * refactor: change toString() to hideEmpty=false * refactor: remove toString() * refactor: remove hideEmpty from title and subtitle * fix: update currentLevel with data * fix: fix from rebase Approved-by: Michael Zetterberg
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { serverClient } from "@/lib/trpc/server"
|
|
|
|
import Header from "@/components/SectionHeader"
|
|
import { getIntl } from "@/i18n"
|
|
import { getMembership } from "@/utils/user"
|
|
|
|
import styles from "./currentPointsBalance.module.css"
|
|
|
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
|
|
|
async function CurrentPointsBalance({
|
|
title,
|
|
subtitle,
|
|
link,
|
|
}: AccountPageComponentProps) {
|
|
const user = await serverClient().user.get()
|
|
const { formatMessage } = await getIntl()
|
|
if (!user) {
|
|
return null
|
|
}
|
|
const membership = getMembership(user.memberships)
|
|
return (
|
|
<div>
|
|
<Header title={title} link={link} subtitle={subtitle} />
|
|
<div className={styles.card}>
|
|
<h2>{`${formatMessage({ id: "Total Points" })}*`}</h2>
|
|
<p className={styles.points}>
|
|
{`${formatMessage({ id: "Points" })}: ${membership ? membership.currentPoints : "N/A"}`}
|
|
</p>
|
|
<p className={styles.disclaimer}>
|
|
{`*${formatMessage({ id: "Points may take up to 10 days to be displayed." })}`}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default CurrentPointsBalance
|