Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Zukqurnain committed May 31, 2022
1 parent f477705 commit be6d8d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
21 changes: 9 additions & 12 deletions frontend/src/pages/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function SignIn({setLoggedin}) {

const handleForgotClick = () =>{
const {email} = form
console.log(form)

if(email){
setopenBackdrop(!openBackdrop);
const data = {
Expand All @@ -54,11 +54,11 @@ export default function SignIn({setLoggedin}) {
.then(function (response) {
setOpen(true);
handleCloseBackdrop();
console.log(response,"response")

SetMessage({value: response.data.message, type:"success"})
})
.catch(function (error) {
console.log(error);

handleCloseBackdrop();

});
Expand Down Expand Up @@ -90,7 +90,7 @@ export default function SignIn({setLoggedin}) {
setForm({NewPassword:"", ConfirmPassword:""})
})
.catch(function (error) {
console.log(error);

handleCloseBackdrop();

});
Expand All @@ -113,7 +113,7 @@ export default function SignIn({setLoggedin}) {

const handleChange = (e) =>{
setForm({...form,[ e.target.name] : e.target.value })
console.log(form, "asdasd")

}


Expand All @@ -131,10 +131,7 @@ export default function SignIn({setLoggedin}) {
const handleSubmit = (event) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});


if(data.get('email') && data.get('password')){
setopenBackdrop(!openBackdrop);
Expand All @@ -146,12 +143,12 @@ export default function SignIn({setLoggedin}) {
})
.then(function (response) {
handleCloseBackdrop();
console.log(response);

if(response.data.status ){
response.data.token ? localStorage.setItem("token", response.data.token) : console.log(response)
localStorage.setItem("data", JSON.stringify(response))
const token = localStorage.getItem("token")
console.log("token", token )

setLoggedin(true);
SetMessage({value: "Login Success", type:"success"})
handleCloseBackdrop();
Expand All @@ -162,7 +159,7 @@ export default function SignIn({setLoggedin}) {
}
})
.catch(function (error) {
console.log(error);

handleCloseBackdrop();

});
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/pages/UserRegister.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function UserRegister() {
// On autofill we get a stringified value.

);
console.log("per",personName)

};
const classes = useStyles();
const [users, setUsers] = useState([]);
Expand All @@ -133,7 +133,7 @@ export default function UserRegister() {
.catch(function (error) {
// handle error
handleCloseBackdrop();
console.log(error);

})
.then(function () {
handleCloseBackdrop();
Expand Down Expand Up @@ -168,7 +168,7 @@ export default function UserRegister() {
})
.catch(function (error) {
// handle error
console.log(error);

})
handleclose();
handleCloseBackdrop();
Expand All @@ -182,7 +182,7 @@ export default function UserRegister() {
event.preventDefault();
let api = '/api/register';

console.log(form._id)

if (form._id && form.FirstName) {
api = `/api/user/${form._id}`
const token = localStorage.getItem('token');
Expand Down

0 comments on commit be6d8d0

Please sign in to comment.