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