From 422ff492c2e64217f9ec5ba2db31c896545bdf58 Mon Sep 17 00:00:00 2001 From: Ludovic Mermod Date: Sun, 10 Mar 2024 22:40:51 +0100 Subject: [PATCH] fix: link commision dropdown to directus --- app/src/components/NavigationBar.tsx | 26 ++++++++++++------- app/src/directus.ts | 17 ++++++++++-- app/src/pages/_app.tsx | 4 ++- .../{commission => commissions}/[slug].tsx | 0 4 files changed, 35 insertions(+), 12 deletions(-) rename app/src/pages/{commission => commissions}/[slug].tsx (100%) diff --git a/app/src/components/NavigationBar.tsx b/app/src/components/NavigationBar.tsx index c5e336f..333e24b 100644 --- a/app/src/components/NavigationBar.tsx +++ b/app/src/components/NavigationBar.tsx @@ -1,5 +1,6 @@ import Corner from "@/assets/corner.svg"; import styles from "@/styles/NavigationBar.module.scss"; +import { Commission } from "@/types/aliases"; import Link from "next/link"; type LinkRef = { @@ -39,7 +40,7 @@ function DropdownMenuItem({ ); } -export default function NavigationBar() { +export default function NavigationBar(props: { commissions?: Commission[] }) { return (
@@ -48,18 +49,25 @@ export default function NavigationBar() {
- L'Association + L'Association {/* TODO: translation */} { + if (c.name && c.slug) { + return { + title: c.name, + href: `/${c.slug}`, + }; + } else { + throw new Error("Invalid commission"); + } + }) + : [] + } /> diff --git a/app/src/directus.ts b/app/src/directus.ts index 320e8ae..1594a6e 100644 --- a/app/src/directus.ts +++ b/app/src/directus.ts @@ -1,3 +1,4 @@ +import { queryTranslations } from "./locales"; import { SocialLink } from "./types/aliases"; import { Schema } from "./types/schema"; import { @@ -50,17 +51,29 @@ export function populateLayoutProps( }) ); + let commissions = await directus().request( + readItems("commissions", queryTranslations) + ); + console.log(commissions); + if (f) { let res = await f(context); if ("props" in res) { - return { props: { layoutProps: socialLinks, ...res.props } as any }; + return { + props: { + layoutProps: { socialLinks: socialLinks, commissions: commissions }, + ...res.props, + } as any, + }; } else { return res; } } else { return { - props: { layoutProps: socialLinks }, + props: { + layoutProps: { socialLinks: socialLinks, commissions: commissions }, + }, }; } }; diff --git a/app/src/pages/_app.tsx b/app/src/pages/_app.tsx index 308f28d..c563268 100644 --- a/app/src/pages/_app.tsx +++ b/app/src/pages/_app.tsx @@ -8,9 +8,11 @@ import "@/styles/globals.scss"; import type { AppProps } from "next/app"; export default function App({ Component, pageProps }: AppProps) { + console.log("hi"); + console.log(pageProps); return ( <> - +