Skip to content

feat(front): date range field component - #1043

Open
ElisaROGGE wants to merge 4 commits into
developfrom
feat/front/date-range-field-component
Open

feat(front): date range field component#1043
ElisaROGGE wants to merge 4 commits into
developfrom
feat/front/date-range-field-component

Conversation

@ElisaROGGE

@ElisaROGGE ElisaROGGE commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Introduces a new composite form field component for capturing a duration (days/hours/minutes) in the frontend, along with the necessary i18n resources and unit tests.

Changes:

Add DateRangeField component rendering three NumberField inputs (days/hours/minutes) within a fieldset.
Register a new duration i18n namespace and its typed resources.
Add unit tests for the new field component.

@ElisaROGGE ElisaROGGE self-assigned this Jun 7, 2026
@GuillaumeKESTEMAN GuillaumeKESTEMAN linked an issue Jun 12, 2026 that may be closed by this pull request
@ElisaROGGE
ElisaROGGE marked this pull request as ready for review June 30, 2026 11:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new composite form field component for capturing a duration (days/hours/minutes) in the frontend, along with the necessary i18n resources and unit tests.

Changes:

  • Add DateRangeField component rendering three NumberField inputs (days/hours/minutes) within a fieldset.
  • Register a new duration i18n namespace and its typed resources.
  • Add unit tests for the new field component.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
front/src/i18n/locales/en/duration.json Adds English strings for duration units (days/hours/minutes).
front/src/i18n/index.ts Registers the new duration namespace in the i18n initialization.
front/src/i18n/@types/resources.ts Adds duration to the typed i18n resources map.
front/src/components/fields/DateRangeField/DateRangeField.tsx Implements the composite field UI (days/hours/minutes) using NumberField.
front/src/components/fields/DateRangeField/DateRangeField.scss Styles layout and sizing for the composite field.
front/src/components/fields/DateRangeField/tests/DateRangeField.test.tsx Adds unit tests for rendering, error display, and typing behavior.

Comment thread front/src/components/fields/DateRangeField/DateRangeField.tsx Outdated
Comment thread front/src/components/fields/DateRangeField/DateRangeField.scss Outdated
Comment thread front/src/components/fields/DateRangeField/DateRangeField.tsx Outdated
Comment thread front/src/components/fields/DateRangeField/DateRangeField.tsx Outdated
Comment thread front/src/components/fields/DateRangeField/DateRangeField.scss Outdated
Comment thread front/src/components/fields/DateRangeField/DateRangeField.scss Outdated
Comment thread front/src/components/fields/DateRangeField/DateRangeField.scss Outdated
Comment on lines +15 to +18
span {
font-weight: normal;
color: var(--color-error);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

il faudrait peut-être cibler une classe directement non ?

De plus je pense qu'il faudrait qu'on voit comment mieux gérer l'emplacement des erreurs 🤔
Qu'en penses-tu ?

Voici ce qu'il y a actuellement :
Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Je ne sais pas trop comment gérer l'emplacement car je fais des row-reverse pour bien correspondre à la maquette, et donc quand l'erreur s'affiche, ça nous rajoute une div
<div class="ds-input"><label for="_r_0_" class="ds-label-input">days<span aria-hidden="true">*</span></label><input class="ds-number-input-atom" id="_r_0_" aria-invalid="true" required="" min="0" max="21" type="number" name="duration.days" aria-describedby="_r_0_-error"><div class="ds-input-error-message" role="alert"><span id="_r_0_-error">requiredDays</span></div></div>
Faudrait-il revoir l'affichage du flex quand une erreur s'affiche et mettre tout en colonne ?

Je ne sais pas ce que t'en penses, je n'ai pas vraiment d'idées

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Faire un composant DurationInput en utilisant les atomes NumberInputAtom et LabelInput.
Gérer le react hook form (comme dans le composant Field) directement dans le composant DurationField.
Aligner en colonne en dessous des inputs les erreurs (composant ErrorMessageInput) lié via un id à chaque input. (génération d'id via useId et personalisation de celui-ci avec un modifier pour chaque input days, hours et minutes)

Comment thread front/src/components/fields/DateRangeField/DateRangeField.scss Outdated
@GuillaumeKESTEMAN
GuillaumeKESTEMAN changed the base branch from main to develop July 1, 2026 16:11
@nekeo
nekeo deleted the branch develop July 1, 2026 16:19
@nekeo nekeo closed this Jul 1, 2026
return (
<fieldset className={parentClassName}>
<legend className="ds-date-range-field__legend">
<legend className={`${parentClassName}__legend`}>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ parentClassName contient en effet la defaultClassname, mais rajoute aussi les classname que l'utilisateur rajoute, ce qui veut dire que si une classname est rajouté, ici ça donnera comme résultat : duration-field classname_legend

Ce que tu peux faire c'est avoir une constante default classname que tu réutilises dans le getClassname, maiss aussi comme base pour tes classname dans le composant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Pourtant dans le scss en faisant &__legend ça fonctionne bien et dans mon navigateur j'ai bien duration-field__legend en className, ou alors je n'ai pas bien compris ce que tu veux dire par "l'utilisateur rajoute une classname"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(front): create DateRangeField project component

4 participants