Skip to content

Commit

Permalink
[SiteSettings] Sort projects alphabetically (#2650)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Oct 9, 2023
1 parent 7063cb2 commit 735e9ce
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/SiteSettings/ProjectManagement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function ProjectManagement() {

useEffect(() => {
updateProjectList();
}, [setAllProjects]);
}, []);

async function updateProjectList(): Promise<void> {
await getAllProjects().then(setAllProjects);
Expand All @@ -24,9 +24,17 @@ export default function ProjectManagement() {
// Sort projects into active vs archived as conditional effect here rather than inside
// the ProjectList function to avoid react mounting/rendering error in console.
useEffect(() => {
setActiveProjects(allProjects.filter((project) => project.isActive));
setArchivedProjects(allProjects.filter((project) => !project.isActive));
}, [allProjects, setActiveProjects, setArchivedProjects]);
setActiveProjects(
allProjects
.filter((project) => project.isActive)
.sort((a: Project, b: Project) => a.name.localeCompare(b.name))
);
setArchivedProjects(
allProjects
.filter((project) => !project.isActive)
.sort((a: Project, b: Project) => a.name.localeCompare(b.name))
);
}, [allProjects]);

return ProjectList(activeProjects, archivedProjects, updateProjectList);
}
Expand Down

0 comments on commit 735e9ce

Please sign in to comment.