diff --git a/client/src/components/Projects/ProjectsPage.jsx b/client/src/components/Projects/ProjectsPage.jsx index 3560e975..30c04be1 100644 --- a/client/src/components/Projects/ProjectsPage.jsx +++ b/client/src/components/Projects/ProjectsPage.jsx @@ -214,6 +214,18 @@ const ProjectsPage = ({ contentContainerRef }) => { const projectsPerPage = perPage; const isAdmin = userContext.account?.isAdmin || false; + const enhancedProjects = projects + ? projects.map(project => { + const droName = + droOptions.find(dro => dro.id === project.droId)?.name || ""; + return { + ...project, + droName: droName, + adminNotes: project.adminNotes || "" + }; + }) + : []; + useEffect(() => { const fetchDroOptions = async () => { try { @@ -608,16 +620,6 @@ const ProjectsPage = ({ contentContainerRef }) => { return new Date(dateOnly); }; - const enhancedProjects = projects.map(project => { - const droName = - droOptions.find(dro => dro.id === project.droId)?.name || ""; - return { - ...project, - droName: droName, - adminNotes: project.adminNotes || "" - }; - }); - const filter = (p, criteria) => { if (criteria.type === "draft" && p.dateSnapshotted) return false; if (criteria.type === "snapshot" && !p.dateSnapshotted) return false; @@ -714,6 +716,7 @@ const ProjectsPage = ({ contentContainerRef }) => { ) { return false; } + if (criteria.droList.length > 0) { const droNames = criteria.droList.map(n => n.toLowerCase()); const projectDroName = (p.droName || "").toLowerCase(); @@ -723,27 +726,38 @@ const ProjectsPage = ({ contentContainerRef }) => { } } - if (userContext.account?.isAdmin) { - const projectAdminNotes = (p.adminNotes || "").toLowerCase().trim(); - const criteriaAdminNotes = criteria.adminNotes.toLowerCase().trim(); - - if ( - criteriaAdminNotes && - !projectAdminNotes.includes(criteriaAdminNotes) - ) { - return false; - } - - if ( - criteria.adminNotesList.length > 0 && - !criteria.adminNotesList - .map(n => n.toLowerCase()) - .includes((p.adminNotes || "").toLowerCase()) - ) { - return false; - } + if ( + criteria.adminNotesList.length > 0 && + !criteria.adminNotesList + .map(n => n.toLowerCase()) + .includes( + p.adminNotes ? p.adminNotes.toLowerCase() : "eowurqoieuroiwutposi" + ) + ) { + return false; } + // if (userContext.account?.isAdmin) { + // const projectAdminNotes = (p.adminNotes || "").toLowerCase().trim(); + // const criteriaAdminNotes = criteria.adminNotes.toLowerCase().trim(); + + // if ( + // criteriaAdminNotes && + // !projectAdminNotes.includes(criteriaAdminNotes) + // ) { + // return false; + // } + + // if ( + // criteria.adminNotesList.length > 0 && + // !criteria.adminNotesList + // .map(n => n.toLowerCase()) + // .includes((p.adminNotes || "").toLowerCase()) + // ) { + // return false; + // } + // } + if ( criteria.startDateModifiedAdmin && getDateOnly(p.dateModifiedAdmin) < @@ -857,7 +871,7 @@ const ProjectsPage = ({ contentContainerRef }) => { const indexOfLastPost = currentPage * projectsPerPage; const indexOfFirstPost = indexOfLastPost - projectsPerPage; - let sortedProjects = projects.filter(p => filter(p, filterCriteria)); + let sortedProjects = enhancedProjects.filter(p => filter(p, filterCriteria)); for (let i = 0; i < sortCriteria.length; i++) { sortedProjects.sort( getComparator(sortCriteria[i].direction, sortCriteria[i].field) @@ -972,8 +986,8 @@ const ProjectsPage = ({ contentContainerRef }) => {
- {enhancedProjects?.length ? ( - enhancedProjects.map(project => ( + {enhancedProjects.length ? ( + currentProjects.map(project => ({JSON.stringify(sortCriteria, null, 2)}*/} + {/*
{JSON.stringify(filterCriteria, null, 2)}*/} {(selectedProject || checkedProjectsStatusData) && ( <>