feat(ui) - cards - cards sort

This commit is contained in:
Shekar Siri 2023-01-02 17:54:35 +01:00
parent 9f3d5e553f
commit 2fa02e2ebb
2 changed files with 1 additions and 13 deletions

View file

@ -53,18 +53,6 @@ function MetricsList({
const lenth = list.length;
const sortList = () => {
list.sort((a, b) => {
const aDate = new Date(a.lastModified);
const bDate = new Date(b.lastModified);
return sortBy === 'asc'
? aDate.getTime() - bDate.getTime()
: bDate.getTime() - aDate.getTime();
});
};
sortList();
useEffect(() => {
metricStore.updateKey('sessionsPage', 1);
}, []);

View file

@ -30,7 +30,7 @@ export default class MetricStore {
}
get sortedWidgets() {
return [...this.metrics].sort((a, b) => b.lastModified - a.lastModified);
return [...this.metrics].sort((a, b) => this.sort.by === 'desc' ? b.lastModified - a.lastModified : a.lastModified - b.lastModified)
}
// State Actions