Skip to content

Commit

Permalink
feat(ui): sorted Newsletter Publications by created date desc
Browse files Browse the repository at this point in the history
Improved the table listing of publications for a Newsletter in UI to be sorted by newest to oldest

re #41
  • Loading branch information
flamingquaks committed Jun 28, 2024
1 parent a08c908 commit b86d734
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,20 @@ export default function PublicationsTable () {
id: newsletterId
}
}
})
});

if (result.errors) {
console.error(result.errors)
console.error(result.errors);
} else {
setPublications([
...(result.data.listPublications?.items as Publication[])
])
const sortedPublications = [...(result.data.listPublications?.items as Publication[])]
.sort((a, b) => {
const dateA = new Date(a.createdAt ?? 0);
const dateB = new Date(b.createdAt ?? 0);
return dateB.getTime() - dateA.getTime();
});
setPublications(sortedPublications);
}

}, [appContext, newsletterId])

useEffect(() => {
Expand Down

0 comments on commit b86d734

Please sign in to comment.