Commit 605b08d4 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

Merge branch 'master' of ssh://repo.cs.co.id:2222/wahyu/bahanoprek

# Conflicts:
#	view/Account.js
#	view/Home.js
#	view/MenuConfirmation.js
parents 9ca2ec6b 5330b388
...@@ -30,8 +30,8 @@ const ActionType = { ...@@ -30,8 +30,8 @@ const ActionType = {
SET_ORDERS : 'SET_ORDERS', SET_ORDERS : 'SET_ORDERS',
SET_TYPE : 'SET_TYPE', SET_TYPE : 'SET_TYPE',
SET_TRANS_TYPE : 'SET_TRANS_TYPE', SET_TRANS_TYPE : 'SET_TRANS_TYPE',
SET_RECALCULATE: 'SET_RECALCULATE' SET_RECALCULATE: 'SET_RECALCULATE',
SET_ORDER_FINISH: 'SET_ORDER_FINISH',
} }
export default ActionType; export default ActionType;
\ No newline at end of file
...@@ -49,7 +49,7 @@ const globalState = { ...@@ -49,7 +49,7 @@ const globalState = {
outlet_id: '', outlet_id: '',
name_outlet: '', name_outlet: '',
type_pickup:false, type_pickup:true,
type_trans:'', type_trans:'',
...@@ -92,19 +92,26 @@ const rootReducer = (state = globalState, action) => { ...@@ -92,19 +92,26 @@ const rootReducer = (state = globalState, action) => {
} }
} }
case ActionType.SET_TYPE: { case ActionType.SET_TYPE: {
if (action.data.type_pickup) {
delivery_amount = 0
} else {
delivery_amount = state.grabamount
}
return { return {
...state, ...state,
type_pickup: action.data.type_pickup, type_pickup: action.data.type_pickup,
grabamount: delivery_amount
} }
} }
case ActionType.SET_GRAB: { case ActionType.SET_GRAB: {
return { return {
...state, ...state,
grabtype: action.data.grabtype, // grabtype: action.data.grabtype,
grabamount: action.data.grabamount, grabamount: action.data.grabamount,
grabpickup: action.data.grabpickup, // grabpickup: action.data.grabpickup,
grabdropoff: action.data.grabdropoff, // grabdropoff: action.data.grabdropoff,
grabdestination: action.data.grabdestination, // grabdestination: action.data.grabdestination,
} }
} }
case ActionType.SET_ORDERS: { case ActionType.SET_ORDERS: {
...@@ -408,6 +415,21 @@ const rootReducer = (state = globalState, action) => { ...@@ -408,6 +415,21 @@ const rootReducer = (state = globalState, action) => {
} }
} }
case ActionType.SET_ORDER_FINISH: {
return {
...state,
type_pickup: true,
order_total: 0,
order_quantity: 0,
order_item: [],
grabamount: 0,
outlet_id: '',
name_outlet: '',
address_id: ''
}
}
default: default:
return state; return state;
} }
......
...@@ -40,9 +40,15 @@ class Account extends React.Component { ...@@ -40,9 +40,15 @@ class Account extends React.Component {
} }
componentDidMount() { componentDidMount() {
<<<<<<< HEAD
this._getPermissions() this._getPermissions()
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
this._getPermissions() this._getPermissions()
=======
this._getProfile()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this._getProfile()
>>>>>>> 5330b388dc7213ae44adb8e73631468949e34c73
}); });
} }
......
...@@ -4,14 +4,15 @@ import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler'; ...@@ -4,14 +4,15 @@ import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import ravLog from '../helper/debug';
class DeliveryAddrees extends React.Component { class DeliveryAddrees extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
data: [], data: [],
outlet_id: '', // outlet_id: '',
grabamount: '' // grabamount: ''
} }
} }
...@@ -62,24 +63,29 @@ class DeliveryAddrees extends React.Component { ...@@ -62,24 +63,29 @@ class DeliveryAddrees extends React.Component {
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 => {
this.setState({ // this.setState({
grabamount: res.data.data.amount, // grabamount: res.data.data.amount,
grabdestination: res.data.data.outlet_name, // grabdestination: res.data.data.outlet_name,
}) // })
let setGrabProps = { let setGrabProps = {
grabdestination: this.state.grabdestination, // grabdestination: this.state.grabdestination,
grabamount: this.state.grabamount, // grabamount: this.state.grabamount,
grabamount: res.data.data.amount
} }
let OutletChange = { let OutletChange = {
outlet_id: res.data.data.outlet_id, outlet_id: res.data.data.outlet_id,
name_outlet: res.data.data.outlet_name, name_outlet: res.data.data.outlet_name,
} }
this.props.setGrab(setGrabProps); this.props.setGrab(setGrabProps);
this.props.setChangeOutletProps(OutletChange); this.props.setChangeOutletProps(OutletChange);
console.log("INI SUKSES RESPONNYA ") console.log("INI SUKSES RESPONNYA ")
console.log('Delivery Amount : ' + res.data.data.amount)
// let setOrdersProps = { // let setOrdersProps = {
// balanceUsed: this.state.balanceused, // balanceUsed: this.state.balanceused,
...@@ -109,6 +115,8 @@ class DeliveryAddrees extends React.Component { ...@@ -109,6 +115,8 @@ class DeliveryAddrees extends React.Component {
this.getRate() this.getRate()
this.props.setTypePickup(false)
// console.log(this.props) // console.log(this.props)
if (this.props.route.params.from == 'shoppingCart') { if (this.props.route.params.from == 'shoppingCart') {
...@@ -261,6 +269,12 @@ const mapDispatchToProps = (dispacth) => { ...@@ -261,6 +269,12 @@ const mapDispatchToProps = (dispacth) => {
} }
}), }),
setTypePickup: (type) => dispacth({
type: ActionType.SET_TYPE,
data: {
type_pickup: type
}
}),
} }
} }
......
...@@ -34,8 +34,7 @@ class Home extends React.Component { ...@@ -34,8 +34,7 @@ class Home extends React.Component {
this._renderCarousell() this._renderCarousell()
this._account(); this._account();
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
// do something this._getPermissions()
// this._getPermissions()
this._renderCarousell() this._renderCarousell()
this._account(); this._account();
}); });
...@@ -141,20 +140,14 @@ class Home extends React.Component { ...@@ -141,20 +140,14 @@ class Home extends React.Component {
}) })
} }
_pickup() { _orderNow = () => {
let typeProps = { if (this.props.outlet_id != '' && this.props.name_outlet != '') {
type_pickup: true, this.props.setTypePickup(true)
this.props.navigation.navigate("Menu Select")
} else {
Alert.alert('Belum dapat outlet terdekat')
} }
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Pickup Name', { from: 'home' });
}
_order() {
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Delivery Address', { from: 'home' });
} }
...@@ -200,7 +193,7 @@ class Home extends React.Component { ...@@ -200,7 +193,7 @@ class Home extends React.Component {
<View style={styles.card}> <View style={styles.card}>
<Card> <Card>
<View style={{ flexDirection: 'row', justifyContent: 'center' }}> <View style={{ flexDirection: 'row', justifyContent: 'center' }}>
<TouchableOpacity style={styles.buttonDelivery} onPress={() => this._order()}> <TouchableOpacity style={styles.buttonDelivery} onPress={() => this._delivery() }>
<Text style={{ textAlign: 'center', color: '#354175', fontWeight: 'bold' }}>{i18n.t('delivery')}</Text> <Text style={{ textAlign: 'center', color: '#354175', fontWeight: 'bold' }}>{i18n.t('delivery')}</Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity style={styles.buttonPickup} onPress={() => this._pickup()}> <TouchableOpacity style={styles.buttonPickup} onPress={() => this._pickup()}>
...@@ -217,11 +210,7 @@ class Home extends React.Component { ...@@ -217,11 +210,7 @@ class Home extends React.Component {
Excelso {this.props.name_outlet} Excelso {this.props.name_outlet}
</Text> </Text>
)} )}
<TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={() => <TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={() => this._orderNow()}>
this.props.navigation.navigate('Home', {
screen: 'MENU',
params: { user: 'jckma' },
})}>
<Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>{i18n.t('orderNow')}</Text> <Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>{i18n.t('orderNow')}</Text>
</TouchableOpacity> </TouchableOpacity>
</Card> </Card>
...@@ -365,14 +354,14 @@ const mapDispatchToProps = (dispacth) => { ...@@ -365,14 +354,14 @@ const mapDispatchToProps = (dispacth) => {
name_outlet: OutletChange.name_outlet, name_outlet: OutletChange.name_outlet,
} }
}), }),
setTypePickup: (typeProps) => dispacth({ setTypePickup: (type) => dispacth({
type: ActionType.SET_TYPE, type: ActionType.SET_TYPE,
data: { data: {
type_pickup: type
type_pickup: typeProps.type_pickup
} }
}), }),
} }
} }
......
...@@ -31,15 +31,21 @@ class MenuConfirmation extends React.Component { ...@@ -31,15 +31,21 @@ class MenuConfirmation extends React.Component {
} }
setOrder() { setOrder(is_pickup) {
this.setState({ this.setState({
spinner: true, spinner: true,
}) })
if (is_pickup) {
type = 'Pick Up'
} else {
type = 'Delivery'
}
let params = { let params = {
session_id : this.props.session_id, session_id : this.props.session_id,
outlet_id : this.props.outlet_id, outlet_id : this.props.outlet_id,
address_id : this.props.addressId, address_id : this.props.addressId,
trans_type: "Delivery", trans_type: type,
order_item: this.props.order_item, order_item: this.props.order_item,
delivery_charge: this.props.grabamount, delivery_charge: this.props.grabamount,
voucher: [], voucher: [],
...@@ -58,19 +64,11 @@ class MenuConfirmation extends React.Component { ...@@ -58,19 +64,11 @@ class MenuConfirmation extends React.Component {
"Berhasil", "Berhasil",
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi", "Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi",
[ [
{ text: "OK", onPress: () => this.props.navigation.reset({ { text: "OK", onPress: () => this.orderSuccess()}
routes: [{ name: 'Home' }]
})}
], ],
{ cancelable: false } { cancelable: false }
); );
let typeProps = {
type_pickup: true,
}
this.props.setTypePickup(typeProps);
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
// console.log('error') // console.log('error')
...@@ -81,59 +79,14 @@ class MenuConfirmation extends React.Component { ...@@ -81,59 +79,14 @@ class MenuConfirmation extends React.Component {
}) })
} }
orderSuccess = () => {
setPickup() { this.props.setOrderFinish()
this.setState({ this.props.navigation.reset({
spinner: true, routes: [{ name: 'Home' }]
})
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 => {
this.setState({
spinner: false,
})
Alert.alert(
"Berhasil",
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi",
[
{ text: "OK", onPress: () => this.props.navigation.navigate('Home', {
screen: 'ORDER',
params: { user: 'jane' },
})}
],
{ cancelable: false }
);
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
}).catch(error => {
let response = error.response.data;
// console.log('error')
Alert.alert(response.msg);
this.setState({
spinner: false,
})
}) })
} }
render() { render() {
console.log(this.props) console.log(this.props)
let total = 0 let total = 0
...@@ -235,12 +188,7 @@ class MenuConfirmation extends React.Component { ...@@ -235,12 +188,7 @@ 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.setOrder(this.props.type_pickup)}/>
<Button title='order' onPress={() => this.setPickup()}/>
):(
<Button title='order' onPress={() => this.setOrder()}/>
)}
</View> </View>
</ScrollView> </ScrollView>
) )
...@@ -274,15 +222,9 @@ const styles = StyleSheet.create({ ...@@ -274,15 +222,9 @@ const styles = StyleSheet.create({
const mapDispatchToProps = (dispacth) => { const mapDispatchToProps = (dispacth) => {
return { return {
setOrderFinish: () => dispacth({
setTypePickup: (typeProps) => dispacth({ type: ActionType.SET_ORDER_FINISH
type: ActionType.SET_TYPE, })
data: {
type_pickup : typeProps.type_pickup
}
}),
} }
} }
......
...@@ -71,10 +71,6 @@ class PickupName extends React.Component { ...@@ -71,10 +71,6 @@ class PickupName extends React.Component {
name_outlet:name, name_outlet:name,
} }
let typeProps = {
type_pickup: true,
}
// let recalculateProps = { // let recalculateProps = {
// order_total: 0, // order_total: 0,
// order_quantity:0, // order_quantity:0,
...@@ -82,7 +78,7 @@ class PickupName extends React.Component { ...@@ -82,7 +78,7 @@ class PickupName extends React.Component {
// } // }
// this.props.setRecalculate(recalculateProps) // this.props.setRecalculate(recalculateProps)
this.props.setChangeOutletProps(OutletChange); this.props.setChangeOutletProps(OutletChange);
this.props.setTypePickup(typeProps); this.props.setTypePickup(true);
if (this.props.route.params.from == 'shoppingCart') { if (this.props.route.params.from == 'shoppingCart') {
this.props.navigation.navigate('Shopping Cart') this.props.navigation.navigate('Shopping Cart')
...@@ -314,12 +310,10 @@ const mapDispatchToProps = (dispacth) => { ...@@ -314,12 +310,10 @@ const mapDispatchToProps = (dispacth) => {
} }
}), }),
setTypePickup: (typeProps) => dispacth({ setTypePickup: (type) => dispacth({
type: ActionType.SET_TYPE, type: ActionType.SET_TYPE,
data: { data: {
type_pickup : type
type_pickup : typeProps.type_pickup
} }
}), }),
setRecalculate: (recalculateProps) => dispacth({ setRecalculate: (recalculateProps) => dispacth({
......
...@@ -42,17 +42,19 @@ class ShoppingCart extends React.Component { ...@@ -42,17 +42,19 @@ class ShoppingCart extends React.Component {
componentDidMount() { componentDidMount() {
this.getRate() if (!this.props.type_pickup) {
this.getRate()
}
this.getBalance() this.getBalance()
} }
checkChangeTrans(val) { checkChangeTrans(val) {
if (val == 'delivery') { if (val == 'delivery') {
let typeProps = { // let typeProps = {
type_pickup: false, // type_pickup: false,
} // }
this.props.setTypePickup(typeProps); // this.props.setTypePickup(typeProps);
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
...@@ -62,10 +64,10 @@ class ShoppingCart extends React.Component { ...@@ -62,10 +64,10 @@ class ShoppingCart extends React.Component {
}) })
this.props.navigation.navigate("Delivery Address", {from : 'shoppingCart'}) this.props.navigation.navigate("Delivery Address", {from : 'shoppingCart'})
} else { } else {
let typeProps = { // let typeProps = {
type_pickup: true, // type_pickup: true,
} // }
this.props.setTypePickup(typeProps); // this.props.setTypePickup(typeProps);
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
...@@ -245,6 +247,15 @@ class ShoppingCart extends React.Component { ...@@ -245,6 +247,15 @@ class ShoppingCart extends React.Component {
this.props.setGrab(setGrabProps); this.props.setGrab(setGrabProps);
console.log("INI SUKSES RESPONNYA ") console.log("INI SUKSES RESPONNYA ")
console.log('Delivery Amount Cart : ' + res.data.data.amount)
let OutletChange = {
outlet_id: res.data.data.outlet_id,
name_outlet: res.data.data.outlet_name,
}
this.props.setChangeOutletProps(OutletChange);
let setOrdersProps = { let setOrdersProps = {
balanceUsed: this.state.balanceused, balanceUsed: this.state.balanceused,
...@@ -252,7 +263,6 @@ class ShoppingCart extends React.Component { ...@@ -252,7 +263,6 @@ class ShoppingCart extends React.Component {
} }
this.props.setOrder(setOrdersProps); this.props.setOrder(setOrdersProps);
}).catch(error => { }).catch(error => {
console.log('ini error ' + error) console.log('ini error ' + error)
}) })
...@@ -689,6 +699,15 @@ const styles = StyleSheet.create({ ...@@ -689,6 +699,15 @@ const styles = StyleSheet.create({
const mapDispatchToProps = (dispacth) => { const mapDispatchToProps = (dispacth) => {
return { return {
setChangeOutletProps: (OutletChange) => dispacth({
type: ActionType.SET_CHANGE_OUTLET,
data: {
outlet_id: OutletChange.outlet_id,
name_outlet: OutletChange.name_outlet,
}
}),
addToChart: (item) => dispacth({ addToChart: (item) => dispacth({
type: ActionType.ADD_TO_CHART, type: ActionType.ADD_TO_CHART,
......
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