32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
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>[] = []
|
|
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
|
|
}
|
|
case ContentEntries.AccountPageContentDynamicContent: {
|
|
if (item.dynamic_content.link.linkConnection.edges.length) {
|
|
connections.push(item.dynamic_content.link.linkConnection)
|
|
}
|
|
break
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
return connections
|
|
}
|