From 419d21b3d0d9962875666fb1646b29886091bffd Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Thu, 13 Feb 2025 13:30:46 +0000 Subject: [PATCH] Merged in feat/remove-date-input-from-sas-link-flow (pull request #1328) Remove date input from SAS link flow Approved-by: Linus Flood --- .../sas-x-scandic/link/LinkAccountForm.tsx | 82 ++++++++++--------- .../sas-x-scandic/link/link-sas.module.css | 14 +++- .../(protected)/sas-x-scandic/link/page.tsx | 21 +---- i18n/dictionaries/da.json | 6 +- i18n/dictionaries/de.json | 6 +- i18n/dictionaries/en.json | 6 +- i18n/dictionaries/fi.json | 6 +- i18n/dictionaries/no.json | 6 +- i18n/dictionaries/sv.json | 6 +- 9 files changed, 82 insertions(+), 71 deletions(-) diff --git a/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/LinkAccountForm.tsx b/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/LinkAccountForm.tsx index 7a7931ad0..c5ac3d8ab 100644 --- a/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/LinkAccountForm.tsx +++ b/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/LinkAccountForm.tsx @@ -1,60 +1,54 @@ "use client" import Image from "next/image" -import { useRouter } from "next/navigation" +import { useParams, useRouter } from "next/navigation" import { type ReactNode, useTransition } from "react" import { FormProvider, useForm } from "react-hook-form" import { useIntl } from "react-intl" +import { profileEdit } from "@/constants/routes/myPages" + +import { ArrowRightIcon } from "@/components/Icons" import Button from "@/components/TempDesignSystem/Button" import Checkbox from "@/components/TempDesignSystem/Form/Checkbox" -import DateSelect from "@/components/TempDesignSystem/Form/Date" +import Label from "@/components/TempDesignSystem/Form/Label" import Link from "@/components/TempDesignSystem/Link" import Body from "@/components/TempDesignSystem/Text/Body" -import Caption from "@/components/TempDesignSystem/Text/Caption" import Title from "@/components/TempDesignSystem/Text/Title" import styles from "./link-sas.module.css" +import type { LangParams } from "@/types/params" + type LinkAccountForm = { - dateOfBirth: string | null termsAndConditions: boolean } export function LinkAccountForm({ - initialDateOfBirth, - onSubmit, + userDateOfBirth, }: { - initialDateOfBirth: string | null - onSubmit: ( - dateOfBirth: string - ) => Promise<{ success: boolean; redirectUrl?: string }> + userDateOfBirth: string | null }) { const router = useRouter() + const params = useParams() let [isPending, startTransition] = useTransition() const intl = useIntl() const form = useForm({ defaultValues: { - dateOfBirth: initialDateOfBirth, termsAndConditions: false, }, }) const handleSubmit = form.handleSubmit((data) => { startTransition(async () => { - if (!data.dateOfBirth || !data.termsAndConditions) return + if (!data.termsAndConditions) return - const result = await onSubmit(data.dateOfBirth) - if (!result.success || !result.redirectUrl) { - throw new Error("Unable to redirect") - } - - router.push(result.redirectUrl) + const url = `/${params.lang}/sas-x-scandic/login?intent=link` + router.push(url) }) }) - const dateOfBirth = form.watch("dateOfBirth") const termsAndConditions = form.watch("termsAndConditions") - const disableSubmit = !dateOfBirth || !termsAndConditions + const disableSubmit = !userDateOfBirth || !termsAndConditions return ( @@ -70,27 +64,36 @@ export function LinkAccountForm({ {intl.formatMessage({ id: "Link your accounts" })} -
- - {intl.formatMessage({ - id: "Birth date", - })} +
+ + {userDateOfBirth + ? intl.formatMessage( + { + id: "Birth date: {dateOfBirth, date, ::MMMM d yyyy}", + }, + { + dateOfBirth: new Date(userDateOfBirth), + } + ) + : intl.formatMessage({ id: "Birth date is missing" })} - + + + {intl.formatMessage({ + id: "Edit your personal details", + })} + +
- - {intl.formatMessage({ - id: "We require this additional information in order to match your Scandic account with your EuroBonus account.", - })} -
diff --git a/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/link-sas.module.css b/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/link-sas.module.css index 2e4cd2bd9..0de1ebf48 100644 --- a/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/link-sas.module.css +++ b/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/link-sas.module.css @@ -6,11 +6,23 @@ margin-top: var(--Spacing-x3); } -.dateSelect { +.dateOfBirth { display: flex; flex-direction: column; gap: var(--Spacing-x1); width: 100%; + background-color: var(--Main-Brand-WarmWhite); + padding: var(--Spacing-x2) var(--Spacing-x3); +} + +.dateOfBirthLink { + display: flex; + align-items: center; + gap: var(--Spacing-x-half); +} + +.dateOfBirthDescription { + color: var(--UI-Text-High-contrast); } .termsAndConditions { diff --git a/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/page.tsx b/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/page.tsx index 37f2e2532..948819c2d 100644 --- a/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/page.tsx +++ b/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/link/page.tsx @@ -14,33 +14,16 @@ export default async function SASxScandicLinkPage({ }: PageArgs) { const profile = await getProfileSafely() - // TODO actually check if profile is already linked + // TODO check if already linked const alreadyLinked = false - async function handleLinkAccount(dateOfBirth: string) { - "use server" - - if (dateOfBirth !== profile?.dateOfBirth) { - // TODO update users date of birth here - console.log("updating date of birth") - } - - return { - redirectUrl: `/${params.lang}/sas-x-scandic/login?intent=link`, - success: true, - } - } - if (alreadyLinked) { redirect(`/${params.lang}/sas-x-scandic/error?errorCode=alreadyLinked`) } return ( - + ) } diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index 0937d5a56..5428445b8 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -64,8 +64,9 @@ "Bed type": "Seng type", "Bike friendly": "Cykelvenlig", "Birth date": "Fødselsdato", - "Birth date is required": "Birth date is required", "Boardroom": "Boardroom", + "Birth date is missing": "Birth date is missing", + "Birth date: {dateOfBirth, date, ::MMMM d yyyy}": "Birth date: {dateOfBirth, date, ::MMMM d yyyy}", "Book": "Book", "Book Reward Night": "Book bonusnat", "Book a table online": "Book et bord online", @@ -176,6 +177,7 @@ "Earn & spend points": "Få medlemsfordele og tilbud", "Edit": "Redigere", "Edit profile": "Rediger profil", + "Edit your personal details": "Edit your personal details", "Elevator preference": "Elevatorpræference", "Email": "E-mail", "Email address": "E-mailadresse", @@ -609,7 +611,7 @@ "We had an issue processing your booking. Please try again. No charges have been made.": "Vi havde et problem med at behandle din booking. Prøv venligst igen. Ingen gebyrer er blevet opkrævet.", "We have a special gift waiting for you!": "Vi har en speciel gave, der venter på dig!", "We look forward to your visit!": "Vi ser frem til dit besøg!", - "We require this additional information in order to match your Scandic account with your EuroBonus account.": "We require this additional information in order to match your Scandic account with your EuroBonus account.", + "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.": "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.", "We successfully connected your accounts!": "We successfully connected your accounts!", "We're sorry": "Vi beklager", "Wednesday": "Onsdag", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 1bd861367..74ba3b352 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -65,8 +65,9 @@ "Bed type": "Bettentyp", "Bike friendly": "Fahrradfreundlich", "Birth date": "Geburtsdatum", - "Birth date is required": "Birth date is required", "Boardroom": "Boardroom", + "Birth date is missing": "Birth date is missing", + "Birth date: {dateOfBirth, date, ::MMMM d yyyy}": "Birth date: {dateOfBirth, date, ::MMMM d yyyy}", "Book": "Buchen", "Book Reward Night": "Bonusnacht buchen", "Book a table online": "Tisch online buchen", @@ -177,6 +178,7 @@ "Earn & spend points": "Holen Sie sich Vorteile und Angebote für Mitglieder", "Edit": "Bearbeiten", "Edit profile": "Profil bearbeiten", + "Edit your personal details": "Edit your personal details", "Elevator preference": "Aufzugpräferenz", "Email": "Email", "Email address": "E-Mail-Adresse", @@ -609,7 +611,7 @@ "We had an issue processing your booking. Please try again. No charges have been made.": "Wir hatten ein Problem beim Verarbeiten Ihrer Buchung. Bitte versuchen Sie es erneut. Es wurden keine Gebühren erhoben.", "We have a special gift waiting for you!": "Wir haben ein besonderes Geschenk für Sie!", "We look forward to your visit!": "Wir freuen uns auf Ihren Besuch!", - "We require this additional information in order to match your Scandic account with your EuroBonus account.": "We require this additional information in order to match your Scandic account with your EuroBonus account.", + "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.": "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.", "We successfully connected your accounts!": "We successfully connected your accounts!", "We're sorry": "Es tut uns leid", "Wednesday": "Mittwoch", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index 362fa6fcd..c99e3094e 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -65,8 +65,9 @@ "Bed type": "Bed type", "Bike friendly": "Bike friendly", "Birth date": "Birth date", - "Birth date is required": "Birth date is required", "Boardroom": "Boardroom", + "Birth date is missing": "Birth date is missing", + "Birth date: {dateOfBirth, date, ::MMMM d yyyy}": "Birth date: {dateOfBirth, date, ::MMMM d yyyy}", "Book": "Book", "Book Reward Night": "Book Reward Night", "Book a table online": "Book a table online", @@ -180,6 +181,7 @@ "Earn & spend points": "Earn & spend points", "Edit": "Edit", "Edit profile": "Edit profile", + "Edit your personal details": "Edit your personal details", "Elevator preference": "Elevator preference", "Email": "Email", "Email address": "Email address", @@ -614,7 +616,7 @@ "We had an issue processing your booking. Please try again. No charges have been made.": "We had an issue processing your booking. Please try again. No charges have been made.", "We have a special gift waiting for you!": "We have a special gift waiting for you!", "We look forward to your visit!": "We look forward to your visit!", - "We require this additional information in order to match your Scandic account with your EuroBonus account.": "We require this additional information in order to match your Scandic account with your EuroBonus account.", + "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.": "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.", "We successfully connected your accounts!": "We successfully connected your accounts!", "We're sorry": "We're sorry", "Wednesday": "Wednesday", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index 62ba4f6ea..2db7d6c5f 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -63,8 +63,9 @@ "Bed type": "Vuodetyyppi", "Bike friendly": "Pyöräystävällinen", "Birth date": "Syntymäaika", - "Birth date is required": "Birth date is required", "Boardroom": "Boardroom", + "Birth date is missing": "Birth date is missing", + "Birth date: {dateOfBirth, date, ::MMMM d yyyy}": "Birth date: {dateOfBirth, date, ::MMMM d yyyy}", "Book": "Varaa", "Book Reward Night": "Kirjapalkinto-ilta", "Book a table online": "Varaa pöytä verkossa", @@ -176,6 +177,7 @@ "Earn & spend points": "Hanki jäsenetuja ja -tarjouksia", "Edit": "Muokata", "Edit profile": "Muokkaa profiilia", + "Edit your personal details": "Edit your personal details", "Elevator preference": "Hissitoive", "Email": "Sähköposti", "Email address": "Sähköpostiosoite", @@ -609,7 +611,7 @@ "We had an issue processing your booking. Please try again. No charges have been made.": "Meillä oli ongelma varauksen käsittelyssä. Yritä uudelleen. Ei maksuja on tehty.", "We have a special gift waiting for you!": "Meillä on erityinen lahja odottamassa sinua!", "We look forward to your visit!": "Odotamme innolla vierailuasi!", - "We require this additional information in order to match your Scandic account with your EuroBonus account.": "We require this additional information in order to match your Scandic account with your EuroBonus account.", + "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.": "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.", "We successfully connected your accounts!": "We successfully connected your accounts!", "We're sorry": "Olemme pahoillamme", "Wednesday": "Keskiviikko", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index c224870db..4ec41d8ec 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -63,8 +63,9 @@ "Bed type": "Seng type", "Bike friendly": "Sykkelvennlig", "Birth date": "Fødselsdato", - "Birth date is required": "Birth date is required", "Boardroom": "Boardroom", + "Birth date is missing": "Birth date is missing", + "Birth date: {dateOfBirth, date, ::MMMM d yyyy}": "Birth date: {dateOfBirth, date, ::MMMM d yyyy}", "Book": "Bestill", "Book Reward Night": "Bestill belønningskveld", "Book a table online": "Bestill bord online", @@ -175,6 +176,7 @@ "Earn & spend points": "Få medlemsfordeler og tilbud", "Edit": "Redigere", "Edit profile": "Rediger profil", + "Edit your personal details": "Edit your personal details", "Elevator preference": "Heispreferanse", "Email": "E-post", "Email address": "E-postadresse", @@ -607,7 +609,7 @@ "We had an issue processing your booking. Please try again. No charges have been made.": "Vi hadde et problem med å behandle din bestilling. Vær så snill å prøv igjen. Ingen gebyrer er blevet belastet.", "We have a special gift waiting for you!": "Vi har en spesiell gave som venter på deg!", "We look forward to your visit!": "Vi ser frem til ditt besøk!", - "We require this additional information in order to match your Scandic account with your EuroBonus account.": "We require this additional information in order to match your Scandic account with your EuroBonus account.", + "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.": "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.", "We successfully connected your accounts!": "We successfully connected your accounts!", "We're sorry": "Vi beklager", "Wednesday": "Onsdag", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index a0e2d3d6d..9d28e56c7 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -63,8 +63,9 @@ "Bed type": "Sängtyp", "Bike friendly": "Cykelvänligt", "Birth date": "Födelsedatum", - "Birth date is required": "Birth date is required", "Boardroom": "Boardroom", + "Birth date is missing": "Birth date is missing", + "Birth date: {dateOfBirth, date, ::MMMM d yyyy}": "Birth date: {dateOfBirth, date, ::MMMM d yyyy}", "Book": "Boka", "Book Reward Night": "Boka frinatt", "Book a table online": "Boka ett bord online", @@ -175,6 +176,7 @@ "Earn & spend points": "Ta del av medlemsförmåner och erbjudanden", "Edit": "Redigera", "Edit profile": "Redigera profil", + "Edit your personal details": "Edit your personal details", "Elevator preference": "Hisspreferens", "Email": "E-post", "Email address": "E-postadress", @@ -607,7 +609,7 @@ "We had an issue processing your booking. Please try again. No charges have been made.": "Vi hade ett problem med att bearbeta din bokning. Vänligen försök igen. Inga avgifter har debiterats.", "We have a special gift waiting for you!": "Vi har en speciell present som väntar på dig!", "We look forward to your visit!": "Vi ser fram emot ditt besök!", - "We require this additional information in order to match your Scandic account with your EuroBonus account.": "We require this additional information in order to match your Scandic account with your EuroBonus account.", + "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.": "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.", "We successfully connected your accounts!": "We successfully connected your accounts!", "We're sorry": "Vi beklagar", "Wednesday": "Onsdag",