diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 4c00605..1ad3a4b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,7 +7,7 @@ import Game from './pages/Game'; import About from './pages/About'; import { AuthProvider } from './contexts/AuthContext'; import Login from './pages/Login'; -import SignUp from './pages/SignUp' +import SignUp from './pages/SignUp'; const router = createBrowserRouter([ { @@ -25,8 +25,8 @@ const router = createBrowserRouter([ }, { path: '/about', element: }, { path: '/error', element: }, - { path: '/login', element: }, - { path: '/signup', element: } + { path: '/login', element: }, + { path: '/signup', element: }, ], }, ]); diff --git a/frontend/src/Navbar.tsx b/frontend/src/Navbar.tsx index 08176bb..821d932 100644 --- a/frontend/src/Navbar.tsx +++ b/frontend/src/Navbar.tsx @@ -34,8 +34,8 @@ const Navbar: React.FC = ({ }; const goToLogin = () => { - navigate('/login') - } + navigate('/login'); + }; return (
@@ -50,31 +50,29 @@ const Navbar: React.FC = ({
{auth.isLoggedIn() ? ( - <> -
-
- - - ) : ( - <> -
-
- - )} - + <> +
+
+ + ) : ( + <> +
+
+ + )} {isOpen && (
diff --git a/frontend/src/contexts/AuthContext.tsx b/frontend/src/contexts/AuthContext.tsx index 4b34852..68bc566 100644 --- a/frontend/src/contexts/AuthContext.tsx +++ b/frontend/src/contexts/AuthContext.tsx @@ -30,14 +30,17 @@ export function useAuth() { } export function AuthProvider({ children }: { children: ReactElement }) { - const [user, setUser] = useState(null); - - const login = useCallback((name: string, pass: string) => { - setUser({ - name: name, - pass: pass, - }); - }, [setUser]); + const [user, setUser] = useState(null); + + const login = useCallback( + (name: string, pass: string) => { + setUser({ + name: name, + pass: pass, + }); + }, + [setUser] + ); const logout = useCallback(() => { setUser(null); diff --git a/frontend/src/library/button.tsx b/frontend/src/library/button.tsx index af848eb..add3958 100644 --- a/frontend/src/library/button.tsx +++ b/frontend/src/library/button.tsx @@ -15,7 +15,7 @@ type ButtonProps = { fontSize?: string; rounded?: string; buttonSize?: string; - type?: "submit" | "reset" | "button" + type?: 'submit' | 'reset' | 'button'; borderColor?: string; hoverColor?: string; hoverScale?: boolean; diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx index a0d2e52..6a51c94 100644 --- a/frontend/src/pages/Login.tsx +++ b/frontend/src/pages/Login.tsx @@ -14,8 +14,8 @@ const Login: React.FC = () => { const [username, setUsername] = useState(''); const navigate = useNavigate(); const auth = useAuth(); - const user = auth.getUser(); - + const user = auth.getUser(); + const handleLogin = () => { setUsername(username); console.log(auth.isLoggedIn()); @@ -30,38 +30,39 @@ const Login: React.FC = () => { setName(event.target.value); }; - const handlePasswordChange = (event: React.ChangeEvent) => { + const handlePasswordChange = ( + event: React.ChangeEvent + ) => { setPassword(event.target.value); }; - const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); console.log('Form submitted'); - if(user?.name == name && user.pass == password){ - console.log("Successful Login"); + if (user?.name == name && user.pass == password) { + console.log('Successful Login'); navigate('/home'); - }else{ - console.log("Failed Login"); + } else { + console.log('Failed Login'); } }; useEffect(() => { setIsLoggedIn(auth.isLoggedIn()); console.log(isLoggedIn); - }, [auth, auth.getUser(), auth.isLoggedIn()]); + }, [auth, auth.getUser(), isLoggedIn]); return ( <> -
+
-
-
+
+
{/*
*/}
-
-
-
+ +
+
-
+
-
+
-
- Don't have an account? Sign up +
+ Don't have an account?{' '} + + {' '} + Sign up +
@@ -121,7 +129,6 @@ const Login: React.FC = () => {
- ); }; diff --git a/frontend/src/pages/SignUp.tsx b/frontend/src/pages/SignUp.tsx index f32598a..09d8970 100644 --- a/frontend/src/pages/SignUp.tsx +++ b/frontend/src/pages/SignUp.tsx @@ -15,7 +15,7 @@ const SignUp: React.FC = () => { const [username, setUsername] = useState(''); const navigate = useNavigate(); const auth = useAuth(); - + const handleLogin = () => { setUsername('Username_7'); setIsLoggedIn(true); @@ -26,7 +26,9 @@ const SignUp: React.FC = () => { setIsLoggedIn(false); }; - const handelConfirmPassChange = (event: React.ChangeEvent) => { + const handelConfirmPassChange = ( + event: React.ChangeEvent + ) => { setConfirmPass(event.target.value); }; @@ -34,20 +36,21 @@ const SignUp: React.FC = () => { setName(event.target.value); }; - const handlePasswordChange = (event: React.ChangeEvent) => { + const handlePasswordChange = ( + event: React.ChangeEvent + ) => { setPassword(event.target.value); }; - const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); console.log('Form submitted'); - if(password === confirmPass){ - auth.login(name, password) - console.log("successfull signup") - navigate('/') - }else{ - console.log("failed signup"); + if (password === confirmPass) { + auth.login(name, password); + console.log('successfull signup'); + navigate('/'); + } else { + console.log('failed signup'); } }; @@ -56,20 +59,20 @@ const SignUp: React.FC = () => { console.log(user); setIsLoggedIn(auth.isLoggedIn()); console.log(isLoggedIn); - }, [auth, auth.getUser(), auth.isLoggedIn()]); + }, [auth, auth.getUser(), isLoggedIn]); return ( <> -
+
-
-
- {/*
+
+
+ {/*
*/}
-
-
-
+ +
+
-
+
-
+
-
+
-
- Already have an account? Login +
+ Already have an account?{' '} + + {' '} + Login +
@@ -138,7 +148,6 @@ const SignUp: React.FC = () => {
- ); };