From 5c0831f5effd4c22c8ffcd0c79ac92ecece4f973 Mon Sep 17 00:00:00 2001 From: ALi Josheghani Date: Tue, 15 Oct 2024 18:03:54 +0330 Subject: [PATCH] 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 --- .../shop/section/productList/components/ModalBuy.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/shop/section/productList/components/ModalBuy.tsx b/src/pages/shop/section/productList/components/ModalBuy.tsx index e0265d2..2a500a2 100644 --- a/src/pages/shop/section/productList/components/ModalBuy.tsx +++ b/src/pages/shop/section/productList/components/ModalBuy.tsx @@ -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; }, });