fix: allow any membership level

This commit is contained in:
Michael Zetterberg
2024-08-27 07:40:07 +02:00
parent fcf0f58ab8
commit 2ea6a2d242
4 changed files with 9 additions and 5 deletions

View File

@@ -63,6 +63,7 @@ function getInitialState({ user, lang }: { user?: User; lang: Lang }) {
}
}
if (!membership.membershipLevel) return null
// @ts-expect-error: membership levels needs proper fix
const level = membershipLevels[membership.membershipLevel]
switch (level) {
@@ -155,6 +156,7 @@ export default function OverviewTable({
let activeMembershipLevel: membershipLevels | null = null
if (activeMembership?.membershipLevel) {
// @ts-expect-error: membershiplevel needs proper fix
activeMembershipLevel = membershipLevels[activeMembership?.membershipLevel]
}

View File

@@ -22,6 +22,7 @@ export default async function Friend({
if (!membership?.membershipLevel) {
return null
}
// @ts-expect-error: membershiplevel needs proper fix
const isHighestLevel = isHighestMembership(membership.membershipLevel)
return (
@@ -31,11 +32,13 @@ export default async function Friend({
{formatMessage(
isHighestLevel
? { id: "Highest level" }
: { id: `Level ${membershipLevels[membership.membershipLevel]}` }
: // @ts-expect-error: membershiplevel needs proper fix
{ id: `Level ${membershipLevels[membership.membershipLevel]}` }
)}
</Body>
{membership ? (
<MembershipLevel
// @ts-expect-error: membershiplevel needs proper fix
level={membershipLevels[membership.membershipLevel]}
/>
) : null}

View File

@@ -1,7 +1,5 @@
import { z } from "zod"
import { MembershipLevelEnum } from "@/constants/membershipLevels"
import { countriesMap } from "@/components/TempDesignSystem/Form/Country/countries"
export const getUserSchema = z.object({
@@ -22,7 +20,7 @@ export const getUserSchema = z.object({
currentPoints: z.number(),
expirationDate: z.string(),
membershipNumber: z.string(),
membershipLevel: z.nativeEnum(MembershipLevelEnum).optional(),
membershipLevel: z.string().optional(),
memberSince: z.string(),
membershipType: z.string(),
nextLevel: z.string().optional(),

View File

@@ -33,6 +33,7 @@ import type {
LoginType,
TrackingSDKUserData,
} from "@/types/components/tracking"
import type { MembershipLevel } from "@/constants/membershipLevels"
// OpenTelemetry metrics: User
const meter = metrics.getMeter("trpc.user")
@@ -437,7 +438,7 @@ export const userQueryRouter = router({
loginStatus: "logged in",
loginType: ctx.session.token.loginType as LoginType,
memberId: membership?.membershipNumber,
memberLevel: membership?.membershipLevel,
memberLevel: membership?.membershipLevel as MembershipLevel,
noOfNightsStayed: verifiedPreviousStaysData.data.links?.totalCount ?? 0,
totalPointsAvailableToSpend: membership?.currentPoints,
loginAction: "login success",