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