Skip to content

Commit

Permalink
remove elementUuid (same as id)
Browse files Browse the repository at this point in the history
  • Loading branch information
basseche committed Jan 8, 2025
1 parent 529089a commit 550debf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 27 deletions.
17 changes: 4 additions & 13 deletions src/components/filter/expert/ExpertFilterEditionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function ExpertFilterEditionDialog({
elementExists,
language,
description,
elementUuid,
}: Readonly<FilterProps>) {
const { snackError } = useSnackMessage();
const [dataFetchStatus, setDataFetchStatus] = useState(FetchStatus.IDLE);
Expand All @@ -69,6 +68,7 @@ export function ExpertFilterEditionDialog({
setDataFetchStatus(FetchStatus.FETCH_SUCCESS);
reset({
[FieldConstants.NAME]: name,
[FieldConstants.DESCRIPTION]: description,
[FieldConstants.FILTER_TYPE]: FilterType.EXPERT.id,
[FieldConstants.EQUIPMENT_TYPE]: response[FieldConstants.EQUIPMENT_TYPE],
[EXPERT_FILTER_QUERY]: importExpertRules(response[EXPERT_FILTER_QUERY]),
Expand All @@ -82,7 +82,7 @@ export function ExpertFilterEditionDialog({
});
});
}
}, [id, name, open, reset, snackError, getFilterById]);
}, [id, name, open, reset, snackError, getFilterById, description]);

const onSubmit = useCallback(
(filterForm: { [prop: string]: any }) => {
Expand All @@ -99,23 +99,14 @@ export function ExpertFilterEditionDialog({
snackError({
messageTxt: error,
});
},
elementUuid
}
);
if (itemSelectionForCopy.sourceItemUuid === id) {
setItemSelectionForCopy(NO_ITEM_SELECTION_FOR_COPY);
broadcastChannel.postMessage({ NO_SELECTION_FOR_COPY: NO_ITEM_SELECTION_FOR_COPY });
}
},
[
broadcastChannel,
id,
onClose,
itemSelectionForCopy.sourceItemUuid,
snackError,
setItemSelectionForCopy,
elementUuid,
]
[broadcastChannel, id, onClose, itemSelectionForCopy.sourceItemUuid, snackError, setItemSelectionForCopy]
);

const isDataReady = dataFetchStatus === FetchStatus.FETCH_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function ExplicitNamingFilterEditionDialog({
elementExists,
language,
description,
elementUuid,
}: Readonly<FilterProps>) {
const { snackError } = useSnackMessage();
const [dataFetchStatus, setDataFetchStatus] = useState(FetchStatus.IDLE);
Expand All @@ -72,6 +71,7 @@ export function ExplicitNamingFilterEditionDialog({
setDataFetchStatus(FetchStatus.FETCH_SUCCESS);
reset({
[FieldConstants.NAME]: name,
[FieldConstants.DESCRIPTION]: description,
[FieldConstants.FILTER_TYPE]: FilterType.EXPLICIT_NAMING.id,
[FieldConstants.EQUIPMENT_TYPE]: response[FieldConstants.EQUIPMENT_TYPE],
[FILTER_EQUIPMENTS_ATTRIBUTES]: response[FILTER_EQUIPMENTS_ATTRIBUTES].map((row: any) => ({
Expand All @@ -88,7 +88,7 @@ export function ExplicitNamingFilterEditionDialog({
});
});
}
}, [id, name, open, reset, snackError, getFilterById]);
}, [id, name, open, reset, snackError, getFilterById, description]);

const onSubmit = useCallback<SubmitHandler<FormSchemaType>>(
(filterForm) => {
Expand All @@ -104,15 +104,14 @@ export function ExplicitNamingFilterEditionDialog({
messageTxt: error,
});
},
onClose,
elementUuid
onClose
);
if (itemSelectionForCopy.sourceItemUuid === id) {
setItemSelectionForCopy(NO_ITEM_SELECTION_FOR_COPY);
broadcastChannel.postMessage({ NO_SELECTION_FOR_COPY: NO_ITEM_SELECTION_FOR_COPY });
}
},
[broadcastChannel, id, itemSelectionForCopy, onClose, snackError, setItemSelectionForCopy, elementUuid]
[broadcastChannel, id, itemSelectionForCopy, onClose, snackError, setItemSelectionForCopy]
);

const isDataReady = dataFetchStatus === FetchStatus.FETCH_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion src/components/filter/filter.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface FilterProps {
itemSelectionForCopy: ItemSelectionForCopy;
setItemSelectionForCopy: (selection: ItemSelectionForCopy) => void;
getFilterById: (id: string) => Promise<{ [prop: string]: any }>;
elementUuid: UUID;
activeDirectory?: UUID;
elementExists?: ElementExistsType;
language?: string;
Expand Down
8 changes: 2 additions & 6 deletions src/components/filter/utils/filterApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const saveExplicitNamingFilter = (
id: string | null,
setCreateFilterErr: (value?: string) => void,
handleClose: () => void,
elementUuid?: UUID,
activeDirectory?: UUID,
token?: string
) => {
Expand Down Expand Up @@ -56,7 +55,7 @@ export const saveExplicitNamingFilter = (
.catch((error) => {
setCreateFilterErr(error.message);
});
} else if (elementUuid) {
} else {
saveFilter(
{
id,
Expand All @@ -65,7 +64,6 @@ export const saveExplicitNamingFilter = (
filterEquipmentsAttributes: cleanedTableValues,
},
name,
elementUuid,
description,
token
)
Expand All @@ -87,7 +85,6 @@ export const saveExpertFilter = (
activeDirectory: any,
onClose: () => void,
onError: (message: string) => void,
elementUuid?: UUID,
token?: string
) => {
if (isFilterCreation) {
Expand All @@ -108,7 +105,7 @@ export const saveExpertFilter = (
.catch((error: any) => {
onError(error.message);
});
} else if (elementUuid) {
} else {
saveFilter(
{
id,
Expand All @@ -117,7 +114,6 @@ export const saveExpertFilter = (
rules: exportExpertRules(query),
},
name,
elementUuid,
description,
token
)
Expand Down
3 changes: 1 addition & 2 deletions src/services/explore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ export function createFilter(
);
}

export function saveFilter(filter: any, name: string, elementUuid: UUID, description: string, token?: string) {
export function saveFilter(filter: any, name: string, description: string, token?: string) {
const urlSearchParams = new URLSearchParams();
urlSearchParams.append('name', name);
urlSearchParams.append('elementUuid', elementUuid);
urlSearchParams.append('description', description);
return backendFetch(
`${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/filters/${filter.id}?${urlSearchParams.toString()}`,
Expand Down

0 comments on commit 550debf

Please sign in to comment.