Skip to content

Commit

Permalink
small fixes (#51)
Browse files Browse the repository at this point in the history
* rename deputeGroupParlementaire

* cache requests

* fix

* fix duplicated AN1-COM-AVIS

* fix links to debate
  • Loading branch information
alexfauquette authored Jul 5, 2024
1 parent 472b1ae commit 164ca83
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 128 deletions.
4 changes: 2 additions & 2 deletions components/folderHomePage/DossierList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type DossierListProps = {
export default async function DossierList(props: DossierListProps) {
const { theme, search } = props;

const dossiers = await getDossiers({ legislature: 16 }, 50);
const dossiers = await getDossiers(16);

const dossierMensuels = [{ date: "2024-03-01", dossiers }];
const dossierMensuelsFiltered = dossierMensuels
Expand Down Expand Up @@ -72,7 +72,7 @@ export default async function DossierList(props: DossierListProps) {
{titre}
</Typography>

{themes_labels.map((theme: string) => (
{themes_labels?.map((theme: string) => (
<LabelChip
key={theme}
label={theme}
Expand Down
4 changes: 2 additions & 2 deletions components/folders/AdditionalInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export const AdditionalInfoCard = ({
if (!acteurs[id]) {
return null;
}
const { prenom, nom, slug, deputeGroupeParlementaireUid } =
const { prenom, nom, slug, groupeParlementaireUid } =
acteurs[id];

const group = organes[deputeGroupeParlementaireUid];
const group = organes[groupeParlementaireUid];
return (
<DeputeCard
key={id}
Expand Down
4 changes: 2 additions & 2 deletions components/folders/CommiteeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export const CommiteeCard = ({
Rapporteur
</Typography>
{rapporteursFond.map((acteur) => {
const { prenom, nom, slug, deputeGroupeParlementaireUid } =
const { prenom, nom, slug, groupeParlementaireUid } =
acteur;
const group = organes[deputeGroupeParlementaireUid];
const group = organes[groupeParlementaireUid];
return (
<DeputeCard
key={acteur.uid}
Expand Down
10 changes: 5 additions & 5 deletions components/folders/DebateTranscript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ function getWordsPerGroup(paragraphs: any[]) {
paragraphs.forEach(
({
codeGrammaire,
deputeGroupeParlementaireUid,
groupeParlementaireUid,
group_color,
group_libelle_short,
texte,
}) => {
if (
codeGrammaire !== "PAROLE_GENERIQUE" ||
!deputeGroupeParlementaireUid
!groupeParlementaireUid
) {
return;
}

const wordCount = texte.split(" ").length;
if (groups[deputeGroupeParlementaireUid]) {
groups[deputeGroupeParlementaireUid].count += wordCount;
if (groups[groupeParlementaireUid]) {
groups[groupeParlementaireUid].count += wordCount;
} else {
groups[deputeGroupeParlementaireUid] = {
groups[groupeParlementaireUid] = {
count: wordCount,
group_color,
group_libelle_short,
Expand Down
2 changes: 1 addition & 1 deletion components/folders/HeroSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const HeroSection = ({ dossier, acts = [] }: HeroSectionProps) => {
<StatusChip size="small" status="dropped" label="Non-soutenu" />
<StatusChip size="small" status="review" label="1e lecture AN" />
<StatusChip size="small" status="validated" label="Promulgué" /> */}
{dossier.themes_labels.map((label: string) => (
{dossier.themes_labels?.map((label: string) => (
<LabelChip
key={label}
size="small"
Expand Down
8 changes: 6 additions & 2 deletions components/folders/PreviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const PreviewTab = ({ dossier }: PreviewTabProps) => {
documents = [],
amendementCount = {},
} = dossier ?? {};

return (
<Container
sx={{
Expand Down Expand Up @@ -65,7 +64,12 @@ export const PreviewTab = ({ dossier }: PreviewTabProps) => {
{/* <CardLayout title="Temps de parole par groupe">
<SpeakingTime />
</CardLayout> */}
<TimelineCard acts={acts} documents={documents} />
<TimelineCard
acts={acts}
documents={documents}
dossierUid={dossier?.dossier.uid}
legislature={dossier?.dossier.legislature}
/>
<TextStructureCard />
</Stack>
</Container>
Expand Down
26 changes: 21 additions & 5 deletions components/folders/TimelineCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ const TimelineItemLvl1 = ({
<TimelineConnector />
</TimelineSeparator>
<TimelineContent>
<Typography variant="body1">{title}</Typography>
<Typography variant="body1">
{title}
{/* ({act.uid}) */}
</Typography>
<Typography
variant="caption"
component="p"
Expand All @@ -172,9 +175,13 @@ const TimelineItemLvl1 = ({
export const TimelineCard = ({
acts,
documents,
dossierUid,
legislature,
}: {
acts: ActeLegislatif[];
documents: Record<string, Document>;
dossierUid: string;
legislature: number;
}) => {
const { actsStructure, actsLookup } = groupActs(acts);

Expand Down Expand Up @@ -232,7 +239,7 @@ export const TimelineCard = ({
CODE_ACTS_AVEC_DEBAT.includes(
act.codeActe
)
? `/16/dossier/DLR5L16N46484/debat?compteRenduRef=${act.reunionRefUid}`
? `/${legislature}/dossier/${dossierUid}/debat?compteRenduRef=${act.reunionRefUid}`
: "";
const title = `${act.nomCanonique}${
date
Expand All @@ -257,14 +264,23 @@ export const TimelineCard = ({
sx={{ my: 1.5 }}
>
{title}
{/* ({act.organeRefUid})(
{act.uid}) */}
</Typography>
{lvl3Group &&
getSortedActGroups(
lvl3Group,
actsLookup
)
.flatMap(
({ acts: lvl3Acts }) => lvl3Acts
.flatMap(({ acts: lvl3Acts }) => {
console.log({ lvl3Acts });
return lvl3Acts;
})
// Certain dossier saissisent plusieurs commissions. Ils faut donc les distinguer par oregane
.filter(
(childrenAct) =>
act.organeRefUid ===
childrenAct.organeRefUid
)
?.sort(sortActDate)
?.map((act) => {
Expand Down Expand Up @@ -293,7 +309,7 @@ export const TimelineCard = ({
sx={{ my: 0, ml: 4 }}
>
{title}
{/* ({act.uid}) */}
{/* ({act.organeRefUid})({act.uid}) */}
</Typography>
);
})}
Expand Down
Loading

0 comments on commit 164ca83

Please sign in to comment.