feat: update loyalty overview table ui

This commit is contained in:
Matilda Landström
2024-06-28 10:13:32 +02:00
parent 1c76725b4c
commit 1186511038
35 changed files with 433 additions and 396 deletions

View File

@@ -1,24 +1,14 @@
import { getHighestLevel } from "@/utils/loyaltyTable"
import BenefitCard from "../BenefitCard"
import styles from "./benefitList.module.css"
import {
BenefitListProps,
ComparisonLevel,
} from "@/types/components/loyalty/blocks"
import { BenefitListProps } from "@/types/components/loyalty/blocks"
export default function BenefitList({ levels }: BenefitListProps) {
const highestTier = levels.reduce(
(acc: ComparisonLevel | null, level: ComparisonLevel) => {
if (!acc) {
return level
}
return level.tier > acc.tier ? level : acc
},
null
)
return highestTier?.benefits
const highestLevel = getHighestLevel(levels)
return highestLevel?.benefits
.filter((benefit) => benefit.unlocked)
.map((benefit, idx) => {
const levelBenefits = levels.map((level) => level.benefits[idx])