// import import React from 'react'; import { router } from '@inertiajs/react'; type SearchBarProps = { searchResultCount?: number; newsFilterType?: string; searchData?: string; setSearchData?: (data: string) => void; resultNum?: number; }; export default function SearchBar({ searchResultCount, newsFilterType = '', searchData, setSearchData, resultNum = 0 }: SearchBarProps) { // const searchString = new URLSearchParams(window.location.search).get('search') || ''; return (

Results ({resultNum})

{ e.preventDefault(); const formData = new FormData(e.currentTarget); const value = formData.get('input-search')?.toString() || ''; const query = value.trim(); setSearchData?.(query); // window.alert(`Searching for: ${query}`); // window.location.href = route('news') + (query ? `?search=${encodeURIComponent(query)}` : ''); //inertia location.href // router.visit('/news', { // method: 'get', // data: { // search: query, // type: newsFilterType // }, // }); }} className="flex items-center relative" >
); }