Skip to content

Commit

Permalink
style convention summary page
Browse files Browse the repository at this point in the history
  • Loading branch information
celineung committed Nov 20, 2024
1 parent fa2974b commit 6905837
Show file tree
Hide file tree
Showing 31 changed files with 1,654 additions and 1,498 deletions.
57 changes: 37 additions & 20 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 @@ -42,19 +44,34 @@ export const ConventionValidation = ({
} = convention;

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

return (
<>
<Badge
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

0 comments on commit 6905837

Please sign in to comment.