refactor(SW-556): added a few missing pieces like translations and properties.
removed unneeded changes
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { trpc } from "@/lib/trpc/client"
|
import { trpc } from "@/lib/trpc/client"
|
||||||
import {
|
import { Reward } from "@/server/routers/contentstack/reward/output"
|
||||||
Reward,
|
|
||||||
SurpriseReward,
|
|
||||||
} from "@/server/routers/contentstack/reward/output"
|
|
||||||
|
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||||
import Grids from "@/components/TempDesignSystem/Grids"
|
import Grids from "@/components/TempDesignSystem/Grids"
|
||||||
@@ -14,8 +11,9 @@ import useLang from "@/hooks/useLang"
|
|||||||
|
|
||||||
import styles from "./current.module.css"
|
import styles from "./current.module.css"
|
||||||
|
|
||||||
import type { CurrentRewardsClientProps } from "@/types/components/blocks/currentRewards"
|
type CurrentRewardsClientProps = {
|
||||||
|
initialCurrentRewards: { rewards: Reward[]; nextCursor: number | undefined }
|
||||||
|
}
|
||||||
export default function ClientCurrentRewards({
|
export default function ClientCurrentRewards({
|
||||||
initialCurrentRewards,
|
initialCurrentRewards,
|
||||||
}: CurrentRewardsClientProps) {
|
}: CurrentRewardsClientProps) {
|
||||||
@@ -34,30 +32,27 @@ export default function ClientCurrentRewards({
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <LoadingSpinner />
|
|
||||||
}
|
|
||||||
|
|
||||||
const cmsRewards =
|
|
||||||
data?.pages
|
|
||||||
.flatMap((page) => page?.rewards)
|
|
||||||
.filter((reward): reward is Reward => !!reward) ?? []
|
|
||||||
|
|
||||||
if (!cmsRewards.length) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadMoreData() {
|
function loadMoreData() {
|
||||||
if (hasNextPage) {
|
if (hasNextPage) {
|
||||||
fetchNextPage()
|
fetchNextPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const filteredRewards =
|
||||||
|
data?.pages.filter((page) => page && page.rewards) ?? []
|
||||||
|
const rewards = filteredRewards.flatMap((page) => page?.rewards) as Reward[]
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <LoadingSpinner />
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rewards.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div>
|
||||||
<Grids.Stackable>
|
<Grids.Stackable>
|
||||||
{cmsRewards.map((reward, idx) => (
|
{rewards.map((reward, idx) => (
|
||||||
<article className={styles.card} key={`${reward.reward_id}-${idx}`}>
|
<article className={styles.card} key={`${reward.reward_id}-${idx}`}>
|
||||||
<Title
|
<Title
|
||||||
as="h4"
|
as="h4"
|
||||||
@@ -76,6 +71,6 @@ export default function ClientCurrentRewards({
|
|||||||
) : (
|
) : (
|
||||||
<ShowMoreButton loadMoreData={loadMoreData} />
|
<ShowMoreButton loadMoreData={loadMoreData} />
|
||||||
))}
|
))}
|
||||||
</>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,13 +107,10 @@ export default function SurprisesNotification({
|
|||||||
<>
|
<>
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<Surprise title={surprise.label}>
|
<Surprise title={surprise.label}>
|
||||||
<Body textAlign="center">
|
<Body textAlign="center">{surprise.description}</Body>
|
||||||
This is just some dummy text describing the gift and
|
|
||||||
should be replaced.
|
|
||||||
</Body>
|
|
||||||
<div className={styles.badge}>
|
<div className={styles.badge}>
|
||||||
<Caption>
|
<Caption>
|
||||||
Valid through{" "}
|
{intl.formatMessage({ id: "Valid through" })}{" "}
|
||||||
{dt(surprise.endsAt)
|
{dt(surprise.endsAt)
|
||||||
.locale(lang)
|
.locale(lang)
|
||||||
.format("DD MMM YYYY")}
|
.format("DD MMM YYYY")}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export default async function AccountPage() {
|
|||||||
{linkToOverview ? <LinkToOverview /> : null}
|
{linkToOverview ? <LinkToOverview /> : null}
|
||||||
<Blocks content={accountPage.content} />
|
<Blocks content={accountPage.content} />
|
||||||
</MaxWidth>
|
</MaxWidth>
|
||||||
|
|
||||||
<TrackingSDK pageData={tracking} />
|
<TrackingSDK pageData={tracking} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -304,6 +304,7 @@
|
|||||||
"Use bonus cheque": "Brug Bonus Cheque",
|
"Use bonus cheque": "Brug Bonus Cheque",
|
||||||
"Use code/voucher": "Brug kode/voucher",
|
"Use code/voucher": "Brug kode/voucher",
|
||||||
"User information": "Brugeroplysninger",
|
"User information": "Brugeroplysninger",
|
||||||
|
"Valid through": "Gyldig igennem",
|
||||||
"View as list": "Vis som liste",
|
"View as list": "Vis som liste",
|
||||||
"View as map": "Vis som kort",
|
"View as map": "Vis som kort",
|
||||||
"View your booking": "Se din booking",
|
"View your booking": "Se din booking",
|
||||||
|
|||||||
@@ -304,6 +304,7 @@
|
|||||||
"Use bonus cheque": "Bonusscheck nutzen",
|
"Use bonus cheque": "Bonusscheck nutzen",
|
||||||
"Use code/voucher": "Code/Gutschein nutzen",
|
"Use code/voucher": "Code/Gutschein nutzen",
|
||||||
"User information": "Nutzerinformation",
|
"User information": "Nutzerinformation",
|
||||||
|
"Valid through": "Gültig bis",
|
||||||
"View as list": "Als Liste anzeigen",
|
"View as list": "Als Liste anzeigen",
|
||||||
"View as map": "Als Karte anzeigen",
|
"View as map": "Als Karte anzeigen",
|
||||||
"View your booking": "Ihre Buchung ansehen",
|
"View your booking": "Ihre Buchung ansehen",
|
||||||
|
|||||||
@@ -128,8 +128,8 @@
|
|||||||
"Gift(s) added to your benefits": "{amount, plural, one {Gift} other {Gifts}} added to your benefits",
|
"Gift(s) added to your benefits": "{amount, plural, one {Gift} other {Gifts}} added to your benefits",
|
||||||
"Go back to edit": "Go back to edit",
|
"Go back to edit": "Go back to edit",
|
||||||
"Go back to overview": "Go back to overview",
|
"Go back to overview": "Go back to overview",
|
||||||
"Guest": "Guest",
|
|
||||||
"Go to My Benefits": "Go to My Benefits",
|
"Go to My Benefits": "Go to My Benefits",
|
||||||
|
"Guest": "Guest",
|
||||||
"Guest information": "Guest information",
|
"Guest information": "Guest information",
|
||||||
"Guests & Rooms": "Guests & Rooms",
|
"Guests & Rooms": "Guests & Rooms",
|
||||||
"Hi": "Hi",
|
"Hi": "Hi",
|
||||||
@@ -321,6 +321,7 @@
|
|||||||
"Use code/voucher": "Use code/voucher",
|
"Use code/voucher": "Use code/voucher",
|
||||||
"User information": "User information",
|
"User information": "User information",
|
||||||
"VAT": "VAT",
|
"VAT": "VAT",
|
||||||
|
"Valid through": "Valid through",
|
||||||
"View as list": "View as list",
|
"View as list": "View as list",
|
||||||
"View as map": "View as map",
|
"View as map": "View as map",
|
||||||
"View your booking": "View your booking",
|
"View your booking": "View your booking",
|
||||||
|
|||||||
@@ -305,6 +305,7 @@
|
|||||||
"Use bonus cheque": "Käytä bonussekkiä",
|
"Use bonus cheque": "Käytä bonussekkiä",
|
||||||
"Use code/voucher": "Käytä koodia/voucheria",
|
"Use code/voucher": "Käytä koodia/voucheria",
|
||||||
"User information": "Käyttäjän tiedot",
|
"User information": "Käyttäjän tiedot",
|
||||||
|
"Valid through": "Voimassa läpi",
|
||||||
"View as list": "Näytä listana",
|
"View as list": "Näytä listana",
|
||||||
"View as map": "Näytä kartalla",
|
"View as map": "Näytä kartalla",
|
||||||
"View your booking": "Näytä varauksesi",
|
"View your booking": "Näytä varauksesi",
|
||||||
|
|||||||
@@ -302,6 +302,7 @@
|
|||||||
"Use bonus cheque": "Bruk bonussjekk",
|
"Use bonus cheque": "Bruk bonussjekk",
|
||||||
"Use code/voucher": "Bruk kode/voucher",
|
"Use code/voucher": "Bruk kode/voucher",
|
||||||
"User information": "Brukerinformasjon",
|
"User information": "Brukerinformasjon",
|
||||||
|
"Valid through": "Gyldig gjennom",
|
||||||
"View as list": "Vis som liste",
|
"View as list": "Vis som liste",
|
||||||
"View as map": "Vis som kart",
|
"View as map": "Vis som kart",
|
||||||
"View your booking": "Se din bestilling",
|
"View your booking": "Se din bestilling",
|
||||||
|
|||||||
@@ -302,6 +302,7 @@
|
|||||||
"Use bonus cheque": "Använd bonuscheck",
|
"Use bonus cheque": "Använd bonuscheck",
|
||||||
"Use code/voucher": "Använd kod/voucher",
|
"Use code/voucher": "Använd kod/voucher",
|
||||||
"User information": "Användarinformation",
|
"User information": "Användarinformation",
|
||||||
|
"Valid through": "Giltig t.o.m.",
|
||||||
"View as list": "Visa som lista",
|
"View as list": "Visa som lista",
|
||||||
"View as map": "Visa som karta",
|
"View as map": "Visa som karta",
|
||||||
"View your booking": "Visa din bokning",
|
"View your booking": "Visa din bokning",
|
||||||
|
|||||||
@@ -11,7 +11,15 @@ const Coupon = z.object({
|
|||||||
}),
|
}),
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
claimedAt: z.string().datetime({ offset: true }).optional(),
|
claimedAt: z.string().datetime({ offset: true }).optional(),
|
||||||
// redeemedAt: z.string().datetime({ offset: true }).optional(),
|
redeemedAt: z
|
||||||
|
.date({ coerce: true })
|
||||||
|
.optional()
|
||||||
|
.transform((value) => {
|
||||||
|
if (value?.getFullYear() === 1) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}),
|
||||||
type: z.string().optional(),
|
type: z.string().optional(),
|
||||||
value: z.number().optional(),
|
value: z.number().optional(),
|
||||||
pool: z.string().optional(),
|
pool: z.string().optional(),
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
import { ApiReward, Reward } from "@/server/routers/contentstack/reward/output"
|
|
||||||
|
|
||||||
import { SafeUser } from "@/types/user"
|
|
||||||
|
|
||||||
export type CurrentRewardsClientProps = {
|
|
||||||
initialCurrentRewards: {
|
|
||||||
rewards: Reward[]
|
|
||||||
nextCursor: number | undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user