diff --git a/README.md b/README.md index 857acad35..6dcf12d27 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Technologies Used : - [Check it out here :eyes:](https://www.figma.com/design/sttuMcIvVuk7AORRMS70s5/VigyBag-Redesign?node-id=0-1&t=hA6fe3u7c9kflZzx-0) -We accpet contributions to our project pertaining to the [Code of Conduct](https://github.com/codervivek5/VigyBag?tab=coc-ov-file) and [Contributing Guidelines](https://github.com/codervivek5/VigyBag/blob/main/CONTRIBUTING.md) stated below. +We accept contributions to our project pertaining to the [Code of Conduct](https://github.com/codervivek5/VigyBag?tab=coc-ov-file) and [Contributing Guidelines](https://github.com/codervivek5/VigyBag/blob/main/CONTRIBUTING.md) stated below. ## :handshake: Contributing diff --git a/src/User/components/Popular_Categories/ProductGrid.jsx b/src/User/components/Popular_Categories/ProductGrid.jsx index cd2b310a1..6558a85c9 100644 --- a/src/User/components/Popular_Categories/ProductGrid.jsx +++ b/src/User/components/Popular_Categories/ProductGrid.jsx @@ -6,6 +6,7 @@ import toast from "react-hot-toast"; import { useNavigate } from "react-router-dom"; import { FaHeart, FaRegHeart } from "react-icons/fa"; import PaymentPage from "../../pages/Payment/Payment"; +import { useAuth } from "../../../context/AuthContext"; // ProductGrid component to display a grid of products function ProductGrid({ products, headingText }) { @@ -35,6 +36,7 @@ function ProductGrid({ products, headingText }) { function ProductCard({ product }) { const navigate = useNavigate(); const dispatch = useDispatch(); + const { isLoggedIn } = useAuth(); const cartItems = useSelector((state) => state.cart.items); const wishlistItems = useSelector((state) => state.wishlist.items); @@ -43,11 +45,21 @@ function ProductCard({ product }) { }; const handleBuyNow = () => { + if (!isLoggedIn) { + toast.error("Please login to buy products!"); + navigate("/auth"); + return; + } navigate(`/checkout`); }; // Function to add product to cart const onAddToCart = (product) => { + if (!isLoggedIn) { + toast.error("Please login to add items to cart!"); + navigate("/auth"); + return; + } const quantity = 1; dispatch(manageCartItem({ product, quantity })); toast.success("Successfully added to cart!"); @@ -66,6 +78,11 @@ function ProductCard({ product }) {