diff --git a/components/Loyalty/Sidebar/JoinLoyalty/index.tsx b/components/Loyalty/Sidebar/JoinLoyalty/index.tsx
index 481f984a7..e940aab0f 100644
--- a/components/Loyalty/Sidebar/JoinLoyalty/index.tsx
+++ b/components/Loyalty/Sidebar/JoinLoyalty/index.tsx
@@ -34,11 +34,22 @@ export default async function JoinLoyaltyContact({
{block.preamble ?
{block.preamble} : null}
-
+ {block.button ? (
+
+ ) : null}
{formatMessage({ id: "Already a friend?" })}
{
+ 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 =
diff --git a/server/routers/contentstack/loyaltyPage/utils.ts b/server/routers/contentstack/loyaltyPage/utils.ts
index 409ebadef..95e251075 100644
--- a/server/routers/contentstack/loyaltyPage/utils.ts
+++ b/server/routers/contentstack/loyaltyPage/utils.ts
@@ -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
}
})
}