Files
tibi-docs/frontend/src/lib/functions/fetch/loadNavigationAndSetStores.ts
2024-03-11 17:25:59 +00:00

16 lines
614 B
TypeScript

import { api } from "../../../api"
import { navigation, serviceNavigation } from "../../store"
export async function loadNavigationAndSetStores(): Promise<null> {
const navigations = await api<Navigation[]>("navigation", {})
let navigationStore: NavElement[] = []
let serviceNavigationStore: NavElement[] = []
navigations.data.forEach((nav: Navigation) => {
if (nav.tree == 0) navigationStore = nav.elements
else if (nav.tree == 1) serviceNavigationStore = nav.elements
})
navigation.set(navigationStore)
serviceNavigation.set(serviceNavigationStore)
return null
}