error message

This commit is contained in:
hamid zarghami
2025-10-18 16:11:56 +03:30
parent 75f2f0ab17
commit ef0deaf3bd
+8 -3
View File
@@ -8,17 +8,22 @@ import { Pages } from '../../config/Pages'
import Button from '../../components/Button' import Button from '../../components/Button'
import TrashWithConfrim from '../../components/TrashWithConfrim' import TrashWithConfrim from '../../components/TrashWithConfrim'
import PageTitle from '../../components/PageTitle' import PageTitle from '../../components/PageTitle'
import { toast } from 'react-toastify'
import { extractErrorMessage } from '@/helpers/utils'
const CategoryList: FC = () => { const CategoryList: FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const { data, isLoading, refetch } = useGetCategories(); const { data, isLoading } = useGetCategories();
const deleteCategoryMutation = useDeleteCategory(); const deleteCategoryMutation = useDeleteCategory();
const [expandedCategories, setExpandedCategories] = useState<Set<string>>(new Set()); const [expandedCategories, setExpandedCategories] = useState<Set<string>>(new Set());
const handleDeleteCategory = async (categoryId: string) => { const handleDeleteCategory = async (categoryId: string) => {
await deleteCategoryMutation.mutateAsync(categoryId); await deleteCategoryMutation.mutateAsync(categoryId, {
refetch() onError: (error) => {
toast.error(extractErrorMessage(error));
}
});
}; };
const toggleExpanded = (categoryId: string) => { const toggleExpanded = (categoryId: string) => {