diff --git a/client/package.json b/client/package.json index 1a91585..1395023 100644 --- a/client/package.json +++ b/client/package.json @@ -16,7 +16,8 @@ "react-dom": "^17.0.2", "react-icons": "^4.3.1", "react-router-dom": "^5.3.0", - "react-scripts": "4.0.3" + "react-scripts": "4.0.3", + "yup": "^0.32.11" }, "scripts": { "start": "react-scripts start", diff --git a/client/src/App.js b/client/src/App.js index 1ed2d84..b750db3 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,6 +1,7 @@ import { BrowserRouter as Router } from 'react-router-dom'; import NavBar from './components/Navbar'; import { Footer } from './components'; +// import Login from './components/login'; function App() { return ( diff --git a/client/src/assets/Iconfacebook.png b/client/src/assets/Iconfacebook.png new file mode 100644 index 0000000..aa21d3a Binary files /dev/null and b/client/src/assets/Iconfacebook.png differ diff --git a/client/src/assets/Icongoogle.png b/client/src/assets/Icongoogle.png new file mode 100644 index 0000000..79ee307 Binary files /dev/null and b/client/src/assets/Icongoogle.png differ diff --git a/client/src/components/Navbar/index.js b/client/src/components/Navbar/index.js index 4d2c5ca..7c17076 100644 --- a/client/src/components/Navbar/index.js +++ b/client/src/components/Navbar/index.js @@ -6,11 +6,30 @@ import { } from '@mui/material'; import './style.css'; +import Backdrop from '@mui/material/Backdrop'; +import Box from '@mui/material/Box'; +import Modal from '@mui/material/Modal'; +import Fade from '@mui/material/Fade'; +import Login from '../login'; import Logo from '../../asstes/logo.png'; import PresonImg from '../../asstes/avatar.png'; function NavBar() { - const [logged, setLogged] = useState(true); + const [logged, setLogged] = useState(false); + const [open, setOpen] = useState(false); + const handleOpen = () => setOpen(true); + const handleClose = () => setOpen(false); + const style = { + position: 'absolute', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 650, + bgcolor: 'background.paper', + borderRadius: 3, + boxShadow: 24, + p: 4, + }; return ( + + + + + + + ); diff --git a/client/src/components/login/index.jsx b/client/src/components/login/index.jsx new file mode 100644 index 0000000..9c38b30 --- /dev/null +++ b/client/src/components/login/index.jsx @@ -0,0 +1,169 @@ +/* eslint-disable no-unused-vars */ +import { useState } from 'react'; +import { + Grid, Paper, Avatar, TextField, Button, Typography, +} from '@mui/material'; +import { useHistory, Link } from 'react-router-dom'; +import PropTypes from 'prop-types'; +import axios from 'axios'; +import Facebook from '../../assets/Iconfacebook.png'; +import Google from '../../assets/Icongoogle.png'; + +const Login = ({ handleClose, setLogged }) => { + const history = useHistory(); + const [data, setData] = useState({ email: '', password: '' }); + const [error, setError] = useState({ email: false, password: false }); + const [LoginError, setLoginError] = useState(''); + const [LoginSuccessful, setLoginSuccessful] = useState(''); + + const { email, password } = data; + + const marginBtm = { marginBottom: 10 }; + const btnstyle = { + margin: '8px 0', + backgroundColor: '#CBA41B', + }; + const loginWithSocialMedia = { + margin: '8px ', + backgroundColor: '#2E72DB', + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + textTransform: 'none', + }; + const loginWithEmail = { + width: '50%', + display: 'flex', + flexDirection: 'column', + + }; + const Container = { + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + boxShadow: 'none', + + }; + const containerBtn = { + width: '90%', + display: 'flex', + alignItems: 'center', + + }; + const avatar = { + borderRadius: 0, + width: '30px', + height: '30px', + + }; + + const handleError = (callback) => { + if (email === '' && password === '') { + setError({ email: true, password: true }); + } else if (email === '') { + setError({ email: true, password: false }); + } else if (password === '') { + setError({ email: false, password: true }); + } else { + setError({ email: false, password: false }); + callback(); + } + }; + + const handleChange = (e) => { + const { name, value } = e.target; + setData({ ...data, [name]: value }); + }; + + const handleSubmit = (e) => { + e.preventDefault(); + handleError(() => { + axios.post('/api/v1/user/login', { + email, + password, + }).then((res) => { + setLoginSuccessful(res); + handleClose(); + setLogged(true); + history.push('/'); + }) + .catch((err) => { + setLoginError(err.response.data.message); + }); + }); + }; + return ( + + + +

Welcome Back

+
+ + + + + + + + OR + + + + + + + + {LoginError} + + + {/* */} + + Forgot password ? + + {/* */} + + Do you have an account ? + + Sign Up + + + +
+ +
+ ); +}; + +Login.propTypes = { + handleClose: PropTypes.func.isRequired, + setLogged: PropTypes.func.isRequired, + +}; +export default Login; diff --git a/client/src/components/login/style.css b/client/src/components/login/style.css new file mode 100644 index 0000000..e69de29