From b6cb3855c2c01add43c7d3193a8ad3a68ade0b1f Mon Sep 17 00:00:00 2001 From: Christian Andolf Date: Tue, 22 Oct 2024 12:29:32 +0200 Subject: [PATCH] refactor(SW-556): added a few missing pieces like translations and properties. removed unneeded changes --- .../Rewards/CurrentLevel/Client.tsx | 41 ++++++++----------- .../Surprises/SurprisesNotification.tsx | 7 +--- components/Webviews/AccountPage/index.tsx | 1 + i18n/dictionaries/da.json | 1 + i18n/dictionaries/de.json | 1 + i18n/dictionaries/en.json | 3 +- i18n/dictionaries/fi.json | 1 + i18n/dictionaries/no.json | 1 + i18n/dictionaries/sv.json | 1 + server/routers/contentstack/reward/output.ts | 10 ++++- types/components/blocks/currentRewards.ts | 10 ----- 11 files changed, 37 insertions(+), 40 deletions(-) delete mode 100644 types/components/blocks/currentRewards.ts diff --git a/components/Blocks/DynamicContent/Rewards/CurrentLevel/Client.tsx b/components/Blocks/DynamicContent/Rewards/CurrentLevel/Client.tsx index edfef9782..a57e5e160 100644 --- a/components/Blocks/DynamicContent/Rewards/CurrentLevel/Client.tsx +++ b/components/Blocks/DynamicContent/Rewards/CurrentLevel/Client.tsx @@ -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 - } - - 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 + } + + if (!rewards.length) { + return null + } return ( - <> +
- {cmsRewards.map((reward, idx) => ( + {rewards.map((reward, idx) => (
))} - </> + </div> ) } diff --git a/components/MyPages/Surprises/SurprisesNotification.tsx b/components/MyPages/Surprises/SurprisesNotification.tsx index b8d8ac111..6b71c6703 100644 --- a/components/MyPages/Surprises/SurprisesNotification.tsx +++ b/components/MyPages/Surprises/SurprisesNotification.tsx @@ -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")} diff --git a/components/Webviews/AccountPage/index.tsx b/components/Webviews/AccountPage/index.tsx index b7b651627..572ea485e 100644 --- a/components/Webviews/AccountPage/index.tsx +++ b/components/Webviews/AccountPage/index.tsx @@ -30,6 +30,7 @@ export default async function AccountPage() { {linkToOverview ? <LinkToOverview /> : null} <Blocks content={accountPage.content} /> </MaxWidth> + <TrackingSDK pageData={tracking} /> </> ) diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index 19cd02e5f..1bbfdcd6d 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -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", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 571a43dca..a5c32a198 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -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", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index 5d6e999e3..2299d715b 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -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", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index cbfe95d93..8a98227fa 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -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", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index 0d1e73732..2feec1e8c 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -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", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index c2398bdf7..300b0141d 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -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", diff --git a/server/routers/contentstack/reward/output.ts b/server/routers/contentstack/reward/output.ts index 236b29c62..5bd2c7d75 100644 --- a/server/routers/contentstack/reward/output.ts +++ b/server/routers/contentstack/reward/output.ts @@ -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(), diff --git a/types/components/blocks/currentRewards.ts b/types/components/blocks/currentRewards.ts deleted file mode 100644 index 7e6d8561c..000000000 --- a/types/components/blocks/currentRewards.ts +++ /dev/null @@ -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 - } -}