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"
|
||||
|
||||
import { trpc } from "@/lib/trpc/client"
|
||||
import {
|
||||
Reward,
|
||||
SurpriseReward,
|
||||
} from "@/server/routers/contentstack/reward/output"
|
||||
import { Reward } from "@/server/routers/contentstack/reward/output"
|
||||
|
||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||
import Grids from "@/components/TempDesignSystem/Grids"
|
||||
@@ -14,8 +11,9 @@ import useLang from "@/hooks/useLang"
|
||||
|
||||
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({
|
||||
initialCurrentRewards,
|
||||
}: 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() {
|
||||
if (hasNextPage) {
|
||||
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 (
|
||||
<>
|
||||
<div>
|
||||
<Grids.Stackable>
|
||||
{cmsRewards.map((reward, idx) => (
|
||||
{rewards.map((reward, idx) => (
|
||||
<article className={styles.card} key={`${reward.reward_id}-${idx}`}>
|
||||
<Title
|
||||
as="h4"
|
||||
@@ -76,6 +71,6 @@ export default function ClientCurrentRewards({
|
||||
) : (
|
||||
<ShowMoreButton loadMoreData={loadMoreData} />
|
||||
))}
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -107,13 +107,10 @@ export default function SurprisesNotification({
|
||||
<>
|
||||
<div className={styles.content}>
|
||||
<Surprise title={surprise.label}>
|
||||
<Body textAlign="center">
|
||||
This is just some dummy text describing the gift and
|
||||
should be replaced.
|
||||
</Body>
|
||||
<Body textAlign="center">{surprise.description}</Body>
|
||||
<div className={styles.badge}>
|
||||
<Caption>
|
||||
Valid through{" "}
|
||||
{intl.formatMessage({ id: "Valid through" })}{" "}
|
||||
{dt(surprise.endsAt)
|
||||
.locale(lang)
|
||||
.format("DD MMM YYYY")}
|
||||
|
||||
@@ -30,6 +30,7 @@ export default async function AccountPage() {
|
||||
{linkToOverview ? <LinkToOverview /> : null}
|
||||
<Blocks content={accountPage.content} />
|
||||
</MaxWidth>
|
||||
|
||||
<TrackingSDK pageData={tracking} />
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -304,6 +304,7 @@
|
||||
"Use bonus cheque": "Brug Bonus Cheque",
|
||||
"Use code/voucher": "Brug kode/voucher",
|
||||
"User information": "Brugeroplysninger",
|
||||
"Valid through": "Gyldig igennem",
|
||||
"View as list": "Vis som liste",
|
||||
"View as map": "Vis som kort",
|
||||
"View your booking": "Se din booking",
|
||||
|
||||
@@ -304,6 +304,7 @@
|
||||
"Use bonus cheque": "Bonusscheck nutzen",
|
||||
"Use code/voucher": "Code/Gutschein nutzen",
|
||||
"User information": "Nutzerinformation",
|
||||
"Valid through": "Gültig bis",
|
||||
"View as list": "Als Liste anzeigen",
|
||||
"View as map": "Als Karte anzeigen",
|
||||
"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",
|
||||
"Go back to edit": "Go back to edit",
|
||||
"Go back to overview": "Go back to overview",
|
||||
"Guest": "Guest",
|
||||
"Go to My Benefits": "Go to My Benefits",
|
||||
"Guest": "Guest",
|
||||
"Guest information": "Guest information",
|
||||
"Guests & Rooms": "Guests & Rooms",
|
||||
"Hi": "Hi",
|
||||
@@ -321,6 +321,7 @@
|
||||
"Use code/voucher": "Use code/voucher",
|
||||
"User information": "User information",
|
||||
"VAT": "VAT",
|
||||
"Valid through": "Valid through",
|
||||
"View as list": "View as list",
|
||||
"View as map": "View as map",
|
||||
"View your booking": "View your booking",
|
||||
|
||||
@@ -305,6 +305,7 @@
|
||||
"Use bonus cheque": "Käytä bonussekkiä",
|
||||
"Use code/voucher": "Käytä koodia/voucheria",
|
||||
"User information": "Käyttäjän tiedot",
|
||||
"Valid through": "Voimassa läpi",
|
||||
"View as list": "Näytä listana",
|
||||
"View as map": "Näytä kartalla",
|
||||
"View your booking": "Näytä varauksesi",
|
||||
|
||||
@@ -302,6 +302,7 @@
|
||||
"Use bonus cheque": "Bruk bonussjekk",
|
||||
"Use code/voucher": "Bruk kode/voucher",
|
||||
"User information": "Brukerinformasjon",
|
||||
"Valid through": "Gyldig gjennom",
|
||||
"View as list": "Vis som liste",
|
||||
"View as map": "Vis som kart",
|
||||
"View your booking": "Se din bestilling",
|
||||
|
||||
@@ -302,6 +302,7 @@
|
||||
"Use bonus cheque": "Använd bonuscheck",
|
||||
"Use code/voucher": "Använd kod/voucher",
|
||||
"User information": "Användarinformation",
|
||||
"Valid through": "Giltig t.o.m.",
|
||||
"View as list": "Visa som lista",
|
||||
"View as map": "Visa som karta",
|
||||
"View your booking": "Visa din bokning",
|
||||
|
||||
@@ -11,7 +11,15 @@ const Coupon = z.object({
|
||||
}),
|
||||
name: z.string().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(),
|
||||
value: z.number().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