maryluis 3 年 前
コミット
f1e9434e91

+ 13 - 5
shop/src/App.css

@@ -215,6 +215,11 @@ content {
   font-size: 16px;
   height: 75px;
 }
+.oneGood span {
+  display: flex;
+  text-align: center;
+  justify-content: center;
+}
 .forOneGoodImg {
   height: 170px;
 }
@@ -428,7 +433,7 @@ button {
   display: flex;
   flex-direction: column;
   justify-content: space-around;
-  background-color: rgb(10, 10, 10);
+  background-color: rgba(10, 10, 10, 0.5);
   border: 2px solid;
   border-color:rgb(229, 229, 243);
   border-radius: 5%;
@@ -702,10 +707,7 @@ button {
   .goodCard h2 {
     font-size: 14px;
   }
-  .goodCard p {
-    width: 100%;
-    font-size: 8px;
-  }
+
 
 .basketNoGoods {
   width: 100%;
@@ -728,4 +730,10 @@ button {
     transform: rotate(-90deg);
     width: 30px;
   }
+
+
+  .goodCard p {
+    width: 100%;
+    font-size: 8px;
+  }
 }

+ 1 - 1
shop/src/components/catalog.js

@@ -31,7 +31,7 @@ const Catalog = ({ state, status, categories = [], getData = () => console.log("
                     
                         <Links 
                         key={`${category._id}${Math.random()}`} 
-                        url={history.location.pathname.includes(`/catalog`) ? `/catalog/` + category._id : `/orderPage/` + category._id }
+                        url={(history.location.pathname.includes(`/catalog`) || history.location.pathname.includes(`/search`)) ? `/catalog/` + category._id : `/orderPage/` + category._id }
                          text={category.name}> </Links> :
 
                          <CatalogSubLink name = {category.name} key = {`${category.subCategories._id}${Math.random()}`}arr = {category.subCategories}/>

+ 1 - 1
shop/src/components/goodsCategory.js

@@ -29,7 +29,7 @@ import {OneGood, CGoodsList} from "./index";
 
 
 const GoodsCategory = ({state, goods, wishes, id, tittle = "Товари", addWish, delWish,  onAddtoOrder, getData, onAdd}) => {
-  console.log(state)
+  // console.log(state)
   useEffect(() =>  getData(id), [id])
   return(
       <>

+ 13 - 13
shop/src/components/goodsList.js

@@ -5,22 +5,22 @@ import {Provider, connect} from 'react-redux';
 import {BrowserRouter as Router, Route, Link, Switch, Redirect, useHistory} from 'react-router-dom';
 
 
-  const mapStateToProps = state => ({
-    state: state,
-    arr: getData(state),
-    // search: getGoods(state)
-  });
+  // const mapStateToProps = state => ({
+  //   state: state,
+  //   arr: getData(state),
+  //   // search: getGoods(state)
+  // });
   
-  const mapDispatchToProps = dispatch => bindActionCreators({
-    getData: actionGoods
-  }, dispatch);
+  // const mapDispatchToProps = dispatch => bindActionCreators({
+  //   getData: actionGoods
+  // }, dispatch);
   
 
 
 
 const GoodsList = ({arr = [], isWish, className = "goods", wishAdd, wishDelete, onAdd, onAddtoOrder}) => {
   const history = useHistory();
-  console.log(arr)
+  // console.log(arr)
   if(arr.length == 0) {
     return(
         <>
@@ -38,18 +38,18 @@ const GoodsList = ({arr = [], isWish, className = "goods", wishAdd, wishDelete,
         />
         <div>
           {isWish.indexOf(good._id) == -1 ? 
-          <svg onClick = {() => wishAdd (good._id)} xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart" viewBox="0 0 16 16">
+          <svg onClick = {() => wishAdd (good._id)} xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-heart" viewBox="0 0 16 16">
             <path d="M8 2.748l-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01L8 2.748zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143c.06.055.119.112.176.171a3.12 3.12 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15z"/>
           </svg> :
-          <svg onClick = {() => wishDelete (good._id)} xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart-fill" viewBox="0 0 16 16">
-            <path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
+          <svg onClick = {() => wishDelete (good._id)} xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-heart-fill" viewBox="0 0 16 16">
+            <path fillRule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
           </svg>
           }
 
 
           </div>
         <div>
-           {(history.location.pathname.includes(`/catalog/`) || history.location.pathname.includes(`/search/`)) && <button onClick = {() => onAdd(good.name, good.price, good._id,  good.description, good.images)}>В кошик</button>}
+           {(history.location.pathname.includes(`/catalog/`) || history.location.pathname.includes(`/search/`) || history.location.pathname.includes(`/wishes`)) && <button onClick = {() => onAdd(good.name, good.price, good._id,  good.description, good.images)}>В кошик</button>}
            {history.location.pathname.includes(`/orderPage/`) && <button onClick = {() => onAddtoOrder(good._id, good.name, good.images, good.price,   )}>Додати до замовлення</button>} 
         </div>
       </div>

+ 1 - 1
shop/src/components/header.js

@@ -118,7 +118,7 @@ const CBasket = connect(s => ({data: s.basket, basketCount: s.basket.price}), {}
 const Header = ({}) => {
 
     // const [wishes, wishesCount] = useState(0);
-    console.log(connect((s) => ({isLoggedIn: s.auth.payload})))
+    // console.log(connect((s) => ({isLoggedIn: s.auth.payload})))
     return(
         <>
             <div className = "header">

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

@@ -11,8 +11,8 @@ const OrderUpdate = ({orderFind, orderUpdated, orderUpdate, onAddOne, orderClear
     //const [orderData, findOrder] = useState(_id);
     //useEffect(() => orderFind(orderData), [])
     const history = useHistory();
-    console.log(state)
-    console.log(orderId)
+    // console.log(state)
+    // console.log(orderId)
     // useEffect(() => )
     
 
@@ -21,7 +21,7 @@ const OrderUpdate = ({orderFind, orderUpdated, orderUpdate, onAddOne, orderClear
             <div className = "goods">
                 {goodsArr.length > 0 ? goodsArr.map((good) => 
                     
-                    <div className = "oneGood">
+                    <div key = {good._id} className = "oneGood">
                         <OneGood id = {good._id}  name = {good.good.name} price = {good.price} 
                         image = {good.good.images ? `${urlUpload}/${good.good.images[0].url}` : `https://images.ua.prom.st/2259265311_korobka-syurpriz-dlya.jpg`}
                         
@@ -44,7 +44,12 @@ const OrderUpdate = ({orderFind, orderUpdated, orderUpdate, onAddOne, orderClear
             </div>
             <h4>{orderObj.total}грн</h4>
             <div className = "orderUpdateBottom">
-                <button onClick = {() => orderClear()}>Скасувати замовлення</button>
+                <button onClick = {() =>  { 
+                    let id = orderId;
+                    orderClear()
+                    orderUpdate(id)
+                }
+                }>Скасувати замовлення</button>
                 <button onClick = {async () =>  {
                     // await orderFind(orderId)
                     await orderUpdate(orderId, arrForUpdate(goodsArr));

+ 17 - 11
shop/src/components/profilePage.js

@@ -22,7 +22,11 @@ const YourProfile = ({state, orders, loginStatus = {}, updateStatus, updatedUser
     const [password, changePassword] = useState(null);
     const [password2, changePassword2] = useState(null);
     const [isUpdateImg, changeImg] = useState(false);
-    const [falseTrying, OneRty] = useState(false)
+
+    const date = new Date(data ? +data.createdAt : 0);
+    const [showUpdate, onShow] = useState(false);
+    const [searchInput, changeValue] = useState("Пошук");
+
     // const [isUpdatePage, changePage] = useState(false);
     // const [newImage, getImage] = useState({});
 
@@ -49,7 +53,8 @@ const YourProfile = ({state, orders, loginStatus = {}, updateStatus, updatedUser
               await onLogin(newLogin|| data.login, password || nowPassword);
 
            } 
-          // window.location.reload()
+           onShow(false)
+           window.location.reload()
 
       }
     }, [updateStatus])
@@ -57,9 +62,7 @@ const YourProfile = ({state, orders, loginStatus = {}, updateStatus, updatedUser
      
 
      
-     const date = new Date(data ? +data.createdAt : 0);
-     const [showUpdate, onShow] = useState(false);
-     const [searchInput, changeValue] = useState("Пошук");
+
      
 
        console.log(state);
@@ -110,7 +113,7 @@ const YourProfile = ({state, orders, loginStatus = {}, updateStatus, updatedUser
                     
 
                     {(!isAdmin  || (isAdmin && isOwner.id == data._id))&&
-                    <input type = "password" onChange = {(e) => superPassword(e.target.value)} placeholder = "Пароль"/>}
+                    <input type = "password" onBlur = {() => onLogin(data.login, nowPassword)} onChange = {(e) => superPassword(e.target.value)} placeholder = "Пароль"/>}
                     
                     <input onChange = {(e) => changeNick(e.target.value)} placeholder = "Новий нікнейм"/>
                     <input onChange = {(e) => changeLogin(e.target.value)} placeholder = "Новий логін"/>
@@ -124,16 +127,19 @@ const YourProfile = ({state, orders, loginStatus = {}, updateStatus, updatedUser
                       }
                         }/>
                     <button disabled = {(newPicture == "PENDING") ||
-                       ( !isAdmin && !nowPassword) || 
-                        ((isAdmin && isOwner.id == data._id) && !nowPassword )}  
+                       ( !isAdmin && (!nowPassword)) || 
+                        ((isAdmin && isOwner.id == data._id) && !nowPassword ) ||
+                        (Object.keys(loginStatus).length == 0) ||
+                        (loginStatus.status && loginStatus.status == "RESOLVED" && !loginStatus.payload.data.login) 
+                      }  
                          onClick = {
                         async () => {
 
-                          if(!isAdmin || (isAdmin && isOwner.id == data._id)){
+                          // if(!isAdmin || (isAdmin && isOwner.id == data._id)){
 
-                            await onLogin( data.login, nowPassword);
+                          //   await onLogin(data.login, nowPassword);
 
-                           }
+                          //  }
                             let newUser = {};
                             newUser._id = data._id;
                             if(nick){

+ 2 - 2
shop/src/components/searchInput.js

@@ -6,7 +6,7 @@ import { useHistory } from "react-router-dom";
 
 
 
-const SearchInput = ({ classname = "search", input = "Пошук"}) => {
+const SearchInput = ({ classname = "search", input = "Пошук по товарам"}) => {
     const [name, changeValue] = useState("Пошук");
     const history = useHistory();
  
@@ -15,7 +15,7 @@ const SearchInput = ({ classname = "search", input = "Пошук"}) => {
         <div className = {classname}>
             <input type = "text" placeholder = {input} onChange = {e => changeValue(e.target.value)} onKeyDown = {(e) => e.keyCode == 13 && history.push(`/search/${name}`)}/>
             <Link to = {"/search/" + name}>
-                <button id = "searchButton">пуск</button>
+                <button id = "searchButton">Пошук</button>
             </Link>
         </div>
       </>

+ 1 - 1
shop/src/components/wishesPage.js

@@ -14,7 +14,7 @@ const WishesPage = ({arr, state, getGoods, goods = [], wishes, onAdd, addWish, d
             oneObj._id = key
             newArr.push(oneObj)
         }
-        console.log(newArr)
+        // console.log(newArr)
         await getGoods(newArr) 
     }, [wishes])
     return(

+ 1 - 1
shop/src/reducers/actionUpdateOrder.js

@@ -2,7 +2,7 @@ import {actionPromise, gql} from "./index";
 
 
 
-const actionOrderUpdate = (id, arrGoods) => {
+const actionOrderUpdate = (id, arrGoods = []) => {
 
     return async dispatch => {
 

+ 2 - 1
shop/src/reducers/orderUpdateReduser.js

@@ -165,7 +165,8 @@ const actionOrderAddNewGood = (Id, name, images, price) => ({
 });
 
 const actionOrderClear = () => ({
-    type:"ORDER_CLEAR"
+    type:"ORDER_CLEAR",
+
 })