Commit 6102760c authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

ini rdux grab dan order

parent 630880ee
...@@ -25,7 +25,9 @@ const ActionType = { ...@@ -25,7 +25,9 @@ const ActionType = {
ADD_TO_CHART:'ADD_TO_CHART', ADD_TO_CHART:'ADD_TO_CHART',
REMOVE_FROM_CHART:'REMOVE_FROM_CHART', REMOVE_FROM_CHART:'REMOVE_FROM_CHART',
REDUCE_QUANTITY_ITEM :'REDUCE_QUANTITY_ITEM', REDUCE_QUANTITY_ITEM :'REDUCE_QUANTITY_ITEM',
SET_ADDRESS :'SET_ADDRESS' SET_ADDRESS :'SET_ADDRESS',
SET_GRAB : 'SET_GRAB',
SET_ORDERS : 'SET_ORDERS'
} }
......
...@@ -60,7 +60,16 @@ const globalState = { ...@@ -60,7 +60,16 @@ const globalState = {
address:'', address:'',
addressId:'' addressId:'',
grabtype:'',
grabamount:'',
grabpickup:'',
grabdropoff:'',
grabdestination:'',
balanceUsed:'',
pointused:'',
} }
const rootReducer = (state = globalState, action) => { const rootReducer = (state = globalState, action) => {
...@@ -79,6 +88,24 @@ const rootReducer = (state = globalState, action) => { ...@@ -79,6 +88,24 @@ const rootReducer = (state = globalState, action) => {
isEmailverif: action.data.isEmailverif, isEmailverif: action.data.isEmailverif,
} }
} }
case ActionType.SET_GRAB: {
return {
...state,
grabtype: action.data.grabtype,
grabamount: action.data.grabamount,
grabpickup: action.data.grabpickup,
grabdropoff: action.data.grabdropoff,
grabdestination: action.data.grabdestination,
}
}
case ActionType.SET_ORDERS: {
return {
...state,
balanceUsed: action.data.balanceUsed,
pointused: action.data.pointused,
}
}
case ActionType.SET_PAGE: { case ActionType.SET_PAGE: {
return { return {
...state, ...state,
......
...@@ -16,6 +16,16 @@ class MenuConfirmation extends React.Component { ...@@ -16,6 +16,16 @@ class MenuConfirmation extends React.Component {
} }
} }
componentDidMount(){
console.log(" DESTINASI : "+ this.props.grabdestination)
console.log("ONGKIR"+ this.props.grabamount)
console.log("drop off"+this.props.grabdropoff)
console.log("pickup"+this.props.grabpickup)
console.log("type" +this.props.grabtype)
console.log("BALANCED" +this.props.balanceUsed)
console.log("POINT" +this.props.pointsused)
}
render() { render() {
console.log(this.props) console.log(this.props)
let total = 0 let total = 0
...@@ -136,7 +146,14 @@ const mapStateToProps = (state) => { ...@@ -136,7 +146,14 @@ const mapStateToProps = (state) => {
order_total: state.order_total, order_total: state.order_total,
order_item: state.order_item, order_item: state.order_item,
quantity: state.quantity, quantity: state.quantity,
address: state.address address: state.address,
grabtype: state.grabtype,
grabamount: state.grabamount,
grabpickup: state.grabpickup,
grabdropoff:state.grabdropoff,
grabdestination:state.grabdestination,
balanceUsed: state.balanceUsed,
pointused: state.pointsused,
} }
} }
......
...@@ -28,7 +28,12 @@ class ShoppingCart extends React.Component { ...@@ -28,7 +28,12 @@ class ShoppingCart extends React.Component {
diskon: 0, diskon: 0,
isDelivery: false, isDelivery: false,
isPickUp: false, isPickUp: false,
order_item: this.props.order_item order_item: this.props.order_item,
grabtype: '',
grabamount: '',
grabpickup: '',
grabdropoff: '',
grabdestination: '',
// dummyBalance : 155000, // dummyBalance : 155000,
// dummyPoint : 20000 // dummyPoint : 20000
} }
...@@ -96,10 +101,10 @@ class ShoppingCart extends React.Component { ...@@ -96,10 +101,10 @@ class ShoppingCart extends React.Component {
const order_item = { const order_item = {
id: item.id, id: item.id,
code:item.code, code: item.code,
name: item.name, name: item.name,
description: item.description, description: item.description,
note:'jangan garing', note: 'jangan garing',
price: parseInt(item.price), price: parseInt(item.price),
} }
...@@ -167,7 +172,7 @@ class ShoppingCart extends React.Component { ...@@ -167,7 +172,7 @@ class ShoppingCart extends React.Component {
this.getMenuList() this.getMenuList()
this.getBalance() this.getBalance()
// this.getRate() this.getRate()
} }
getMenuList() { getMenuList() {
...@@ -229,10 +234,37 @@ class ShoppingCart extends React.Component { ...@@ -229,10 +234,37 @@ class ShoppingCart extends React.Component {
order_item: this.props.order_item order_item: this.props.order_item
} }
console.log("INI PARAMETER : " + JSON.stringify(params) ); console.log("INI PARAMETER : " + JSON.stringify(params));
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate', params).then(res => {
console.log("INI : " + JSON.stringify( res.data)) 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 => { }).catch(error => {
console.log('ini error ' + error) console.log('ini error ' + error)
}) })
...@@ -499,7 +531,7 @@ class ShoppingCart extends React.Component { ...@@ -499,7 +531,7 @@ class ShoppingCart extends React.Component {
</View> </View>
</View> </View>
<View style={{ margin: 20, }}> <View style={{ margin: 20, }}>
<Button title='Checkout' color='#ccb46c' onPress={() => this.getRate()} /> <Button title='Checkout' color='#ccb46c' onPress={() => this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused })} />
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
...@@ -661,6 +693,24 @@ const mapDispatchToProps = (dispacth) => { ...@@ -661,6 +693,24 @@ const mapDispatchToProps = (dispacth) => {
item: item item: item
} }
}), }),
setGrab: (setGrabProps) => dispacth({
type: ActionType.SET_GRAB,
data: {
grabtype: setGrabProps.grabtype,
grabamount: setGrabProps.grabamount,
grabpickup: setGrabProps.grabpickup,
grabdropoff: setGrabProps.grabdropoff,
grabdestination: setGrabProps.grabdestination,
}
}),
setOrder: (setOrdersProps) => dispacth({
type: ActionType.SET_ORDERS,
data: {
balanceUsed: setOrdersProps.balanceUsed,
pointused: setOrdersProps.pointsused,
}
}),
} }
} }
......
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