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.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..9bab3c3 100644 --- a/src/components/Register/Register.jsx +++ b/src/components/Register/Register.jsx @@ -0,0 +1,115 @@ +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 ( + + setUsername(e.target.value)} + /> + setEmail(e.target.value)} + /> + setPassword(e.target.value)} + InputProps={{ + endAdornment: ( + + {showPassword ? : } + + ), + }} + /> + setConfirmPassword(e.target.value)} + InputProps={{ + endAdornment: ( + + {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..bcdc08b 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 } 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 ( -
+
-
); }