diff --git a/frontend/src/app-components/dialogs/utils/deleteHandlers.ts b/frontend/src/app-components/dialogs/utils/deleteHandlers.ts index 385fb415..51136b0c 100644 --- a/frontend/src/app-components/dialogs/utils/deleteHandlers.ts +++ b/frontend/src/app-components/dialogs/utils/deleteHandlers.ts @@ -11,9 +11,7 @@ export const deleteCallbackHandler = deleteOne: (id: string) => Promise, deleteMany?: (ids: string[]) => Promise, ) => - async (data: string = ""): Promise => { - const selectedIds = data.split(","); - - if (selectedIds.length === 1) await deleteOne(selectedIds[0]); - else if (selectedIds.length > 1) await deleteMany?.(selectedIds); + async (data: string[] = []): Promise => { + if (data.length === 1) await deleteOne(data[0]); + else if (data.length > 1) await deleteMany?.(data); }; diff --git a/frontend/src/components/categories/index.tsx b/frontend/src/components/categories/index.tsx index 60740014..21ec4c33 100644 --- a/frontend/src/components/categories/index.tsx +++ b/frontend/src/components/categories/index.tsx @@ -43,7 +43,7 @@ export const Categories = () => { const { toast } = useToast(); const addDialogCtl = useDialog(false); const editDialogCtl = useDialog(false); - const deleteDialogCtl = useDialog(false); + const deleteDialogCtl = useDialog(false); const hasPermission = useHasPermission(); const { onSearch, searchPayload } = useSearch({ $iLike: ["label"], @@ -82,7 +82,7 @@ export const Categories = () => { }, { label: ActionColumnLabel.Delete, - action: (row) => deleteDialogCtl.openDialog(row.id), + action: (row) => deleteDialogCtl.openDialog([row.id]), requires: [PermissionAction.DELETE], }, ], @@ -123,9 +123,7 @@ export const Categories = () => { actionColumns, ]; const handleSelectionChange = (selection: GridRowSelectionModel) => - deleteDialogCtl.saveData?.( - selection.length ? selection.toString() : undefined, - ); + deleteDialogCtl.saveData?.(selection as string[]); return ( @@ -160,7 +158,7 @@ export const Categories = () => { ) : null} - {deleteDialogCtl?.data && ( + {deleteDialogCtl?.data?.length && ( ) : null} - {deleteDialogCtl?.data && ( + {deleteDialogCtl?.data?.length && ( ) : null} - {deleteDialogCtl?.data && ( + {deleteDialogCtl?.data?.length && ( ) : null} - {deleteDialogCtl?.data && ( + {deleteDialogCtl?.data?.length && (