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:
ALi Josheghani
2024-10-15 18:03:54 +03:30
parent 65552632d4
commit 5c0831f5ef

View File

@@ -13,9 +13,14 @@ import { queryClient } from "../../../../../main";
import { AxiosError, AxiosResponse } from "axios"; import { AxiosError, AxiosResponse } from "axios";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { debounce } from "@mui/material"; 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 ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
const axios = useAxios(); const axios = useAxios();
const dispatch = useDispatch();
const navigate = useNavigate();
const separateByThree = (num: number): string => { const separateByThree = (num: number): string => {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); 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; errorMessage = (err.response.data as { alert: string }).alert;
} }
toast.error(`خطایی رخ داد : ${errorMessage}`); toast.error(`خطایی رخ داد : ${errorMessage}`);
// dispatch(setIsPaymentGateway(false)); dispatch(setIsPaymentGateway(false));
// navigate("/noactive-payment"); navigate("/noactive-payment");
return errorMessage; return errorMessage;
}, },
}); });