diff --git a/components/ErrorBoundary.jsx b/components/ErrorBoundary.jsx new file mode 100644 index 0000000..e69de29 diff --git a/components/Navbar.jsx b/components/Navbar.jsx index d7fb5c8..4fa8129 100644 --- a/components/Navbar.jsx +++ b/components/Navbar.jsx @@ -2,68 +2,89 @@ import { Search, ShoppingCart } from "lucide-react"; import Link from "next/link"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useState, useCallback } from "react"; import { useSelector } from "react-redux"; const Navbar = () => { + const router = useRouter(); + const [search, setSearch] = useState(""); + const cartCount = useSelector((state) => state.cart.total); - const router = useRouter(); + const handleSearch = useCallback( + (e) => { + e.preventDefault(); + if (search.trim()) { + router.push(`/shop?search=${encodeURIComponent(search.trim())}`); + } + }, + [router, search] + ); - const [search, setSearch] = useState('') - const cartCount = useSelector(state => state.cart.total) + return ( + - ) -} - -export default Navbar \ No newline at end of file +export default Navbar; diff --git a/components/ProductCardSkeleton.jsx b/components/ProductCardSkeleton.jsx new file mode 100644 index 0000000..e69de29 diff --git a/components/ui/Button.jsx b/components/ui/Button.jsx new file mode 100644 index 0000000..e69de29 diff --git a/components/ui/Input.jsx b/components/ui/Input.jsx new file mode 100644 index 0000000..e69de29 diff --git a/hooks/useCart.js b/hooks/useCart.js new file mode 100644 index 0000000..e69de29 diff --git a/hooks/useIntersectionObserver.js b/hooks/useIntersectionObserver.js new file mode 100644 index 0000000..e69de29 diff --git a/lib/utils.js b/lib/utils.js new file mode 100644 index 0000000..e69de29