()
| 5 | import CreateProjectDialog from "../components/CreateProjectDialog"; |
| 6 | |
| 7 | export default function Projects() { |
| 8 | |
| 9 | const projects = useSelector( |
| 10 | (state) => state?.workspace?.currentWorkspace?.projects || [] |
| 11 | ); |
| 12 | |
| 13 | const [filteredProjects, setFilteredProjects] = useState([]); |
| 14 | const [searchTerm, setSearchTerm] = useState(""); |
| 15 | const [isDialogOpen, setIsDialogOpen] = useState(false); |
| 16 | const [filters, setFilters] = useState({ |
| 17 | status: "ALL", |
| 18 | priority: "ALL", |
| 19 | }); |
| 20 | |
| 21 | const filterProjects = () => { |
| 22 | let filtered = projects; |
| 23 | |
| 24 | if (searchTerm) { |
| 25 | filtered = filtered.filter( |
| 26 | (project) => |
| 27 | project.name.toLowerCase().includes(searchTerm.toLowerCase()) || |
| 28 | project.description?.toLowerCase().includes(searchTerm.toLowerCase()) |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | if (filters.status !== "ALL") { |
| 33 | filtered = filtered.filter((project) => project.status === filters.status); |
| 34 | } |
| 35 | |
| 36 | if (filters.priority !== "ALL") { |
| 37 | filtered = filtered.filter( |
| 38 | (project) => project.priority === filters.priority |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | setFilteredProjects(filtered); |
| 43 | }; |
| 44 | |
| 45 | useEffect(() => { |
| 46 | filterProjects(); |
| 47 | }, [projects, searchTerm, filters]); |
| 48 | |
| 49 | return ( |
| 50 | <div className="space-y-6 max-w-6xl mx-auto"> |
| 51 | {/* Header */} |
| 52 | <div className="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-6"> |
| 53 | <div> |
| 54 | <h1 className="text-xl sm:text-2xl font-semibold text-gray-900 dark:text-white mb-1"> Projects </h1> |
| 55 | <p className="text-gray-500 dark:text-zinc-400 text-sm"> Manage and track your projects </p> |
| 56 | </div> |
| 57 | <button onClick={() => setIsDialogOpen(true)} className="flex items-center px-5 py-2 text-sm rounded bg-gradient-to-br from-blue-500 to-blue-600 text-white hover:opacity-90 transition" > |
| 58 | <Plus className="size-4 mr-2" /> New Project |
| 59 | </button> |
| 60 | <CreateProjectDialog isDialogOpen={isDialogOpen} setIsDialogOpen={setIsDialogOpen} /> |
| 61 | </div> |
| 62 | |
| 63 | {/* Search and Filters */} |
| 64 | <div className="flex flex-col md:flex-row gap-4"> |
nothing calls this directly
no test coverage detected