Commit ce1583f3 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

update baeu

parent bb2a774a
......@@ -23,10 +23,7 @@ const ActionType = {
SET_CHANGE_OUTLET:'SET_CHANGE_OUTLET',
SET_CHANGE_SHOP:'SET_CHANGE_SHOP',
ADD_TO_CHART:'ADD_TO_CHART',
<<<<<<< HEAD
=======
REMOVE_FROM_CHART:'REMOVE_FROM_CHART',
>>>>>>> 1f2878b320428b9f86712643addd48e2a9859793
}
......
......@@ -207,22 +207,28 @@ const rootReducer = (state = globalState, action) => {
}
}
case ActionType.ADD_TO_CHART:{
<<<<<<< HEAD
let addedItem = action.data.order_item
let is_exist = cart_shop.find(item => addedItem.id == item.id)
=======
let addedItem = action.data.item
let is_exist = order_item.find(item => addedItem.id == item.id)
>>>>>>> 1f2878b320428b9f86712643addd48e2a9859793
let is_exist = state.order_item.find(item => addedItem.id == item.id)
let order_item = state.order_item;
if (is_exist) {
// update
addedItem.quantity += 1
console.log('Update : ' + JSON.stringify(addedItem))
let quantity = state.order_quantity + 1
let total = parseInt(state.order_total) + parseInt(addedItem.price)
return{
...state,
order_quantity: quantity,
order_total: total
}
} else {
// add
addedItem.quantity = 1
}
let quantity = order_quantity + 1
let total = order_total + addedItem.price
console.log('Baru : ' + JSON.stringify(addedItem))
let quantity = state.order_quantity + 1
let total = parseInt(state.order_total) + parseInt(addedItem.price)
return{
...state,
......@@ -231,6 +237,7 @@ const rootReducer = (state = globalState, action) => {
order_total: total
}
}
}
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment