Merged in monorepo-step-1 (pull request #1080)

Migrate to a monorepo setup - step 1

* Move web to subfolder /apps/scandic-web

* Yarn + transitive deps

- Move to yarn
- design-system package removed for now since yarn doesn't
support the parameter for token (ie project currently broken)
- Add missing transitive dependencies as Yarn otherwise
prevents these imports
- VS Code doesn't pick up TS path aliases unless you open
/apps/scandic-web instead of root (will be fixed with monorepo)

* Pin framer-motion to temporarily fix typing issue

https://github.com/adobe/react-spectrum/issues/7494

* Pin zod to avoid typ error

There seems to have been a breaking change in the types
returned by zod where error is now returned as undefined
instead of missing in the type. We should just handle this
but to avoid merge conflicts just pin the dependency for
now.

* Pin react-intl version

Pin version of react-intl to avoid tiny type issue where formatMessage
does not accept a generic any more. This will be fixed in a future
commit, but to avoid merge conflicts just pin for now.

* Pin typescript version

Temporarily pin version as newer versions as stricter and results in
a type error. Will be fixed in future commit after merge.

* Setup workspaces

* Add design-system as a monorepo package

* Remove unused env var DESIGN_SYSTEM_ACCESS_TOKEN

* Fix husky for monorepo setup

* Update netlify.toml

* Add lint script to root package.json

* Add stub readme

* Fix react-intl formatMessage types

* Test netlify.toml in root

* Remove root toml

* Update netlify.toml publish path

* Remove package-lock.json

* Update build for branch/preview builds


Approved-by: Linus Flood
This commit is contained in:
Anton Gunnarsson
2025-02-26 10:36:17 +00:00
committed by Linus Flood
parent 667cab6fb6
commit 80100e7631
2731 changed files with 30986 additions and 23708 deletions

View File

@@ -0,0 +1,149 @@
"use client"
import Image from "next/image"
import { useParams, useRouter } from "next/navigation"
import { 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 Label from "@/components/TempDesignSystem/Form/Label"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Title from "@/components/TempDesignSystem/Text/Title"
import styles from "./link-sas.module.css"
import type { LangParams } from "@/types/params"
type LinkAccountForm = {
termsAndConditions: boolean
}
export function LinkAccountForm({
userDateOfBirth,
}: {
userDateOfBirth: string | null
}) {
const router = useRouter()
const params = useParams<LangParams>()
let [isPending, startTransition] = useTransition()
const intl = useIntl()
const form = useForm<LinkAccountForm>({
defaultValues: {
termsAndConditions: false,
},
})
const handleSubmit = form.handleSubmit((data) => {
startTransition(async () => {
if (!data.termsAndConditions) return
const url = `/${params.lang}/sas-x-scandic/login?intent=link`
router.push(url)
})
})
const termsAndConditions = form.watch("termsAndConditions")
const disableSubmit = !userDateOfBirth || !termsAndConditions
return (
<FormProvider {...form}>
<form onSubmit={handleSubmit} className={styles.form}>
<div className={styles.titles}>
<Image
alt={"Scandic ❤️ SAS"}
height={25}
width={182}
src="/_static/img/partner/sas/sas-campaign-logo.png"
/>
<Title level="h3" textTransform="regular">
{intl.formatMessage({ id: "Link your accounts" })}
</Title>
</div>
<div className={styles.dateOfBirth}>
<Body textTransform="bold">
{userDateOfBirth
? intl.formatMessage(
{
id: "Birth date: {dateOfBirth, date, ::MMMM d yyyy}",
},
{
dateOfBirth: new Date(userDateOfBirth),
}
)
: intl.formatMessage({ id: "Birth date is missing" })}
</Body>
<Label size="small" className={styles.dateOfBirthDescription}>
{intl.formatMessage({
id: "We require your birth date in order to link your Scandic account with your SAS EuroBonus account. Please check that it is correct.",
})}
</Label>
<Link
href={profileEdit[params.lang]}
className={styles.dateOfBirthLink}
color="peach80"
variant="underscored"
>
{intl.formatMessage({
id: "Edit your personal details",
})}
<ArrowRightIcon color="peach80" height={18} width={18} />
</Link>
</div>
<div className={styles.termsAndConditions}>
<Checkbox
name="termsAndConditions"
registerOptions={{
required: {
value: true,
message: intl.formatMessage({
id: "You must accept the terms and conditions",
}),
},
disabled: !userDateOfBirth,
}}
>
<Body>
{intl.formatMessage({ id: "I accept the terms and conditions" })}
</Body>
</Checkbox>
<Body className={styles.termsDescription}>
{intl.formatMessage(
{
id: "By linking your accounts you accept the <sasScandicTermsAndConditionsLink>Scandic Friends & SAS Terms and Conditions</sasScandicTermsAndConditionsLink>. You will be connected throughout the duration of your employment or until further notice, and you can opt out at any time.",
},
{
sasScandicTermsAndConditionsLink: (str) => (
<Link
// TODO correct link
href={"#"}
weight="bold"
variant="default"
textDecoration="underline"
>
{str}
</Link>
),
}
)}
</Body>
</div>
<div className={styles.ctaContainer}>
<Button
theme="base"
fullWidth
className={styles.ctaButton}
type="submit"
disabled={isPending || disableSubmit}
>
{intl.formatMessage({ id: "Link my accounts" })}
</Button>
</div>
</form>
</FormProvider>
)
}

View File

@@ -0,0 +1,55 @@
.titles {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--Spacing-x2);
margin-top: var(--Spacing-x3);
}
.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 {
display: flex;
flex-direction: column;
gap: var(--Spacing-x2);
}
.termsDescription {
margin-left: calc(var(--Spacing-x4) + var(--Spacing-x-half));
}
.ctaContainer {
display: flex;
justify-content: center;
padding: var(--Spacing-x3) var(--Spacing-x3) 0;
width: calc(100% + var(--Spacing-x3) + var(--Spacing-x3));
border-top: 1px solid var(--Base-Border-Subtle);
}
.ctaButton {
max-width: 350px;
}
.form {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--Spacing-x3);
}

View File

@@ -0,0 +1,28 @@
import { redirect } from "next/navigation"
import React from "react"
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
import { SASModal } from "../components/SASModal"
import { LinkAccountForm } from "./LinkAccountForm"
import type { LangParams, PageArgs } from "@/types/params"
export default async function SASxScandicLinkPage({
params,
}: PageArgs<LangParams>) {
const profile = await getProfileSafely()
// TODO check if already linked
const alreadyLinked = false
if (alreadyLinked) {
redirect(`/${params.lang}/sas-x-scandic/error?errorCode=alreadyLinked`)
}
return (
<SASModal>
<LinkAccountForm userDateOfBirth={profile?.dateOfBirth ?? null} />
</SASModal>
)
}

View File

@@ -0,0 +1,41 @@
import React from "react"
import { scandicXSAS } from "@/constants/routes/myPages"
import CheckCircle from "@/components/Icons/CheckCircle"
import { Redirect } from "@/components/Redirect"
import Body from "@/components/TempDesignSystem/Text/Body"
import Title from "@/components/TempDesignSystem/Text/Title"
import { getIntl } from "@/i18n"
import { SASModal } from "../../components/SASModal"
import type { LangParams, PageArgs } from "@/types/params"
export default async function SASxScandicLinkPage({
params,
}: PageArgs<LangParams>) {
const intl = await getIntl()
return (
<SASModal>
<Redirect url={scandicXSAS[params.lang]} timeout={3000} />
<CheckCircle height={64} width={64} color="uiSemanticSuccess" />
<Title as="h2" level="h1" textAlign="center">
{intl.formatMessage({ id: "Your accounts are connected" })}
</Title>
<div>
<Body textAlign="center">
{intl.formatMessage({
id: "We successfully connected your accounts!",
})}
</Body>
<Body textAlign="center">
{intl.formatMessage({
id: "Redirecting you to my pages.",
})}
</Body>
</div>
</SASModal>
)
}