From 918a04076fa582200cc5b5b542f6d7b47c0fa5e0 Mon Sep 17 00:00:00 2001 From: Parker Date: Mon, 11 Nov 2024 20:29:56 -0600 Subject: Fix formatting - mainly spacing --- app/src/components/Dashboard.tsx | 233 +++++++++++++++++++++------------------ 1 file changed, 124 insertions(+), 109 deletions(-) (limited to 'app/src/components/Dashboard.tsx') diff --git a/app/src/components/Dashboard.tsx b/app/src/components/Dashboard.tsx index ccbfd99..851308e 100644 --- a/app/src/components/Dashboard.tsx +++ b/app/src/components/Dashboard.tsx @@ -6,124 +6,139 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faTrash } from '@fortawesome/free-solid-svg-icons'; function Dashboard() { - document.title = 'LinkLogger | Dashboard' + document.title = 'LinkLogger | Dashboard'; - interface Log { - id: number; - link: string; - timestamp: string; - ip: string; - location: string; - browser: string; - os: string; - userAgent: string; - isp: string; - } + interface Log { + id: number; + link: string; + timestamp: string; + ip: string; + location: string; + browser: string; + os: string; + userAgent: string; + isp: string; + } - interface Link { - link: string; - owner: number; - redirect_link: string; - expire_date: string; - } + interface Link { + link: string; + owner: number; + redirect_link: string; + expire_date: string; + } - const [links, setLinks] = useState([]); - const [logs, setLogs] = useState([]); - const [visibleLog, setVisibleLog] = useState(null); - const navigate = useNavigate(); + const [links, setLinks] = useState([]); + const [logs, setLogs] = useState([]); + const [visibleLog, setVisibleLog] = useState(null); + const navigate = useNavigate(); - // Fetch links from API - useEffect(() => { - Axios.get('/api/links').then((res) => { - if (res.status === 200) { - setLinks(res.data); - } else { - navigate('/login'); - } - }).catch(() => { - navigate('/login'); - }); - }, []); + // Fetch links from API + useEffect(() => { + Axios.get('/api/links') + .then((res) => { + if (res.status === 200) { + setLinks(res.data); + } else { + navigate('/login'); + } + }) + .catch(() => { + navigate('/login'); + }); + }, []); - // Fetch logs from API - useEffect(() => { - Axios.get('/api/logs').then((res) => { - if (res.status === 200) { - setLogs(res.data); - } else { - navigate('/login'); - } - }).catch(() => { - navigate('/login'); - }); - }, []); + // Fetch logs from API + useEffect(() => { + Axios.get('/api/logs') + .then((res) => { + if (res.status === 200) { + setLogs(res.data); + } else { + navigate('/login'); + } + }) + .catch(() => { + navigate('/login'); + }); + }, []); + const toggleLogRow = (link: string) => { + setVisibleLog(visibleLog === link ? null : link); + }; - const toggleLogRow = (link: string) => { - setVisibleLog(visibleLog === link ? null : link); - }; + return ( + + + + + + + + + + + {/* For every link and its logs */} + {links.map((link) => ( + + + + + + + - return ( -
LinkVisitsRedirectExpire Date
+ + + {logs.filter((log) => log.link === link.link).length || 0} + {link.redirect_link}{link.expire_date}
- - - - - - - - - - {/* For every link and its logs */} - {links.map((link) => ( - - + {/* Conditionally render logs for this link */} + {visibleLog === link.link && ( + + + ))} + +
LinkVisitsRedirectExpire Date
+ + + + + + + + + + + + {/* Render logs only if visibleLog matches the link */} + {logs + .filter((log) => log.link === link.link) + .map((log, index, filteredLogs) => ( + + + + + + - - - - - - {/* Conditionally render logs for this link */} - {visibleLog === link.link && ( - - - - )} - - ))} - -
IDTimestampIPLocationISP
{filteredLogs.length - index}{log.timestamp}{log.ip}{log.location}{log.isp} - + {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}
-
- ) +
+ + + )} + + ))} + + + ); } -export default Dashboard; \ No newline at end of file +export default Dashboard; -- cgit v1.2.3-70-g09d2