adrianhajdin / ecommerce_sanity_stripe

Modern Full Stack ECommerce Application with Stripe
https://jsmastery.pro
2.21k stars 674 forks source link

How to link search bar I added the code but when I click on search it is redirecting me and showing 404 Not Found. can you help me plzzz..! #107

Open UdayGavada opened 1 year ago

UdayGavada commented 1 year ago

import React from 'react'; import Link from 'next/link'; import { AiOutlineShopping } from 'react-icons/ai' import { useState } from 'react'; import { Cart } from './'; import { useStateContext} from '../context/StateContext';

const Navbar = () => { const { showCart, setShowCart, totalQuantities } = useStateContext(); const [searchQuery, setSearchQuery] = useState('');

const handleSearch = (event) => { event.preventDefault(); // Redirect to search page with the search query as a query parameter window.location.href = /search?query=${searchQuery}; };

const handleSearchQueryChange = (event) => { setSearchQuery(event.target.value); };

return (

Barwa

{showCart && }

) }

export default Navbar