(model: string, manufacturer: string)
| 35 | }; |
| 36 | |
| 37 | const updateSearchParams = (model: string, manufacturer: string) => { |
| 38 | // Create a new URLSearchParams object using the current URL search parameters |
| 39 | const searchParams = new URLSearchParams(window.location.search); |
| 40 | |
| 41 | // Update or delete the 'model' search parameter based on the 'model' value |
| 42 | if (model) { |
| 43 | searchParams.set("model", model); |
| 44 | } else { |
| 45 | searchParams.delete("model"); |
| 46 | } |
| 47 | |
| 48 | // Update or delete the 'manufacturer' search parameter based on the 'manufacturer' value |
| 49 | if (manufacturer) { |
| 50 | searchParams.set("manufacturer", manufacturer); |
| 51 | } else { |
| 52 | searchParams.delete("manufacturer"); |
| 53 | } |
| 54 | |
| 55 | // Generate the new pathname with the updated search parameters |
| 56 | const newPathname = `${window.location.pathname}?${searchParams.toString()}`; |
| 57 | |
| 58 | router.push(newPathname); |
| 59 | }; |
| 60 | |
| 61 | return ( |
| 62 | <form className='searchbar' onSubmit={handleSearch}> |
no outgoing calls
no test coverage detected