Commit 3cfeaef7 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo
parents b165c5d6 c03e6b0e
import ActionType from './globalActionType';
import {Alert} from 'react-native';
import { Alert } from 'react-native';
const globalState = {
......@@ -50,9 +50,9 @@ const globalState = {
outlet_id: '',
name_outlet: '',
type_pickup:true,
type_pickup: true,
type_trans:'',
type_trans: '',
quantity: 0,
orders: 0,
......@@ -64,25 +64,25 @@ const globalState = {
order_quantity: 0,
order_total: 0,
address:'',
addressId:'',
address: '',
addressId: '',
grabtype:'',
grabamount:'',
grabpickup:'',
grabdropoff:'',
grabdestination:'',
grabtype: '',
grabamount: '',
grabpickup: '',
grabdropoff: '',
grabdestination: '',
balanceUsed:'',
pointused:'',
balanceUsed: '',
pointused: '',
trans_id:'',
trans_id: '',
lat:'',
long:'',
lat: '',
long: '',
voucher :[],
value_voucher:''
voucher: [],
value_voucher: ''
}
......@@ -286,7 +286,7 @@ const rootReducer = (state = globalState, action) => {
return {
...state,
address: action.data.address,
addressId:action.data.addressId
addressId: action.data.addressId
}
}
case ActionType.SET_TRANS_ID: {
......@@ -507,7 +507,7 @@ const rootReducer = (state = globalState, action) => {
let addedItem = action.data.item
let is_exist = state.order_item.find(item => addedItem.id == item.id)
let new_items = state.order_item.filter(item=> addedItem.id !== item.id)
let new_items = state.order_item.filter(item => addedItem.id !== item.id)
let order_item = []
if (is_exist) {
// update
......@@ -554,7 +554,9 @@ const rootReducer = (state = globalState, action) => {
grabamount: 0,
outlet_id: '',
name_outlet: '',
address_id: ''
address_id: '',
voucher: [],
value_voucher: ''
}
}
......
......@@ -48,6 +48,74 @@ class MenuConfirmation extends React.Component {
}
// console.log(is_pickup)
if (this.props.value == '') {
let params = {
session_id: this.props.session_id,
outlet_id: this.props.outlet_id,
address_id: this.props.addressId,
trans_type: this.state.type,
order_item: this.props.order_item,
delivery_charge: this.props.grabamount,
voucher: [],
payment: {
balance: this.props.route.params.balanceUsed,
point: this.props.route.params.pointused
}
}
console.log(params)
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => {
let data_order = res.data.data.id
this.setState({
spinner: false,
})
let transIdProps = {
trans_id: data_order
}
this.props.setTransId(transIdProps);
// add API use voucher here
// let param = {
// session_id: this.props.session_id,
// reward_id: this.props.voucher.id,
// lat: this.props.lat,
// long: this.props.long
// }
// Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/use_reward', param).then(res => {
// console.log(res.data)
// }).catch(error => {
// const { navigation } = this.props
// let response = error.response.data
// session(response, navigation)
// Alert.alert(response.msg);
// this.setState({
// spinner: false,
// })
// })
Alert.alert(
"Berhasil",
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi",
[
{ text: "OK", onPress: () => this.orderSuccess() }
],
{ cancelable: false }
);
}).catch(error => {
const { navigation } = this.props
let response = error.response.data
session(response, navigation)
Alert.alert(response.msg);
this.setState({
spinner: false,
})
})
} else {
let params = {
session_id: this.props.session_id,
outlet_id: this.props.outlet_id,
......@@ -117,6 +185,7 @@ class MenuConfirmation extends React.Component {
})
})
}
}
orderSuccess = () => {
this.props.setOrderFinish()
......@@ -168,7 +237,14 @@ class MenuConfirmation extends React.Component {
<Text>Voucher Discount</Text>
</View>
<View style={{ margin: 10 }}>
{
this.props.value_voucher == '' ? (
<Text>0</Text>
) : (
<Text>{this.props.voucher.reward.value}</Text>
)
}
</View>
</View>
<View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between' }}>
......@@ -194,11 +270,24 @@ class MenuConfirmation extends React.Component {
</View>
{this.props.type_pickup == true ? (
<View style={{ margin: 10 }}>
{
this.props.value_voucher == '' ? (
<Text>{this.props.order_total}</Text>
) : (
<Text>{Math.max(0, this.props.order_total - this.props.voucher.reward.value)}</Text>
)
}
</View>
) : (
<View style={{ margin: 10 }}>
{
this.props.value_voucher == '' ? (
<Text>{this.props.order_total + this.props.grabamount + this.state.diskon}</Text>
) : (
<Text>{Math.max(this.props.order_total + this.props.grabamount - this.props.voucher.reward.value)}</Text>
)
}
</View>
)}
......
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