import { useState, useRef, useEffect } from 'react'; import {BrowserRouter as Router, Route, Link, Switch, Redirect, useHistory} from 'react-router-dom'; import {gql, urlUpload, actionPromise, actionGoodCard, getGoods, updateImgAction, actionUserUpdate} from "../reducers"; import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux'; import { connect } from 'react-redux'; const UpdateForm = ({updateImg, updateUser, id}) => { const history = useHistory(); const formRef = useRef(null); const [nick, changeNick] = useState(null); const [login, changeLogin] = useState(null); const [password, changePassword] = useState(null); const [password2, changePassword2] = useState(null); const [isUpdateImg, changeImg] = useState(false); const [isUpdatePage, changePage] = useState(false); useEffect(() => isUpdatePage && window.location.reload()[isUpdatePage]) console.log(formRef); return( <>

Редагування

changeNick(e.target.value)} placeholder = "Новий нікнейм"/> changeLogin(e.target.value)} placeholder = "Новий логін"/> changePassword(e.target.value)} placeholder = "Новий пароль"/> changePassword2(e.target.value)} placeholder = "Повторіть пароль"/>
{ updateImg(formRef); changeImg(true); }}>
{/* */} ) } const mapStateToProps = state => ({ state: state, // data: state.promiseRed && state.promiseRed.user && // state.promiseRed.user.payload && state.promiseRed.user.payload.data && // state.promiseRed.user.payload.data.UserFindOne // basket: state.basket, // GoodsArr: arrFromObj(ObjFilter(state.basket, "price")), // order: orderArr(arrFromObj(ObjFilter(state.basket, "price"))), // orderDone: state.promiseRed && state.promiseRed.order && // state.promiseRed.order.payload && // state.promiseRed.order.payload.data.OrderUpsert }); const mapDispatchToProps = dispatch => bindActionCreators({ updateImg: updateImgAction, updateUser: actionUserUpdate, // onDel: actionCartDelete, // onClear: actionCartClear, // onOrder: actionOrder }, dispatch); const CUpdateForm = connect(mapStateToProps, mapDispatchToProps)(UpdateForm) export default CUpdateForm;