fix: typing issues

This commit is contained in:
abdou6666 2024-11-22 18:31:34 +01:00
parent 332a2b7a70
commit 4f4f2a4275
2 changed files with 9 additions and 19 deletions

View File

@ -8,25 +8,24 @@
import ErrorIcon from "@mui/icons-material/Error"; import ErrorIcon from "@mui/icons-material/Error";
import { import {
Button,
Dialog, Dialog,
DialogActions, DialogActions,
DialogContent,
Grid, Grid,
Typography, Typography,
DialogContent,
Button,
} from "@mui/material"; } from "@mui/material";
import { FC } from "react";
import { DialogTitle } from "@/app-components/dialogs/DialogTitle"; import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
import { DialogControl } from "@/hooks/useDialog"; import { DialogControl } from "@/hooks/useDialog";
import { useTranslate } from "@/hooks/useTranslate"; import { useTranslate } from "@/hooks/useTranslate";
export type DeleteDialogProps = DialogControl<string>; export type DeleteDialogProps<T = string> = DialogControl<T>;
export const DeleteDialog: FC<DeleteDialogProps> = ({ export const DeleteDialog = <T extends any = string>({
open, open,
callback, callback,
closeDialog: closeFunction, closeDialog: closeFunction,
}: DeleteDialogProps) => { }: DeleteDialogProps<T>) => {
const { t } = useTranslate(); const { t } = useTranslate();
return ( return (

View File

@ -42,7 +42,7 @@ import { DeleteDialog } from "@/app-components/dialogs";
import { MoveDialog } from "@/app-components/dialogs/MoveDialog"; import { MoveDialog } from "@/app-components/dialogs/MoveDialog";
import { CategoryDialog } from "@/components/categories/CategoryDialog"; import { CategoryDialog } from "@/components/categories/CategoryDialog";
import { isSameEntity } from "@/hooks/crud/helpers"; import { isSameEntity } from "@/hooks/crud/helpers";
import { useDelete, useDeleteFromCache } from "@/hooks/crud/useDelete"; import { useDeleteFromCache } from "@/hooks/crud/useDelete";
import { useDeleteMany } from "@/hooks/crud/useDeleteMany"; import { useDeleteMany } from "@/hooks/crud/useDeleteMany";
import { useFind } from "@/hooks/crud/useFind"; import { useFind } from "@/hooks/crud/useFind";
import { useGetFromCache } from "@/hooks/crud/useGet"; import { useGetFromCache } from "@/hooks/crud/useGet";
@ -90,10 +90,7 @@ const Diagrams = () => {
const { data: categories } = useFind( const { data: categories } = useFind(
{ entity: EntityType.CATEGORY }, { entity: EntityType.CATEGORY },
{ {
initialPaginationState: { hasCount: false,
page: 0,
pageSize: 999, // @TODO: We need to display all categories
},
initialSortState: [{ field: "createdAt", sort: "asc" }], initialSortState: [{ field: "createdAt", sort: "asc" }],
}, },
{ {
@ -114,13 +111,6 @@ const Diagrams = () => {
const { mutateAsync: updateCategory } = useUpdate(EntityType.CATEGORY, { const { mutateAsync: updateCategory } = useUpdate(EntityType.CATEGORY, {
invalidate: false, invalidate: false,
}); });
const { mutateAsync: deleteBlock } = useDelete(EntityType.BLOCK, {
onSuccess() {
deleteDialogCtl.closeDialog();
setSelectedBlockId(undefined);
},
invalidate: false,
});
const { mutateAsync: deleteBlocks } = useDeleteMany(EntityType.BLOCK, { const { mutateAsync: deleteBlocks } = useDeleteMany(EntityType.BLOCK, {
onSuccess: () => { onSuccess: () => {
deleteDialogCtl.closeDialog(); deleteDialogCtl.closeDialog();
@ -188,6 +178,7 @@ const Diagrams = () => {
if (categories?.length > 0 && !selectedCategoryId) { if (categories?.length > 0 && !selectedCategoryId) {
setSelectedCategoryId(categories[0].id); setSelectedCategoryId(categories[0].id);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
useEffect(() => { useEffect(() => {
@ -525,7 +516,7 @@ const Diagrams = () => {
<Box sx={{ width: "100%" }}> <Box sx={{ width: "100%" }}>
<CategoryDialog {...getDisplayDialogs(addCategoryDialogCtl)} /> <CategoryDialog {...getDisplayDialogs(addCategoryDialogCtl)} />
<BlockDialog {...getDisplayDialogs(editDialogCtl)} /> <BlockDialog {...getDisplayDialogs(editDialogCtl)} />
<DeleteDialog {...deleteDialogCtl} callback={onDelete} /> <DeleteDialog<string[]> {...deleteDialogCtl} callback={onDelete} />
<MoveDialog <MoveDialog
open={moveDialogCtl.open} open={moveDialogCtl.open}
openDialog={moveDialogCtl.openDialog} openDialog={moveDialogCtl.openDialog}