feat(BOOK-609): Using embedded url for assets instead of href since that is not updated when the asset is updated)
* feat(BOOK-609): Updated refs handling for assets inside content pages Approved-by: Linus Flood
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { LoyaltyPageEnum } from "../../../enums/loyaltyPage"
|
||||
|
||||
import type { LoyaltyPageRefs } from "../../../types/loyaltyPage"
|
||||
import type { System } from "../schemas/system"
|
||||
import type { AssetSystem, System } from "../schemas/system"
|
||||
|
||||
export function getConnections({ loyalty_page }: LoyaltyPageRefs) {
|
||||
const connections: System["system"][] = [loyalty_page.system]
|
||||
const assetConnections: AssetSystem[] = []
|
||||
|
||||
if (loyalty_page.blocks) {
|
||||
loyalty_page.blocks.forEach((block) => {
|
||||
@@ -16,9 +17,13 @@ export function getConnections({ loyalty_page }: LoyaltyPageRefs) {
|
||||
break
|
||||
case LoyaltyPageEnum.ContentStack.blocks.Content:
|
||||
if (block?.content?.length) {
|
||||
// TS has trouble infering the filtered types
|
||||
// @ts-ignore
|
||||
connections.push(...block.content)
|
||||
block.content.forEach((contentBlock) => {
|
||||
if ("system" in contentBlock) {
|
||||
assetConnections.push(contentBlock)
|
||||
} else {
|
||||
connections.push(contentBlock)
|
||||
}
|
||||
})
|
||||
}
|
||||
break
|
||||
case LoyaltyPageEnum.ContentStack.blocks.DynamicContent:
|
||||
@@ -41,10 +46,14 @@ export function getConnections({ loyalty_page }: LoyaltyPageRefs) {
|
||||
loyalty_page.sidebar.forEach((block) => {
|
||||
switch (block?.__typename) {
|
||||
case LoyaltyPageEnum.ContentStack.sidebar.Content:
|
||||
if (block.content.length) {
|
||||
// TS has trouble infering the filtered types
|
||||
// @ts-ignore
|
||||
connections.push(...block.content)
|
||||
if (block?.content?.length) {
|
||||
block.content.forEach((contentBlock) => {
|
||||
if ("system" in contentBlock) {
|
||||
assetConnections.push(contentBlock)
|
||||
} else {
|
||||
connections.push(contentBlock)
|
||||
}
|
||||
})
|
||||
}
|
||||
break
|
||||
case LoyaltyPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
|
||||
@@ -59,5 +68,5 @@ export function getConnections({ loyalty_page }: LoyaltyPageRefs) {
|
||||
})
|
||||
}
|
||||
|
||||
return connections
|
||||
return { connections, assetConnections }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user