Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/home/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:');
});
});
5 changes: 4 additions & 1 deletion src/components/LoginPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';
import '../css/login.css';

Expand All @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/components/navbar/NavbarLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default function NavbarLink({ label, nav }: NavbarLinkProps) {
const navigate = useNavigate();

const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
if (location.pathname === nav) {
return;
}

e.preventDefault();

const content = document.querySelector('.app-content');
Expand Down
1 change: 1 addition & 0 deletions src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
headers: {
Accept: 'application/json',
},
credentials: 'include',
});

if (response.ok) {
Expand Down
1 change: 0 additions & 1 deletion src/css/app-layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

.app-content {
padding: 3rem;
width: 100%;
position: relative;
overflow: hidden;
transition:
Expand Down
2 changes: 1 addition & 1 deletion src/css/carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

.carousel {
width: 100%;
width: 72rem;
background: var(--carousel-bg);
height: 18rem;
border-radius: 2rem;
Expand Down
13 changes: 13 additions & 0 deletions src/css/home.css
Original file line number Diff line number Diff line change
@@ -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;
}
12 changes: 8 additions & 4 deletions src/css/login.css
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -38,10 +46,6 @@
font-size: 14px;
}

.popup-button:hover {
background-color: #f0f0f0;
}

.popup-close-x {
position: absolute;
top: 8px;
Expand Down
23 changes: 21 additions & 2 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
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 (
<>
<div>
<h1>Home</h1>
<div className="home-grid">
<div className="home-grid-panel">
<a className="register-btn" onClick={() => setShowLogin(true)}>
Register
</a>
<LoginPopup isOpen={showLogin} onClose={() => setShowLogin(false)} />
<p style={{ color: 'black' }}>
UserId: <span style={{ color: user?.id ? 'green' : 'red' }}>{user?.id ?? 'Not logged in'}</span>
</p>
</div>
<div className="home-grid-panel"></div>
<div className="home-grid-panel"></div>
<div className="home-grid-panel"></div>
</div>
</>
);
Expand Down
131 changes: 0 additions & 131 deletions src/pages/Login.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/pages/Testing.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { useState } from 'react';
import DarkModeToggle from '../components/DarkModeToggle.tsx';
import LoginPopup from '../components/LoginPopup.tsx';

export default function Testing() {
const [showLogin, setShowLogin] = useState(false);
return (
<>
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', color: 'black' }}>
<h1>[dev] Testing</h1>
<p>This page is for misc features that have been developed, but not placed.</p>
<DarkModeToggle />
<a onClick={() => setShowLogin(true)}>Register</a>
<LoginPopup isOpen={showLogin} onClose={() => setShowLogin(false)} />
</div>
</>
);
Expand Down