Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relier les amendement vers le debat associé #50

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/[legislature]/dossier/[id]/[tab]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default async function Page({
amendements={amendements}
documents={dossier?.documents}
amendementCount={dossier?.amendementCount}
dossierRefUid={params.id}
/>
</Suspense>
);
Expand Down
21 changes: 16 additions & 5 deletions components/folders/AmendementTab/AmendementCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use client";
import * as React from "react";

import Link from "next/link";

import { Amendement } from "@/repository/types";
import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack";
Expand Down Expand Up @@ -44,6 +46,9 @@ export default function AmendementCard(props: Amendement) {
uid,
group_color,
group_libelle,
seanceRefUid,
dossierRefUid,
numeroOrdreDepot,
} = props;

// TODO: utiliser la base cosignataires amendement pour avoir le nombre et les noms
Expand Down Expand Up @@ -103,12 +108,18 @@ export default function AmendementCard(props: Amendement) {
dangerouslySetInnerHTML={{ __html: dispositif }}
/>

<Typography fontWeight="light" variant="body2">
Examiné par:&nbsp;
<Typography component="a" variant="body2">
Le nom d&apos;une commission parlementaire
{dossierRefUid && seanceRefUid && (
// <Typography fontWeight="light" variant="body2">
// Examiné par:&nbsp;
<Typography
component={Link}
href={`/16/dossier/${dossierRefUid}/debat?compteRenduRef=${seanceRefUid}#adt-${numeroOrdreDepot}`}
variant="body2"
>
Voire le debat associé
</Typography>
</Typography>
// </Typography>
)}
<Stack direction="row" justifyContent="space-between" flexBasis={0}>
<Typography fontWeight="light" variant="body2">
Déposé par:&nbsp;
Expand Down
17 changes: 14 additions & 3 deletions components/folders/AmendementTab/AmendementList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ import AmendementCard from "./AmendementCard";
import { AmendementTabProps } from ".";

export default function AmendementsList(
props: Pick<AmendementTabProps, "amendements"> & {
props: Pick<AmendementTabProps, "amendements" | "dossierRefUid"> & {
numero: string;
selectedDocument: string;
depute: string;
status: string;
}
) {
const { amendements, numero, depute, status, selectedDocument } = props;
const {
amendements,
numero,
depute,
status,
selectedDocument,
dossierRefUid,
} = props;

const filteredAmendements = amendements
.filter((amendement) => {
Expand Down Expand Up @@ -50,7 +57,11 @@ export default function AmendementsList(
return (
<Stack>
{filteredAmendements.map((amendement) => (
<AmendementCard {...amendement} key={amendement.uid} />
<AmendementCard
{...amendement}
key={amendement.uid}
dossierRefUid={dossierRefUid}
/>
))}
</Stack>
);
Expand Down
3 changes: 3 additions & 0 deletions components/folders/AmendementTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export type AmendementTabProps = Pick<
"amendementCount" | "documents"
> & {
amendements: (Amendement & Acteur)[];
dossierRefUid: string;
};

export const AmendementTab = ({
amendements,
documents,
amendementCount,
dossierRefUid,
}: AmendementTabProps) => {
const [numero, handleNumero] = useFilterSearch("numero");
const [document, handleDocument] = useFilterSearch("document");
Expand Down Expand Up @@ -65,6 +67,7 @@ export const AmendementTab = ({
</Typography>
<AmendementList
amendements={amendements}
dossierRefUid={dossierRefUid}
numero={numero}
selectedDocument={document}
depute={depute}
Expand Down
5 changes: 3 additions & 2 deletions components/folders/DebatTab/SubSectionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import { cleanText } from "./cleanText";

interface ParoleItemProps {
title: string | null;
id?: string;
withoutConnector?: boolean;
}

export default function SubSectionItem(props: ParoleItemProps) {
const { title, withoutConnector } = props;
const { title, withoutConnector, id } = props;

return (
<TimelineItem>
<TimelineItem id={id}>
<TimelineSeparator sx={{ minWidth: 50 }}>
<TimelineDot />
{!withoutConnector && <TimelineConnector />}
Expand Down
18 changes: 18 additions & 0 deletions components/folders/DebateTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const DebateTimeline = ({ paragraphs }: DebateTimelineProps) => (
group_libelle_short,
roleDebat,
texte,
adt,
...other
}) => {
switch (codeGrammaire) {
Expand Down Expand Up @@ -70,6 +71,10 @@ export const DebateTimeline = ({ paragraphs }: DebateTimelineProps) => (
return <SectionItem id={hash} title={texte} />;

case "TITRE_TEXTE_DISCUSSION":
console.log(codeGrammaire);
console.log(texte);
console.log(other);

return (
<Typography
variant="h1"
Expand All @@ -78,6 +83,10 @@ export const DebateTimeline = ({ paragraphs }: DebateTimelineProps) => (
/>
);
case "SOUS_TITRE_TEXTE_DISCUSSION":
console.log(codeGrammaire);
console.log(texte);
console.log(other);

return (
<Typography
variant="h3"
Expand All @@ -86,16 +95,25 @@ export const DebateTimeline = ({ paragraphs }: DebateTimelineProps) => (
/>
);
case "ODJ_APPEL_DISCUSSION":
console.log(codeGrammaire);
console.log(texte);
console.log(other);

return (
<Typography
component="p"
dangerouslySetInnerHTML={{ __html: cleanText(texte) }}
/>
);
default:
console.log(codeGrammaire);
console.log(texte);
console.log(other);

return texte ? (
<SubSectionItem
title={texte}
id={adt ? `adt-${adt}` : undefined}
withoutConnector={codeGrammaire === "FIN_SEAN_1_0"}
/>
) : null;
Expand Down
9 changes: 9 additions & 0 deletions repository/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,15 @@ export async function getDeputeAmendement(slug: string) {
.select("*")
.from("Amendement")
.where("acteurRefUid", "=", depute[0].uid)
.rightJoin(
function () {
this.select(["texteAssocieRefUid", "dossierRefUid"])
.from("ActeLegislatif")
.as("acte");
},
"Amendement.texteLegislatifRefUid",
"acte.texteAssocieRefUid"
)
.options({ nestTables: true });

return {
Expand Down
Loading