Skip to content

Commit

Permalink
show the timeline with some data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Dec 13, 2023
1 parent ac11152 commit f8683a3
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 8 deletions.
7 changes: 5 additions & 2 deletions app/[legislature]/dossier/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export default async function Page({
params: { legislature: string; id: string };
}) {
const dossier = await getDossier(params.legislature, params.id);
console.log({ params, dossier });
return <PreviewTab />;

if (dossier === undefined) {
return <p>Dossier Not Found</p>;
}
return <PreviewTab dossier={dossier} />;
}
5 changes: 3 additions & 2 deletions components/folders/PreviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { SpeakingTime } from "@/components/folders/SpeakingTime";
import Container from "@mui/material/Container";
import Stack from "@mui/material/Stack";

export const PreviewTab = () => {
export const PreviewTab = (props) => {
console.log(props);
return (
<Container
sx={{
Expand All @@ -35,7 +36,7 @@ export const PreviewTab = () => {
<CardLayout title="Temps de parole par groupe">
<SpeakingTime />
</CardLayout>
<TimelineCard />
<TimelineCard acts={props.dossier.acts} />
<TextStructureCard />
</Stack>
</Container>
Expand Down
53 changes: 52 additions & 1 deletion components/folders/TimelineCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import Stack from "@mui/material/Stack";
import { CardLayout } from "@/components/folders/CardLayout";
import StatusChip from "@/components/StatusChip";

export const TimelineCard = () => {
export const TimelineCard = ({ acts }) => {
// console.log(acts.map((act) => act.dateActe));
console.log(acts);

return (
<CardLayout title="Chronologie du dossier">
<Timeline
Expand All @@ -24,6 +27,54 @@ export const TimelineCard = () => {
},
}}
>
{acts.map((act) => {
const title = act.nomCanonique || act.codeActe;

return (
<TimelineItem key={act.uid}>
<TimelineOppositeContent>
<Typography variant="body2" fontWeight="light">
{act.dateActe
? act.dateActe.toLocaleDateString("fr-FR", {
year: "numeric",
month: "short",
day: "numeric",
})
: "?"}
</Typography>
</TimelineOppositeContent>
<TimelineSeparator>
<TimelineDot />
<TimelineConnector />
</TimelineSeparator>
<TimelineContent>
<Stack direction="column" spacing={1}>
<Typography variant="body1" fontWeight="bold">
{title}
</Typography>

{act.texteAdopteRefUid && (
<Stack direction="row" spacing={1} alignItems="center">
<Typography variant="caption" fontWeight="light">
text: {act.texteAdopteRefUid}
</Typography>
<StatusChip
status="validated"
label="Adopté"
size="small"
/>
</Stack>
)}
{act.texteAssocieRefUid && (
<Typography variant="caption" fontWeight="light">
Text associé: {act.texteAssocieRefUid}
</Typography>
)}
</Stack>
</TimelineContent>
</TimelineItem>
);
})}
<TimelineItem>
<TimelineOppositeContent>
<Typography variant="body2" fontWeight="light">
Expand Down
66 changes: 63 additions & 3 deletions repository/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,56 @@ export interface DossierRow {
organeRefUid: string | null;
}

export interface ActLegislatif {
uid: string;
codeActe: string;
nomCanonique: string;
libelleCourtActe: string;
xsiType: string;
dateActe: Date | null;
organeRefUid: string;
organeProvenanceRefUid: string | null;
famCodeStatutConclusion: string | null;
libelleStatutConclusion: string | null;
famCodeCasSaisine: string | null;
libelleCasSaisine: string | null;
anneeDecisionConseilConstitutionnel: string | null;
urlConclusionConseilConstitutionnel: string | null;
motifConseilConstitutionnel: string | null;
numDecisionConseilConstitutionnel: string | null;
auteurMotionRefUid: string | null;
famCodeTypeMotion: string | null;
libelleTypeMotion: string | null;
famCodeTypeMotionCensure: string | null;
libelleTypeMotionCensure: string | null;
famCodeDecision: string | null;
libelleDecision: string | null;
formuleDecision: string | null;
codeLoiRefUid: string | null;
dateJo: string | null;
numJo: string | null;
referenceNor: string | null;
typeJo: string | null;
urlLegifrance: string | null;
titreLoi: string | null;
urlEcheancierLoi: string | null;
dateFermetureContributionInternaute: string | null;
dateOuvertureContributionInternaute: string | null;
dateJoce: string | null;
refJoce: string | null;
titreTexteEuropeen: string | null;
typeTexteEuropeen: string | null;
odjRefUid: string | null;
reunionRefUid: string | null;
famCodeStatutAdoption: string | null;
libelleStatutAdoption: string | null;
texteAdopteRefUid: string | null;
texteAssocieRefUid: string;
famCodeStatutTypeDeclaration: string | null;
libelleStatutTypeDeclaration: string | null;
dossierRefUid: string;
}

export async function getDossiers(
{ legislature = 16 },
limit = 10
Expand All @@ -50,15 +100,25 @@ export async function getDossiers(
export async function getDossier(
legislature: string,
id: string
): Promise<DossierRow | undefined> {
): Promise<{ dossier: DossierRow; acts: ActLegislatif[] } | undefined> {
try {
const rows = await db
const dossiers = await db
.select("*")
.from("Dossier")
.where("legislature", "=", legislature)
.where("uid", "=", id);

return rows[0];
const dossier = dossiers[0];
if (dossier === undefined) {
return undefined;
}

const acts = await db
.select("*")
.from("ActeLegislatif")
.where("dossierRefUid", "=", dossier.uid);

return { dossier, acts };
} catch (error) {
console.error("Error fetching rows from Dossier:", error);
throw error;
Expand Down

0 comments on commit f8683a3

Please # to comment.