From ccee2be133ef2ef41dcd268873c44872475613c9 Mon Sep 17 00:00:00 2001 From: Pooria Setayesh Date: Wed, 22 May 2024 00:38:06 +0330 Subject: [PATCH] refactor: remove needless base layout --- src/app/[locale]/(main)/layout.tsx | 50 +++++++++++++++++++- src/components/BaseLayout/BaseLayout.tsx | 58 ------------------------ 2 files changed, 48 insertions(+), 60 deletions(-) delete mode 100644 src/components/BaseLayout/BaseLayout.tsx diff --git a/src/app/[locale]/(main)/layout.tsx b/src/app/[locale]/(main)/layout.tsx index d2f0e50..c729030 100644 --- a/src/app/[locale]/(main)/layout.tsx +++ b/src/app/[locale]/(main)/layout.tsx @@ -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 => { + const { data } = await getClient().query({ + query: GET_PUBLISHED_PAGES_LIST, + }); + + return data.pages?.edges?.map((item) => item.node) || []; +}; + +const getTopBanner = async () => { + const { data } = await getClient().query({ + 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 = async ({ children }) => { - return {children}; + const pagesList = await getPagesList(); + const topBanner = await getTopBanner(); + + return ( + <> +
+ {children} +