import type { GetNavigationMyPagesRefsData } from "@/types/requests/myPages/navigation"
import type { Edges } from "@/types/requests/utils/edges"
import type { NodeRefs } from "@/types/requests/utils/refs"

export function getConnections(refs: GetNavigationMyPagesRefsData) {
  const connections: Edges<NodeRefs>[] = []
  refs.all_navigation_my_pages.items.forEach((ref) => {
    ref.items.forEach(({ item }) => {
      connections.push(item.pageConnection)

      item.sub_items.forEach(({ item: subItem }) => {
        connections.push(subItem.pageConnection)
      })
    })
  })

  return connections
}
