Commit dc1734cc authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

trans type

parent a717d5c8
...@@ -27,7 +27,9 @@ const ActionType = { ...@@ -27,7 +27,9 @@ const ActionType = {
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_GRAB : 'SET_GRAB',
SET_ORDERS : 'SET_ORDERS' SET_ORDERS : 'SET_ORDERS',
SET_TYPE : 'SET_TYPE',
SET_TRANS_TYPE : 'SET_TRANS_TYPE'
} }
......
...@@ -49,6 +49,9 @@ const globalState = { ...@@ -49,6 +49,9 @@ const globalState = {
outlet_id: '', outlet_id: '',
name_outlet: '', name_outlet: '',
type_pickup:false,
type_trans:'',
quantity: 0, quantity: 0,
orders: 0, orders: 0,
...@@ -88,6 +91,12 @@ const rootReducer = (state = globalState, action) => { ...@@ -88,6 +91,12 @@ const rootReducer = (state = globalState, action) => {
isEmailverif: action.data.isEmailverif, isEmailverif: action.data.isEmailverif,
} }
} }
case ActionType.SET_TYPE: {
return {
...state,
type_pickup: action.data.type_pickup,
}
}
case ActionType.SET_GRAB: { case ActionType.SET_GRAB: {
return { return {
...state, ...state,
...@@ -112,6 +121,14 @@ const rootReducer = (state = globalState, action) => { ...@@ -112,6 +121,14 @@ const rootReducer = (state = globalState, action) => {
pageEmailConfirmation: action.data.pageEmailConfirmation pageEmailConfirmation: action.data.pageEmailConfirmation
} }
} }
case ActionType.SET_TRANS_TYPE: {
return {
...state,
type_trans: action.data.type_trans
}
}
case ActionType.SET_DEVICE_INFO: { case ActionType.SET_DEVICE_INFO: {
return { return {
...state, ...state,
......
...@@ -45,11 +45,12 @@ class DeliveryAddrees extends React.Component { ...@@ -45,11 +45,12 @@ class DeliveryAddrees extends React.Component {
this.props.setGrab(setGrabProps); this.props.setGrab(setGrabProps);
let OutletChange = {
outlet_id: this.state.outlet_id ,
}
this.props.setChangeOutletProps(OutletChange); // let OutletChange = {
// outlet_id: this.state.outlet_id ,
// }
// this.props.setChangeOutletProps(OutletChange);
}).catch(error => { }).catch(error => {
console.log('ini error ' + error) console.log('ini error ' + error)
...@@ -222,15 +223,15 @@ const mapDispatchToProps = (dispacth) => { ...@@ -222,15 +223,15 @@ const mapDispatchToProps = (dispacth) => {
addressId: setDataAddress.addressId addressId: setDataAddress.addressId
} }
}), }),
setChangeOutletProps: (OutletChange) => dispacth({ // setChangeOutletProps: (OutletChange) => dispacth({
type: ActionType.SET_CHANGE_OUTLET, // type: ActionType.SET_CHANGE_OUTLET,
data: { // data: {
outlet_id: OutletChange.outlet_id, // outlet_id: OutletChange.outlet_id,
} // }
}), // }),
setGrab: (setGrabProps) => dispacth({ setGrab: (setGrabProps) => dispacth({
type: ActionType.SET_GRAB, type: ActionType.SET_GRAB,
......
...@@ -47,7 +47,44 @@ class MenuConfirmation extends React.Component { ...@@ -47,7 +47,44 @@ class MenuConfirmation extends React.Component {
Alert.alert( 'Transaksi Anda Berhasil') Alert.alert( 'Transaksi Anda Berhasil')
this.props.navigation.navigate('Order History'); this.props.navigation.navigate('Order History');
// console.log(res.data.data) let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
}).catch(error => {
let response = error.response.data;
// console.log('error')
Alert.alert(response.msg);
})
}
setPickup() {
let params = {
session_id : this.props.session_id,
outlet_id : this.props.outlet_id,
address_id : this.props.addressId,
trans_type: "Pick Up",
order_item: this.props.order_item,
delivery_charge: 0,
voucher: [],
payment: {
balance: this.props.route.params.balanceUsed,
point: this.props.route.params.pointused
}
}
console.log("INI params : " + JSON.stringify(params) )
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => {
Alert.alert( 'Transaksi Anda Berhasil')
this.props.navigation.navigate('Order History');
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
// console.log('error') // console.log('error')
...@@ -95,20 +132,36 @@ class MenuConfirmation extends React.Component { ...@@ -95,20 +132,36 @@ class MenuConfirmation extends React.Component {
</View> </View>
</View> </View>
<View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between' }}>
{this.props.type_pickup == true? (
null
):(
<View>
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
<Text>Delivery Charge</Text> <Text>Delivery Charge</Text>
</View> </View>
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
<Text>{this.props.grabamount}</Text> <Text>{this.props.grabamount}</Text>
</View> </View>
</View>
)}
</View> </View>
<View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between', borderTopWidth: 1 }}> <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between', borderTopWidth: 1 }}>
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
<Text>Total</Text> <Text>Total</Text>
</View> </View>
{this.props.type_pickup == true? (
<View style={{ margin: 10 }}>
<Text>{this.props.order_total + this.state.diskon }</Text>
</View>
):(
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
<Text>{this.props.order_total + this.props.grabamount + this.state.diskon }</Text> <Text>{this.props.order_total + this.props.grabamount + this.state.diskon }</Text>
</View> </View>
)}
</View> </View>
<View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between', borderTopWidth: 1 }}> <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between', borderTopWidth: 1 }}>
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
...@@ -135,7 +188,12 @@ class MenuConfirmation extends React.Component { ...@@ -135,7 +188,12 @@ class MenuConfirmation extends React.Component {
</View> </View>
</View> </View>
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
{this.props.type_pickup == true ? (
<Button title='order' onPress={() => this.setPickup()}/>
):(
<Button title='order' onPress={() => this.setOrder()}/> <Button title='order' onPress={() => this.setOrder()}/>
)}
</View> </View>
</ScrollView> </ScrollView>
) )
...@@ -166,10 +224,26 @@ const styles = StyleSheet.create({ ...@@ -166,10 +224,26 @@ const styles = StyleSheet.create({
}) })
const mapDispatchToProps = (dispacth) => {
return {
setTypePickup: (typeProps) => dispacth({
type: ActionType.SET_TYPE,
data: {
type_pickup : typeProps.type_pickup
}
}),
}
}
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
console.log(state) console.log(state)
return { return {
session_id: state.session_id, session_id: state.session_id,
type_pickup: state.type_pickup,
outlet_id: state.outlet_id, outlet_id: state.outlet_id,
order_quantity: state.order_quantity, order_quantity: state.order_quantity,
order_total: state.order_total, order_total: state.order_total,
...@@ -188,4 +262,4 @@ const mapStateToProps = (state) => { ...@@ -188,4 +262,4 @@ const mapStateToProps = (state) => {
} }
export default connect(mapStateToProps)(MenuConfirmation) export default connect(mapStateToProps,mapDispatchToProps)(MenuConfirmation)
...@@ -22,7 +22,7 @@ class MenuSelection extends React.Component { ...@@ -22,7 +22,7 @@ class MenuSelection extends React.Component {
} }
} }
componentDidMount() { componentDidMount() {
console.log("INI YA :" + this.props.outlet_id) console.log("INI YA :" + JSON.stringify(this.props.outlet_id) )
this.getMenuList() this.getMenuList()
} }
......
...@@ -71,8 +71,13 @@ class PickupName extends React.Component { ...@@ -71,8 +71,13 @@ class PickupName extends React.Component {
name_outlet:name, name_outlet:name,
} }
let typeProps = {
type_pickup: true,
}
this.props.setChangeOutletProps(OutletChange); this.props.setChangeOutletProps(OutletChange);
this.props.navigation.navigate('Home', { screen: 'MENU' }) this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Menu Select')
} }
getOutlet() { getOutlet() {
...@@ -290,6 +295,14 @@ const mapDispatchToProps = (dispacth) => { ...@@ -290,6 +295,14 @@ const mapDispatchToProps = (dispacth) => {
} }
}), }),
setTypePickup: (typeProps) => dispacth({
type: ActionType.SET_TYPE,
data: {
type_pickup : typeProps.type_pickup
}
}),
} }
} }
......
...@@ -269,6 +269,13 @@ class ShoppingCart extends React.Component { ...@@ -269,6 +269,13 @@ class ShoppingCart extends React.Component {
}) })
} }
checkOut(){
this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused })
}
getBalance() { getBalance() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
...@@ -306,16 +313,22 @@ class ShoppingCart extends React.Component { ...@@ -306,16 +313,22 @@ class ShoppingCart extends React.Component {
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
{ {
this.state.isDelivery == true ? ( this.state.isDelivery == true ? (
<TouchableOpacity >
<Card style={{ margin: 5, padding: 10 }}> <Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text> <Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text>
<Text style={{ textAlign: 'center' }}>{this.props.name_outlet}</Text> <Text style={{ textAlign: 'center' }}>{this.props.name_outlet}</Text>
</Card> </Card>
</TouchableOpacity>
) : ( ) : (
<TouchableOpacity>
<Card style={{ margin: 5, padding: 10 }}> <Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text> <Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text>
<Text style={{ textAlign: 'center' }}>{this.props.address}</Text> <Text style={{ textAlign: 'center' }}>{this.props.address}</Text>
</Card> </Card>
</TouchableOpacity>
) )
} }
</View> </View>
...@@ -500,6 +513,10 @@ class ShoppingCart extends React.Component { ...@@ -500,6 +513,10 @@ class ShoppingCart extends React.Component {
<Text style={{ color: 'gray' }}>{this.props.order_total}</Text> <Text style={{ color: 'gray' }}>{this.props.order_total}</Text>
</View> </View>
</View> </View>
{this.props.type_pickup == true ? (
null
):(
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View> <View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text> <Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text>
...@@ -507,7 +524,8 @@ class ShoppingCart extends React.Component { ...@@ -507,7 +524,8 @@ class ShoppingCart extends React.Component {
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}> <View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>{this.props.grabamount}</Text> <Text style={{ color: 'gray' }}>{this.props.grabamount}</Text>
</View> </View>
</View> </View>)}
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View> <View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Diskon</Text> <Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Diskon</Text>
...@@ -520,9 +538,15 @@ class ShoppingCart extends React.Component { ...@@ -520,9 +538,15 @@ class ShoppingCart extends React.Component {
<View style={{ marginTop: 15, paddingLeft: 20, paddingTop: 10 }}> <View style={{ marginTop: 15, paddingLeft: 20, paddingTop: 10 }}>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>Total</Text> <Text style={{ fontSize: 35, color: '#ccb46c' }}>Total</Text>
</View> </View>
{this.props.type_pickup == true ? (
<View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}> <View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total + this.props.grabamount + this.state.diskon}</Text> <Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total + this.state.diskon}</Text>
</View> </View>
): (
<View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total +this.props.grabamount + this.state.diskon }</Text>
</View>
)}
</View> </View>
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View> <View>
...@@ -533,7 +557,7 @@ class ShoppingCart extends React.Component { ...@@ -533,7 +557,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.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused })} /> <Button title='Checkout' color='#ccb46c' onPress={() => this.checkOut() } />
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
...@@ -712,11 +736,14 @@ const mapDispatchToProps = (dispacth) => { ...@@ -712,11 +736,14 @@ const mapDispatchToProps = (dispacth) => {
pointused: setOrdersProps.pointused, pointused: setOrdersProps.pointused,
} }
}), }),
} }
} }
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
type_pickup : state.type_pickup,
session_id: state.session_id, session_id: state.session_id,
outlet_id: state.outlet_id, outlet_id: state.outlet_id,
name_outlet: state.name_outlet, name_outlet: state.name_outlet,
......
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