diff --git a/frontend/src/components/MyNavbar.jsx b/frontend/src/components/MyNavbar.jsx index 29df7fa..d63cf7a 100644 --- a/frontend/src/components/MyNavbar.jsx +++ b/frontend/src/components/MyNavbar.jsx @@ -7,26 +7,28 @@ const MyNavbar = () => { const { currentUser } = useContext(UserContext); const MyLink = ({ children, ...rest }) => { - return {children}; + return ( + + {children} + + ); }; return ( - - - - LearningTree - - - - - - - + + + LearningTree + + + + + + ); }; diff --git a/frontend/src/pages/HomePage.jsx b/frontend/src/pages/HomePage.jsx index 46b1559..467f6d8 100644 --- a/frontend/src/pages/HomePage.jsx +++ b/frontend/src/pages/HomePage.jsx @@ -1,4 +1,4 @@ -import { useContext, useEffect } from "react"; +import { useContext } from "react"; import { Container } from "react-bootstrap"; import MyNavbar from "../components/MyNavbar"; import UserContext from "../contexts/UserContext"; diff --git a/frontend/src/pages/LoginPage.jsx b/frontend/src/pages/LoginPage.jsx index 6f49bfc..5f55e96 100644 --- a/frontend/src/pages/LoginPage.jsx +++ b/frontend/src/pages/LoginPage.jsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState } from "react"; import { Button, Col, Container, Form, Row, Alert } from "react-bootstrap"; -import { Link } from "wouter"; +import { Link, useLocation } from "wouter"; import MyNavbar from "../components/MyNavbar"; import UserContext from "../contexts/UserContext"; import { makeRequest } from "../utils.ts"; @@ -11,6 +11,7 @@ const LoginPage = () => { const [error, setError] = useState(null); const { currentUser, setCurrentUser } = useContext(UserContext); + const [location, setLocation] = useLocation(); useEffect(() => { if (currentUser?.id) { @@ -19,7 +20,7 @@ const LoginPage = () => { }, [currentUser]); const gotoHome = () => { - window.location.href = "/"; + setLocation("/"); }; const sendLoginRequest = async (e) => { diff --git a/frontend/src/pages/RegisterPage.jsx b/frontend/src/pages/RegisterPage.jsx index 1288cf5..37796d5 100644 --- a/frontend/src/pages/RegisterPage.jsx +++ b/frontend/src/pages/RegisterPage.jsx @@ -1,6 +1,6 @@ import React, { useState } from "react"; import { Button, Col, Container, Form, Row, Alert } from "react-bootstrap"; -import { Link } from "wouter"; +import { Link, useLocation } from "wouter"; import MyNavbar from "../components/MyNavbar"; import { makeRequest } from "../utils.ts"; @@ -12,6 +12,7 @@ const RegisterPage = () => { const [password2, setPassword2] = useState(""); const [error, setError] = useState(null); + const [location, setLocation] = useLocation(); const sendRegisterRequest = (e) => { e?.preventDefault(); @@ -32,7 +33,7 @@ const RegisterPage = () => { setError(data); return; } - window.location.href = "/login"; + setLocation("/login"); }); };