feat: Add toast message for disabled payment
- Add toast message to display an error when payment is disabled - Dispatch setIsPaymentGateway action to update payment gateway status - Navigate to "/noactive-payment" when payment is disabled
This commit is contained in:
@@ -13,9 +13,14 @@ import { queryClient } from "../../../../../main";
|
||||
import { AxiosError, AxiosResponse } from "axios";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { debounce } from "@mui/material";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setIsPaymentGateway } from "../../../../../redux/slices/isPaymentGateway";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
||||
const axios = useAxios();
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const separateByThree = (num: number): string => {
|
||||
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
};
|
||||
@@ -149,8 +154,8 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
||||
errorMessage = (err.response.data as { alert: string }).alert;
|
||||
}
|
||||
toast.error(`خطایی رخ داد : ${errorMessage}`);
|
||||
// dispatch(setIsPaymentGateway(false));
|
||||
// navigate("/noactive-payment");
|
||||
dispatch(setIsPaymentGateway(false));
|
||||
navigate("/noactive-payment");
|
||||
return errorMessage;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user