aboutsummaryrefslogtreecommitdiff
path: root/app/src/components/Navbar.tsx
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-13 22:45:57 -0600
committerParker <contact@pkrm.dev>2024-11-13 22:45:57 -0600
commitdbc53a555e64fdd0b848bf33b4208820b8701509 (patch)
tree9b89e5fc4a3fce4c68114010da6e3bb61b25d027 /app/src/components/Navbar.tsx
parent9ce608b637f3ade7346afbaf2bdd1dbf0a8767f7 (diff)
Update UI
Diffstat (limited to 'app/src/components/Navbar.tsx')
-rw-r--r--app/src/components/Navbar.tsx56
1 files changed, 49 insertions, 7 deletions
diff --git a/app/src/components/Navbar.tsx b/app/src/components/Navbar.tsx
index 5107bf4..53c1f52 100644
--- a/app/src/components/Navbar.tsx
+++ b/app/src/components/Navbar.tsx
@@ -1,21 +1,63 @@
+import { useState, useEffect } from 'react';
import styles from '../styles/Navbar.module.css';
import { Link } from 'react-router-dom';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { faCircleUp, faCircleDown } from '@fortawesome/free-solid-svg-icons';
function Navbar() {
+ const [isOnline, setIsOnline] = useState<boolean | null>(null);
+
+ useEffect(() => {
+ const checkAPIStatus = async () => {
+ try {
+ const res = await fetch('/api/ping');
+
+ if (res.status === 200) {
+ setIsOnline(true);
+ } else {
+ setIsOnline(false);
+ }
+ } catch (error) {
+ setIsOnline(false);
+ }
+ };
+
+ checkAPIStatus();
+ });
+
return (
<div className={styles.navbar}>
- <div className={styles.navbarLeft}>
+ <div className={styles.left}>
<Link to={'/login'}>
- <a className={styles.navbarLink}>Login</a>
+ <a className={styles.link}>Login</a>
</Link>
<Link to={'/signup'}>
- <a className={styles.navbarLink}>Signup</a>
+ <a className={styles.link}>Signup</a>
</Link>
</div>
- <div className={styles.navbarRight}>
- <Link to={'/status'}>
- <a className={styles.navbarLink}>API Status</a>
- </Link>
+ <div className={styles.right}>
+ <a
+ className={styles.link}
+ title={
+ isOnline === null
+ ? 'Loading...'
+ : isOnline
+ ? 'API is online'
+ : 'API is offline'
+ }
+ >
+ API Status:{' '}
+ {isOnline === null ? (
+ 'Loading...'
+ ) : isOnline ? (
+ <FontAwesomeIcon icon={faCircleUp} className={styles.circleUp} />
+ ) : (
+ <FontAwesomeIcon
+ icon={faCircleDown}
+ className={styles.circleDown}
+ />
+ )}
+ </a>
</div>
</div>
);