From 3b2258877fcbd211314b153c56273e3a597ad08b Mon Sep 17 00:00:00 2001 From: Parker Date: Tue, 12 Nov 2024 16:37:28 -0600 Subject: Begin navbar --- app/src/components/Dashboard.tsx | 159 +++++++++++++++++++++------------------ 1 file changed, 84 insertions(+), 75 deletions(-) (limited to 'app/src/components/Dashboard.tsx') diff --git a/app/src/components/Dashboard.tsx b/app/src/components/Dashboard.tsx index 51d3020..e16c44e 100644 --- a/app/src/components/Dashboard.tsx +++ b/app/src/components/Dashboard.tsx @@ -4,6 +4,7 @@ import styles from '../styles/Dashboard.module.css'; import { useNavigate } from 'react-router-dom'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faTrash } from '@fortawesome/free-solid-svg-icons'; +import Navbar from './Navbar'; function Dashboard() { document.title = 'LinkLogger | Dashboard'; @@ -44,10 +45,15 @@ function Dashboard() { } }) - // Catch 404 error = user has no links - - .catch(() => { - navigate('/login'); + .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 { + navigate('/login'); + } + } }); }, []); @@ -109,79 +115,82 @@ function Dashboard() { }; return ( - - - - - - - - - - - {/* For every link and its logs */} - {links.map((link) => ( - - - - - - - - - {/* Conditionally render logs for this link */} - {visibleLog === link.link && ( - - + + + )} + + ))} + +
LinkVisitsRedirectExpire Date
- - - {logs.filter((log) => log.link === link.link).length || 0} - {link.redirect_link}{link.expire_date}
- - - - - - - - - - - - {/* Render logs only if visibleLog matches the link */} - {logs - .filter((log) => log.link === link.link) - .map((log, index, filteredLogs) => ( - - - - - - - - - ))} - -
IDTimestampIPLocationISP
{filteredLogs.length - index}{log.timestamp}{log.ip}{log.location}{log.isp} - -
+ <> + + + + + + + + + + + + {/* For every link and its logs */} + {links.map((link) => ( + + + + + + - )} - - ))} - -
LinkVisitsRedirectExpire Date
+ + + {logs.filter((log) => log.link === link.link).length || 0} {link.redirect_link}{link.expire_date}
+ + {/* Conditionally render logs for this link */} + {visibleLog === link.link && ( +
+ + + + + + + + + + + + {/* Render logs only if visibleLog matches the link */} + {logs + .filter((log) => log.link === link.link) + .map((log, index, filteredLogs) => ( + + + + + + + + + ))} + +
IDTimestampIPLocationISP
{filteredLogs.length - index}{log.timestamp}{log.ip}{log.location}{log.isp} + +
+
+ ); } -- cgit v1.2.3-70-g09d2