From ef0deaf3bd00b34aed79649b0264f5d5babea48d Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sat, 18 Oct 2025 16:11:56 +0330 Subject: [PATCH] error message --- src/pages/category/List.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pages/category/List.tsx b/src/pages/category/List.tsx index 986ebf3..deed16d 100644 --- a/src/pages/category/List.tsx +++ b/src/pages/category/List.tsx @@ -8,17 +8,22 @@ import { Pages } from '../../config/Pages' import Button from '../../components/Button' import TrashWithConfrim from '../../components/TrashWithConfrim' import PageTitle from '../../components/PageTitle' +import { toast } from 'react-toastify' +import { extractErrorMessage } from '@/helpers/utils' const CategoryList: FC = () => { const navigate = useNavigate(); - const { data, isLoading, refetch } = useGetCategories(); + const { data, isLoading } = useGetCategories(); const deleteCategoryMutation = useDeleteCategory(); const [expandedCategories, setExpandedCategories] = useState>(new Set()); const handleDeleteCategory = async (categoryId: string) => { - await deleteCategoryMutation.mutateAsync(categoryId); - refetch() + await deleteCategoryMutation.mutateAsync(categoryId, { + onError: (error) => { + toast.error(extractErrorMessage(error)); + } + }); }; const toggleExpanded = (categoryId: string) => {