fix: remove delete opearation

This commit is contained in:
abdou6666 2025-01-17 19:46:12 +01:00
parent 854cfd856f
commit c0691b0ab8

View File

@ -47,7 +47,6 @@ type MediaLibraryProps = {
export const MediaLibrary = ({ onSelect, accept }: MediaLibraryProps) => { export const MediaLibrary = ({ onSelect, accept }: MediaLibraryProps) => {
const { t } = useTranslate(); const { t } = useTranslate();
const { toast } = useToast(); const { toast } = useToast();
const deleteDialogCtl = useDialog<string>(false);
const formatFileSize = useFormattedFileSize(); const formatFileSize = useFormattedFileSize();
const { onSearch, searchPayload } = useSearch<IAttachment>({ const { onSearch, searchPayload } = useSearch<IAttachment>({
$iLike: ["name"], $iLike: ["name"],
@ -77,26 +76,7 @@ export const MediaLibrary = ({ onSelect, accept }: MediaLibraryProps) => {
}, },
}, },
); );
const { mutateAsync: deleteCategory } = useDelete(EntityType.ATTACHMENT, {
onError: () => {
toast.error(t("message.internal_server_error"));
},
onSuccess: () => {
deleteDialogCtl.closeDialog();
toast.success(t("message.item_delete_success"));
},
});
const actionColumns = useActionColumns<IAttachment>(
EntityType.ATTACHMENT,
[
{
label: ActionColumnLabel.Delete,
action: (row) => deleteDialogCtl.openDialog(row.id),
requires: [PermissionAction.DELETE],
},
],
t("label.operations"),
);
const columns: GridColDef<IAttachment>[] = [ const columns: GridColDef<IAttachment>[] = [
{ field: "id", headerName: "ID" }, { field: "id", headerName: "ID" },
{ {
@ -169,17 +149,10 @@ export const MediaLibrary = ({ onSelect, accept }: MediaLibraryProps) => {
valueGetter: (params) => valueGetter: (params) =>
t("datetime.updated_at", getDateTimeFormatter(params)), t("datetime.updated_at", getDateTimeFormatter(params)),
}, },
actionColumns,
]; ];
return ( return (
<Grid container gap={3} flexDirection="column"> <Grid container gap={3} flexDirection="column">
<DeleteDialog
{...deleteDialogCtl}
callback={() => {
if (deleteDialogCtl?.data) deleteCategory(deleteDialogCtl.data);
}}
/>
<PageHeader title={t("title.media_library")} icon={DriveFolderUploadIcon}> <PageHeader title={t("title.media_library")} icon={DriveFolderUploadIcon}>
<Grid <Grid
justifyContent="flex-end" justifyContent="flex-end"