Skip to content

Commit

Permalink
Fix order by sandbox date on projects page (#677)
Browse files Browse the repository at this point in the history
Signed-off-by: Cintia Sanchez Garcia <[email protected]>
  • Loading branch information
cynthia-sg authored Jul 24, 2024
1 parent 8a0fae8 commit fc54103
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions ui/webapp/src/layout/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,7 @@ const Projects = () => {
return orderBy(items, [(i: Item) => i.name.toLowerCase()], [direction]);

case 'sandbox_at':
return orderBy(
items,
[
(i: Item) =>
getValue(
i.accepted_at !== i.incubating_at && i.accepted_at !== i.graduated_at ? i.accepted_at : undefined
),
],
[]
);
return orderBy(items, [(i: Item) => getValue(getSandboxDate(i))], [direction]);

case 'num_audits':
return orderBy(items, [(i: Item) => (i.audits ? i.audits.length : 0)], [direction]);
Expand Down Expand Up @@ -163,6 +154,17 @@ const Projects = () => {
return undefined;
};

const getSandboxDate = (project: Item): string | undefined => {
if (
project.accepted_at &&
project.accepted_at !== project.incubating_at &&
project.accepted_at !== project.graduated_at
) {
return project.accepted_at;
}
return undefined;
};

const applyFilters = (newFilters: ActiveFilters) => {
setActiveFilters(newFilters);
filterData();
Expand Down Expand Up @@ -415,13 +417,8 @@ const Projects = () => {
{formatDatesForDevices(project.accepted_at!)}
</td>
<td class="px-1 px-md-2 px-lg-3 text-center text-muted text-nowrap">
<Show when={!isUndefined(project.accepted_at)} fallback={'-'}>
{project.accepted_at === project.incubating_at ||
project.accepted_at === project.graduated_at ? (
'-'
) : (
<>{formatDatesForDevices(project.accepted_at!)}</>
)}
<Show when={getSandboxDate(project)} fallback={'-'}>
<>{formatDatesForDevices(getSandboxDate(project)!)}</>
</Show>
</td>
<td class="px-1 px-md-2 px-lg-3 text-center text-muted text-nowrap">
Expand Down

0 comments on commit fc54103

Please sign in to comment.