From 9c86e0d7af05f20907f1de648dcc6b9c8d09eb04 Mon Sep 17 00:00:00 2001 From: JManion32 Date: Fri, 6 Mar 2026 00:29:32 -0500 Subject: [PATCH 1/3] Working on login --- src/components/navbar/NavbarLink.tsx | 4 + src/pages/Home.tsx | 7 ++ src/pages/Login.tsx | 131 --------------------------- src/pages/Testing.tsx | 3 - 4 files changed, 11 insertions(+), 134 deletions(-) delete mode 100644 src/pages/Login.tsx diff --git a/src/components/navbar/NavbarLink.tsx b/src/components/navbar/NavbarLink.tsx index 7a4f920..47a1d5a 100644 --- a/src/components/navbar/NavbarLink.tsx +++ b/src/components/navbar/NavbarLink.tsx @@ -10,6 +10,10 @@ export default function NavbarLink({ label, nav }: NavbarLinkProps) { const navigate = useNavigate(); const handleClick = (e: MouseEvent) => { + if (location.pathname === nav) { + return; + } + e.preventDefault(); const content = document.querySelector('.app-content'); diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 7758cfa..fd0936b 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,8 +1,15 @@ +import { useState } from 'react'; +import LoginPopup from '../components/LoginPopup.tsx'; +import '../css/login.css'; + export default function Home() { + const [showLogin, setShowLogin] = useState(false); return ( <>

Home

+ setShowLogin(true)}>Register + setShowLogin(false)} />
); diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx deleted file mode 100644 index 4f570fc..0000000 --- a/src/pages/Login.tsx +++ /dev/null @@ -1,131 +0,0 @@ -import { Navigate, useLocation } from 'react-router-dom'; -import { useAuth } from '../contexts/AuthContext'; -import { Shield, Sparkles } from 'lucide-react'; - -const Login = () => { - const { user, login } = useAuth(); - const location = useLocation(); - const from = location.state?.from?.pathname || '/becapy'; - - if (user) { - return ; - } - - return ( -
-
-
-
- -
-

- Be CAPY -

-
- -
- - - -
-
- SECURE ACCESS -
-
-
- -
- - Interactive dashboard for RPI students -
-
-
- ); -}; - -export default Login; diff --git a/src/pages/Testing.tsx b/src/pages/Testing.tsx index 5e1aaf1..77171f3 100644 --- a/src/pages/Testing.tsx +++ b/src/pages/Testing.tsx @@ -3,15 +3,12 @@ import DarkModeToggle from '../components/DarkModeToggle.tsx'; import LoginPopup from '../components/LoginPopup.tsx'; export default function Testing() { - const [showLogin, setShowLogin] = useState(false); return ( <>

[dev] Testing

This page is for misc features that have been developed, but not placed.

- setShowLogin(true)}>Register - setShowLogin(false)} />
); From 52b0598b99934c22437fd26122461984aaf2ee67 Mon Sep 17 00:00:00 2001 From: JManion32 Date: Fri, 6 Mar 2026 11:41:28 -0500 Subject: [PATCH 2/3] Improved home page and login --- src/components/LoginPopup.tsx | 5 ++++- src/contexts/AuthContext.tsx | 19 +++++++++++++------ src/css/app-layout.css | 1 - src/css/carousel.css | 2 +- src/css/home.css | 13 +++++++++++++ src/css/login.css | 12 ++++++++---- src/pages/Home.tsx | 22 ++++++++++++++++++---- src/pages/Testing.tsx | 2 -- 8 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 src/css/home.css diff --git a/src/components/LoginPopup.tsx b/src/components/LoginPopup.tsx index 6033abb..80a339c 100644 --- a/src/components/LoginPopup.tsx +++ b/src/components/LoginPopup.tsx @@ -1,4 +1,5 @@ import React, { useEffect } from 'react'; +import { useNavigate } from 'react-router-dom'; import { useAuth } from '../contexts/AuthContext'; import '../css/login.css'; @@ -9,12 +10,14 @@ type Props = { export default function LoginPopup({ isOpen, onClose }: Props) { const { login, user } = useAuth(); + const navigate = useNavigate(); useEffect(() => { if (user && isOpen) { onClose(); + navigate('/'); } - }, [user, isOpen, onClose]); + }, [user, isOpen, onClose, navigate]); if (!isOpen) return null; diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index e2eb7fb..bad14e1 100644 --- a/src/contexts/AuthContext.tsx +++ b/src/contexts/AuthContext.tsx @@ -35,25 +35,30 @@ export const AuthProvider: React.FC = ({ children }) => { headers: { Accept: 'application/json', }, + credentials: "include" }); if (response.ok) { const data: User = await response.json(); setUser(data); - } else { + } + else { setUser(null); } - } catch (err: unknown) { + } + catch (err: unknown) { if (err instanceof Error) { console.error('Failed to fetch user:', err); setError(err.message); - } else { + } + else { console.error('Unknown error:', err); setError('Unknown error'); } setUser(null); - } finally { + } + finally { setLoading(false); } }; @@ -79,7 +84,8 @@ export const AuthProvider: React.FC = ({ children }) => { setUser(data); clearInterval(pollInterval); } - } catch (err: unknown) { + } + catch (err: unknown) { if (err instanceof Error) { console.error('Polling failed:', err.message); } @@ -99,7 +105,8 @@ export const AuthProvider: React.FC = ({ children }) => { setUser(null); window.location.href = '/app/'; - } catch (err: unknown) { + } + catch (err: unknown) { if (err instanceof Error) { console.error('Logout failed:', err.message); } diff --git a/src/css/app-layout.css b/src/css/app-layout.css index 979d6af..b15b87b 100644 --- a/src/css/app-layout.css +++ b/src/css/app-layout.css @@ -8,7 +8,6 @@ .app-content { padding: 3rem; - width: 100%; position: relative; overflow: hidden; transition: diff --git a/src/css/carousel.css b/src/css/carousel.css index 7803865..5373094 100644 --- a/src/css/carousel.css +++ b/src/css/carousel.css @@ -11,7 +11,7 @@ } .carousel { - width: 100%; + width: 72rem; background: var(--carousel-bg); height: 18rem; border-radius: 2rem; diff --git a/src/css/home.css b/src/css/home.css new file mode 100644 index 0000000..be25192 --- /dev/null +++ b/src/css/home.css @@ -0,0 +1,13 @@ +.home-grid { + display: grid; + width: 50rem; + grid-template-columns: 24rem 24rem; + gap: 2rem; +} + +.home-grid-panel { + height: 20rem; + background: #e8e8e8; + border-radius: 3rem; + padding: 2rem; +} \ No newline at end of file diff --git a/src/css/login.css b/src/css/login.css index 218bcfa..f6fbefa 100644 --- a/src/css/login.css +++ b/src/css/login.css @@ -1,3 +1,11 @@ +.register-btn { + color: var(--standard-bw-text); + cursor: pointer; + padding: 0.5rem; + border-radius: 1rem; + border: 1px solid black; +} + .popup-overlay { position: fixed; inset: 0; @@ -38,10 +46,6 @@ font-size: 14px; } -.popup-button:hover { - background-color: #f0f0f0; -} - .popup-close-x { position: absolute; top: 8px; diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index fd0936b..8babf43 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,15 +1,29 @@ import { useState } from 'react'; import LoginPopup from '../components/LoginPopup.tsx'; import '../css/login.css'; +import '../css/home.css'; +import { useAuth } from '../contexts/AuthContext'; export default function Home() { const [showLogin, setShowLogin] = useState(false); + const { user } = useAuth(); return ( <> -
-

Home

- setShowLogin(true)}>Register - setShowLogin(false)} /> +
+
+ setShowLogin(true)}>Register + setShowLogin(false)} /> +

UserId: {user?.id ?? "Not logged in"}

+
+
+ +
+
+ +
+
+ +
); diff --git a/src/pages/Testing.tsx b/src/pages/Testing.tsx index 77171f3..630d762 100644 --- a/src/pages/Testing.tsx +++ b/src/pages/Testing.tsx @@ -1,6 +1,4 @@ -import { useState } from 'react'; import DarkModeToggle from '../components/DarkModeToggle.tsx'; -import LoginPopup from '../components/LoginPopup.tsx'; export default function Testing() { return ( From 6b5a4c1e9b44af451cb2e10fa54a10f6b3f815c3 Mon Sep 17 00:00:00 2001 From: JManion32 Date: Fri, 6 Mar 2026 11:53:18 -0500 Subject: [PATCH 3/3] Fixed CI --- cypress/e2e/home/home.cy.ts | 2 +- src/contexts/AuthContext.tsx | 20 +++++++------------- src/css/home.css | 2 +- src/pages/Home.tsx | 20 +++++++++----------- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/cypress/e2e/home/home.cy.ts b/cypress/e2e/home/home.cy.ts index 1a9848f..22426e3 100644 --- a/cypress/e2e/home/home.cy.ts +++ b/cypress/e2e/home/home.cy.ts @@ -2,6 +2,6 @@ describe('Home Page', () => { it('displays the correct main title', () => { cy.visit('localhost:5173'); - cy.get('h1').should('contain', 'Home'); + cy.contains('UserId:'); }); }); diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index bad14e1..3d2c507 100644 --- a/src/contexts/AuthContext.tsx +++ b/src/contexts/AuthContext.tsx @@ -35,30 +35,26 @@ export const AuthProvider: React.FC = ({ children }) => { headers: { Accept: 'application/json', }, - credentials: "include" + credentials: 'include', }); if (response.ok) { const data: User = await response.json(); setUser(data); - } - else { + } else { setUser(null); } - } - catch (err: unknown) { + } catch (err: unknown) { if (err instanceof Error) { console.error('Failed to fetch user:', err); setError(err.message); - } - else { + } else { console.error('Unknown error:', err); setError('Unknown error'); } setUser(null); - } - finally { + } finally { setLoading(false); } }; @@ -84,8 +80,7 @@ export const AuthProvider: React.FC = ({ children }) => { setUser(data); clearInterval(pollInterval); } - } - catch (err: unknown) { + } catch (err: unknown) { if (err instanceof Error) { console.error('Polling failed:', err.message); } @@ -105,8 +100,7 @@ export const AuthProvider: React.FC = ({ children }) => { setUser(null); window.location.href = '/app/'; - } - catch (err: unknown) { + } catch (err: unknown) { if (err instanceof Error) { console.error('Logout failed:', err.message); } diff --git a/src/css/home.css b/src/css/home.css index be25192..6e19381 100644 --- a/src/css/home.css +++ b/src/css/home.css @@ -10,4 +10,4 @@ background: #e8e8e8; border-radius: 3rem; padding: 2rem; -} \ No newline at end of file +} diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 8babf43..f90ebae 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -11,19 +11,17 @@ export default function Home() { <>
- setShowLogin(true)}>Register + setShowLogin(true)}> + Register + setShowLogin(false)} /> -

UserId: {user?.id ?? "Not logged in"}

-
-
- -
-
- -
-
- +

+ UserId: {user?.id ?? 'Not logged in'} +

+
+
+
);