Skip to content

Moving the byFilterDeletion form gridstudy to commons-ui#1056

Open
benrejebmoh wants to merge 2 commits intomainfrom
modif-delete-by-filter
Open

Moving the byFilterDeletion form gridstudy to commons-ui#1056
benrejebmoh wants to merge 2 commits intomainfrom
modif-delete-by-filter

Conversation

@benrejebmoh
Copy link
Contributor

PR Summary

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

@sonarqubecloud
Copy link

Copy link
Contributor

@dbraquart dbraquart left a comment

Choose a reason for hiding this comment

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

code: made some requests. some of them are already resolved in #1040


import type { EquipmentType, ModificationType } from '../../../../utils';

export type Filter = {
Copy link
Contributor

Choose a reason for hiding this comment

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

you should put it in by-filter/commons, like it was in grid-study.

setValue(FieldConstants.FILTERS, []);
}, [setValue]);

const getOptionLabel = useCallback(
Copy link
Contributor

Choose a reason for hiding this comment

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

you should have moved the hook useGetLabelEquipmentTypes, and keep using it

onChangeCallback={handleEquipmentTypeChange}
getOptionLabel={getOptionLabel}
size="small"
formProps={{ variant: 'filled' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[FieldConstants.TYPE]: yup.mixed<EquipmentType>().required(),
[FieldConstants.TYPE]: yup.mixed<EquipmentType>().required(YUP_REQUIRED),


export const byFilterDeletionFormToDto = (
formData: ByFilterDeletionFormData
): Omit<ByFilterDeletionDto, 'uuid' | 'type'> => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

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",
Copy link
Contributor

Choose a reason for hiding this comment

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

EquipmentType enum is not translated in grid-explore. We need a new translation file ?

};

export type ByFilterDeletionDto = {
uuid: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

it is easier to remove uuid, we dont need it here.

filters: Filter[];
};

export type ByFilterDeletionFormData = {
Copy link
Contributor

Choose a reason for hiding this comment

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

can be removed and infered by Yup from the schema

.min(1, YUP_REQUIRED),
})
.required();

Copy link
Contributor

@dbraquart dbraquart Mar 16, 2026

Choose a reason for hiding this comment

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

we can generate the Form type here:

export type ByFilterDeletionFormData = InferType<typeof byFilterDeletionFormSchema>;

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants