UserProfile.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React, { Component, Fragment } from 'react';
  2. import { Link } from "react-router-dom";
  3. import { connect } from 'react-redux';
  4. import { getUsersData } from "../actions/usersAuthActions";
  5. import { getUsersDataById } from "../actions/getUserById"
  6. import { getParams } from "../actions/getUserById"
  7. import { bindActionCreators } from "redux";
  8. import Header from '../container/Header'
  9. class UserProfile extends Component {
  10. singOut = () => {
  11. const { getParams, match } = this.props
  12. localStorage.removeItem("login")
  13. getParams(match.params.id)
  14. }
  15. componentDidMount() {
  16. const { getUsersDataById } = this.props
  17. console.log(this.props);
  18. let localS = JSON.parse(localStorage.getItem("login"));
  19. if (localS === null) {
  20. }
  21. else {
  22. getUsersDataById(localS)
  23. }
  24. }
  25. render() {
  26. const { getUser } = this.props
  27. const { staffs } = this.props.getUser
  28. return (
  29. <Fragment>
  30. <Header getUser={getUser} />
  31. <div className="menuAndContent">
  32. <div className="profil">
  33. <h2>{getUser.name}</h2>
  34. <div className="profilData">
  35. <p>{getUser.login}</p>
  36. <p>{getUser.email}</p>
  37. <p>{getUser.phone}</p>
  38. <div className="buttonConteiner">
  39. <Link to="/activeStaffs"><button className="profilLink">Активные Товары</button></Link>
  40. <Link to="/"><button className="profilBtn" onClick={this.singOut}>Выход</button></Link>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </Fragment>
  46. );
  47. }
  48. }
  49. const mapStateToProps = state => ({
  50. inputData: state.usersAuth.inputData,
  51. getUser: state.getUserById.getUser,
  52. });
  53. const mapDispatchToProps = dispatch => bindActionCreators({ getUsersData, getUsersDataById, getParams }, dispatch);
  54. export default UserProfile = connect(
  55. mapStateToProps,
  56. mapDispatchToProps
  57. )(UserProfile);