diff --git a/src/Components/Cart.jsx b/src/Components/Cart.jsx index 8a28170..7a9de31 100644 --- a/src/Components/Cart.jsx +++ b/src/Components/Cart.jsx @@ -1,5 +1,5 @@ import { Dialog, Transition } from "@headlessui/react"; -import { XIcon } from "@heroicons/react/outline"; +import { XIcon, ShoppingCartIcon } from "@heroicons/react/outline"; import React, { Fragment } from "react"; export default function Cart({ open, setOpen, cart, updateCart }) { @@ -39,7 +39,7 @@ export default function Cart({ open, setOpen, cart, updateCart }) { >
-
+
Shopping cart
@@ -54,8 +54,15 @@ export default function Cart({ open, setOpen, cart, updateCart }) {
-
-
+
+ { + cart.length == 0 ? +
+ + Your Cart is Empty. +
+ : +
    { cart.map((product) => ( @@ -105,9 +112,14 @@ export default function Cart({ open, setOpen, cart, updateCart }) {
- ))} + )) + + + } -
+
+ } +
diff --git a/src/Components/NavBar.jsx b/src/Components/NavBar.jsx index b1d0db9..b7ce27c 100644 --- a/src/Components/NavBar.jsx +++ b/src/Components/NavBar.jsx @@ -1,7 +1,7 @@ import { ShoppingBagIcon } from "@heroicons/react/outline"; import React from "react"; -export default function NavBar({ setOpen }) { +export default function NavBar({ setOpen, cart }) { return (
@@ -41,7 +41,7 @@ export default function NavBar({ setOpen }) { className="flex-shrink-0 h-6 w-6 text-gray-400 group-hover:text-gray-500" aria-hidden="true" /> - 0 + {cart.length} items in cart, view bag
diff --git a/src/Components/ProductFilters.jsx b/src/Components/ProductFilters.jsx index f57bcba..7950385 100644 --- a/src/Components/ProductFilters.jsx +++ b/src/Components/ProductFilters.jsx @@ -30,7 +30,6 @@ export default function ProductFilters({ filterOptions, setFilterOptions, sortOp const customFilter = ()=>{ const productsCopy = [...default_products]; - // filter price first let price_i=0 @@ -89,20 +88,39 @@ export default function ProductFilters({ filterOptions, setFilterOptions, sortOp } } } - setProducts(productsCopy); } const clearFilter=()=>{ - setProducts(default_products) + + + + const all_checkboxes = document.querySelectorAll(`input[type="checkbox"]`); + all_checkboxes.forEach( + element=>{ + element.checked=false; + } + ); + + setProducts(default_products ); + } useEffect( ()=>{ + if(filter_num != 0) - customFilter(); + customFilter(); else - clearFilter(); + clearFilter(); + + + console.log("default_products"); + console.log(default_products); + console.log("products"); + console.log(products); + console.log("filterOptions"); + console.log(filterOptions); }, [filter_num] ) @@ -130,13 +148,7 @@ export default function ProductFilters({ filterOptions, setFilterOptions, sortOp