|
@@ -1,7 +1,9 @@
|
|
|
import React, { Component, Fragment } from 'react';
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
-import * as actions from "../actions/staffsAction";
|
|
|
+import { getStaffsData } from "../actions/staffsAction";
|
|
|
+
|
|
|
+import { getUsersDataById } from "../actions/getUserById"
|
|
|
|
|
|
import { bindActionCreators } from "redux";
|
|
|
|
|
@@ -10,18 +12,50 @@ import LeftMenu from '../container/LeftMenu'
|
|
|
import AllStaffs from "../components/AllStaffs"
|
|
|
|
|
|
class MainPage extends Component {
|
|
|
-
|
|
|
+ constructor(props){
|
|
|
+ super(props)
|
|
|
+ //this.state = {trig:false}
|
|
|
+
|
|
|
+ }
|
|
|
+ // componentDidUpdate(prevProps){
|
|
|
+
|
|
|
+ // let localS = JSON.parse(localStorage.getItem("login"));
|
|
|
+ // console.log("prevProps-" ,prevProps, "this.props-", this.props)
|
|
|
+ // if ( prevProps.isFetching !== this.props.isFetching ){
|
|
|
+ // console.log(2342)
|
|
|
+ // this.setState({trig: !this.state.trig})
|
|
|
+ // //this.props.getStaffsData()
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
componentDidMount() {
|
|
|
- this.props.getStaffsData()
|
|
|
+
|
|
|
+ const { getStaffsData, getUsersDataById } = this.props
|
|
|
+
|
|
|
+ getStaffsData()
|
|
|
+
|
|
|
+ let localS = JSON.parse(localStorage.getItem("login"));
|
|
|
+ if(localS===null){
|
|
|
+
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ getUsersDataById(localS)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { inputStaffs, isFetching } = this.props
|
|
|
+ console.log(this.state)
|
|
|
+ const { inputStaffs, isFetching, getUser } = this.props
|
|
|
+ const { name, isAdmin, id } = this.props
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return (
|
|
|
<Fragment>
|
|
|
- <Header />
|
|
|
+ <Header name={ name } getUser={ getUser } id={ id }/>
|
|
|
<div className="contentDiv">
|
|
|
- <LeftMenu />
|
|
|
+ <LeftMenu isAdmin = {isAdmin} getUser={ getUser } />
|
|
|
<AllStaffs inputStaffs={inputStaffs} isFetching={isFetching} />
|
|
|
</div>
|
|
|
</Fragment>
|
|
@@ -31,10 +65,12 @@ class MainPage extends Component {
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
inputStaffs: state.staffs.inputStaffs,
|
|
|
- isFetching: state.staffs.isFetching
|
|
|
+ isFetching: state.staffs.isFetching,
|
|
|
+ getUser: state.getUserById.getUser,
|
|
|
+ params: state.getUserById.params,
|
|
|
});
|
|
|
|
|
|
-const mapDispatchToProps = dispatch => bindActionCreators({ ...actions }, dispatch);
|
|
|
+const mapDispatchToProps = dispatch => bindActionCreators({ getStaffsData, getUsersDataById }, dispatch);
|
|
|
|
|
|
export default MainPage = connect(
|
|
|
mapStateToProps,
|