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,93 @@
import Overview from "@/components/Blocks/DynamicContent/Overview"
import EarnAndBurn from "@/components/Blocks/DynamicContent/Points/EarnAndBurn"
import PointsOverview from "@/components/Blocks/DynamicContent/Points/Overview"
import CurrentRewardsBlock from "@/components/Blocks/DynamicContent/Rewards/CurrentRewards"
import NextLevelRewardsBlock from "@/components/Blocks/DynamicContent/Rewards/NextLevel"
import ShortcutsList from "@/components/Blocks/ShortcutsList"
import JsonToHtml from "@/components/JsonToHtml"
import { getLang } from "@/i18n/serverContext"
import { modWebviewLink } from "@/utils/webviews"
import type {
AccountPageContentProps,
ContentProps,
} from "@/types/components/myPages/myPage/accountPage"
import { BlocksEnums } from "@/types/enums/blocks"
import { DynamicContentEnum } from "@/types/enums/dynamicContent"
function DynamicComponent({ dynamic_content }: AccountPageContentProps) {
const dynamicContent = {
...dynamic_content,
link: dynamic_content.link
? {
...dynamic_content.link,
href: modWebviewLink(dynamic_content.link.href, getLang()),
}
: undefined,
}
switch (dynamic_content.component) {
case DynamicContentEnum.Blocks.components.membership_overview:
return <Overview {...dynamicContent} />
case DynamicContentEnum.Blocks.components.points_overview:
return <PointsOverview {...dynamicContent} />
case DynamicContentEnum.Blocks.components.current_benefits:
return <CurrentRewardsBlock {...dynamicContent} />
case DynamicContentEnum.Blocks.components.next_benefits:
return <NextLevelRewardsBlock {...dynamicContent} />
case DynamicContentEnum.Blocks.components.expiring_points:
// TODO: Add once available
// return <ExpiringPoints />
return null
case DynamicContentEnum.Blocks.components.earn_and_burn:
return <EarnAndBurn {...dynamicContent} />
default:
return null
}
}
export default function Content({ content }: ContentProps) {
return (
<>
{content.map((item, idx) => {
switch (item.typename) {
case BlocksEnums.block.DynamicContent:
return (
<DynamicComponent
key={`${item.dynamic_content.title}-${idx}`}
dynamic_content={item.dynamic_content}
/>
)
case BlocksEnums.block.Shortcuts:
const shortcuts = item.shortcuts.shortcuts.map((shortcut) => {
return {
...shortcut,
url: modWebviewLink(shortcut.url, getLang()),
}
})
return (
<ShortcutsList
key={`${item.shortcuts.title}-${idx}`}
shortcuts={shortcuts}
subtitle={item.shortcuts.subtitle}
title={item.shortcuts.title}
hasTwoColumns={item.shortcuts.hasTwoColumns}
/>
)
case BlocksEnums.block.TextContent:
return (
<section key={`${item.__typename}-${idx}`}>
<JsonToHtml
embeds={
item.text_content.content.embedded_itemsConnection.edges
}
nodes={item.text_content.content.json.children}
/>
</section>
)
default:
return null
}
})}
</>
)
}

View File

@@ -0,0 +1,5 @@
.blocks {
display: grid;
gap: var(--Spacing-x5);
padding: var(--Spacing-x2);
}

View File

@@ -0,0 +1,41 @@
import "@/app/globals.css"
import "@scandic-hotels/design-system/style.css"
import { Suspense } from "react"
import { overview } from "@/constants/routes/webviews"
import { serverClient } from "@/lib/trpc/server"
import MaxWidth from "@/components/MaxWidth"
import TrackingSDK from "@/components/TrackingSDK"
import Blocks from "@/components/Webviews/AccountPage/Blocks"
import LinkToOverview from "@/components/Webviews/LinkToOverview"
import { getLang } from "@/i18n/serverContext"
import styles from "./accountPage.module.css"
export default async function AccountPage() {
const accountPageRes = await serverClient().contentstack.accountPage.get()
if (!accountPageRes) {
return null
}
const { tracking, accountPage } = accountPageRes
const linkToOverview =
`/${getLang()}/webview${accountPage.url}` !== overview[getLang()]
return (
<>
<MaxWidth className={styles.blocks} tag="main">
{linkToOverview ? <LinkToOverview /> : null}
<Blocks content={accountPage.content} />
</MaxWidth>
<Suspense fallback={null}>
<TrackingSDK pageData={tracking} />
</Suspense>
</>
)
}

View File

@@ -0,0 +1,23 @@
import { ArrowLeft } from "react-feather"
import { overview } from "@/constants/routes/webviews"
import Link from "@/components/TempDesignSystem/Link"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import { webviewSearchParams } from "@/utils/webviews"
import styles from "./linkToOverview.module.css"
export default async function LinkToOverview() {
const intl = await getIntl()
const searchParams = webviewSearchParams()
const overviewHref = `${overview[getLang()]}?${searchParams.toString()}`
return (
<Link className={styles.overviewLink} href={overviewHref}>
<ArrowLeft height={20} width={20} />
{intl.formatMessage({ id: "Go back to overview" })}
</Link>
)
}

View File

@@ -0,0 +1,7 @@
.overviewLink {
align-items: center;
color: var(--Scandic-Brand-Burgundy);
display: flex;
font-size: var(--Spacing-x2);
gap: var(--Spacing-x1);
}

View File

@@ -0,0 +1,71 @@
import CardsGrid from "@/components/Blocks/CardsGrid"
import DynamicContent from "@/components/Blocks/DynamicContent"
import ShortcutsList from "@/components/Blocks/ShortcutsList"
import JsonToHtml from "@/components/JsonToHtml"
import { getLang } from "@/i18n/serverContext"
import { modWebviewLink } from "@/utils/webviews"
import type { BlocksProps } from "@/types/components/blocks"
import { BlocksEnums } from "@/types/enums/blocks"
export default function Blocks({ blocks }: BlocksProps) {
return blocks.map((block, idx) => {
const firstItem = idx === 0
switch (block.typename) {
case BlocksEnums.block.CardsGrid:
return (
<CardsGrid
key={`${block.cards_grid.title}-${idx}`}
cards_grid={block.cards_grid}
/>
)
case BlocksEnums.block.Content:
return (
<section key={`${block.__typename}-${idx}`}>
<JsonToHtml
nodes={block.content.json.children}
embeds={block.content.embedded_itemsConnection.edges}
/>
</section>
)
case BlocksEnums.block.DynamicContent:
const dynamicContent = {
...block.dynamic_content,
link: block.dynamic_content.link
? {
...block.dynamic_content.link,
href: modWebviewLink(
block.dynamic_content.link.href,
getLang()
),
}
: undefined,
}
return (
<DynamicContent
dynamic_content={dynamicContent}
firstItem={firstItem}
key={`${block.dynamic_content.title}-${idx}`}
/>
)
case BlocksEnums.block.Shortcuts:
const shortcuts = block.shortcuts.shortcuts.map((shortcut) => ({
...shortcut,
url: modWebviewLink(shortcut.url, getLang()),
}))
return (
<ShortcutsList
key={`${block.shortcuts.title}-${idx}`}
firstItem={firstItem}
shortcuts={shortcuts}
subtitle={block.shortcuts.subtitle}
title={block.shortcuts.title}
hasTwoColumns={block.shortcuts.hasTwoColumns}
/>
)
default:
return null
}
})
}

View File

@@ -0,0 +1,37 @@
import { Suspense } from "react"
import { serverClient } from "@/lib/trpc/server"
import MaxWidth from "@/components/MaxWidth"
import Title from "@/components/TempDesignSystem/Text/Title"
import TrackingSDK from "@/components/TrackingSDK"
import LinkToOverview from "@/components/Webviews/LinkToOverview"
import Blocks from "./Blocks"
import styles from "./loyaltyPage.module.css"
export default async function AboutScandicFriends() {
const loyaltyPageRes = await serverClient().contentstack.loyaltyPage.get()
if (!loyaltyPageRes) {
return null
}
const { tracking, loyaltyPage } = loyaltyPageRes
return (
<>
<section className={styles.content}>
<LinkToOverview />
<MaxWidth tag="main" className={styles.blocks}>
<Title>{loyaltyPage.heading}</Title>
<Blocks blocks={loyaltyPage.blocks} />
</MaxWidth>
</section>
<Suspense fallback={null}>
<TrackingSDK pageData={tracking} />
</Suspense>
</>
)
}

View File

@@ -0,0 +1,10 @@
.content {
display: grid;
padding: var(--Spacing-x2);
gap: var(--Spacing-x5);
}
.blocks {
display: grid;
gap: var(--Spacing-x5);
}