|
@@ -1,7 +1,7 @@
|
|
import {CUsersList, SearchUserInput, CUpdateAdminForm} from "./index";
|
|
import {CUsersList, SearchUserInput, CUpdateAdminForm} from "./index";
|
|
import {gql, urlUpload, actionPromise, actionGoodCard, getGoods,
|
|
import {gql, urlUpload, actionPromise, actionGoodCard, getGoods,
|
|
actionUserFindOne, updateImgAction, actionAuthLogin, actionAuthLogout,
|
|
actionUserFindOne, updateImgAction, actionAuthLogin, actionAuthLogout,
|
|
- actionUserUpdate,getData, actionLogin } from "../reducers";
|
|
|
|
|
|
+ actionUserUpdate, actionOrdersFind, getData, actionLogin } from "../reducers";
|
|
import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
|
|
import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
|
|
import { connect } from "react-redux";
|
|
import { connect } from "react-redux";
|
|
import { useEffect, useState, useRef } from "react";
|
|
import { useEffect, useState, useRef } from "react";
|
|
@@ -10,7 +10,7 @@ import {BrowserRouter as Router, Route, Link, Switch, Redirect, useHistory} from
|
|
import { NewAuth } from "../reducers/actionAuthLog";
|
|
import { NewAuth } from "../reducers/actionAuthLog";
|
|
|
|
|
|
|
|
|
|
-const YourProfile = ({state, updateStatus, updatedUser = {}, newImg, token, onLogin, onLogout, updateImg,
|
|
|
|
|
|
+const YourProfile = ({state, orders, updateStatus, updatedUser = {}, newImg, token, onLogin, onLogout, updateImg,
|
|
updateUser, isUserAdmin = {}, status, data = {}, getData,
|
|
updateUser, isUserAdmin = {}, status, data = {}, getData,
|
|
match:{params:{_id}}, isAdmin = [], isOwner = {}, newPicture = "clear"}) => {
|
|
match:{params:{_id}}, isAdmin = [], isOwner = {}, newPicture = "clear"}) => {
|
|
|
|
|
|
@@ -25,7 +25,16 @@ const YourProfile = ({state, updateStatus, updatedUser = {}, newImg, token, onLo
|
|
// const [isUpdatePage, changePage] = useState(false);
|
|
// const [isUpdatePage, changePage] = useState(false);
|
|
// const [newImage, getImage] = useState({});
|
|
// const [newImage, getImage] = useState({});
|
|
|
|
|
|
- useEffect(() => history.location.pathname.includes(`/profile/`) ? getData(`${isOwner.id}`) : getData(`${_id}`),[history.location.pathname])
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if(history.location.pathname.includes(`/profile/`)) {
|
|
|
|
+ getData(`${isOwner.id}`);
|
|
|
|
+ orders(`${isOwner.id}`) ;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ getData(`${_id}`);
|
|
|
|
+ orders(`${_id}`) ;
|
|
|
|
+ }
|
|
|
|
+ },[history.location.pathname])
|
|
|
|
|
|
useEffect(
|
|
useEffect(
|
|
async() => {
|
|
async() => {
|
|
@@ -50,7 +59,7 @@ const YourProfile = ({state, updateStatus, updatedUser = {}, newImg, token, onLo
|
|
const [searchInput, changeValue] = useState("Пошук");
|
|
const [searchInput, changeValue] = useState("Пошук");
|
|
|
|
|
|
|
|
|
|
- // console.log(state);
|
|
|
|
|
|
+ console.log(state);
|
|
// console.log(data);
|
|
// console.log(data);
|
|
|
|
|
|
|
|
|
|
@@ -192,7 +201,9 @@ const mapStateToProps = state => ({
|
|
state.promiseRed.photo.payload && state.promiseRed.photo.payload,
|
|
state.promiseRed.photo.payload && state.promiseRed.photo.payload,
|
|
|
|
|
|
isAdmin: state.auth && state.auth.payload && state.auth.payload.sub &&
|
|
isAdmin: state.auth && state.auth.payload && state.auth.payload.sub &&
|
|
- state.auth.payload.sub.acl && state.auth.payload.sub.acl.indexOf("admin") > -1
|
|
|
|
|
|
+ state.auth.payload.sub.acl && state.auth.payload.sub.acl.indexOf("admin") > -1,
|
|
|
|
+
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -202,7 +213,8 @@ const mapStateToProps = state => ({
|
|
updateImg: updateImgAction,
|
|
updateImg: updateImgAction,
|
|
updateUser: actionUserUpdate,
|
|
updateUser: actionUserUpdate,
|
|
onLogout: actionAuthLogout,
|
|
onLogout: actionAuthLogout,
|
|
- onLogin: actionLogin
|
|
|
|
|
|
+ onLogin: actionLogin,
|
|
|
|
+ orders: actionOrdersFind
|
|
}, dispatch);
|
|
}, dispatch);
|
|
|
|
|
|
const CYourProfile = connect(mapStateToProps, mapDispatchToProps)
|
|
const CYourProfile = connect(mapStateToProps, mapDispatchToProps)
|