Skip to content

Commit 193e0c9

Browse files
committed
fix(my-space): render ordinal suffix on side panel dates (#3207)
"Modifiable" and "Échéance" lines now show the day with a superscripted ordinal suffix (1ᵉʳ, 2ᵉ, 3ᵉ…) via a new local `OrdinalLongDate` component that splits the day from the month/year. Keeps `formatLongDate` untouched for PDF / log call sites where `<sup>` has no meaning.
1 parent 7de1e74 commit 193e0c9

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

packages/app/src/modules/my-space/VerticalStepper.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ReactNode } from "react";
22

33
import type { CampaignDeadlines } from "~/modules/domain";
4-
import { formatLongDate, isDeadlinePassed } from "~/modules/domain";
4+
import { isDeadlinePassed } from "~/modules/domain";
55
import type { PanelVariant } from "./DeclarationProcessPanel";
66
import styles from "./DeclarationProcessPanel.module.scss";
77

@@ -379,8 +379,9 @@ function TransmittedRow({
379379
<p className="fr-mb-0">{label}</p>
380380
<p className="fr-text-mention--grey fr-mb-0">
381381
{deadlinePassed
382-
? `Modification close depuis le ${formatLongDate(modifiableUntil)}`
383-
: `Modifiable jusqu'au ${formatLongDate(modifiableUntil)}`}
382+
? "Modification close depuis le "
383+
: "Modifiable jusqu'au "}
384+
<OrdinalLongDate date={modifiableUntil} />
384385
</p>
385386
</div>
386387
<div className={styles.transmittedActions}>
@@ -409,8 +410,23 @@ function DeadlineRow({ date }: { date: Date }) {
409410
<div className={styles.deadlineRow}>
410411
<span aria-hidden="true" className="fr-icon-calendar-line fr-icon--sm" />
411412
<p className="fr-text--sm fr-text-mention--grey fr-mb-0">
412-
Échéance : {formatLongDate(date)}
413+
Échéance : <OrdinalLongDate date={date} />
413414
</p>
414415
</div>
415416
);
416417
}
418+
419+
function OrdinalLongDate({ date }: { date: Date }) {
420+
const day = date.getDate();
421+
const suffix = day === 1 ? "er" : "e";
422+
const monthYear = date.toLocaleDateString("fr-FR", {
423+
month: "long",
424+
year: "numeric",
425+
});
426+
return (
427+
<>
428+
{day}
429+
<sup>{suffix}</sup> {monthYear}
430+
</>
431+
);
432+
}

0 commit comments

Comments
 (0)