SearchStaff.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React, { Component, Fragment } from 'react';
  2. import { connect } from 'react-redux';
  3. import { searchStaff } from "../actions/searchStaffAction";
  4. import { getUsersDataById } from "../actions/getUserById"
  5. import { bindActionCreators } from "redux";
  6. import SearchStaffsPage from "../components/SearchStaffsPage"
  7. import LeftMenu from '../container/LeftMenu'
  8. import Header from '../container/Header'
  9. class SearchStaff extends Component {
  10. componentDidMount() {
  11. const { searchStaff, match, getUsersDataById } = this.props
  12. searchStaff(match.params.title)
  13. let localS = JSON.parse(localStorage.getItem("login"));
  14. if (localS === null) {
  15. }
  16. else {
  17. getUsersDataById(localS)
  18. }
  19. }
  20. render() {
  21. const { getUser } = this.props
  22. console.log(this.props)
  23. return (
  24. <Fragment>
  25. <Header getUser={ getUser } />
  26. <div className="menuAndContent">
  27. <LeftMenu getUser={ getUser }/>
  28. <SearchStaffsPage {...this.props} />
  29. </div>
  30. </Fragment>
  31. );
  32. }
  33. }
  34. const mapStateToProps = state => ({
  35. searchData: state.searchStaff.searchData,
  36. isFetching: state.searchStaff.isFetching,
  37. getUser: state.getUserById.getUser,
  38. });
  39. const mapDispatchToProps = dispatch => bindActionCreators({ searchStaff, getUsersDataById }, dispatch);
  40. export default SearchStaff = connect(
  41. mapStateToProps,
  42. mapDispatchToProps
  43. )(SearchStaff);