|
@@ -6,21 +6,32 @@ import {Switch, Route} from "react-router-dom";
|
|
|
import UserInfo from '../components/userInfo'
|
|
|
import UserOrders from '../components/userOrders'
|
|
|
|
|
|
-import { getOrders,getUserOrders } from "../actions/orders"
|
|
|
+import { getUserOrders,getOrders } from "../actions/orders"
|
|
|
import { changeInputValueUserUserForm } from '../actions/auth'
|
|
|
import {putUser} from '../actions/user'
|
|
|
|
|
|
class UserContainer extends Component {
|
|
|
|
|
|
componentDidMount() {
|
|
|
- this.props.getOrders(this.props.currentUser);
|
|
|
- this.props.getUserOrders(this.props.currentUser)
|
|
|
-
|
|
|
+ this.props.getOrders({
|
|
|
+ doctors: this.props.doctors,
|
|
|
+ services: this.props.services,
|
|
|
+ users: this.props.users})
|
|
|
+ }
|
|
|
+ // componentDidUpdate(){
|
|
|
+ // if(this.props.orders.length > 0 &&)
|
|
|
+ // // console.log('did update', this.props.orders)
|
|
|
+ // this.props.getUserOrders(this.props.currentUser)
|
|
|
+ // }
|
|
|
+ componentDidUpdate(prevProps) {
|
|
|
+ if(this.props.orders.length > 0 )
|
|
|
+ if(prevProps.orders !== this.props.orders)
|
|
|
+ this.props.getUserOrders(this.props.currentUser)
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- // const {currentUser, dataOrders, getUserOrders} = this.props
|
|
|
- const { currentUser,changeUserUserForm, changeInputValueUserUserForm,putUser } = this.props
|
|
|
+ console.log(this.props.userOrdersArray)
|
|
|
+ const { currentUser,changeUserUserForm, changeInputValueUserUserForm,putUser,userOrdersArray } = this.props
|
|
|
return (
|
|
|
<div className="main">
|
|
|
<div className="info-wrap">
|
|
@@ -30,7 +41,9 @@ class UserContainer extends Component {
|
|
|
<Link to='/user/info' className = "btn link admin">Редактировать профиль</Link>
|
|
|
</div>
|
|
|
<Switch>
|
|
|
- <Route path='/user/orders' component={ UserOrders } />
|
|
|
+ <Route path='/user/orders' render={() => <UserOrders
|
|
|
+ data={ userOrdersArray}
|
|
|
+ />} />
|
|
|
<Route path='/user/info' render={() => <UserInfo
|
|
|
user={currentUser}
|
|
|
changeUserUserForm = {changeUserUserForm}
|
|
@@ -48,8 +61,12 @@ class UserContainer extends Component {
|
|
|
const mapStateToProps = state => {
|
|
|
return {
|
|
|
currentUser: state.auth.user,
|
|
|
- dataOrders: state.orders,
|
|
|
- changeUserUserForm: state.auth.changeUserForm
|
|
|
+ changeUserUserForm: state.auth.changeUserForm,
|
|
|
+ orders: state.orders.orders,
|
|
|
+ users:state.user.users,
|
|
|
+ services: state.services.services,
|
|
|
+ doctors:state.app.doctors,
|
|
|
+ userOrdersArray: state.orders.userOrdersArray
|
|
|
}
|
|
|
}
|
|
|
-export default connect(mapStateToProps, { getOrders,getUserOrders, changeInputValueUserUserForm, putUser })(UserContainer);
|
|
|
+export default connect(mapStateToProps, { changeInputValueUserUserForm, putUser, getOrders,getUserOrders })(UserContainer);
|