/*
  This is the layout for the pages.
  It includes a header and a footer.
*/
import { getDictionarys } from "@/getDictionarys";
import Footer from "@/src/components/Layout/Footer/Footer";
import Header from "@/src/components/Layout/Header/Header";
import { HeaderFooterContent } from "@/src/types/StaticContent/headerfooter.content.type";
import { LRFFlowContent } from "@/src/types/StaticContent/lrfflow.content.type";
import { AUTH_COOKIES } from "@/src/utils/commonVariables";
import { cookies } from "next/headers";

// Default Metadata for all the pages
export async function generateMetadata() {

  return {
    title: 'Blankbase',
    description: 'Blankbase',
    openGraph: {
      title: 'Blankbase',
      description: 'Blankbase',
      images: [
        {
          url: '',
          width: 1200,
          height: 630,
          alt: 'Blankbase',
        }
      ],
      url: `${process.env.NEXT_PUBLIC_API_URL}`,
      type: 'website',
      locale: 'en_US',
      site_name: 'Blankbase',
    },
    twitter: {
      card: 'summary_large_image',
      title: 'Blankbase',
      description: 'Blankbase',
      image: '',
      width: 1200,
      height: 628,
      creator: '@Blankbase',
      site: '@Blankbase',
    },
    author: 'Blankbase',
    robots: 'noindex, nofollow',
    alternates: {
      canonical: `${process.env.NEXT_PUBLIC_API_URL}`,
    },
  };
}

// Root layout
export default async function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  // Get the LRFFlow content
  const LRFFlow = await getDictionarys('lrf-flow') as LRFFlowContent;
  // Get the Header Footer content
  const HeaderFooterContent = await getDictionarys('header-footer') as HeaderFooterContent;

  const cookieStore = await cookies();
  const AuthToken = cookieStore.get(AUTH_COOKIES.USER_TOKEN)?.value;
  return (
    <>
      <Header AuthToken={AuthToken} LRFFlow={LRFFlow} HeaderFooterContent={HeaderFooterContent} />
      {children}
      <Footer HeaderFooterContent={HeaderFooterContent} />
    </>
  );
}

