From 7e54ab35e591114ac64c42b79a15e21d2d092d95 Mon Sep 17 00:00:00 2001 From: mohammedsalah7 Date: Mon, 8 Nov 2021 12:57:35 +0200 Subject: [PATCH 1/2] create login component #64 --- client/package.json | 3 +- client/src/App.js | 2 +- client/src/components/Navbar/index.js | 45 +++++++- client/src/components/login/index.jsx | 150 ++++++++++++++++++++++++++ client/src/components/login/style.css | 0 5 files changed, 194 insertions(+), 6 deletions(-) create mode 100644 client/src/components/login/index.jsx create mode 100644 client/src/components/login/style.css 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 b3e97a5..8709b66 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,7 +1,7 @@ import { BrowserRouter as Router } from 'react-router-dom'; -import PropertyCard from './components/PropertyCard'; import NavBar from './components/Navbar'; import { Footer } from './components'; +// import Login from './components/login'; function App() { return ( diff --git a/client/src/components/Navbar/index.js b/client/src/components/Navbar/index.js index 4d2c5ca..6a65b19 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: 800, + bgcolor: 'background.paper', + // border: '2px solid #000', + 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..0ba8c97 --- /dev/null +++ b/client/src/components/login/index.jsx @@ -0,0 +1,150 @@ +/* eslint-disable no-unused-vars */ +/* eslint-disable no-console */ +import { useState } from 'react'; +import { + Grid, Paper, Avatar, TextField, Button, Typography, +} from '@mui/material'; +import { useHistory, Link } from 'react-router-dom'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import Checkbox from '@mui/material/Checkbox'; +import PropTypes from 'prop-types'; +import axios from 'axios'; + +const Login = ({ handleClose, setLogged }) => { + // console.log(handleClose); + 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 avatarStyle = { backgroundColor: '#1bbd7e' }; + const btnstyle = { + margin: '8px 0', + backgroundColor: '#CBA41B', + }; + const btnTopstyle = { + margin: '8px ', + backgroundColor: '#2E72DB', + }; + const box = { + border: '1px solid red', + width: '50%', + display: 'flex', + flexDirection: 'column', + + }; + + 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) => { + // console.log('yes'); + 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

+
+ + + + + + + + + + + + {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 From 539594cf7038b5ac4323e58339a90160e46a02e5 Mon Sep 17 00:00:00 2001 From: mohammedsalah7 Date: Mon, 8 Nov 2021 16:27:47 +0200 Subject: [PATCH 2/2] edit style login component #64 --- client/src/assets/Iconfacebook.png | Bin 0 -> 2827 bytes client/src/assets/Icongoogle.png | Bin 0 -> 3010 bytes client/src/components/Navbar/index.js | 12 ++--- client/src/components/login/index.jsx | 73 ++++++++++++++++---------- 4 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 client/src/assets/Iconfacebook.png create mode 100644 client/src/assets/Icongoogle.png diff --git a/client/src/assets/Iconfacebook.png b/client/src/assets/Iconfacebook.png new file mode 100644 index 0000000000000000000000000000000000000000..aa21d3a28effc2afb02971a77c2f3909069255f3 GIT binary patch literal 2827 zcmV+m3-t7fP)A00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yPIJFOkC-|2kwW{&5cci;1UwyXL{{iLIN?s?~) zJ2Pj_%$&LB5&a*OmF*Zp$QW7;q;=mOyJB4QX?WS@GijSVlaArujea4ahxEmbFKQE& zWo{8_)S&uZ}-qY^1th^8s)g;d}2uPVdckW!(U#YHDa#fTYJ^e8CaxE+mUMXmWC3Y>Y`Hrg4s9WQ0D-enz4b+9Q`@?V6E_XD$oEf z`%yxNKTDm5C)22@;lnCrlUW_R!2?U*G2 zTA5~Hn3n~XwX~bD47wCT!IDVB<|r`?dh+B++9_7nYBY0im8R}|MKiN&e7`{}t2O!U z)UktfYV-h2jP=m@vwgH%xN+kKF3|9r3L$g5P@C8&jZ7m$7!-Q)Aph{HGwxcepyIa zUtg!~;L+kbz4iM!`r^y4%RjTQPVaoOKp)L4)4OjTr(;7^Y7>$EGiT0(+qZ8E;~GDh z2gD_$c?f6$!L{fh6%1g@fQ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O0rV)%;u&aD6LN>SsK`6G zld66>9Mo7ryu__rx5n4j);>(sqGR`eXePm=Lo1dSTX9focX=!Om2JP$X%aF2nV-mNKYugGTc`g+E?xWaR(&q1L zNk6H(gXM+MaK+9R>s2&C4NQz45i@|s;o)IqIq>;-U=WfZ8X}~O^5q3B{yx{IzrTN& z8J2#iHyLAiU|?WK-+^}y>a|bli2)L5b)Lb;2R=|DD$s_g3BH3J+S2cm73?Z`W0E@s zHZ(LO&nzx3rt0PIGiD+@eOmw4$aT_s!_LnC#zLXxz$P8;DCBT3)ebUCX z2ma_1^s8E`K~zu|-x)h1J&o@VnqY|!Tatyt=%{kcJc@r&s+wRd=%ENH%w%BY$*HZ~ z<2PLSzNXLASkO{zOx8ka$43?ufYN8DYa}_u8WuB3k?YOl%MJgOkt2MzURc6$0KjK$ z@vME}!3_(f#x^1q0*E$2)R-}2C~&(Jwj;RTKwTNaGhk2{#qW3ybqE>H+j|xk7HT>X zk_h(i_USZ#Cc#g#@sa+Y%Et+^-LwHvSSy4X`=G%F651e4BHzG962EVFVeH$tuf_}! zW{ulLV@Ndzzo8BNs?{pK!`GNGFe_Kw>+c($ai>k91=uo!7A#Zb4zL6~AMPAu<_~2Q zWt9wK7tB>Af4Yb+lky?8xKHPrdUYFX*F$ODiW)R&cg8K&i=NSUm;toXrR6|k3>!8~ d%3D(b{0CXt5(x3Ts09E3002ovPDHLkV1gH(MCbqj literal 0 HcmV?d00001 diff --git a/client/src/assets/Icongoogle.png b/client/src/assets/Icongoogle.png new file mode 100644 index 0000000000000000000000000000000000000000..79ee307f949027be75dac0edc093e1da7fba20c9 GIT binary patch literal 3010 zcmV;z3qACSP)A00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yP@5K&+TA7hcDf7i!fQbMhzSzca=+L2H*REZ9I^%kW z4<8Oso;+!6AFe<0$3YpG#l%EP+7fuVcBZ@zrQAwUoTnO>h@PE9-i8p!+1X6QHeKfe zGb1(jzb_F&zf84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index.jsx b/client/src/components/login/index.jsx index 0ba8c97..9c38b30 100644 --- a/client/src/components/login/index.jsx +++ b/client/src/components/login/index.jsx @@ -1,17 +1,15 @@ /* eslint-disable no-unused-vars */ -/* eslint-disable no-console */ import { useState } from 'react'; import { Grid, Paper, Avatar, TextField, Button, Typography, } from '@mui/material'; import { useHistory, Link } from 'react-router-dom'; -import FormControlLabel from '@mui/material/FormControlLabel'; -import Checkbox from '@mui/material/Checkbox'; 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 }) => { - // console.log(handleClose); const history = useHistory(); const [data, setData] = useState({ email: '', password: '' }); const [error, setError] = useState({ email: false, password: false }); @@ -21,21 +19,42 @@ const Login = ({ handleClose, setLogged }) => { const { email, password } = data; const marginBtm = { marginBottom: 10 }; - const avatarStyle = { backgroundColor: '#1bbd7e' }; const btnstyle = { margin: '8px 0', backgroundColor: '#CBA41B', }; - const btnTopstyle = { + const loginWithSocialMedia = { margin: '8px ', backgroundColor: '#2E72DB', + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + textTransform: 'none', }; - const box = { - border: '1px solid red', + 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) => { @@ -57,7 +76,6 @@ const Login = ({ handleClose, setLogged }) => { }; const handleSubmit = (e) => { - // console.log('yes'); e.preventDefault(); handleError(() => { axios.post('/api/v1/user/login', { @@ -76,24 +94,28 @@ const Login = ({ handleClose, setLogged }) => { }; return ( - +

Welcome Back

- - - - - + + + OR + + + { placeholder="Enter password" type="password" name="password" - fullWidth required error={!!error.password} onChange={handleChange} @@ -121,17 +142,15 @@ const Login = ({ handleClose, setLogged }) => { {LoginError} - {/* */} - {/* */} - - - Forgot password ? - - + {/* */} + + Forgot password ? + + {/* */} Do you have an account ? - + Sign Up