2024-04-16 16:25:21 -04:00
|
|
|
"use client"
|
|
|
|
|
|
|
|
import { Input } from "../../ui/input"
|
|
|
|
import { Search } from "lucide-react"
|
2024-04-18 15:07:15 -04:00
|
|
|
import { useEffect, useState } from "react"
|
|
|
|
import { useRouter } from "next/navigation"
|
2024-04-16 16:25:21 -04:00
|
|
|
|
|
|
|
export default function DashboardNavbarSearch() {
|
|
|
|
const [search, setSearch] = useState("")
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const delayDebounceFn = setTimeout(() => {
|
|
|
|
console.log("SEARCH", search)
|
|
|
|
if (search) {
|
|
|
|
router.push(`/dashboard?q=${search}`)
|
|
|
|
} else {
|
|
|
|
router.push(`/dashboard`)
|
|
|
|
}
|
|
|
|
}, 300)
|
|
|
|
|
|
|
|
return () => clearTimeout(delayDebounceFn)
|
|
|
|
}, [search])
|
|
|
|
|
|
|
|
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
|
|
|
|
value={search}
|
|
|
|
onChange={(e) => setSearch(e.target.value)}
|
|
|
|
placeholder="Search projects..."
|
|
|
|
className="pl-8"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|