error message
This commit is contained in:
@@ -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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user