Commit 923faaa6 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

cek

parent c5203ecc
......@@ -132,6 +132,7 @@ class MenuSelection extends React.Component {
const listMenu = [...this.state.listMenu]
listMenu[index].qty = quantity
console.log("HASIL : " + listMenu[index].qty)
this.setState({
listMenu
})
......@@ -156,7 +157,6 @@ class MenuSelection extends React.Component {
handleMin(item, index) {
const list_order_item = this.props.order_item;
let is_xist = list_order_item.find(row => row.id == item.id)
if (is_xist) {
if (is_xist.quantity != 0) {
......@@ -171,7 +171,6 @@ class MenuSelection extends React.Component {
let quantity = 0
for (let i = 0; i < list_order_item.length; i++) {
const row = list_order_item[i];
const qty = list_order_item[i];
if (row.id == item.id) {
quantity = row.quantity
}
......@@ -183,10 +182,6 @@ class MenuSelection extends React.Component {
}
}
}
// this.clearNegatif(item,index)
// ini buat update list menu
}
render() {
......@@ -263,13 +258,6 @@ const mapStateToProps = (state) => {
quantity: state.quantity,
address: state.address,
// qty: state.qty,
// totalOrder: state.totalOrder,
// totalQty: state.totalQty,
// orders: state.orders,
// cart_shop: state.cart_shop,
}
}
......
......@@ -81,6 +81,17 @@ class ShoppingCart extends React.Component {
}
}
}else if (is_xist.quantity === 0){
const order_item = {
id: item.id,
name: item.name,
price: item.price,
}
this.props.reduceQuantityItem(order_item)
}
}
}
......@@ -100,6 +111,7 @@ class ShoppingCart extends React.Component {
const list_order_item = this.props.order_item;
let is_xist = list_order_item.find(row => row.id == item.id)
console.log("INI YA : "+is_xist)
let quantity = 0
if (is_xist) {
......@@ -144,122 +156,23 @@ class ShoppingCart extends React.Component {
pointsused: this.state.kasproPoint
})
}
}
}
componentDidMount() {
this.getBalance()
this.getRate()
}
// getMenuList() {
// let params = {
// outlet_id: "dec1abbb-95d0-46ae-a6cd-2bf306590f15"
// }
// Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list', params).then(res => {
// let data = res.data.data
// this.setState({
// listCategory: data.category,
// listMenu: data.menu
// })
// let last_category = ''
// let list_menu = []
// for (let i = 0; i < data.menu.length; i++) {
// const row = data.menu[i];
// // cari sudah ada belum di redux
// let is_xist = this.props.order_item.find(item => row.id == item.id)
// if (is_xist) {
// row['qty'] = is_xist.quantity
// } else {
// row['qty'] = 0
// }
// if (last_category != row.category.name) {
// let category = {
// "id": row.category.id,
// "name": row.category.name,
// "code": "CATEGORY"
// }
// list_menu.push(category)
// list_menu.push(row)
// last_category = row.category.name
// } else {
// list_menu.push(row)
// }
// }
// this.setState({
// listMenu: list_menu
// })
// })
// }
getRate() {
if (this.props.outlet_id === '') {
let params = {
session_id: this.props.session_id,
outlet_id: '0cb81ffe0c8242bea42d39c9b92ccaac',
address_id: this.props.addressId,
order_item: this.props.order_item
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate', params).then(res => {
console.log("INI LHO CUY : " + JSON.stringify(res.data.data.destination.address))
this.setState({
grabtype: res.data.data.quotes[0].service.type,
grabamount: res.data.data.quotes[0].amount,
grabpickup: res.data.data.quotes[0].estimatedTimeline.pickup,
grabdropoff: res.data.data.quotes[0].estimatedTimeline.dropoff,
grabdestination: res.data.data.destination.address,
})
let setGrabProps = {
grabtype: this.state.grabtype,
grabamount: this.state.grabamount,
grabpickup: this.state.grabpickup,
grabdropoff: this.state.grabdropoff,
grabdestination: this.state.grabdestination,
}
this.props.setGrab(setGrabProps);
let setOrdersProps = {
balanceUsed: this.state.balanceused,
pointused: this.state.pointsused,
}
this.props.setOrder(setOrdersProps);
}).catch(error => {
console.log('ini error ' + error)
})
}else{
let params = {
session_id: this.props.session_id,
outlet_id: this.props.outlet_id,
address_id: this.props.addressId,
order_item: this.props.order_item
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate', params).then(res => {
console.log("INI LHO CUY : " + JSON.stringify(res.data.data.destination.address))
......@@ -292,8 +205,6 @@ class ShoppingCart extends React.Component {
}).catch(error => {
console.log('ini error ' + error)
})
}
}
......
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