-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove needless base layout
- Loading branch information
Showing
2 changed files
with
48 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,58 @@ | ||
import BaseLayout from '@/components/BaseLayout/BaseLayout'; | ||
import { Footer } from '@/components/Footer'; | ||
import { Header } from '@/components/Header'; | ||
import { ISliderItem } from '@/app/[locale]/(main)/(container)/(homepage)/components/MainSlider/types'; | ||
import { getClient } from '@/graphql/clients/serverSideClient'; | ||
import { GET_PUBLISHED_PAGES_LIST } from '@/graphql/queries/pages'; | ||
import { GET_TOP_BANNER } from '@/graphql/queries/sliders'; | ||
import { IPageListItem } from '@/graphql/types/common'; | ||
import { | ||
GetPublishedPagesListQuery, | ||
GetTopBannerQuery, | ||
} from '@/graphql/types/graphql'; | ||
import { FC, ReactNode } from 'react'; | ||
|
||
export interface LayoutProps { | ||
children: ReactNode; | ||
} | ||
|
||
const getPagesList = async (): Promise<IPageListItem[]> => { | ||
const { data } = await getClient().query<GetPublishedPagesListQuery>({ | ||
query: GET_PUBLISHED_PAGES_LIST, | ||
}); | ||
|
||
return data.pages?.edges?.map((item) => item.node) || []; | ||
}; | ||
|
||
const getTopBanner = async () => { | ||
const { data } = await getClient().query<GetTopBannerQuery>({ | ||
query: GET_TOP_BANNER, | ||
}); | ||
|
||
const _item = data?.sliderCategories?.nodes?.[0]?.sliders?.edges?.[0]?.node; | ||
if (_item && _item?.featuredImage?.node.url) { | ||
const data: ISliderItem = { | ||
id: _item.id, | ||
imageUrl: _item.featuredImage?.node.url, | ||
url: _item.url, | ||
title: _item.title!, | ||
}; | ||
return data; | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
const Layout: FC<LayoutProps> = async ({ children }) => { | ||
return <BaseLayout>{children}</BaseLayout>; | ||
const pagesList = await getPagesList(); | ||
const topBanner = await getTopBanner(); | ||
|
||
return ( | ||
<> | ||
<Header topBanner={topBanner} /> | ||
{children} | ||
<Footer pages={pagesList} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file was deleted.
Oops, something went wrong.