feat: use hardcodded benefits data
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
import DA from "./DA.json"
|
||||
import DE from "./DE.json"
|
||||
import EN from "./EN.json"
|
||||
import FI from "./FI.json"
|
||||
import NO from "./NO.json"
|
||||
import SV from "./SV.json"
|
||||
|
||||
const levelsData = {
|
||||
[Lang.en]: EN,
|
||||
[Lang.sv]: SV,
|
||||
[Lang.no]: NO,
|
||||
[Lang.fi]: FI,
|
||||
[Lang.da]: DA,
|
||||
[Lang.de]: DE,
|
||||
}
|
||||
|
||||
export default levelsData
|
||||
@@ -1,24 +1,30 @@
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
import { Check } from "react-feather"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { _ } from "@/lib/translation"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Image from "@/components/Image"
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
import Title from "@/components/Title"
|
||||
|
||||
import levelsData from "./data"
|
||||
|
||||
import styles from "./loyaltyLevels.module.css"
|
||||
|
||||
import { LevelCardProps } from "@/types/components/loyalty/blocks"
|
||||
import { Level, LevelCardProps } from "@/types/components/loyalty/blocks"
|
||||
|
||||
export default async function LoyaltyLevels() {
|
||||
const data = await serverClient().loyalty.levels.all()
|
||||
export default function LoyaltyLevels() {
|
||||
const { lang } = useParams()
|
||||
|
||||
const { levels } = levelsData[lang as Lang]
|
||||
return (
|
||||
<section className={styles.container}>
|
||||
<div className={styles.cardContainer}>
|
||||
{data.map((level) => (
|
||||
{levels.map((level: Level) => (
|
||||
<LevelCard key={level.tier} level={level} />
|
||||
))}
|
||||
</div>
|
||||
@@ -32,17 +38,23 @@ export default async function LoyaltyLevels() {
|
||||
}
|
||||
|
||||
function LevelCard({ level }: LevelCardProps) {
|
||||
const { lang } = useParams()
|
||||
|
||||
const pointsString = `${level.requiredPoints.toLocaleString(lang)}p`
|
||||
const qualifications = level.requiredNights
|
||||
? `${pointsString} ${_("or")} ${level.requiredNights} ${_("nights")}`
|
||||
: pointsString
|
||||
return (
|
||||
<article className={styles.card}>
|
||||
<Title level="h4">{level.tier}</Title>
|
||||
<Title className={styles.tierHeading} level="h4">
|
||||
{level.tier}
|
||||
</Title>
|
||||
<Image src={level.logo} alt={level.name} width={140} height={54} />
|
||||
<p className={styles.qualifications}>
|
||||
{level.requiredPoints} {_("or")} {level.requiredNights} {_("nights")}
|
||||
</p>
|
||||
<p className={styles.qualifications}>{qualifications}</p>
|
||||
{level.topBenefits.map((benefit) => (
|
||||
<p key={benefit} className={styles.benefits}>
|
||||
<p key={benefit.title} className={styles.benefits}>
|
||||
<Check className={styles.icon} />
|
||||
{benefit}
|
||||
{benefit.title}
|
||||
</p>
|
||||
))}
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user