chore: move function declarations
This commit is contained in:
@@ -16,19 +16,7 @@ import {
|
|||||||
} from "@/types/requests/myPages/navigation"
|
} from "@/types/requests/myPages/navigation"
|
||||||
import { GetNavigationMyPages } from "@/lib/graphql/Query/NavigationMyPages.graphql"
|
import { GetNavigationMyPages } from "@/lib/graphql/Query/NavigationMyPages.graphql"
|
||||||
|
|
||||||
export default async function MyPagesLayout({
|
function getURL(node: PageLink) {
|
||||||
children,
|
|
||||||
params,
|
|
||||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
|
||||||
const response = await request<GetNavigationMyPagesData>(
|
|
||||||
GetNavigationMyPages,
|
|
||||||
{
|
|
||||||
locale: params.lang,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
function mapMenuItems(navigationItems: NavigationItem[]) {
|
|
||||||
function getURL(node: PageLink) {
|
|
||||||
switch (node.__typename) {
|
switch (node.__typename) {
|
||||||
case PageLinkEnum.ContentPage:
|
case PageLinkEnum.ContentPage:
|
||||||
return node.web.url
|
return node.web.url
|
||||||
@@ -37,8 +25,9 @@ export default async function MyPagesLayout({
|
|||||||
case PageLinkEnum.CodeDefinedPage:
|
case PageLinkEnum.CodeDefinedPage:
|
||||||
return node.url
|
return node.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mapMenuItems(navigationItems: NavigationItem[]) {
|
||||||
return navigationItems.map(({ item }): MenuItem => {
|
return navigationItems.map(({ item }): MenuItem => {
|
||||||
const { node } = item.pageConnection.edges[0]
|
const { node } = item.pageConnection.edges[0]
|
||||||
const {
|
const {
|
||||||
@@ -54,7 +43,18 @@ export default async function MyPagesLayout({
|
|||||||
subItems: item.sub_items ? mapMenuItems(item.sub_items) : null,
|
subItems: item.sub_items ? mapMenuItems(item.sub_items) : null,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function MyPagesLayout({
|
||||||
|
children,
|
||||||
|
params,
|
||||||
|
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||||
|
const response = await request<GetNavigationMyPagesData>(
|
||||||
|
GetNavigationMyPages,
|
||||||
|
{
|
||||||
|
locale: params.lang,
|
||||||
}
|
}
|
||||||
|
)
|
||||||
// navigation_my_pages is of type Single, hence the hard [0]
|
// navigation_my_pages is of type Single, hence the hard [0]
|
||||||
const navigation = response.data.all_navigation_my_pages.items[0]
|
const navigation = response.data.all_navigation_my_pages.items[0]
|
||||||
const menuItems = mapMenuItems(navigation.items)
|
const menuItems = mapMenuItems(navigation.items)
|
||||||
|
|||||||
Reference in New Issue
Block a user