Compare commits
No commits in common. "c5edddf9e9550ef8637cdb8232392617e0028c12" and "e3032d2a0570027f5b578bbe8d2274562b15766c" have entirely different histories.
c5edddf9e9
...
e3032d2a05
@ -53,15 +53,8 @@ const EmployeeList = () =>
|
|||||||
setCurrentPage(1);
|
setCurrentPage(1);
|
||||||
|
|
||||||
if (!loading && Array.isArray(employees)) {
|
if (!loading && Array.isArray(employees)) {
|
||||||
// Sort by full name (firstName + lastName)
|
setEmployeeList(employees);
|
||||||
const sorted = [...employees].sort((a, b) => {
|
setFilteredData(employees);
|
||||||
const nameA = `${a.firstName || ""}${a.lastName || ""}`.toLowerCase();
|
|
||||||
const nameB = `${b.firstName || ""}${b.lastName || ""}`.toLowerCase();
|
|
||||||
return nameA.localeCompare(nameB);
|
|
||||||
});
|
|
||||||
|
|
||||||
setEmployeeList(sorted);
|
|
||||||
setFilteredData(sorted);
|
|
||||||
}
|
}
|
||||||
}, [loading, employees, selectedProject]);
|
}, [loading, employees, selectedProject]);
|
||||||
|
|
||||||
@ -350,6 +343,7 @@ const EmployeeList = () =>
|
|||||||
{currentItems &&
|
{currentItems &&
|
||||||
!loading &&
|
!loading &&
|
||||||
currentItems
|
currentItems
|
||||||
|
.sort((a, b) => b.id - a.id)
|
||||||
.map((item) => (
|
.map((item) => (
|
||||||
<tr className="odd" key={item.id}>
|
<tr className="odd" key={item.id}>
|
||||||
<td className="sorting_1" colSpan={2}>
|
<td className="sorting_1" colSpan={2}>
|
||||||
|
|||||||
@ -33,29 +33,7 @@ const ProjectList = () =>
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading && Array.isArray(projects)) {
|
setProjectList( projects )
|
||||||
// Step 1: Group projects by statusId
|
|
||||||
const grouped = {};
|
|
||||||
|
|
||||||
projects.forEach((project) => {
|
|
||||||
const statusId = project.projectStatusId;
|
|
||||||
if (!grouped[statusId]) {
|
|
||||||
grouped[statusId] = [];
|
|
||||||
}
|
|
||||||
grouped[statusId].push(project);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Step 2: Sort each group by name
|
|
||||||
const sortedGrouped = Object.keys(grouped)
|
|
||||||
.sort() // sort group keys (status IDs)
|
|
||||||
.flatMap((statusId) =>
|
|
||||||
grouped[statusId].sort((a, b) =>
|
|
||||||
a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setProjectList(sortedGrouped); // final sorted flat list
|
|
||||||
}
|
|
||||||
|
|
||||||
}, [ projects, loginUser?.projects, loading ] );
|
}, [ projects, loginUser?.projects, loading ] );
|
||||||
|
|
||||||
@ -107,8 +85,20 @@ const ProjectList = () =>
|
|||||||
? Math.ceil(projectList.length / itemsPerPage)
|
? Math.ceil(projectList.length / itemsPerPage)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
const statusMap = {
|
||||||
|
1: { label: 'active', priority: 1 },
|
||||||
|
2: { label: 'hold', priority: 2 },
|
||||||
|
3: { label: 'inactive', priority: 3 },
|
||||||
|
4: { label: 'complete', priority: 4 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const sortedProjects = [...currentItems].sort((a, b) => {
|
||||||
|
const aPriority = statusMap[+a.projectStatusId]?.priority ?? 99;
|
||||||
|
const bPriority = statusMap[+b.projectStatusId]?.priority ?? 99;
|
||||||
|
return aPriority - bPriority;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@ -177,7 +167,7 @@ const ProjectList = () =>
|
|||||||
|
|
||||||
|
|
||||||
{currentItems &&
|
{currentItems &&
|
||||||
currentItems.map((item) => (
|
sortedProjects.map((item) => (
|
||||||
<ProjectCard projectData={item} key={item.id}></ProjectCard>
|
<ProjectCard projectData={item} key={item.id}></ProjectCard>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user