From 6fcc3716e83d01d7741389fd9afe966375708c57 Mon Sep 17 00:00:00 2001 From: Ramiro Vazquez Date: Tue, 28 Apr 2020 10:03:39 -0300 Subject: [PATCH 1/2] make date column sortable --- src/components/List/helpers.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/List/helpers.tsx b/src/components/List/helpers.tsx index a425eec..069be3a 100644 --- a/src/components/List/helpers.tsx +++ b/src/components/List/helpers.tsx @@ -267,7 +267,10 @@ export const VoterHistoryColumns = () => { id: 'date', separator: true, disableFilters: true, - sortType: 'datetime', + accessor: 'lastParticipation.timestamp', + sortType: (a, b) => { + return a.original.lastParticipation.timestamp - b.original.lastParticipation.timestamp + }, Cell: ({ row }) => { if (!row.original.lastParticipation) { return From d15fc80138dd6134c6e8169190b28fa21974e6d7 Mon Sep 17 00:00:00 2001 From: Ramiro Vazquez Date: Tue, 28 Apr 2020 10:40:52 -0300 Subject: [PATCH 2/2] sort by date by default --- src/containers/VoterHistory/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/containers/VoterHistory/index.tsx b/src/containers/VoterHistory/index.tsx index e70f9ef..1a8dc3e 100644 --- a/src/containers/VoterHistory/index.tsx +++ b/src/containers/VoterHistory/index.tsx @@ -26,6 +26,7 @@ const getHomeVariables = data => { } const descendantTimestampSort = (a, b) => (a.timestamp > b.timestamp ? 1 : -1) +const defaultSort = [{ desc: true, id: 'date' }] function VoterHistory(props: Props) { const { match, history } = props @@ -134,7 +135,7 @@ function VoterHistory(props: Props) { return ( <> {`Voter History - ${voterId}`} - + ) }