Skip to content

Commit

Permalink
feat: add association page
Browse files Browse the repository at this point in the history
  • Loading branch information
NoeTerrier committed Mar 16, 2024
1 parent 071ef6b commit 6128d02
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions app/src/pages/association.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import AssociationDescription from "@/components/AssociationDescription";
import { directus, populateLayoutProps } from "@/directus";
import { queryTranslations } from "@/locales";
import { Association, SocialLink } from "@/types/aliases";
import { readItems, readSingleton } from "@directus/sdk";
import { GetServerSideProps, InferGetServerSidePropsType } from "next";
import { useRouter } from "next/router";

export default function Association(
props: InferGetServerSidePropsType<typeof getServerSideProps>
) {
const router = useRouter();
return (
<AssociationDescription
association={props.association}
social_links={props.social_links}
></AssociationDescription>
);
}

export const getServerSideProps: GetServerSideProps<{
association: Association;
social_links: SocialLink[];
}> = populateLayoutProps(async (context) => {
return { props: {
association: await directus().request(
readSingleton("association", queryTranslations)
),
social_links: (await directus()
.request(
readItems("association_social_links", {
fields: [{ social_links_id: ["*"] }],
})
)
.then((result) =>
result.map((s) => s.social_links_id)
)) as SocialLink[],
}}});

0 comments on commit 6128d02

Please sign in to comment.