fix: refs for account page

This commit is contained in:
Christel Westerberg
2024-05-15 11:06:52 +02:00
parent d651ea526c
commit 863d99ad44
5 changed files with 210 additions and 7 deletions
@@ -0,0 +1,33 @@
import { AccountPageRefsDataRaw } from "./output"
import { ContentEntries } from "@/types/components/myPages/myPage/enums"
import type { Edges } from "@/types/requests/utils/edges"
import type { NodeRefs } from "@/types/requests/utils/refs"
export function getConnections(refs: AccountPageRefsDataRaw) {
const connections: Edges<NodeRefs>[] = []
refs.all_account_page.items.forEach((ref) => {
if (ref.content) {
ref.content.forEach((item) => {
switch (item.__typename) {
case ContentEntries.AccountPageContentShortcuts: {
item.shortcuts.shortcuts.forEach((shortcut) => {
if (shortcut.linkConnection.edges.length) {
connections.push(shortcut.linkConnection)
}
})
break
}
case ContentEntries.AccountPageContentDynamicContent: {
if (item.dynamic_content.link.linkConnection.edges.length) {
connections.push(item.dynamic_content.link.linkConnection)
}
break
}
}
})
}
})
return connections
}