diff --git a/app/depute/[slug]/Tabs.tsx b/app/depute/[slug]/Tabs.tsx index fe335be..0b2201f 100644 --- a/app/depute/[slug]/Tabs.tsx +++ b/app/depute/[slug]/Tabs.tsx @@ -35,6 +35,12 @@ export default function DeputeTabs({ slug }: { slug: string }) { component={Link} href={`/depute/${slug}/votes`} /> + ); } diff --git a/app/depute/[slug]/layout.tsx b/app/depute/[slug]/layout.tsx index bcaf33c..63efb87 100644 --- a/app/depute/[slug]/layout.tsx +++ b/app/depute/[slug]/layout.tsx @@ -78,7 +78,7 @@ export default async function Page({ <>
Fin de mandat le{" "} - {new Date(circonscription.dateFin).toLocaleDateString()} + {new Date(circonscription.dateFin).toLocaleDateString("fr-FR")} )} diff --git a/app/depute/[slug]/qag/QuestionCard.tsx b/app/depute/[slug]/qag/QuestionCard.tsx new file mode 100644 index 0000000..7bddbbf --- /dev/null +++ b/app/depute/[slug]/qag/QuestionCard.tsx @@ -0,0 +1,146 @@ +"use client"; +import * as React from "react"; + +import Typography from "@mui/material/Typography"; +import Stack from "@mui/material/Stack"; +import Accordion from "@mui/material/Accordion"; +import AccordionDetails from "@mui/material/AccordionDetails"; +import AccordionSummary from "@mui/material/AccordionSummary"; + +import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; + +import { Organe, Question } from "@prisma/client"; +import StatusChip from "@/components/StatusChip"; + +type QuestionCardProps = { + question: Question & { minIntRef: Organe | null }; +}; + +export default function QuestionCard(props: QuestionCardProps) { + const { + question: { + uid, + type, + numero, + dateDepot, + dateCloture, + titre, + rubrique, + texteQuestion, + erratumQuestion, + texteReponse, + erratumReponse, + minIntRef, + }, + } = props; + + const pannelId = `${uid}-pannel`; + const headerId = `${uid}-header`; + + return ( + ({ + borderBottom: `solid ${theme.palette.divider} 1px`, + borderRadius: 0, + })} + > + } + > + + {titre && {titre}} + {rubrique && } + {type && } + + + + + N°{numero} + {texteQuestion && ( + + {texteQuestion} + + )} + {texteReponse && ( + + {texteReponse} + + )} + {erratumQuestion && ( + + {erratumQuestion} + + )} + {erratumReponse && ( + + {erratumReponse} + + )} + + + Envoyé à:  + + {minIntRef?.libelleAbrege} + + + + + Date de dépôt:  + + {dateDepot && dateDepot.toLocaleDateString("fr-FR")} + + + + + Date de cloture:  + + {dateCloture && dateCloture.toLocaleDateString("fr-FR")} + + + + + + + ); +} diff --git a/app/depute/[slug]/qag/page.tsx b/app/depute/[slug]/qag/page.tsx new file mode 100644 index 0000000..449298d --- /dev/null +++ b/app/depute/[slug]/qag/page.tsx @@ -0,0 +1,40 @@ +import React from "react"; + +import { prisma } from "@/prisma"; +import QuestionCard from "./QuestionCard"; + +async function getDeputeQuestionsUnCached(slug: string) { + try { + return await prisma.acteur.findFirst({ + where: { slug }, + include: { + questions: { + include: { + minIntRef: true, + }, + }, + }, + }); + } catch (error) { + console.error(`Error fetching QAG from depute ${slug}:`, error); + throw error; + } +} + +const getDeputeQuestions = React.cache(getDeputeQuestionsUnCached); + +export default async function Votes({ params }: { params: { slug: string } }) { + const deputeWithQuestions = await getDeputeQuestions(params.slug); + + if (!deputeWithQuestions) { + return

Deputé inconnu

; + } + const { questions = [] } = deputeWithQuestions; + return ( +
+ {questions?.map((question) => { + return ; + })} +
+ ); +}