|
@@ -5,10 +5,10 @@ import {BrowserRouter as Router, Route, Link, Switch, Redirect, useHistory} from
|
|
import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
|
|
import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
|
|
|
|
|
|
|
|
|
|
-const OneOrderGood = ({img, name, count, price}) => {
|
|
|
|
|
|
+const OneOrderGood = ({img, name, count, keyprop, price}) => {
|
|
|
|
|
|
return(
|
|
return(
|
|
- <div className = "oneOrderGood">
|
|
|
|
|
|
+ <div key = {keyprop} className = "oneOrderGood">
|
|
<div className = "goodInner">
|
|
<div className = "goodInner">
|
|
<img src={img ? `${urlUpload}/${img}`: 'https://pngicon.ru/file/uploads/picca-1.png'} />
|
|
<img src={img ? `${urlUpload}/${img}`: 'https://pngicon.ru/file/uploads/picca-1.png'} />
|
|
<p>{name}</p>
|
|
<p>{name}</p>
|
|
@@ -23,36 +23,39 @@ const OneOrderGood = ({img, name, count, price}) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-const OneOrder = ({price, total, _id, img, goodsArr = [],count, createdAt}) => {
|
|
|
|
|
|
+const OneOrder = ({price, total, _id, img, isAdmin, keyprop, goodsArr = [],count, createdAt}) => {
|
|
const date = new Date(+createdAt);
|
|
const date = new Date(+createdAt);
|
|
-
|
|
|
|
|
|
+ const history = useHistory();
|
|
return(
|
|
return(
|
|
|
|
|
|
- <div key = {_id} className = "oneOrder">
|
|
|
|
- <div>
|
|
|
|
|
|
+ <div key = {keyprop} className = "oneOrder">
|
|
|
|
+ <div key = {Math.random()}>
|
|
<h5>
|
|
<h5>
|
|
Створено: {`${date.getDate()}. ${date.getMonth() + 1}. ${date.getFullYear()} о ${date.getHours()}: ${date.getMinutes()}: ${date.getSeconds()} `}
|
|
Створено: {`${date.getDate()}. ${date.getMonth() + 1}. ${date.getFullYear()} о ${date.getHours()}: ${date.getMinutes()}: ${date.getSeconds()} `}
|
|
</h5>
|
|
</h5>
|
|
- <div className = "oneOrderInner">
|
|
|
|
|
|
+ <div key = {Math.random()} className = "oneOrderInner">
|
|
<div className = "oneOrderGoods">
|
|
<div className = "oneOrderGoods">
|
|
- {(!goodsArr || goodsArr.length == 0) && <div>Замовлення скасовано</div>}
|
|
|
|
|
|
+ {(!goodsArr || goodsArr.length == 0) && <div key = {`${_id}${Math.random}`}>Замовлення скасовано</div>}
|
|
{goodsArr && goodsArr.map((good) => {
|
|
{goodsArr && goodsArr.map((good) => {
|
|
if(good.good == null || good.good.name == null) {
|
|
if(good.good == null || good.good.name == null) {
|
|
return(
|
|
return(
|
|
- <div>Товар відмінено</div>
|
|
|
|
|
|
+ <div key = {`${Math.random()}`}>Товар відмінено</div>
|
|
)
|
|
)
|
|
} else {
|
|
} else {
|
|
|
|
|
|
return(
|
|
return(
|
|
- <>
|
|
|
|
- <OneOrderGood name = {good.good ? good.good.name : "товар"} count = {good.count} price = {good.good ? good.good.price : "0"} img = {good.good && good.good.images && good.good.images[0].url ? `${good.good.images[0].url}` : `https://images.ua.prom.st/2259265311_korobka-syurpriz-dlya.jpg`}/>
|
|
|
|
|
|
+
|
|
|
|
+ <OneOrderGood key = {Math.random()} name = {good.good ? good.good.name : "товар"} count = {good.count} price = {good.good ? good.good.price : ""} img = {good.good && good.good.images && good.good.images[0].url ? `${good.good.images[0].url}` : `https://images.ua.prom.st/2259265311_korobka-syurpriz-dlya.jpg`}/>
|
|
|
|
|
|
- </>
|
|
|
|
|
|
+
|
|
)
|
|
)
|
|
}
|
|
}
|
|
})}
|
|
})}
|
|
</div>
|
|
</div>
|
|
- <div> {<h5>{(total && total > 0) ? `Сума замовлення: ${total}грн` : ""}</h5>}</div>
|
|
|
|
|
|
+ <div> {<h5>{(total && total > 0 && total != 0) ? `Сума замовлення: ${total}грн` : ""}</h5>}
|
|
|
|
+ {isAdmin && goodsArr && total > 0 && <button onClick = {() => history.push(`/orderPage/${_id}`)}>Редагувати</button>}
|
|
|
|
+
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@@ -70,8 +73,8 @@ const OrdersList = ({orders = [], status, ordersFind, owner, isAdmin, match:{par
|
|
function ordersOnPage(arr) {
|
|
function ordersOnPage(arr) {
|
|
let newArr = arr.slice();
|
|
let newArr = arr.slice();
|
|
newArr.reverse()
|
|
newArr.reverse()
|
|
-
|
|
|
|
- return newArr.map((order) => <OneOrder _id = {order._id} createdAt = {order.createdAt} goodsArr = {order.orderGoods} total = {order.total}/>)}
|
|
|
|
|
|
+ console.log(newArr)
|
|
|
|
+ return newArr.map((order) => <OneOrder isAdmin = {isAdmin} key = {order._id} _id = {order._id} createdAt = {order.createdAt} goodsArr = {order.orderGoods} total = {order.total}/>)}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -86,10 +89,10 @@ const OrdersList = ({orders = [], status, ordersFind, owner, isAdmin, match:{par
|
|
|
|
|
|
|
|
|
|
return(
|
|
return(
|
|
- <>
|
|
|
|
|
|
+ <div key = "ordersDiv">
|
|
{ (status == "RESOLVED" && orders) &&
|
|
{ (status == "RESOLVED" && orders) &&
|
|
|
|
|
|
- <div className = "ordersList">
|
|
|
|
|
|
+ <div key = {Math.random} className = "ordersList">
|
|
<h4>Попередні замовлення</h4>
|
|
<h4>Попередні замовлення</h4>
|
|
{orders.length == 0 &&
|
|
{orders.length == 0 &&
|
|
<div className = "noOrders" onClick = {() => history.push("/catalog/")}>
|
|
<div className = "noOrders" onClick = {() => history.push("/catalog/")}>
|
|
@@ -100,7 +103,7 @@ const OrdersList = ({orders = [], status, ordersFind, owner, isAdmin, match:{par
|
|
|
|
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
- </>
|
|
|
|
|
|
+ </div>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|