-
Notifications
You must be signed in to change notification settings - Fork 7
Nouveau filtres fiche action #3805
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
base: main
Are you sure you want to change the base?
Conversation
...ansitions.react/src/ui/dropdownLists/ficheAction/NoteDeSuiviDropdown/NoteDeSuiviDropdown.tsx
Outdated
Show resolved
Hide resolved
...eact/src/ui/dropdownLists/ficheAction/AnneesNoteDeSuiviDropdown/AnneeNoteDeSuiviDropdown.tsx
Outdated
Show resolved
Hide resolved
...p/pages/collectivite/PlansActions/ToutesLesFichesAction/MenuFiltresToutesLesFichesAction.tsx
Outdated
Show resolved
Hide resolved
a37336b
to
27b1e38
Compare
<SelectWithTrueFalseUndefinedValueDropdown | ||
values={filters.hasIndicateurLies} | ||
onChange={(value) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
je pense que ce composant SelectWithTrueFalseUndefinedValueDropdown
peut être remplacé par un simple select qui prend des options
[{id: 1, label: "..."}, {id:2, label: "..."}, ...]
et c'est dans le onChange que le mapping est fait pour savoir si l'on parle d'une valeur true
, false
ou autre
@@ -59,374 +47,457 @@ const MenuFiltresToutesLesFichesAction = ({ | |||
|
|||
const debutPeriodeRef = useRef<HTMLInputElement>(null); | |||
const finPeriodeRef = useRef<HTMLInputElement>(null); | |||
const { register, watch } = useForm({ defaultValues: filters }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tous les dropdowns ne sont pas branchés sur react-hook-form donc on est dans un entre-deux pas idéal je pense. Faudrait soit l'un soit l'autre.
Par ailleurs, avec react-hook-form, tu peux trigger le submit de ton formulaire sur des onChange
event donc tu te retrouvais à faire setFilters
uniquement dans le onSubmit.
Sinon, chaque dropdown et input manipuleraient uniquement les onChange
fournit par react-hook-form.
<PlansActionDropdown | ||
values={filters.planActionIds} | ||
onChange={({ plans }) => { | ||
const { planActionIds, ...rest } = filters; | ||
setFilters({ | ||
...rest, | ||
...(plans ? { planActionIds: plans } : {}), | ||
}); | ||
}} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avec react-hook-form only, on aurait ceci:
<PlansActionDropdown | |
values={filters.planActionIds} | |
onChange={({ plans }) => { | |
const { planActionIds, ...rest } = filters; | |
setFilters({ | |
...rest, | |
...(plans ? { planActionIds: plans } : {}), | |
}); | |
}} | |
/> | |
import { Controller } from 'react-hook-form'; | |
<Controller | |
name="planActionIds" | |
control={control} | |
render={({ field }) => ( | |
<PlansActionDropdown | |
values={field.value} | |
onChange={({ plans }) => { | |
field.onChange(plans || null); | |
}} | |
/> | |
)} | |
/> |
Nouveau filtres de toutes les fiches actions :
notion :https://www.notion.so/accelerateur-transition-ecologique-ademe/Am-liorations-filtres-de-la-page-Toutes-les-FA-1746523d57d78056b00bf5be1762949c?source=copy_link