|
@@ -44,8 +44,10 @@ const mapStateToProps = state => ({
|
|
|
state: state,
|
|
|
basket: state.basket,
|
|
|
GoodsArr: arrFromObj(ObjFilter(state.basket, "price")),
|
|
|
- order: orderArr(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
|
|
|
});
|
|
|
|
|
|
|
|
@@ -58,14 +60,16 @@ const mapStateToProps = state => ({
|
|
|
}, dispatch);
|
|
|
|
|
|
|
|
|
-const BasketPage = ({state, orderDeal, basket, GoodsArr, onAdd, onDel, onClear, onOrder, order}) => {
|
|
|
+const BasketPage = ({state, orderDeal, orderDone, basket, GoodsArr, onAdd, onDel, onClear, onOrder, order}) => {
|
|
|
const history = useHistory();
|
|
|
+ console.log(state)
|
|
|
+ console.log(orderDone)
|
|
|
|
|
|
- if(!basket.price){
|
|
|
+ if(!basket.price && !orderDone){
|
|
|
return(
|
|
|
<div>Зайдіть у каталог щоб замовити, та повертайтесь</div>
|
|
|
)
|
|
|
- }
|
|
|
+ } else if(basket.price) {
|
|
|
return (
|
|
|
<>
|
|
|
<div className = "basketInner">
|
|
@@ -90,7 +94,7 @@ const BasketPage = ({state, orderDeal, basket, GoodsArr, onAdd, onDel, onClear,
|
|
|
if(localStorage.authToken) {
|
|
|
onOrder(order);
|
|
|
onClear(basket);
|
|
|
- history.push("./well")
|
|
|
+ // history.push("./order")
|
|
|
} else{
|
|
|
history.push("./login")
|
|
|
}
|
|
@@ -101,7 +105,11 @@ const BasketPage = ({state, orderDeal, basket, GoodsArr, onAdd, onDel, onClear,
|
|
|
</div>
|
|
|
</div>
|
|
|
</>
|
|
|
- )
|
|
|
+ )} else if(orderDone) {
|
|
|
+ return(
|
|
|
+ <>{ history.push("./order")}</>
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|