Merged develop into chore/da-translations
This commit is contained in:
@@ -34,11 +34,22 @@ export default async function JoinLoyaltyContact({
|
||||
</Title>
|
||||
<ScandicFriends color="red" />
|
||||
{block.preamble ? <Body>{block.preamble}</Body> : null}
|
||||
<Button asChild intent="primary" theme="base" className={styles.button}>
|
||||
<Link href={login[lang]} color="white">
|
||||
{formatMessage({ id: "Join Scandic Friends" })}
|
||||
</Link>
|
||||
</Button>
|
||||
{block.button ? (
|
||||
<Button
|
||||
asChild
|
||||
intent="primary"
|
||||
theme="base"
|
||||
className={styles.button}
|
||||
>
|
||||
<Link
|
||||
href={block.button.href}
|
||||
color="white"
|
||||
target={block.button.openInNewTab ? "_blank" : "_self"}
|
||||
>
|
||||
{block.button.title}
|
||||
</Link>
|
||||
</Button>
|
||||
) : null}
|
||||
<section className={styles.loginContainer}>
|
||||
<Body>{formatMessage({ id: "Already a friend?" })}</Body>
|
||||
<Link
|
||||
|
||||
@@ -109,6 +109,24 @@ query GetLoyaltyPage($locale: String!, $uid: String!) {
|
||||
join_loyalty_contact {
|
||||
title
|
||||
preamble
|
||||
button {
|
||||
cta_text
|
||||
external_link {
|
||||
title
|
||||
href
|
||||
}
|
||||
open_in_new_tab
|
||||
linkConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageLink
|
||||
...ContentPageLink
|
||||
...LoyaltyPageLink
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
contact {
|
||||
... on LoyaltyPageSidebarJoinLoyaltyContactBlockContactContact {
|
||||
__typename
|
||||
@@ -252,6 +270,23 @@ query GetLoyaltyPageRefs($locale: String!, $uid: String!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
... on LoyaltyPageSidebarJoinLoyaltyContact {
|
||||
__typename
|
||||
join_loyalty_contact {
|
||||
button {
|
||||
linkConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageRef
|
||||
...ContentPageRef
|
||||
...LoyaltyPageRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
system {
|
||||
...System
|
||||
|
||||
@@ -152,6 +152,14 @@ const loyaltyPageJoinLoyaltyContact = z.object({
|
||||
join_loyalty_contact: z.object({
|
||||
title: z.string().nullable(),
|
||||
preamble: z.string().nullable(),
|
||||
button: z
|
||||
.object({
|
||||
openInNewTab: z.boolean(),
|
||||
title: z.string(),
|
||||
href: z.string(),
|
||||
isExternal: z.boolean(),
|
||||
})
|
||||
.nullable(),
|
||||
contact: z.array(
|
||||
z.object({
|
||||
__typename: z.literal(
|
||||
@@ -362,8 +370,22 @@ const loyaltyPageSidebarTextContentRef = z.object({
|
||||
}),
|
||||
})
|
||||
|
||||
const loyaltyPageSidebarJoinLoyaltyContactRef = z.object({
|
||||
__typename: z.literal(
|
||||
SidebarTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContact
|
||||
),
|
||||
join_loyalty_contact: z.object({
|
||||
button: z
|
||||
.object({
|
||||
linkConnection: pageConnectionRefs,
|
||||
})
|
||||
.nullable(),
|
||||
}),
|
||||
})
|
||||
|
||||
const loyaltyPageSidebarRefsItem = z.discriminatedUnion("__typename", [
|
||||
loyaltyPageSidebarTextContentRef,
|
||||
loyaltyPageSidebarJoinLoyaltyContactRef,
|
||||
])
|
||||
|
||||
export const validateLoyaltyPageRefsSchema = z.object({
|
||||
|
||||
@@ -27,6 +27,7 @@ import { InsertResponse } from "@/types/components/imageVaultImage"
|
||||
import {
|
||||
LoyaltyBlocksTypenameEnum,
|
||||
LoyaltyCardsGridEnum,
|
||||
SidebarTypenameEnum,
|
||||
} from "@/types/components/loyalty/enums"
|
||||
|
||||
function makeImageVaultImage(image: any) {
|
||||
@@ -36,21 +37,25 @@ function makeImageVaultImage(image: any) {
|
||||
}
|
||||
|
||||
function makeButtonObject(button: any) {
|
||||
if (!button) return null
|
||||
|
||||
const isContenstackLink =
|
||||
button?.is_contentstack_link || button.linkConnection?.edges?.length
|
||||
|
||||
return {
|
||||
openInNewTab: button.open_in_new_tab,
|
||||
openInNewTab: button?.open_in_new_tab,
|
||||
title:
|
||||
button.cta_text ||
|
||||
(button.is_contentstack_link && button.linkConnection.edges.length
|
||||
(isContenstackLink
|
||||
? button.linkConnection.edges[0].node.title
|
||||
: button.external_link.title),
|
||||
href:
|
||||
button.is_contentstack_link && button.linkConnection.edges.length
|
||||
? button.linkConnection.edges[0].node.web?.original_url ||
|
||||
removeMultipleSlashes(
|
||||
`/${button.linkConnection.edges[0].node.system.locale}/${button.linkConnection.edges[0].node.url}`
|
||||
)
|
||||
: button.external_link.href,
|
||||
isExternal: !button.is_contentstack_link,
|
||||
href: isContenstackLink
|
||||
? button.linkConnection.edges[0].node.web?.original_url ||
|
||||
removeMultipleSlashes(
|
||||
`/${button.linkConnection.edges[0].node.system.locale}/${button.linkConnection.edges[0].node.url}`
|
||||
)
|
||||
: button.external_link.href,
|
||||
isExternal: !isContenstackLink,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,11 +160,7 @@ export const loyaltyPageQueryRouter = router({
|
||||
return {
|
||||
...card,
|
||||
image: makeImageVaultImage(card.image),
|
||||
link: makeButtonObject({
|
||||
...card.link,
|
||||
is_contentstack_link:
|
||||
!!card.link.linkConnection.edges.length,
|
||||
}),
|
||||
link: makeButtonObject(card.link),
|
||||
}
|
||||
case LoyaltyCardsGridEnum.Card:
|
||||
return {
|
||||
@@ -185,11 +186,28 @@ export const loyaltyPageQueryRouter = router({
|
||||
})
|
||||
: null
|
||||
|
||||
const sidebar = response.data.loyalty_page.sidebar
|
||||
? response.data.loyalty_page.sidebar.map((item: any) => {
|
||||
switch (item.__typename) {
|
||||
case SidebarTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContact:
|
||||
return {
|
||||
...item,
|
||||
join_loyalty_contact: {
|
||||
...item.join_loyalty_contact,
|
||||
button: makeButtonObject(item.join_loyalty_contact.button),
|
||||
},
|
||||
}
|
||||
default:
|
||||
return item
|
||||
}
|
||||
})
|
||||
: null
|
||||
|
||||
const loyaltyPage = {
|
||||
heading: response.data.loyalty_page.heading,
|
||||
system: response.data.loyalty_page.system,
|
||||
blocks,
|
||||
sidebar: response.data.loyalty_page.sidebar,
|
||||
sidebar,
|
||||
}
|
||||
|
||||
const validatedLoyaltyPage =
|
||||
|
||||
@@ -3,6 +3,7 @@ import { LoyaltyPageRefsDataRaw } from "./output"
|
||||
import {
|
||||
LoyaltyBlocksTypenameEnum,
|
||||
LoyaltyCardsGridEnum,
|
||||
SidebarTypenameEnum,
|
||||
} from "@/types/components/loyalty/enums"
|
||||
import type { Edges } from "@/types/requests/utils/edges"
|
||||
import type { NodeRefs } from "@/types/requests/utils/refs"
|
||||
@@ -59,8 +60,17 @@ export function getConnections(refs: LoyaltyPageRefsDataRaw) {
|
||||
}
|
||||
if (refs.loyalty_page.sidebar) {
|
||||
refs.loyalty_page.sidebar?.forEach((item) => {
|
||||
if (item.content.content.embedded_itemsConnection.edges.length) {
|
||||
connections.push(item.content.content.embedded_itemsConnection)
|
||||
switch (item.__typename) {
|
||||
case SidebarTypenameEnum.LoyaltyPageSidebarContent:
|
||||
if (item.content.content.embedded_itemsConnection.edges.length) {
|
||||
connections.push(item.content.content.embedded_itemsConnection)
|
||||
}
|
||||
break
|
||||
case SidebarTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContact:
|
||||
if (item.join_loyalty_contact.button?.linkConnection) {
|
||||
connections.push(item.join_loyalty_contact.button.linkConnection)
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user