From 8fab2d03bce82e4dee798ebffb1e93c557f62a4b Mon Sep 17 00:00:00 2001
From: Zach Berwaldt <zberwaldt@tutamail.com>
Date: Thu, 7 Mar 2024 23:16:22 -0500
Subject: feat: Update authentication route and add comments to exported
 members

- The authentication route in the API has been updated to use a new router setup function.
- Comments have been added to all exported members of the `auth.go` module in the internal controllers package.
---
 fe/src/lib/Table.svelte | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

(limited to 'fe/src/lib/Table.svelte')

diff --git a/fe/src/lib/Table.svelte b/fe/src/lib/Table.svelte
index d1cd7da..621157e 100644
--- a/fe/src/lib/Table.svelte
+++ b/fe/src/lib/Table.svelte
@@ -5,6 +5,10 @@
     export let omit: string[] = ["id"];
     export let title: string | undefined = undefined;
 
+    export let sortBy: string = 'date';
+
+    type SortComparator = (a, b) => number
+
     function getDataKeys(data: any[]): string[] {
         if (!data || data.length === 0) return [];
         return Object.keys(data[0])
@@ -16,11 +20,8 @@
         return Object.entries(row).filter((r) => !omit.includes(r[0]));
     }
 
-
-    let limitedData: Array<any> = [];
-
-    if (data && (data as any[]).length > 0) {
-        limitedData = (data as any[]).slice(0, 4);
+    function sort(arr: Array<Record<string, any>>, fn: SortComparator = (a , b) => new Date(b[sortBy]) - new Date(a[sortBy])) {
+        return arr.sort(fn)
     }
 
     const formatter = new Intl.DateTimeFormat("en", {
@@ -62,7 +63,7 @@
     {/if}
     <tbody>
     {#if data}
-        {#each limitedData as row}
+        {#each sort(data) as row}
             <tr>
                 {#each getRow(row) as datum}
                     <td>{formatDatum(datum)}</td>
-- 
cgit v1.1

