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 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<Set<string>>(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) => {