From fe6e4e27e15635954707225d951b9b5c07edcda2 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Mon, 24 Jun 2024 12:03:05 +0200 Subject: [PATCH] fix: add heading and subtitle to overview table --- .../(protected)/my-pages/[...path]/page.tsx | 2 + components/ContentType/LoyaltyPage.tsx | 3 ++ .../ContentType/Webviews/LoyaltyPage.tsx | 2 + .../DynamicContent/OverviewTable/index.tsx | 45 ++----------------- .../OverviewTable/overviewTable.module.css | 29 ------------ .../DynamicContent/dynamicContent.module.css | 19 +++----- .../Loyalty/Blocks/DynamicContent/index.tsx | 42 ++++++++++++++++- lib/graphql/Query/AccountPage.graphql | 1 + .../contentstack/accountPage/output.ts | 1 + .../routers/contentstack/accountPage/query.ts | 3 +- 10 files changed, 60 insertions(+), 87 deletions(-) diff --git a/app/[lang]/(live)/(protected)/my-pages/[...path]/page.tsx b/app/[lang]/(live)/(protected)/my-pages/[...path]/page.tsx index b61739b18..caca3de82 100644 --- a/app/[lang]/(live)/(protected)/my-pages/[...path]/page.tsx +++ b/app/[lang]/(live)/(protected)/my-pages/[...path]/page.tsx @@ -1,6 +1,7 @@ import { serverClient } from "@/lib/trpc/server" import Content from "@/components/MyPages/AccountPage/Content" +import Title from "@/components/TempDesignSystem/Text/Title" import { getIntl } from "@/i18n" import styles from "./page.module.css" @@ -19,6 +20,7 @@ export default async function MyPages({ return (
+ {accountPage.heading} {accountPage.content.length ? ( ) : ( diff --git a/components/ContentType/LoyaltyPage.tsx b/components/ContentType/LoyaltyPage.tsx index 811fbf7f9..b889cbcd0 100644 --- a/components/ContentType/LoyaltyPage.tsx +++ b/components/ContentType/LoyaltyPage.tsx @@ -4,6 +4,8 @@ import { Blocks } from "@/components/Loyalty/Blocks" import Sidebar from "@/components/Loyalty/Sidebar" import MaxWidth from "@/components/MaxWidth" +import Title from "../TempDesignSystem/Text/Title" + import styles from "./loyaltyPage.module.css" import type { LangParams } from "@/types/params" @@ -20,6 +22,7 @@ export default async function LoyaltyPage({ lang }: LangParams) { ) : null} + {loyaltyPage.heading} {loyaltyPage.blocks ? : null} diff --git a/components/ContentType/Webviews/LoyaltyPage.tsx b/components/ContentType/Webviews/LoyaltyPage.tsx index b0d9f80c5..d34d32fca 100644 --- a/components/ContentType/Webviews/LoyaltyPage.tsx +++ b/components/ContentType/Webviews/LoyaltyPage.tsx @@ -3,6 +3,7 @@ import { serverClient } from "@/lib/trpc/server" import { Blocks } from "@/components/Loyalty/Blocks/WebView" import Sidebar from "@/components/Loyalty/Sidebar" import MaxWidth from "@/components/MaxWidth" +import Title from "@/components/TempDesignSystem/Text/Title" import LinkToOverview from "@/components/Webviews/LinkToOverview" import styles from "./loyaltyPage.module.css" @@ -25,6 +26,7 @@ export default async function AboutScandicFriends({ lang }: LangParams) { ) : null} + {loyaltyPage.heading} diff --git a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx index 2b03633ff..a2e2bbe25 100644 --- a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx +++ b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx @@ -21,7 +21,6 @@ import SV from "./data/SV.json" import BenefitList from "./BenefitList" import LargeTable from "./LargeTable" import LevelSummary from "./LevelSummary" -import OverviewTableTitle from "./Title" import styles from "./overviewTable.module.css" @@ -34,6 +33,7 @@ import { import { LangParams } from "@/types/params" import { User } from "@/types/user" + const levelsTranslations = { [Lang.en]: EN, [Lang.sv]: SV, @@ -42,36 +42,7 @@ const levelsTranslations = { [Lang.fi]: FI, [Lang.de]: DE, } - -// These should ultimately be fetched from Contentstack -const titleTranslations = { - [Lang.en]: [ - { text: "7 delightful levels", highlight: true }, - { text: "of friendship", highlight: false }, - ], - // TODO: Add translations for the following languages - [Lang.da]: [ - { text: "7 delightful levels", highlight: true }, - { text: "of friendship", highlight: false }, - ], - [Lang.no]: [ - { text: "7 delightful levels", highlight: true }, - { text: "of friendship", highlight: false }, - ], - [Lang.sv]: [ - { text: "7 delightful levels", highlight: true }, - { text: "of friendship", highlight: false }, - ], - [Lang.fi]: [ - { text: "7 delightful levels", highlight: true }, - { text: "of friendship", highlight: false }, - ], - [Lang.de]: [ - { text: "7 delightful levels", highlight: true }, - { text: "of friendship", highlight: false }, - ], -} - + function getTranslatedLevelByTier(tier: membershipLevels, lang: Lang) { return levelsTranslations[lang].levels.find( (level) => level.tier === tier @@ -179,17 +150,7 @@ export default function OverviewTable({ user }: OverviewTableProps) { })) return ( -
-
- -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Arcu risus - quis varius quam quisque id diam vel. Rhoncus urna neque viverra - justo. Mattis aliquam faucibus purus in massa. Id cursus metus aliquam - eleifend mi in nulla posuere. -

-
+
diff --git a/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css b/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css index 951e3cdb8..159c32da0 100644 --- a/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css +++ b/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css @@ -1,29 +1,8 @@ -.container { - margin-top: calc(var(--Spacing-x2) * -1); - margin-left: calc(var(--Spacing-x2) * -1); - margin-right: calc(var(--Spacing-x2) * -1); - margin-bottom: calc( - (var(--Spacing-x2) + 7.7rem) * -1 - ); /* Based on the MaxWidth's 1.6rem + the LoyaltyPage's 7.7rem bottom margins */ - position: relative; - width: 100dvw; - padding: var(--Spacing-x2); - display: grid; - gap: var(--Spacing-x6); -} - .intro { display: grid; gap: var(--Spacing-x3); } -.preamble { - color: var(--Base-Text-Primary-High-contrast); - font-size: var(--typography-Body-Regular-fontSize); - line-height: var(--typography-Body-Regular-lineHeight); - margin: 0; -} - .largeTableContainer { display: none; } @@ -80,12 +59,6 @@ } @media screen and (min-width: 950px) { - .container { - margin-top: calc((var(--Spacing-x2) + 5.8rem) * -1); - margin-left: calc(var(--Spacing-x3) * -1); - margin-right: calc(var(--Spacing-x3) * -1); - margin-bottom: calc((17.5rem + var(--Spacing-x2)) * -1); - } .mobileColumns { display: none; } @@ -111,12 +84,10 @@ .intro { margin: auto; - max-width: 1512px; } .largeTableContainer { display: block; margin: auto; - max-width: 1512px; } } diff --git a/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css b/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css index 97082479d..4eb79cdcd 100644 --- a/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css +++ b/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css @@ -8,22 +8,13 @@ .header { display: grid; gap: var(--Spacing-x1); - grid-template-columns: 1fr auto; } -.title { - grid-column: 1/2; - grid-row: 1/2; -} - -.link { - grid-column: 2/-1; - grid-row: 1/2; -} - -.subtitle { - grid-column: 1/-1; - grid-row: 2; +.preamble { + color: var(--Base-Text-Primary-High-contrast); + font-size: var(--typography-Body-Regular-fontSize); + line-height: var(--typography-Body-Regular-lineHeight); + margin: 0; } @media screen and (min-width: 950px) { diff --git a/components/Loyalty/Blocks/DynamicContent/index.tsx b/components/Loyalty/Blocks/DynamicContent/index.tsx index 68dc8534a..4f94c59b9 100644 --- a/components/Loyalty/Blocks/DynamicContent/index.tsx +++ b/components/Loyalty/Blocks/DynamicContent/index.tsx @@ -1,9 +1,12 @@ +import { Lang } from "@/constants/languages" import { serverClient } from "@/lib/trpc/server" import { auth } from "@/auth" import SectionContainer from "@/components/Section/Container" import Header from "@/components/Section/Header" +import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" +import OverviewTableTitle from "./OverviewTable/Title" import HowItWorks from "./HowItWorks" import LoyaltyLevels from "./LoyaltyLevels" import OverviewTable from "./OverviewTable" @@ -33,6 +36,35 @@ async function DynamicComponentBlock({ component }: DynamicComponentProps) { } } +// These should ultimately be fetched from Contentstack +const titleTranslations = { + [Lang.en]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + // TODO: Add translations for the following languages + [Lang.da]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.no]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.sv]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.fi]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.de]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], +} + export default function DynamicContent({ dynamicContent, firstItem, @@ -43,9 +75,17 @@ export default function DynamicContent({ dynamicContent.title ) + const isOverviewTable = + dynamicContent.component === LoyaltyComponentEnum.overview_table + return ( - {displayHeader ? ( + {isOverviewTable ? ( +
+ + {dynamicContent.subtitle} +
+ ) : displayHeader ? (
( + const response = await request( GetAccountPage, { locale: lang,