Continued with the same updates

This commit is contained in:
Tiago Ribeiro
2023-10-23 23:17:47 +01:00
parent e16a9873be
commit 8b872020c6
4 changed files with 61 additions and 9 deletions

10
src/utils/index.ts Normal file
View File

@@ -0,0 +1,10 @@
import moment from "moment";
export function dateSorter(a: any, b: any, direction: "asc" | "desc", key: string) {
if (!a[key] && b[key]) return direction === "asc" ? -1 : 1;
if (a[key] && !b[key]) return direction === "asc" ? 1 : -1;
if (!a[key] && !b[key]) return 0;
if (moment(a[key]).isAfter(b[key])) return direction === "asc" ? -1 : 1;
if (moment(b[key]).isAfter(a[key])) return direction === "asc" ? 1 : -1;
return 0;
}