From bf8976c24cb0e8a246be73a4f632a79b05c3cef6 Mon Sep 17 00:00:00 2001 From: Chuma McPhoy Date: Thu, 3 Oct 2024 15:29:45 +0200 Subject: [PATCH] feat(SW-360): Add signup verification route w. tracking for login --- .../SignUpVerification/index.tsx | 26 +++++++++++++++++++ .../signUpVerification.module.css | 6 +++++ .../SignupFormWrapper}/index.tsx | 17 ++++++------ components/Blocks/DynamicContent/index.tsx | 7 +++-- components/Current/Header/LoginButton.tsx | 3 +++ .../TempDesignSystem/Link/link.module.css | 12 +++++++++ components/TempDesignSystem/Link/variants.ts | 1 + i18n/dictionaries/da.json | 1 + i18n/dictionaries/de.json | 2 +- i18n/dictionaries/en.json | 1 + i18n/dictionaries/fi.json | 1 + i18n/dictionaries/no.json | 1 + i18n/dictionaries/sv.json | 1 + .../routers/contentstack/contentPage/query.ts | 2 -- types/components/blocks/dynamicContent.ts | 13 ++++++++++ types/components/tracking.ts | 1 + types/enums/dynamicContent.ts | 2 ++ 17 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 components/Blocks/DynamicContent/SignUpVerification/index.tsx create mode 100644 components/Blocks/DynamicContent/SignUpVerification/signUpVerification.module.css rename components/{Forms/Register/ServerRegisterForm => Blocks/DynamicContent/SignupFormWrapper}/index.tsx (55%) diff --git a/components/Blocks/DynamicContent/SignUpVerification/index.tsx b/components/Blocks/DynamicContent/SignUpVerification/index.tsx new file mode 100644 index 000000000..eea95205a --- /dev/null +++ b/components/Blocks/DynamicContent/SignUpVerification/index.tsx @@ -0,0 +1,26 @@ +import LoginButton from "@/components/Current/Header/LoginButton" +import { getIntl } from "@/i18n" + +import styles from "./signUpVerification.module.css" + +import type { SignUpVerificationProps } from "@/types/components/blocks/dynamicContent" + +export default async function SignUpVerification({ + title, + subtitle, +}: SignUpVerificationProps) { + const intl = await getIntl() + + return ( +
+ + {intl.formatMessage({ id: "Proceed to login" })} + +
+ ) +} diff --git a/components/Blocks/DynamicContent/SignUpVerification/signUpVerification.module.css b/components/Blocks/DynamicContent/SignUpVerification/signUpVerification.module.css new file mode 100644 index 000000000..8e1a8e925 --- /dev/null +++ b/components/Blocks/DynamicContent/SignUpVerification/signUpVerification.module.css @@ -0,0 +1,6 @@ +.container { + display: flex; + flex-direction: column; + align-items: flex-start; + margin-top: var(--Spacing-x3); +} diff --git a/components/Forms/Register/ServerRegisterForm/index.tsx b/components/Blocks/DynamicContent/SignupFormWrapper/index.tsx similarity index 55% rename from components/Forms/Register/ServerRegisterForm/index.tsx rename to components/Blocks/DynamicContent/SignupFormWrapper/index.tsx index c7915f22e..6b9ab9673 100644 --- a/components/Forms/Register/ServerRegisterForm/index.tsx +++ b/components/Blocks/DynamicContent/SignupFormWrapper/index.tsx @@ -3,21 +3,20 @@ import { redirect } from "next/navigation" import { overview } from "@/constants/routes/myPages" import { auth } from "@/auth" +import Form from "@/components/Forms/Register" import { getLang } from "@/i18n/serverContext" -import Form from "../index" +import type { RegisterFormProps } from "@/types/components/form/registerForm" -import { RegisterFormProps } from "@/types/components/form/registerForm" - -export default async function ServerRegisterForm({ - link, - subtitle, - title, -}: RegisterFormProps) { +export default async function SignupFormWrapper({ + dynamic_content, +}: { + dynamic_content: RegisterFormProps +}) { const session = await auth() if (session) { // We don't want to allow users to signup if they are already authenticated. redirect(overview[getLang()]) } - return
+ return } diff --git a/components/Blocks/DynamicContent/index.tsx b/components/Blocks/DynamicContent/index.tsx index c73ea430f..e03264f5d 100644 --- a/components/Blocks/DynamicContent/index.tsx +++ b/components/Blocks/DynamicContent/index.tsx @@ -7,10 +7,11 @@ import ExpiringPoints from "@/components/Blocks/DynamicContent/Points/ExpiringPo import PointsOverview from "@/components/Blocks/DynamicContent/Points/Overview" import CurrentRewardsBlock from "@/components/Blocks/DynamicContent/Rewards/CurrentLevel" import NextLevelRewardsBlock from "@/components/Blocks/DynamicContent/Rewards/NextLevel" +import SignupFormWrapper from "@/components/Blocks/DynamicContent/SignupFormWrapper" +import SignUpVerification from "@/components/Blocks/DynamicContent/SignUpVerification" import PreviousStays from "@/components/Blocks/DynamicContent/Stays/Previous" import SoonestStays from "@/components/Blocks/DynamicContent/Stays/Soonest" import UpcomingStays from "@/components/Blocks/DynamicContent/Stays/Upcoming" -import ServerRegisterForm from "@/components/Forms/Register/ServerRegisterForm" import type { DynamicContentProps } from "@/types/components/blocks/dynamicContent" import { DynamicContentEnum } from "@/types/enums/dynamicContent" @@ -53,7 +54,9 @@ export default async function DynamicContent({ case DynamicContentEnum.Blocks.components.previous_stays: return case DynamicContentEnum.Blocks.components.sign_up_form: - return + return + case DynamicContentEnum.Blocks.components.sign_up_verification: + return case DynamicContentEnum.Blocks.components.soonest_stays: return case DynamicContentEnum.Blocks.components.upcoming_stays: diff --git a/components/Current/Header/LoginButton.tsx b/components/Current/Header/LoginButton.tsx index d74d63e80..475640879 100644 --- a/components/Current/Header/LoginButton.tsx +++ b/components/Current/Header/LoginButton.tsx @@ -18,11 +18,13 @@ export default function LoginButton({ trackingId, children, color = "black", + variant = "default", }: PropsWithChildren<{ className: string trackingId: string position: TrackingPosition color?: LinkProps["color"] + variant?: "default" | "signupVerification" }>) { const lang = useLang() const pathName = useLazyPathname() @@ -49,6 +51,7 @@ export default function LoginButton({ color={color} href={href} prefetch={false} + variant={variant} > {children} diff --git a/components/TempDesignSystem/Link/link.module.css b/components/TempDesignSystem/Link/link.module.css index abd860406..a22274051 100644 --- a/components/TempDesignSystem/Link/link.module.css +++ b/components/TempDesignSystem/Link/link.module.css @@ -218,3 +218,15 @@ color: var(--Base-Text-High-contrast); background-color: var(--Base-Surface-Primary-light-Hover-alt); } + +.signupVerification { + background-color: var(--Base-Button-Primary-Fill-Normal); + color: var(--Base-Button-Inverted-Fill-Normal); + cursor: pointer; + padding: var(--Spacing-x-one-and-half) var(--Spacing-x2); + border-radius: var(--Corner-radius-Rounded); + text-decoration: none; + display: inline-block; + text-align: center; + transition: background-color 0.3s ease; +} diff --git a/components/TempDesignSystem/Link/variants.ts b/components/TempDesignSystem/Link/variants.ts index 1930b8cb8..273eea928 100644 --- a/components/TempDesignSystem/Link/variants.ts +++ b/components/TempDesignSystem/Link/variants.ts @@ -35,6 +35,7 @@ export const linkVariants = cva(styles.link, { shortcut: styles.shortcut, sidebar: styles.sidebar, tab: styles.tab, + signupVerification: styles.signupVerification, }, }, defaultVariants: { diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index 515cb88cc..7c63144f9 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -219,6 +219,7 @@ "Points needed to level up": "Point nødvendige for at stige i niveau", "Points needed to stay on level": "Point nødvendige for at holde sig på niveau", "Previous victories": "Tidligere sejre", + "Proceed to login": "Fortsæt til login", "Proceed to payment method": "Fortsæt til betalingsmetode", "Public price from": "Offentlig pris fra", "Public transport": "Offentlig transport", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 8d88a5baf..cef8605eb 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -213,13 +213,13 @@ "Please enter a valid phone number": "Bitte geben Sie eine gültige Telefonnummer ein", "points": "Punkte", "Points": "Punkte", - "points": "Punkte", "Points being calculated": "Punkte werden berechnet", "Points earned prior to May 1, 2021": "Zusammengeführte Punkte vor dem 1. Mai 2021", "Points may take up to 10 days to be displayed.": "Es kann bis zu 10 Tage dauern, bis Punkte angezeigt werden.", "Points needed to level up": "Punkte, die zum Levelaufstieg benötigt werden", "Points needed to stay on level": "Erforderliche Punkte, um auf diesem Level zu bleiben", "Previous victories": "Bisherige Siege", + "Proceed to login": "Weiter zum Login", "Proceed to payment method": "Weiter zur Zahlungsmethode", "Public price from": "Öffentlicher Preis ab", "Public transport": "Öffentliche Verkehrsmittel", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index bcc340535..9248144e1 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -218,6 +218,7 @@ "Points needed to level up": "Points needed to level up", "Points needed to stay on level": "Points needed to stay on level", "Previous victories": "Previous victories", + "Proceed to login": "Proceed to login", "Proceed to payment method": "Proceed to payment method", "Public price from": "Public price from", "Public transport": "Public transport", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index 70bc6d14c..66cad603e 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -219,6 +219,7 @@ "Points needed to level up": "Tarvitset vielä", "Points needed to stay on level": "Tällä tasolla pysymiseen tarvittavat pisteet", "Previous victories": "Edelliset voitot", + "Proceed to login": "Jatka kirjautumiseen", "Proceed to payment method": "Siirry maksutavalle", "Public price from": "Julkinen hinta alkaen", "Public transport": "Julkinen liikenne", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index 47667622e..1e0276d87 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -216,6 +216,7 @@ "Points needed to level up": "Poeng som trengs for å komme opp i nivå", "Points needed to stay on level": "Poeng som trengs for å holde seg på nivå", "Previous victories": "Tidligere seire", + "Proceed to login": "Fortsett til innlogging", "Proceed to payment method": "Fortsett til betalingsmetode", "Public price from": "Offentlig pris fra", "Public transport": "Offentlig transport", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index ce8afd41a..45b7d3ca2 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -217,6 +217,7 @@ "Points needed to level up": "Poäng som behövs för att gå upp i nivå", "Points needed to stay on level": "Poäng som behövs för att hålla sig på nivå", "Previous victories": "Tidigare segrar", + "Proceed to login": "Fortsätt till inloggning", "Proceed to payment method": "Gå vidare till betalningsmetod", "Public price from": "Offentligt pris från", "Public transport": "Kollektivtrafik", diff --git a/server/routers/contentstack/contentPage/query.ts b/server/routers/contentstack/contentPage/query.ts index bae7addbe..79ef83a4e 100644 --- a/server/routers/contentstack/contentPage/query.ts +++ b/server/routers/contentstack/contentPage/query.ts @@ -21,8 +21,6 @@ export const contentPageQueryRouter = router({ get: contentstackExtendedProcedureUID.query(async ({ ctx }) => { const { lang, uid } = ctx - // TODO: Add logic to: check if Authed & Content Page URL is a "signup page", if so, redirect to home page. - const contentPageRefsData = await fetchContentPageRefs(lang, uid) const contentPageRefs = validateContentPageRefs( contentPageRefsData, diff --git a/types/components/blocks/dynamicContent.ts b/types/components/blocks/dynamicContent.ts index b2c779e45..8d183bfd6 100644 --- a/types/components/blocks/dynamicContent.ts +++ b/types/components/blocks/dynamicContent.ts @@ -18,3 +18,16 @@ export interface LoyaltyLevelsProps extends PartialDynamicContent { export interface OverviewTableProps extends PartialDynamicContent { firstItem: boolean } + +export interface SignUpVerificationProps { + title: string + subtitle: string +} + +export interface SignupFormWrapperProps { + dynamic_content: { + link: string + subtitle: string + title: string + } +} diff --git a/types/components/tracking.ts b/types/components/tracking.ts index 92128d939..72aa6f853 100644 --- a/types/components/tracking.ts +++ b/types/components/tracking.ts @@ -78,3 +78,4 @@ export type TrackingPosition = | "top menu" | "hamburger menu" | "join scandic friends sidebar" + | "sign up verification" diff --git a/types/enums/dynamicContent.ts b/types/enums/dynamicContent.ts index 0661d51ae..0dcd29937 100644 --- a/types/enums/dynamicContent.ts +++ b/types/enums/dynamicContent.ts @@ -13,6 +13,7 @@ export namespace DynamicContentEnum { points_overview = "points_overview", previous_stays = "previous_stays", sign_up_form = "sign_up_form", + sign_up_verification = "sign_up_verification", soonest_stays = "soonest_stays", upcoming_stays = "upcoming_stays", } @@ -31,6 +32,7 @@ export namespace DynamicContentEnum { components.points_overview, components.previous_stays, components.sign_up_form, + components.sign_up_verification, components.soonest_stays, components.upcoming_stays, ]