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

trans type

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