diff --git a/app/(dashboard)/tasks/page.tsx b/app/(dashboard)/tasks/page.tsx index a8a0ca2..e5decc0 100644 --- a/app/(dashboard)/tasks/page.tsx +++ b/app/(dashboard)/tasks/page.tsx @@ -1,9 +1,8 @@ import { Suspense } from "react" import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" -import { Plus, Search } from "lucide-react" +import { Plus } from "lucide-react" import Link from "next/link" -import { TaskList } from "@/components/task-list" +import { TasksPageClient } from "@/components/tasks-page-client" import { poppins } from "@/lib/fonts" import { getAllTasks } from "@/app/(dashboard)/tasks/actions" @@ -31,7 +30,7 @@ export default async function TasksPage() { Loading tasks...}> - + ) diff --git a/components/tasks-page-client.tsx b/components/tasks-page-client.tsx index e69de29..2ebd79f 100644 --- a/components/tasks-page-client.tsx +++ b/components/tasks-page-client.tsx @@ -0,0 +1,63 @@ +"use client" + +import { useState } from "react" +import { Input } from "@/components/ui/input" +import { Button } from "@/components/ui/button" +import { Search, X, Filter } from "lucide-react" +import { TaskList } from "@/components/task-list" +import type { Task as PrismaTask, User } from "@/app/generated/prisma/client" + +type TaskWithProfile = PrismaTask & { + assignee?: Pick | null +} + +export function TasksPageClient({ initialTasks }: { initialTasks: TaskWithProfile[] }) { + const [searchQuery, setSearchQuery] = useState("") + + const filteredTasks = searchQuery + ? initialTasks.filter((task) => + task.name.includes(searchQuery) + ) + : initialTasks + + const handleClearSearch = () => { + setSearchQuery("") + } + + return ( + + + + + setSearchQuery(e.target.value)} + className="pl-10 pr-10" + aria-label="Search tasks by title" + /> + {searchQuery && ( + + + + )} + + + + + + + + + ) +}