Moving the byFilterDeletion form gridstudy to commons-ui#1056
Moving the byFilterDeletion form gridstudy to commons-ui#1056benrejebmoh wants to merge 2 commits intomainfrom
Conversation
Signed-off-by: benrejebmoh <mohamed.ben-rejeb@rte-france.com>
|
|
|
||
| import type { EquipmentType, ModificationType } from '../../../../utils'; | ||
|
|
||
| export type Filter = { |
There was a problem hiding this comment.
you should put it in by-filter/commons, like it was in grid-study.
| setValue(FieldConstants.FILTERS, []); | ||
| }, [setValue]); | ||
|
|
||
| const getOptionLabel = useCallback( |
There was a problem hiding this comment.
you should have moved the hook useGetLabelEquipmentTypes, and keep using it
| onChangeCallback={handleEquipmentTypeChange} | ||
| getOptionLabel={getOptionLabel} | ||
| size="small" | ||
| formProps={{ variant: 'filled' }} |
There was a problem hiding this comment.
isOptionEqualToValue={richTypeEquals}
has disappeared. Dont know what is the use, but we should keep it.
| <Grid item xs={6}> | ||
| <AutocompleteInput | ||
| name={FieldConstants.TYPE} | ||
| label="equipmentType" |
There was a problem hiding this comment.
| label="equipmentType" | |
| label="Type" |
we should not change the content, even if it's very close.
| export const byFilterDeletionFormSchema = yup | ||
| .object() | ||
| .shape({ | ||
| [FieldConstants.TYPE]: yup.mixed<EquipmentType>().required(), |
There was a problem hiding this comment.
| [FieldConstants.TYPE]: yup.mixed<EquipmentType>().required(), | |
| [FieldConstants.TYPE]: yup.mixed<EquipmentType>().required(YUP_REQUIRED), |
|
|
||
| export const byFilterDeletionFormToDto = ( | ||
| formData: ByFilterDeletionFormData | ||
| ): Omit<ByFilterDeletionDto, 'uuid' | 'type'> => ({ |
There was a problem hiding this comment.
you can remove Omit, and set type to ModificationType.BY_FILTER_DELETION
| DeleteEquipmentByFilter: 'Supprimer des ouvrages par filtre', | ||
| SubstationCreationError: "Erreur lors de la création d'un site'", | ||
| ModifySubstation: 'Modifier un site', | ||
| SubstationModificationError: "Erreur lors de la modification d'un site", |
There was a problem hiding this comment.
EquipmentType enum is not translated in grid-explore. We need a new translation file ?
| }; | ||
|
|
||
| export type ByFilterDeletionDto = { | ||
| uuid: string; |
There was a problem hiding this comment.
it is easier to remove uuid, we dont need it here.
| filters: Filter[]; | ||
| }; | ||
|
|
||
| export type ByFilterDeletionFormData = { |
There was a problem hiding this comment.
can be removed and infered by Yup from the schema
| .min(1, YUP_REQUIRED), | ||
| }) | ||
| .required(); | ||
|
|
There was a problem hiding this comment.
we can generate the Form type here:
export type ByFilterDeletionFormData = InferType<typeof byFilterDeletionFormSchema>;



PR Summary
Extracting byFilterDeletion form to commons-ui for common usage (study, explore,..)