Commit 7f8fc28c authored by Trisno's avatar Trisno

fix recalculate, cek menu,balance, verifikasi sebelum checkout

parent 501fb054
...@@ -16,8 +16,8 @@ class ShoppingCart extends React.Component { ...@@ -16,8 +16,8 @@ class ShoppingCart extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
kasproBalance: '', kasproBalance: 0,
kasproPoint: '', kasproPoint: 0,
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
checkedBalancePoint: false, checkedBalancePoint: false,
...@@ -106,6 +106,13 @@ class ShoppingCart extends React.Component { ...@@ -106,6 +106,13 @@ class ShoppingCart extends React.Component {
} }
handleMin(item, index) { handleMin(item, index) {
this.setState({
checkedBalance: false,
checkedPoint: false,
checkedBalancePoint: false,
pointsused: 0,
balanceused: 0
})
// console.log("hai") // console.log("hai")
const list_order_item = this.props.order_item; const list_order_item = this.props.order_item;
// console.log('wakwaw') // console.log('wakwaw')
...@@ -152,7 +159,13 @@ class ShoppingCart extends React.Component { ...@@ -152,7 +159,13 @@ class ShoppingCart extends React.Component {
} }
handleAdd(item, index) { handleAdd(item, index) {
this.setState({
checkedBalance: false,
checkedPoint: false,
checkedBalancePoint: false,
pointsused: 0,
balanceused: 0
})
const order_item = { const order_item = {
id: item.id, id: item.id,
code: item.code, code: item.code,
...@@ -291,7 +304,9 @@ class ShoppingCart extends React.Component { ...@@ -291,7 +304,9 @@ class ShoppingCart extends React.Component {
checkOut() { checkOut() {
if (this.state.checkedBalance == false && this.state.checkedPoint == false && this.state.checkedBalancePoint == false) { if (this.props.order_item.length == 0){
Alert.alert('Error', 'Please choose your order first')
} else if (this.state.checkedBalance == false && this.state.checkedPoint == false && this.state.checkedBalancePoint == false){
Alert.alert('Error', 'Please insert payment methods') Alert.alert('Error', 'Please insert payment methods')
} else { } else {
this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused }) this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused })
...@@ -306,8 +321,8 @@ class ShoppingCart extends React.Component { ...@@ -306,8 +321,8 @@ class ShoppingCart extends React.Component {
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
const { kaspro_balance, kaspro_point } = res.data const { kaspro_balance, kaspro_point } = res.data
this.setState({ this.setState({
kasproBalance: kaspro_balance, kasproBalance: kaspro_balance.replace(/,/g, ''),
kasproPoint: kaspro_point kasproPoint: kaspro_point.replace(/,/g, '')
}) })
// console.log(this.state.kasproBalance, this.state.kasproPoint) // console.log(this.state.kasproBalance, this.state.kasproPoint)
...@@ -317,6 +332,10 @@ class ShoppingCart extends React.Component { ...@@ -317,6 +332,10 @@ class ShoppingCart extends React.Component {
} }
render() { render() {
// console.log('496000'.replace(/,/g, ''))
// console.log(this.state.kasproBalance)
// console.log(this.props.order_total)
// console.log(this.props.order_item.length)
return ( return (
<ScrollView style={styles.container}> <ScrollView style={styles.container}>
<View style={{ flexDirection: 'row', justifyContent: 'center' }}> <View style={{ flexDirection: 'row', justifyContent: 'center' }}>
......
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