Skip to content

Commit

Permalink
Merge pull request #138 from marvinvr/develop
Browse files Browse the repository at this point in the history
fix: request sorting
  • Loading branch information
marvinvr authored Aug 1, 2023
2 parents 6e36400 + dc6c4ac commit d244cbc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/utils/requests.utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OverviewContentRequest } from 'src/models/content';

export const sort = (lists: [OverviewContentRequest[], OverviewContentRequest[]]): OverviewContentRequest[] => (
Array.prototype.concat(...lists)
.sort((a, b) => b.request.date - a.request.date)
.sort((a, b) => ((a.request.approved || a.request.denied || a.request.available)
&& (b.request.approved || b.request.denied || b.request.available))
? 0 : (a.request.approved || a.request.denied || a.request.available) ? 1 : -1)
);
export const sort = (lists: [OverviewContentRequest[], OverviewContentRequest[]]): OverviewContentRequest[] => {
const items = Array.prototype.concat([...lists[0], ...lists[1]])
.sort((a, b) => b.request.date > a.request.date ? 1 : -1);

const openItems = items.filter(item =>!(item.request.approved || item.request.denied || item.request.available));
const closedItems = items.filter(item => item.request.approved || item.request.denied || item.request.available);

return [...openItems,...closedItems];
};

0 comments on commit d244cbc

Please sign in to comment.