added filter, only display logged user associated projects

This commit is contained in:
Pramod Mahajan 2025-04-22 13:01:31 +05:30
parent a096f3d743
commit 1caeeb890d
2 changed files with 33 additions and 28 deletions

View File

@ -163,30 +163,32 @@ const EmployeeList = () => {
className="dataTables_length text-start"
id="DataTables_Table_0_length"
>
<label>
<select
id="project-select"
onChange={(e) => setSelectedProject(e.target.value)}
name="DataTables_Table_0_length"
aria-controls="DataTables_Table_0"
className="form-select form-select-sm"
value={selectedProject || ""}
>
{projectLoading ? (
<option value="Loading">Loading...</option>
) : (
<>
<option value="">All Employees</option>
{Array.isArray(projects) &&
projects.map((item) => (
<option key={item.id} value={item.id}>
{item.name}
</option>
))}
</>
)}
</select>
</label>
<label>
<select
id="project-select"
onChange={(e) => setSelectedProject(e.target.value)}
name="DataTables_Table_0_length"
aria-controls="DataTables_Table_0"
className="form-select form-select-sm"
value={selectedProject || ""}
>
{projectLoading ? (
<option value="Loading">Loading...</option>
) : (
<>
<option value="">All Employees</option>
{Array.isArray(projects) &&
projects
.filter((item) => loginUser?.projects?.includes(String(item.id)))
.map((item) => (
<option key={item.id} value={item.id}>
{item.name}
</option>
))}
</>
)}
</select>
</label>
</div>
</div>
</div>

View File

@ -176,10 +176,13 @@ const ProjectList = () =>
{loading && <p className="text-center">Loading...</p>}
{currentItems &&
currentItems.map((item) => (
<ProjectCard projectData={item} key={item.id}></ProjectCard>
))}
{Array.isArray(currentItems) && loginUser?.projects && (
currentItems
.filter((item) => loginUser.projects.includes(String(item.id)))
.map((item) => (
<ProjectCard projectData={item} key={item.id} />
))
)}
</div>
{/* Pagination */}
{!loading && (