feat(SW-207): add expiring points and date when they will expire
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
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"
|
||||
@@ -8,16 +11,19 @@ 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.expiringPoints*/) {
|
||||
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">
|
||||
{membership.currentPoints} {formatMessage({ id: "points expiring by" })}{" "}
|
||||
{membership.expirationDate}
|
||||
{formatter.format(membership.pointsToExpire)}{" "}
|
||||
{formatMessage({ id: "points expiring by" })} {d.format("YYYY-MM-DD")}
|
||||
</Body>
|
||||
</section>
|
||||
)
|
||||
|
||||
@@ -26,7 +26,9 @@ export const getUserSchema = z.object({
|
||||
memberSince: z.string(),
|
||||
membershipType: z.string(),
|
||||
nextLevel: z.string().optional(),
|
||||
pointsExpiryDate: z.string().optional(),
|
||||
pointsRequiredToNextlevel: z.number().optional(),
|
||||
pointsToExpire: z.number().optional(),
|
||||
})
|
||||
),
|
||||
phoneNumber: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user