Logout is working now : )

This commit is contained in:
2019-10-09 12:03:57 -04:00
parent bb6c7a07fc
commit d1233e77ed
6 changed files with 115 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
/* eslint-disable */
import React, { Component } from 'react';
import '../App.css';
// import '../App.css';
import PropTypes from 'prop-types';
import logo from '../images/twistter-logo.png';
@@ -173,6 +173,7 @@ const mapStateToProps = (state) => ({
const mapActionsToProps = {
loginUser
}
Login.propTypes = {
classes: PropTypes.object.isRequired
};

View File

@@ -0,0 +1,56 @@
/* eslint-disable */
import React, { Component } from "react";
import PropTypes from "prop-types";
// Material UI stuff
import Button from "@material-ui/core/Button";
import withStyles from "@material-ui/core/styles/withStyles";
// Redux stuff
import { logoutUser } from "../redux/actions/userActions";
import { connect } from "react-redux";
const styles = {
form: {
textAlign: "center"
},
textField: {
marginBottom: 30
},
pageTitle: {
marginBottom: 40
},
button: {
positon: "relative",
marginBottom: 30
},
progress: {
position: "absolute"
}
};
export class Logout extends Component {
componentDidMount() {
this.props.logoutUser();
this.props.history.push('/');
}
render() {
return null;
}
}
const mapStateToProps = (state) => ({
user: state.user
});
const mapActionsToProps = { logoutUser };
Logout.propTypes = {
logoutUser: PropTypes.func.isRequired,
user: PropTypes.object.isRequired,
classes: PropTypes.object.isRequired
};
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Logout));

View File

@@ -1,6 +1,6 @@
/* eslint-disable */
import React, { Component } from 'react';
import '../App.css';
// import '../App.css';
import PropTypes from 'prop-types';
import logo from '../images/twistter-logo.png';
@@ -42,8 +42,10 @@ export class Signup extends Component {
constructor() {
super();
this.state = {
handle: "",
email: "",
password:"",
confirmPassword: "",
errors: {}
};
}
@@ -60,8 +62,10 @@ export class Signup extends Component {
handleSubmit = (event) => {
event.preventDefault();
const signupData = {
handle: this.state.handle,
email: this.state.email,
password: this.state.password,
confirmPassword: this.state.confirmPassword
};
this.props.signupUser(signupData, this.props.history);
};
@@ -88,7 +92,7 @@ export class Signup extends Component {
<Grid item sm>
<img src={logo} className="app-logo" alt="logo" />
<Typography variant="h2" className={classes.pageTitle}>
Log in to Twistter
Create a new account
</Typography>
<form noValidate onSubmit={this.handleSubmit}>
<TextField
@@ -156,6 +160,7 @@ const mapStateToProps = (state) => ({
const mapActionsToProps = {
signupUser
}
Signup.propTypes = {
classes: PropTypes.object.isRequired
};