feat: add mapping of benefits AccountPage
This commit is contained in:
@@ -1,39 +1,21 @@
|
|||||||
import CurrentBenefitsBlock from "@/components/MyPages/Blocks/Benefits/CurrentLevel"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
import NextLevelBenefitsBlock from "@/components/MyPages/Blocks/Benefits/NextLevel"
|
|
||||||
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
|
||||||
import Title from "@/components/Title"
|
|
||||||
|
|
||||||
import { shortcuts } from "./_constants"
|
import Content from "@/components/MyPages/AccountPage/Content"
|
||||||
|
|
||||||
import styles from "./page.module.css"
|
import styles from "./page.module.css"
|
||||||
|
|
||||||
import type { LangParams, PageArgs } from "@/types/params"
|
import type { LangParams, PageArgs } from "@/types/params"
|
||||||
|
|
||||||
export default function BenefitsPage({ params }: PageArgs<LangParams>) {
|
export default async function BenefitsPage({ params }: PageArgs<LangParams>) {
|
||||||
|
const user = await serverClient().user.get()
|
||||||
|
const accountPage = await serverClient().contentstack.accountPage.get({
|
||||||
|
lang: params.lang,
|
||||||
|
uri: "/my-pages/benefits",
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className={styles.container}>
|
<main className={styles.container}>
|
||||||
<header className={styles.header}>
|
<Content user={user} lang={params.lang} content={accountPage.content} />
|
||||||
<Title as="h3" className={styles.title} uppercase>
|
|
||||||
Your Perks and benefits. Tailored just for{" "}
|
|
||||||
<span className={styles.red}>you.</span>
|
|
||||||
</Title>
|
|
||||||
<p className={styles.preamble}>
|
|
||||||
Discover the exclusive benefits and delightful surprises our
|
|
||||||
friendship unlocks.
|
|
||||||
</p>
|
|
||||||
</header>
|
|
||||||
<CurrentBenefitsBlock />
|
|
||||||
<Shortcuts
|
|
||||||
shortcuts={shortcuts}
|
|
||||||
title={
|
|
||||||
<span className={styles.title}>
|
|
||||||
Perks and benefits{" "}
|
|
||||||
<span className={styles.red}>for All friends.</span>
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
subtitle="Always Yours. Universal Benefits for the Scandic Friends community."
|
|
||||||
/>
|
|
||||||
<NextLevelBenefitsBlock />
|
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
import { Lang } from "@/constants/languages"
|
import { Lang } from "@/constants/languages"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccountPageContentItem,
|
AccountPageContentItem,
|
||||||
ContentEntries,
|
ContentEntries,
|
||||||
DynamicContent,
|
DynamicContent,
|
||||||
DynamicContentComponents,
|
DynamicContentComponents,
|
||||||
} from "@/types/requests/myPages/accountpage"
|
} from "@/types/requests/myPages/accountpage"
|
||||||
import { User } from "@/types/user"
|
|
||||||
|
import CurrentBenefitsBlock from "@/components/MyPages/Blocks/Benefits/CurrentLevel"
|
||||||
|
import NextLevelBenefitsBlock from "@/components/MyPages/Blocks/Benefits/NextLevel"
|
||||||
import Overview from "@/components/MyPages/Blocks/Overview"
|
import Overview from "@/components/MyPages/Blocks/Overview"
|
||||||
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
||||||
import UpcomingStays from "@/components/MyPages/Blocks/UpcomingStays"
|
import UpcomingStays from "@/components/MyPages/Blocks/Stays/Upcoming"
|
||||||
|
import { User } from "@/types/user"
|
||||||
|
|
||||||
function DynamicComponent({
|
function DynamicComponent({
|
||||||
user,
|
user,
|
||||||
@@ -37,8 +41,20 @@ function DynamicComponent({
|
|||||||
case DynamicContentComponents.previous_stays:
|
case DynamicContentComponents.previous_stays:
|
||||||
return null
|
return null
|
||||||
case DynamicContentComponents.upcoming_stays:
|
case DynamicContentComponents.upcoming_stays:
|
||||||
|
return <UpcomingStays lang={lang} {...componentProps} />
|
||||||
|
case DynamicContentComponents.current_benefits:
|
||||||
return (
|
return (
|
||||||
<UpcomingStays lang={lang} stays={user.stays} {...componentProps} />
|
<CurrentBenefitsBlock
|
||||||
|
title={content.title}
|
||||||
|
preamble={content.preamble}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
case DynamicContentComponents.next_benefits:
|
||||||
|
return (
|
||||||
|
<NextLevelBenefitsBlock
|
||||||
|
title={content.title}
|
||||||
|
preamble={content.preamble}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
.container {
|
.cardContainer {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
color: var(--some-black-color, #111);
|
font-weight: 600;
|
||||||
/* font-family: var(--ff-brandon-text); */
|
|
||||||
font-weight: 500;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.value {
|
||||||
@@ -49,7 +46,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 950px) {
|
@media screen and (min-width: 950px) {
|
||||||
.container {
|
.cardContainer {
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"card card2"
|
"card card2"
|
||||||
"card card3";
|
"card card3";
|
||||||
|
|||||||
@@ -6,20 +6,37 @@ import Title from "@/components/Title"
|
|||||||
|
|
||||||
import styles from "./current.module.css"
|
import styles from "./current.module.css"
|
||||||
|
|
||||||
export default async function CurrentBenefitsBlock() {
|
export type CurrentLevelProps = {
|
||||||
|
title: string
|
||||||
|
preamble?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function CurrentBenefitsBlock({
|
||||||
|
title,
|
||||||
|
preamble,
|
||||||
|
}: CurrentLevelProps) {
|
||||||
const benefits = await serverClient().user.benefits.current()
|
const benefits = await serverClient().user.benefits.current()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={styles.container}>
|
<section>
|
||||||
{benefits.map((benefit) => (
|
<header className={styles.header}>
|
||||||
<Link href={benefit.href} key={benefit.id} className={styles.card}>
|
<Title as="h4" level="h2" className={styles.title} uppercase>
|
||||||
<Title level="h3" as="h5" className={styles.title}>
|
{title}
|
||||||
<span className={styles.value}>{benefit.value}</span>{" "}
|
</Title>
|
||||||
{benefit.explanation}
|
{preamble && <p className={styles.preamble}>{preamble}</p>}
|
||||||
</Title>
|
</header>
|
||||||
<p className={styles.subtitle}>{benefit.subtitle}</p>
|
|
||||||
</Link>
|
<div className={styles.cardContainer}>
|
||||||
))}
|
{benefits.map((benefit) => (
|
||||||
|
<Link href={benefit.href} key={benefit.id} className={styles.card}>
|
||||||
|
<Title as="h5" level="h3" className={styles.title}>
|
||||||
|
<span className={styles.value}>{benefit.value}</span>{" "}
|
||||||
|
{benefit.explanation}
|
||||||
|
</Title>
|
||||||
|
<p className={styles.subtitle}>{benefit.subtitle}</p>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,24 @@ import Title from "@/components/Title"
|
|||||||
|
|
||||||
import styles from "./next.module.css"
|
import styles from "./next.module.css"
|
||||||
|
|
||||||
export default async function NextLevelBenefitsBlock() {
|
export type NextLevelProps = {
|
||||||
|
title: string
|
||||||
|
preamble?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function NextLevelBenefitsBlock({
|
||||||
|
title,
|
||||||
|
preamble,
|
||||||
|
}: NextLevelProps) {
|
||||||
const { nextLevel, perks } = await serverClient().user.benefits.nextLevel()
|
const { nextLevel, perks } = await serverClient().user.benefits.nextLevel()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={styles.container}>
|
<section className={styles.container}>
|
||||||
<header className={styles.header}>
|
<header className={styles.header}>
|
||||||
<Title as="h4" level="h2" uppercase className={styles.title}>
|
<Title as="h4" level="h2" uppercase className={styles.title}>
|
||||||
Next Level perks and benefits.
|
{title}
|
||||||
</Title>
|
</Title>
|
||||||
<p className={styles.subtitle}>
|
{preamble && <p className={styles.preamble}>{preamble}</p>}
|
||||||
Here's a sneak peek at the extra benefits waiting just for you,
|
|
||||||
when you level up to {nextLevel}
|
|
||||||
</p>
|
|
||||||
</header>
|
</header>
|
||||||
<div className={styles.cardContainer}>
|
<div className={styles.cardContainer}>
|
||||||
{perks.map((perk) => (
|
{perks.map((perk) => (
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export default function UpcomingStays({
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
|
{preamble}
|
||||||
<section className={styles.stays}>
|
<section className={styles.stays}>
|
||||||
{stays.map((stay) => (
|
{stays.map((stay) => (
|
||||||
<Stay key={stay.hotel} {...stay} lang={lang} />
|
<Stay key={stay.hotel} {...stay} lang={lang} />
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export enum DynamicContentComponents {
|
|||||||
benefits = "benefits",
|
benefits = "benefits",
|
||||||
previous_stays = "previous_stays",
|
previous_stays = "previous_stays",
|
||||||
upcoming_stays = "upcoming_stays",
|
upcoming_stays = "upcoming_stays",
|
||||||
|
current_benefits = "current_benefits",
|
||||||
|
next_benefits = "next_benefits",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ContentEntries {
|
export enum ContentEntries {
|
||||||
|
|||||||
Reference in New Issue
Block a user