Skip to content

Commit

Permalink
sort by createdOn client side
Browse files Browse the repository at this point in the history
  • Loading branch information
lovincyrus committed Sep 18, 2024
1 parent c5b6340 commit 6225b5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
17 changes: 1 addition & 16 deletions web-admin/src/features/public-urls/PublicURLsTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@
export let onDelete: (deletedTokenId: string) => void;
let virtualListEl: HTMLDivElement;
let sorting: SortingState = [
// Data gets arbitrary sorted as user scrolls for more data
// {
// id: "createdOn",
// desc: true,
// },
];
let sorting: SortingState = [];
function formatDate(value: string) {
return new Date(value).toLocaleDateString(undefined, {
Expand Down Expand Up @@ -96,15 +90,6 @@
return date;
},
},
{
accessorKey: "createdOn",
header: "Created on",
cell: (info) => {
if (!info.getValue()) return "-";
const date = formatDate(info.getValue() as string);
return date;
},
},
{
accessorKey: "actions",
header: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
};
});
// REVISIT when server-side sorting is implemented
$: sortedAllRowsWithDashboardTitle = allRowsWithDashboardTitle.sort(
(a, b) => new Date(b.createdOn).getTime() - new Date(a.createdOn).getTime(),
);
const queryClient = useQueryClient();
const revokeMagicAuthToken = createAdminServiceRevokeMagicAuthToken();
Expand Down Expand Up @@ -86,7 +91,7 @@
<NoPublicURLCTA />
{:else}
<PublicURLsTable
data={allRowsWithDashboardTitle}
data={sortedAllRowsWithDashboardTitle}
query={$magicAuthTokensInfiniteQuery}
onDelete={handleDelete}
/>
Expand Down

0 comments on commit 6225b5a

Please sign in to comment.