Commit 9a70f352 authored by Afid's avatar Afid

bug pertama kali langsung edit quantity tidak bisa

parent 4aff7651
......@@ -606,6 +606,7 @@ const rootReducer = (state = globalState, action) => {
// ini kalau sudah ada diupdate
if (!isNaN(parseInt(new_quantity))) {
console.log('Number : ' + parseInt(new_quantity))
exist = false
for (let i = 0; i < state.order_item.length; i++) {
const row = state.order_item[i];
......@@ -616,31 +617,42 @@ const rootReducer = (state = globalState, action) => {
exist = true
}
quantity += parseInt(row.quantity)
total += parseInt(row.price) * parseInt(row.quantity)
if (row.quantity != 0) {
if (row.quantity > 0) {
quantity += parseInt(row.quantity)
total += parseInt(row.price) * parseInt(row.quantity)
list_item.push(row)
}
}
// kalo belum ada
if (!exist) {
list_item.push(item)
item.quantity = parseInt(new_quantity)
if (item.quantity < 0) {
item.quantity = 0
}
console.log('sama sekali blm ada : ' + JSON.stringify(item))
if (item.quantity > 0) {
quantity += parseInt(item.quantity)
total += parseInt(item.price) * parseInt(item.quantity)
list_item.push(item)
}
}
for (let i = 0; i < state.menu_item.length; i++) {
const row = state.menu_item[i];
console.log('MENU : ' + JSON.stringify(row))
// cari sudah ada belum di redux
let is_xist = list_item.find(it => it.id == row.id)
if (is_xist) {
row['qty'] = is_xist.quantity
row['qty'] = is_xist.quantity
} else {
row['qty'] = 0
console.log(parseInt(new_quantity))
if (parseInt(new_quantity) < 0) {
row.qty = 0
} else {
row.qty = 0
}
}
list_menu.push(row)
}
return {
......
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