Skip to content

Commit

Permalink
fix: link commision dropdown to directus
Browse files Browse the repository at this point in the history
  • Loading branch information
Thechi2000 committed Mar 10, 2024
1 parent 02db08a commit 422ff49
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
26 changes: 17 additions & 9 deletions app/src/components/NavigationBar.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -39,7 +40,7 @@ function DropdownMenuItem({
);
}

export default function NavigationBar() {
export default function NavigationBar(props: { commissions?: Commission[] }) {
return (
<div className={styles.navigationBar}>
<Link href="/" className={styles.corner}>
Expand All @@ -48,18 +49,25 @@ export default function NavigationBar() {

<div className={styles.navigationMenu}>
<Link className={styles.menuItem} href="/association">
L'Association
L&apos;Association {/* TODO: translation */}
</Link>

<DropdownMenuItem
link={{ title: "Commissions", href: "/commissions" }}
subLinks={[
{ title: "PolyglOts", href: "/Polygl0ts" },
{ title: "CEVE", href: "/CEVE" },
{ title: "Game*", href: "/Game*" },
{ title: "IC Travel", href: "/ICTravel" },
{ title: "Orbital Game Jam", href: "/OrbitalGameJam" },
]}
subLinks={
props.commissions
? props.commissions.map((c) => {
if (c.name && c.slug) {
return {
title: c.name,
href: `/${c.slug}`,
};
} else {
throw new Error("Invalid commission");
}
})
: []
}
/>

<Link className={styles.menuItem} href="/news">
Expand Down
17 changes: 15 additions & 2 deletions app/src/directus.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { queryTranslations } from "./locales";
import { SocialLink } from "./types/aliases";
import { Schema } from "./types/schema";
import {
Expand Down Expand Up @@ -50,17 +51,29 @@ export function populateLayoutProps<T>(
})
);

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 },
},
};
}
};
Expand Down
4 changes: 3 additions & 1 deletion app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<NavigationBar />
<NavigationBar commissions={pageProps.layoutProps?.commissions} />
<div
className="main"
style={{ backgroundImage: `url(${Background.src})` }}
Expand Down
File renamed without changes.

0 comments on commit 422ff49

Please sign in to comment.