MCPcopy Index your code
hub / github.com/code100x/cms / Search

Function Search

src/components/search.tsx:10–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { getUpdatedUrl, searchParamsToObject } from '@/lib/utils';
9
10const Search = () => {
11 const router = useRouter();
12 const searchParams = useSearchParams();
13 const [search, setSearch] = useState('');
14 const path = usePathname();
15 const paramsObj = searchParamsToObject(searchParams as any); // build fix (eslint)
16
17 const handleSearch = () => {
18 router.push(getUpdatedUrl(path, paramsObj, { search }));
19 };
20 return (
21 <div className="relative flex h-10 w-full items-center md:w-[300px] lg:w-[400px] xl:w-[500px]">
22 <SearchIcon className="absolute left-5 top-1/2 h-4 w-4 -translate-y-1/2 transform text-gray-500" />
23 <Input
24 aria-label="Search Input"
25 className="focus:ring-none rounded-lg border-none bg-primary/5 px-10 text-base focus:outline-none"
26 placeholder="Search..."
27 type="search"
28 value={search}
29 onChange={(e) => setSearch(e.target.value)}
30 />
31 <input type="submit" hidden />
32 <Button size={'sm'} type="submit" onClick={handleSearch}>
33 <p className="hidden md:block">Search</p>
34 <SearchIcon className="block h-4 w-4 md:hidden" />
35 </Button>
36 </div>
37 );
38};
39
40export default Search;

Callers

nothing calls this directly

Calls 1

searchParamsToObjectFunction · 0.90

Tested by

no test coverage detected