32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { Lang } from "@/constants/languages"
|
|
import { dt } from "@/lib/dt"
|
|
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import { getIntl } from "@/i18n"
|
|
import { getMembership } from "@/utils/user"
|
|
|
|
import type { UserProps } from "@/types/components/myPages/user"
|
|
|
|
export default async function ExpiringPoints({ user }: UserProps) {
|
|
const { formatMessage } = await getIntl()
|
|
const membership = getMembership(user.memberships)
|
|
// TODO - add correct points when available from API
|
|
if (!membership || !membership.pointsToExpire) {
|
|
// TODO: handle this case?
|
|
return null
|
|
}
|
|
|
|
// sv hardcoded to force space on thousands
|
|
const formatter = new Intl.NumberFormat(Lang.sv)
|
|
const d = dt(membership.pointsExpiryDate)
|
|
return (
|
|
<section>
|
|
<Body color="white" textTransform="bold" textAlign="center">
|
|
{formatter.format(membership.pointsToExpire)}{" "}
|
|
{formatMessage({ id: "spendable points expiring by" })}{" "}
|
|
{d.format("YYYY-MM-DD")}
|
|
</Body>
|
|
</section>
|
|
)
|
|
}
|