From dbc53a555e64fdd0b848bf33b4208820b8701509 Mon Sep 17 00:00:00 2001 From: Parker Date: Wed, 13 Nov 2024 22:45:57 -0600 Subject: Update UI --- app/src/components/Dashboard.tsx | 42 +++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'app/src/components/Dashboard.tsx') diff --git a/app/src/components/Dashboard.tsx b/app/src/components/Dashboard.tsx index e16c44e..f3442e0 100644 --- a/app/src/components/Dashboard.tsx +++ b/app/src/components/Dashboard.tsx @@ -47,10 +47,7 @@ function Dashboard() { .catch((error: unknown) => { if (axios.isAxiosError(error)) { - if (error.response?.status === 404) { - // Create a message alerting the user there are no links - navigate('/login'); - } else { + if (error.response?.status != 404) { navigate('/login'); } } @@ -68,11 +65,12 @@ function Dashboard() { navigate('/login'); } }) - - // Catch 404 error = user has no logs - - .catch(() => { - navigate('/login'); + .catch((error: unknown) => { + if (axios.isAxiosError(error)) { + if (error.response?.status != 404) { + navigate('/login'); + } + } }); }, []); @@ -117,7 +115,7 @@ function Dashboard() { return ( <> - +
@@ -127,6 +125,17 @@ function Dashboard() { + {/* If there are no links, put a special message */} + {links.length === 0 && ( + + + + )} + {/* For every link and its logs */} {links.map((link) => ( @@ -161,7 +170,7 @@ function Dashboard() { - {/* Render logs only if visibleLog matches the link */} + {/* Render all logs for the link */} {logs .filter((log) => log.link === link.link) .map((log, index, filteredLogs) => ( @@ -181,6 +190,17 @@ function Dashboard() { ))} + {/* If the link has no logs, put a special message */} + {logs.filter((log) => log.link === link.link).length === + 0 && ( + + + + )}
Link
+
+ You do not have any shortened links - try creating one. +
+
+
+ No logs for this link +
+
-- cgit v1.2.3-70-g09d2