43 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

"use client";
2024-04-16 16:25:21 -04:00
import { Input } from "../../ui/input";
import { Search } from "lucide-react";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
2024-04-16 16:25:21 -04:00
export default function DashboardNavbarSearch() {
2024-05-17 23:54:34 -07:00
// const [search, setSearch] = useState("");
const router = useRouter();
2024-04-16 16:25:21 -04:00
2024-05-17 23:54:34 -07:00
// useEffect(() => {
// const delayDebounceFn = setTimeout(() => {
// if (search) {
// router.push(`/dashboard?q=${search}`);
// } else {
// router.push(`/dashboard`);
// }
// }, 300);
2024-04-16 16:25:21 -04:00
2024-05-17 23:54:34 -07:00
// return () => clearTimeout(delayDebounceFn);
// }, [search]);
2024-04-16 16:25:21 -04:00
return (
<div className="relative h-9 w-44 flex items-center justify-start">
<Search className="w-4 h-4 absolute left-2 text-muted-foreground" />
<Input
2024-05-17 23:54:34 -07:00
// value={search}
// onChange={(e) => setSearch(e.target.value)}
onChange={(e) => {
if (e.target.value === "") {
router.push(`/dashboard`);
return;
}
router.push(`/dashboard?q=${e.target.value}`);
}}
2024-04-16 16:25:21 -04:00
placeholder="Search projects..."
className="pl-8"
/>
</div>
);
2024-04-16 16:25:21 -04:00
}