From ce215ba347a1a147cd323d8af9c481bc96f60f95 Mon Sep 17 00:00:00 2001 From: Greg Bowne Date: Thu, 27 Jul 2023 17:44:38 -0700 Subject: [PATCH 1/3] This commit includes remaining fixes for the Login page UI. This commit adds a Register or Sign Up page so that the user can register or sign up for the app. --- src/components/Register/Register.css | 8 +++ src/components/Register/Register.jsx | 102 +++++++++++++++++++++++++++ src/pages/Login/Login.css | 42 +++++++++++ src/pages/Login/Login.jsx | 34 ++++++--- 4 files changed, 178 insertions(+), 8 deletions(-) diff --git a/src/components/Register/Register.css b/src/components/Register/Register.css index e69de29..4eff54f 100644 --- a/src/components/Register/Register.css +++ b/src/components/Register/Register.css @@ -0,0 +1,8 @@ +.register-container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + min-height: 100vh; + padding: 16px; +} diff --git a/src/components/Register/Register.jsx b/src/components/Register/Register.jsx index e69de29..1709bb7 100644 --- a/src/components/Register/Register.jsx +++ b/src/components/Register/Register.jsx @@ -0,0 +1,102 @@ +import React, { useState } from 'react'; +import { + TextField, + FormControlLabel, + Checkbox, + Link, + Button, + Typography, + Container, + IconButton, +} from '@mui/material'; +import { Visibility, VisibilityOff } from '@mui/icons-material'; +import axios from 'axios'; +import './Register.css'; + +const Register = () => { + const [username, setUsername] = useState(''); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [showPassword, setShowPassword] = useState(false); + const [showConfirmPassword, setShowConfirmPassword] = useState(false); + + const handleTogglePasswordVisibility = () => { + setShowPassword((prevShowPassword) => !prevShowPassword); + }; + + const handleToggleConfirmPasswordVisibility = () => { + setShowConfirmPassword( + (prevShowConfirmPassword) => !prevShowConfirmPassword + ); + }; + + const handleRegister = async () => { + try { + const response = await axios.post('/api/register', { + username, + email, + password, + }); + if (response.status === 200) { + // Registration successful, redirect to login page or desired location + window.location.href = '/login'; + } + } catch (error) { + console.error(error); + // Handle registration error, display error message to the user + } + }; + + return ( + + + + + {showPassword ? : } + + ), + }} + /> + + {showConfirmPassword ? ( + + ) : ( + + )} + + ), + }} + /> + {/* Add optional fields here */} + } + label='I agree to the Terms and Conditions' + /> + + Read our{' '} + + Privacy Policy + + . + + + + ); +}; + +export default Register; diff --git a/src/pages/Login/Login.css b/src/pages/Login/Login.css index e69de29..db88bb9 100644 --- a/src/pages/Login/Login.css +++ b/src/pages/Login/Login.css @@ -0,0 +1,42 @@ +.login-wrapper { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100vh; + font-family: 'Roboto', 'Open Sans', sans-serif; +} + +.MuiFormControl-root { + margin-bottom: 15px; + /* Adjust margin between the fields */ +} + +.MuiInputBase-input { + font-family: 'Roboto', 'Open Sans', sans-serif; + margin-top: 15px; + margin-bottom: 15px; +} + +.checkbox-wrapper { + display: flex; + align-items: center; + margin-bottom: 5px; + /* Adjust margin between the checkbox and the label */ +} + +.forgot-password { + margin-bottom: 5px; + /* Adjust margin below the "Forgot Password" link */ +} + +.login-button { + /* Adjust margin above the login button */ + background-color: #1976d2; + /* Set primary color */ + color: #fff; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; +} diff --git a/src/pages/Login/Login.jsx b/src/pages/Login/Login.jsx index 640a975..541536d 100644 --- a/src/pages/Login/Login.jsx +++ b/src/pages/Login/Login.jsx @@ -1,7 +1,14 @@ import React, { useState } from 'react'; import axios from 'axios'; -import { IconButton, InputAdornment, TextField } from '@mui/material'; +import { + IconButton, + InputAdornment, + TextField, + Typography, +} from '@mui/material'; import { Visibility, VisibilityOff } from '@mui/icons-material'; +import { Link as RouterLink } from 'react-router-dom'; +import './Login.css'; function Login() { const [usernameOrEmail, setUsernameOrEmail] = useState(''); @@ -17,7 +24,7 @@ function Login() { rememberMe, }); if (response.status === 200) { - window.location.href = '/'; // Redirect to the desired page + window.location.href = 'http://localhost:3000/home'; // Redirect to the desired page } } catch (error) { console.error(error); @@ -25,7 +32,7 @@ function Login() { }; return ( -
+
-
); } From b71032d9ed278baf0ffce5e3d0b367cfb2bede8c Mon Sep 17 00:00:00 2001 From: Greg Bowne Date: Fri, 28 Jul 2023 14:53:51 -0700 Subject: [PATCH 2/3] Fixing ESLint and Prettier error and defines from Register.jsx --- src/components/Register/Register.jsx | 4 ++++ src/pages/Login/Login.jsx | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/Register/Register.jsx b/src/components/Register/Register.jsx index 1709bb7..93a38d0 100644 --- a/src/components/Register/Register.jsx +++ b/src/components/Register/Register.jsx @@ -55,6 +55,8 @@ const Register = () => { setPassword(e.target.value)} InputProps={{ endAdornment: ( @@ -66,6 +68,8 @@ const Register = () => { setConfirmPassword(e.target.value)} InputProps={{ endAdornment: ( - Don't have an account? Please{' '} - - register here - - . + Don't have an account? Please{' '} + register here
); From 5c41882cb09aa8b1c3295c54ffac6d5f920769a7 Mon Sep 17 00:00:00 2001 From: Greg Bowne Date: Fri, 28 Jul 2023 15:06:50 -0700 Subject: [PATCH 3/3] This commit adds route for /tegister so that Register.jsx does render to /register. Also fixes defines in Register.jsx --- src/App.js | 2 ++ src/components/Register/Register.jsx | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index d8b31d2..3a9c2df 100644 --- a/src/App.js +++ b/src/App.js @@ -4,6 +4,7 @@ import { Route, Routes } from 'react-router-dom'; import { BrowserRouter as Router } from 'react-router-dom'; import Login from './pages/Login/Login'; import Profile from './pages/Profile/Profile'; +import Register from './components/Register/Register'; export default function App() { return ( @@ -11,6 +12,7 @@ export default function App() { } /> } /> + } /> } /> diff --git a/src/components/Register/Register.jsx b/src/components/Register/Register.jsx index 93a38d0..9bab3c3 100644 --- a/src/components/Register/Register.jsx +++ b/src/components/Register/Register.jsx @@ -50,8 +50,17 @@ const Register = () => { return ( - - + setUsername(e.target.value)} + /> + setEmail(e.target.value)} + />