2024-10-21 13:57:45 -06:00
|
|
|
"use client"
|
2024-04-16 16:25:21 -04:00
|
|
|
|
2024-10-21 13:57:45 -06:00
|
|
|
import { Search } from "lucide-react"
|
|
|
|
import { useRouter } from "next/navigation"
|
|
|
|
import { Input } from "../../ui/input"
|
2024-04-16 16:25:21 -04:00
|
|
|
|
|
|
|
export default function DashboardNavbarSearch() {
|
2024-05-17 23:54:34 -07:00
|
|
|
// const [search, setSearch] = useState("");
|
2024-10-21 13:57:45 -06:00
|
|
|
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 === "") {
|
2024-10-21 13:57:45 -06:00
|
|
|
router.push(`/dashboard`)
|
|
|
|
return
|
2024-05-17 23:54:34 -07:00
|
|
|
}
|
2024-10-21 13:57:45 -06:00
|
|
|
router.push(`/dashboard?q=${e.target.value}`)
|
2024-05-17 23:54:34 -07:00
|
|
|
}}
|
2024-04-16 16:25:21 -04:00
|
|
|
placeholder="Search projects..."
|
|
|
|
className="pl-8"
|
|
|
|
/>
|
|
|
|
</div>
|
2024-10-21 13:57:45 -06:00
|
|
|
)
|
2024-04-16 16:25:21 -04:00
|
|
|
}
|