diff --git a/public/locales/en/project.json b/public/locales/en/project.json index a3dbb05e..22656716 100644 --- a/public/locales/en/project.json +++ b/public/locales/en/project.json @@ -1,5 +1,6 @@ { "page": { + "description": "Description", "links": "Links", "submissions": "Submissions", "loading": "Loading submissions..." diff --git a/src/app/[lang]/(DynamicLayout)/projects/[slug]/layout.tsx b/src/app/[lang]/(DynamicLayout)/projects/[slug]/layout.tsx index 06240631..1c9f71fe 100644 --- a/src/app/[lang]/(DynamicLayout)/projects/[slug]/layout.tsx +++ b/src/app/[lang]/(DynamicLayout)/projects/[slug]/layout.tsx @@ -3,6 +3,7 @@ import Navbar from 'ui/Navbar'; import Footer from 'ui/Footer'; import PayloadResponse from 'types/PayloadResponse'; import { Flag, Project } from 'types/payload-types'; +import ProjectHeader from '../../../../../ui/ProjectHeader'; interface IProps { children: React.ReactNode; @@ -11,7 +12,13 @@ interface IProps { } } -async function getFlags(slug: string): Promise { +interface PropsProject { + flags: string[]; + title: string; + description: string; +} + +async function getProject(slug: string): Promise { const res = await fetch(`${process.env.NEXT_PUBLIC_CMS_URL!}/api/projects?where[slug][like]=${slug}&depth=2`, { headers: { 'X-RateLimit-Bypass': process.env.PAYLOAD_BYPASS_RATE_LIMIT_KEY ?? undefined, @@ -19,29 +26,36 @@ async function getFlags(slug: string): Promise { } as Record, }); const parsedRes = (await res.json() as PayloadResponse); - if (parsedRes.totalDocs === 0) return []; + if (parsedRes.totalDocs === 0) return null; const project = parsedRes.docs[0]; - return (project.flags as Flag[] ?? []).map((flag) => flag.code); + return { + title: project.title, + description: project.shortDescription, + flags: (project.flags as Flag[] ?? []).map((flag) => flag.code), + }; } export default async function RootLayout({ children, params: { slug } }: IProps) { - let flags: string[] = []; + let project: PropsProject | null = null; if (slug) { - flags = await getFlags(slug); + project = await getProject(slug); } return ( <> - {/* @ts-ignore */} - + + { + project && ( + + ) + }
{children}
- {/* @ts-ignore */} -