maryluis 3 yıl önce
ebeveyn
işleme
370a7dee8f

+ 3 - 2
shop/src/components/profilePage.js

@@ -7,9 +7,10 @@ import { useEffect, useState, useRef } from "react";
 
 
 const YourProfile = ({state, data, getData, match:{params:{login}}}) => {
-     useEffect(() =>  getData(`${login}`),[login, data])
+     useEffect(() =>  getData(`${login}`),[login])
      const date = new Date(data ? +data.createdAt : 0);
-     const [showUpdate, onShow] = useState(false)
+     const [showUpdate, onShow] = useState(false);
+     const [isUpdate, onUpdate] = useState(false);
      //console.log(data)
      if(data){
         return (

+ 9 - 4
shop/src/components/updateForm.js

@@ -1,4 +1,4 @@
-import { useState, useRef } from 'react';
+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';
@@ -11,8 +11,11 @@ const UpdateForm = ({updateImg, updateUser, id}) => {
     const [login, changeLogin] = useState(null);
     const [password, changePassword] = useState(null);
     const [password2, changePassword2] = useState(null);
-    const [isUpdateImg, changeImg] = useState(false)
-
+    const [isUpdateImg, changeImg] = useState(false);
+    const [isUpdatePage, changePage] = useState(false);
+    
+    useEffect(() => isUpdatePage && window.location.reload()[isUpdatePage])
+    console.log(formRef);
 
   return(
     <>
@@ -51,7 +54,9 @@ const UpdateForm = ({updateImg, updateUser, id}) => {
             url:"est"
           }
         }
-         updateUser(newUser)
+         updateUser(newUser);
+         changePage(true);
+         
          
       }}>Зберегти</button>
     </div>

+ 4 - 2
shop/src/reducers/actionUpdateImg.js

@@ -3,16 +3,18 @@ import {gql, urlUpload, actionPromise} from "./index";
 
 
 
-async function updateImgAction(ref) {
+ function updateImgAction(ref) {
  
     fetch(`${urlUpload}/upload`, {
       method: "POST",
       headers: localStorage.authToken ? {Authorization: 'Bearer ' + localStorage.authToken} : {},
       body: new FormData(ref.current)
     })
-    .then((res) => res.json()).then(res => console.log(res))
+    .then((res) => res.json())
   
   
   }    
 
+  
+
   export default updateImgAction;