feat: improve structure and error handling

This commit is contained in:
Michael Zetterberg
2024-05-14 15:55:46 +02:00
parent 01587d7fd5
commit f5108d1a8e
104 changed files with 1505 additions and 1570 deletions

View File

@@ -6,28 +6,26 @@ 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)
if (refs.account_page.content) {
refs.account_page.content.forEach((item) => {
switch (item.__typename) {
case ContentEntries.AccountPageContentShortcuts: {
item.shortcuts.shortcuts.forEach((shortcut) => {
if (shortcut.linkConnection.edges.length) {
connections.push(shortcut.linkConnection)
}
break
}
})
break
}
})
}
})
case ContentEntries.AccountPageContentDynamicContent: {
if (item.dynamic_content.link.linkConnection.edges.length) {
connections.push(item.dynamic_content.link.linkConnection)
}
break
}
}
})
}
return connections
}