From 94a73c8823b0ca18ff141d62f83ed219b18bf5c6 Mon Sep 17 00:00:00 2001 From: Charlie Luo Date: Thu, 21 Aug 2025 15:21:53 -0700 Subject: [PATCH] ending the clone wars --- src/pages/ProjectList.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/pages/ProjectList.js b/src/pages/ProjectList.js index 0eac2e3..ed343fc 100644 --- a/src/pages/ProjectList.js +++ b/src/pages/ProjectList.js @@ -17,6 +17,21 @@ import Select from 'react-select'; import PageHeader from '../components/PageHeader'; import Button from '../components/Button'; +// Sort function to prioritize projects with "cmd" in the name +function sortProjectsWithCmd(projects) { + return projects.sort((a, b) => { + const aHasCmd = a.name.toLowerCase().includes('cmd'); + const bHasCmd = b.name.toLowerCase().includes('cmd'); + + // If one has "cmd" and the other doesn't, prioritize the one with "cmd" + if (aHasCmd && !bHasCmd) return -1; + if (!aHasCmd && bHasCmd) return 1; + + // If both have "cmd" or neither has "cmd", maintain alphabetical order + return a.name.localeCompare(b.name); + }); +} + function getAuthUserVotes(uid, voteList) { return Object.values(voteList || {}).filter((vote) => vote.creator === uid); } @@ -394,6 +409,10 @@ class ProjectList extends Component { } }); + // Sort winning and other projects with "cmd" projects at the top + winningProjects = sortProjectsWithCmd(winningProjects); + otherProjects = sortProjectsWithCmd(otherProjects); + let awardCategoryOptions = getAwardCategories(awardCategoryList); if (this.state.groupFilter) { @@ -424,6 +443,11 @@ class ProjectList extends Component { else actualProjects.push(p); }); + // Sort each category with "cmd" projects at the top + projectIdeas = sortProjectsWithCmd(projectIdeas); + actualProjects = sortProjectsWithCmd(actualProjects); + myProjects = sortProjectsWithCmd(myProjects); + return (
{this.renderControls({ @@ -653,6 +677,11 @@ class ProjectList extends Component { else otherProjects.push(p); }); + // Sort each category with "cmd" projects at the top + // Note: projectsLFH and otherProjects are sorted together when displayed + projectIdeas = sortProjectsWithCmd(projectIdeas); + myProjects = sortProjectsWithCmd(myProjects); + const {show: showParam, view: viewParam} = this.props.location.query; const showIdeas = !showParam || showParam === 'ideas'; const showProjects = showParam === 'projects'; @@ -791,7 +820,7 @@ class ProjectList extends Component {
{viewStyle === 'grid' ? (
    - {[...projectsLFH, ...otherProjects].map((project) => ( + {sortProjectsWithCmd([...projectsLFH, ...otherProjects]).map((project) => ( ) : (
      - {[...projectsLFH, ...otherProjects].map((project) => ( + {sortProjectsWithCmd([...projectsLFH, ...otherProjects]).map((project) => (