Adding sorting in Project display.
This commit is contained in:
parent
9daeffd90e
commit
b31195c5a1
@ -33,21 +33,7 @@ const ProjectsDisplay = ({
|
|||||||
currentPage,
|
currentPage,
|
||||||
debouncedSearch
|
debouncedSearch
|
||||||
);
|
);
|
||||||
|
|
||||||
const filteredProjects =
|
|
||||||
data?.data?.filter((project) => {
|
|
||||||
const statusId =
|
|
||||||
project.projectStatusId ?? project?.status?.id ?? project?.statusId;
|
|
||||||
|
|
||||||
const matchesStatus = selectedStatuses.includes(statusId);
|
|
||||||
|
|
||||||
const matchesSearch = project?.name
|
|
||||||
?.toLowerCase()
|
|
||||||
?.includes(searchTerm?.toLowerCase());
|
|
||||||
|
|
||||||
return matchesStatus && matchesSearch;
|
|
||||||
}) ?? [];
|
|
||||||
|
|
||||||
const paginate = (page) => {
|
const paginate = (page) => {
|
||||||
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
||||||
setCurrentPage(page);
|
setCurrentPage(page);
|
||||||
@ -68,7 +54,7 @@ const ProjectsDisplay = ({
|
|||||||
.filter((statusId) => grouped[statusId])
|
.filter((statusId) => grouped[statusId])
|
||||||
.flatMap((statusId) =>
|
.flatMap((statusId) =>
|
||||||
grouped[statusId].sort((a, b) =>
|
grouped[statusId].sort((a, b) =>
|
||||||
a?.name?.toLowerCase()?.localeCompare(b?.name?.toLowerCase())
|
a?.shortName?.toLowerCase()?.localeCompare(b?.shortName?.toLowerCase())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user