Adding sorting in Project display.

This commit is contained in:
Kartik Sharma 2025-12-11 11:04:29 +05:30
parent 9daeffd90e
commit b31195c5a1

View File

@ -34,20 +34,6 @@ const ProjectsDisplay = ({
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) => {
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
setCurrentPage(page);
@ -68,7 +54,7 @@ const ProjectsDisplay = ({
.filter((statusId) => grouped[statusId])
.flatMap((statusId) =>
grouped[statusId].sort((a, b) =>
a?.name?.toLowerCase()?.localeCompare(b?.name?.toLowerCase())
a?.shortName?.toLowerCase()?.localeCompare(b?.shortName?.toLowerCase())
)
);