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

#2363 - Réutiliser le même composant d'affichage de détail d'une convention #2465

Merged
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: 0 additions & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"date-fns": "2.28.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-jest": "^28.8.3",
"html-templates": "workspace:*",
"jest": "^29.5.0",
"leaflet": "^1.9.4",
Expand Down
62 changes: 39 additions & 23 deletions front/src/app/components/admin/conventions/ConventionValidation.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
import { fr } from "@codegouvfr/react-dsfr";
import { Badge } from "@codegouvfr/react-dsfr/Badge";
import { formatDistance } from "date-fns";
import { fr } from "date-fns/locale";
import { fr as french } from "date-fns/locale";
import React from "react";
import type { ConventionReadDto, ConventionStatus } from "shared";
import { ConventionValidationDetails } from "./ConventionValidationDetails";
import {
ConventionRenewedInformations,
ConventionSummary,
} from "react-design-system";
import {
ConventionReadDto,
isConventionRenewed,
toDisplayedDate,
} from "shared";
import { labelAndSeverityByStatus } from "src/app/contents/convention/labelAndSeverityByStatus";
import { useStyles } from "tss-react/dsfr";
import { makeConventionSections } from "../../../contents/convention/conventionSummary.helpers";

const beforeAfterString = (date: string) => {
const eventDate = new Date(date);
const currentDate = new Date();

return formatDistance(eventDate, currentDate, {
addSuffix: true,
locale: fr,
locale: french,
});
};

const labelByStatus: Record<ConventionStatus, string> = {
ACCEPTED_BY_COUNSELLOR: "[📗 DEMANDE ÉLIGIBLE]",
ACCEPTED_BY_VALIDATOR: "[✅ DEMANDE VALIDÉE]",
CANCELLED: "[🗑️ CONVENTION ANNULÉE]",
DRAFT: "[📕 BROUILLON]",
IN_REVIEW: "[📙 DEMANDE À ETUDIER]",
PARTIALLY_SIGNED: "[✍️ Partiellement signée]",
READY_TO_SIGN: "[📄 En cours de signature]",
REJECTED: "[❌ DEMANDE REJETÉE]",
DEPRECATED: "[❌ DEMANDE OBSOLÈTE]",
};

export interface ConventionValidationProps {
convention: ConventionReadDto;
}

export const ConventionValidation = ({
convention,
}: ConventionValidationProps) => {
const { cx } = useStyles();

const {
status,
signatories: { beneficiary },
Expand All @@ -41,20 +43,34 @@ export const ConventionValidation = ({
dateEnd: _,
} = convention;

const title =
`${labelByStatus[status]} ` +
`${beneficiary.lastName.toUpperCase()} ${
beneficiary.firstName
} chez ${businessName} ` +
`${beforeAfterString(dateStart)}`;
const title = `${beneficiary.lastName.toUpperCase()} ${
beneficiary.firstName
} chez ${businessName} ${beforeAfterString(dateStart)}`;

return (
<>
<Badge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est dommage que l'info de statut soit à part du récap de convention, mais je vois pourquoi. On verra si on peut pas (via un changement d'UI) le rapatrier plus tard

className={cx(
fr.cx("fr-mb-3w"),
labelAndSeverityByStatus[status].color,
)}
>
{labelAndSeverityByStatus[status].label}
</Badge>
<h3>{title}</h3>
{convention.statusJustification && (
<p>Justification : {convention.statusJustification}</p>
)}
<ConventionValidationDetails convention={convention} />
{isConventionRenewed(convention) && (
<ConventionRenewedInformations renewed={convention.renewed} />
)}
<ConventionSummary
submittedAt={toDisplayedDate({
date: new Date(convention.dateSubmission),
})}
summary={makeConventionSections(convention, cx)}
conventionId={convention.id}
/>
</>
);
};

This file was deleted.

Loading
Loading