diff --git a/src/pages/shop/section/productList/components/ListAllProduct.tsx b/src/pages/shop/section/productList/components/ListAllProduct.tsx index 2bb78be..081b833 100644 --- a/src/pages/shop/section/productList/components/ListAllProduct.tsx +++ b/src/pages/shop/section/productList/components/ListAllProduct.tsx @@ -4,11 +4,17 @@ import Alert from "../../../../../components/alert/Alert"; import Button from "../../../../../components/button"; import ModalBuy from "./ModalBuy"; import { useState } from "react"; +import { useSelector } from "react-redux"; +import { RootState } from "../../../../../redux/store"; +import { useNavigate } from "react-router-dom"; +import toast from "react-hot-toast"; const ListAllProduct = ({ activeId }: { activeId: number }) => { const axios = useAxios(); const [isOpen, setIsOpen] = useState(false); const [configId, setConfigId] = useState(1); + const { token } = useSelector((state: RootState) => state.token); + const navigate = useNavigate(); const { data, error, isLoading, isFetching } = useQuery({ queryKey: ["configs", activeId], queryFn: () => { @@ -67,15 +73,27 @@ const ListAllProduct = ({ activeId }: { activeId: number }) => {
{item.title}
- + {token ? ( + + ) : ( + + )}
); diff --git a/src/pages/shop/section/productList/components/ModalBuy.tsx b/src/pages/shop/section/productList/components/ModalBuy.tsx index 256531f..9aadaaf 100644 --- a/src/pages/shop/section/productList/components/ModalBuy.tsx +++ b/src/pages/shop/section/productList/components/ModalBuy.tsx @@ -24,6 +24,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => { queryFn: () => { return axios.get(`/home/config/${configId}/see`); }, + enabled: isOpen, }); const [price, setPrice] = useState(0); @@ -204,7 +205,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => { مبلغ قابل پرداخت :{" "} {separateByThree( - price === 0 ? data?.data?.result?.price : price + price === 0 ? data?.data?.result?.price || 0 : price )}