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

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

# Conflicts:
#	view/ShoppingCart.js
parents 696c03bf 30e1d19e
...@@ -29,7 +29,8 @@ const ActionType = { ...@@ -29,7 +29,8 @@ const ActionType = {
SET_GRAB : 'SET_GRAB', SET_GRAB : 'SET_GRAB',
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'
} }
......
...@@ -399,6 +399,15 @@ const rootReducer = (state = globalState, action) => { ...@@ -399,6 +399,15 @@ const rootReducer = (state = globalState, action) => {
order_item: new_items, order_item: new_items,
} }
} }
case ActionType.SET_RECALCULATE: {
return {
...state,
order_total: action.data.order_total,
order_quantity: action.data.order_quantity,
order_item: action.data.order_item
}
}
default: default:
return state; return state;
} }
......
...@@ -44,6 +44,9 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; ...@@ -44,6 +44,9 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { enableScreens } from 'react-native-screens'; import { enableScreens } from 'react-native-screens';
import MenuDetail from './MenuDetail'; import MenuDetail from './MenuDetail';
import OrderHistory from './OrderHistory' import OrderHistory from './OrderHistory'
import { TouchableOpacity } from 'react-native-gesture-handler';
import { StackActions } from '@react-navigation/native';
import { NavigationActions } from 'react-navigation';
enableScreens(); enableScreens();
function Rewards() { function Rewards() {
...@@ -73,9 +76,10 @@ function Outlets() { ...@@ -73,9 +76,10 @@ function Outlets() {
const Tab = createBottomTabNavigator(); const Tab = createBottomTabNavigator();
function HomePage() { function HomePage({navigation}) {
return ( return (
<Tab.Navigator <Tab.Navigator
screenOptions={({ route }) => ({ screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => { tabBarIcon: ({ focused, color, size }) => {
let iconName; let iconName;
...@@ -98,12 +102,13 @@ function HomePage() { ...@@ -98,12 +102,13 @@ function HomePage() {
// You can return any component that you like here! // You can return any component that you like here!
return <Ionicons name={iconName} size={size} color={color} />; return <Ionicons name={iconName} size={size} color={color} />;
}, },
})} })}
tabBarOptions={{ activeTintColor: 'cornflowerblue', inactiveTintColor: 'gray' }} tabBarOptions={{ activeTintColor: 'cornflowerblue', inactiveTintColor: 'gray' }}
> >
<Tab.Screen name="HOME" component={Home} /> <Tab.Screen name="HOME" component={Home} />
<Tab.Screen name="MENU" component={MenuSelection} /> <Tab.Screen name="MENU" component={MenuSelection} />
<Tab.Screen name="REWARDS" component={Rewards} /> <Tab.Screen name="REWARDS" component={Rewards} />
<Tab.Screen name="ORDER" component={TransactionHistory} /> <Tab.Screen name="ORDER" component={TransactionHistory} />
......
...@@ -101,12 +101,20 @@ class DeliveryAddrees extends React.Component { ...@@ -101,12 +101,20 @@ class DeliveryAddrees extends React.Component {
} }
this.props.setAddress(setDataAddress); this.props.setAddress(setDataAddress);
let recalculateProps = {
order_total: 0,
order_quantity:0,
order_item:[]
}
this.props.setRecalculate(recalculateProps)
Alert.alert( Alert.alert(
'', '',
'Apakah anda akan memilih alamat untuk pengiriman ?', 'Apakah anda akan memilih alamat untuk pengiriman ?',
[ [
{text: 'OK', onPress: () => this.getRate() }, {text: 'OK', onPress: () => this.props.navigation.navigate("Menu Select") },
], ],
{ cancelable: false } { cancelable: false }
) )
...@@ -120,7 +128,6 @@ class DeliveryAddrees extends React.Component { ...@@ -120,7 +128,6 @@ class DeliveryAddrees extends React.Component {
<View style={styles.list_addrees}> <View style={styles.list_addrees}>
<TouchableOpacity onPress={()=> this.onSave(item.address,item.id)}> <TouchableOpacity onPress={()=> this.onSave(item.address,item.id)}>
<View style={{ margin: 5, }}> <View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.id}</Text>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text> <Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text>
</View> </View>
<Text style={{ margin: 5 }}> <Text style={{ margin: 5 }}>
...@@ -152,19 +159,6 @@ class DeliveryAddrees extends React.Component { ...@@ -152,19 +159,6 @@ class DeliveryAddrees extends React.Component {
renderItem={this.renderItem} renderItem={this.renderItem}
keyExtractor={item => item.id} keyExtractor={item => item.id}
/> />
{/*
<View style={styles.list_addrees}>
<View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>Rumah</Text>
</View>
<Text style={{ margin: 5 }}>
Perkantoran Grenvil Maisonette Blok FB/16,
Tanjung Duren, Duri Kepa, Kebon Jeruk, RT.13/RW.9,
Duri Kepa, DKI Jakarta, Kota Jakarta Barat,
Daerah Khusus Ibukota Jakarta 11510
</Text>
</View> */}
{/* </ScrollView> */}
</View> </View>
</View> </View>
) )
...@@ -232,6 +226,16 @@ const mapDispatchToProps = (dispacth) => { ...@@ -232,6 +226,16 @@ const mapDispatchToProps = (dispacth) => {
// grabdestination: setGrabProps.grabdestination, // grabdestination: setGrabProps.grabdestination,
} }
}), }),
setRecalculate: (recalculateProps) => dispacth({
type: ActionType.SET_RECALCULATE,
data: {
order_total : recalculateProps.order_total,
order_quantity: recalculateProps.order_quantity,
order_item: recalculateProps.order_item
}
}),
} }
} }
......
...@@ -115,7 +115,7 @@ class Home extends React.Component { ...@@ -115,7 +115,7 @@ class Home extends React.Component {
console.log(params); console.log(params);
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/outlet/get_closest', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/outlet/get_closest', params).then(res => {
let outletId = res.data.data.outlet_id let outletId = res.data.data.outlet_id
let outletName = res.data.data.outlet_name let outletName = res.data.data.outlet_name
...@@ -132,6 +132,14 @@ class Home extends React.Component { ...@@ -132,6 +132,14 @@ class Home extends React.Component {
}) })
} }
_pickup() {
let typeProps = {
type_pickup: true,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Pickup Name');
}
render() { render() {
return ( return (
...@@ -178,7 +186,7 @@ class Home extends React.Component { ...@@ -178,7 +186,7 @@ class Home extends React.Component {
<TouchableOpacity style={styles.buttonDelivery} onPress={() => this.props.navigation.navigate('Delivery Address')}> <TouchableOpacity style={styles.buttonDelivery} onPress={() => this.props.navigation.navigate('Delivery Address')}>
<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.props.navigation.navigate('Pickup Name')}> <TouchableOpacity style={styles.buttonPickup} onPress={() => this._pickup()}>
<Text style={{ textAlign: 'center', color: '#fff', fontWeight: 'bold' }}>{i18n.t('pickup')}</Text> <Text style={{ textAlign: 'center', color: '#fff', fontWeight: 'bold' }}>{i18n.t('pickup')}</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
...@@ -335,6 +343,14 @@ const mapDispatchToProps = (dispacth) => { ...@@ -335,6 +343,14 @@ const mapDispatchToProps = (dispacth) => {
name_outlet: OutletChange.name_outlet, name_outlet: OutletChange.name_outlet,
} }
}), }),
setTypePickup: (typeProps) => dispacth({
type: ActionType.SET_TYPE,
data: {
type_pickup: typeProps.type_pickup
}
}),
} }
} }
......
...@@ -2,6 +2,7 @@ import React from 'react'; ...@@ -2,6 +2,7 @@ import React from 'react';
import { View, Text, Alert, TextInput, StyleSheet, Button, ScrollView } from 'react-native'; import { View, Text, Alert, TextInput, StyleSheet, Button, ScrollView } from 'react-native';
import Axios from 'axios' import Axios from 'axios'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import Spinner from 'react-native-loading-spinner-overlay';
class MenuConfirmation extends React.Component { class MenuConfirmation extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -12,7 +13,8 @@ class MenuConfirmation extends React.Component { ...@@ -12,7 +13,8 @@ class MenuConfirmation extends React.Component {
pointsused: 0, pointsused: 0,
ongkir: 0, ongkir: 0,
diskon: 0, diskon: 0,
totalOrder: 0 totalOrder: 0,
spinner: false,
} }
} }
...@@ -29,6 +31,9 @@ class MenuConfirmation extends React.Component { ...@@ -29,6 +31,9 @@ class MenuConfirmation extends React.Component {
} }
setOrder() { setOrder() {
this.setState({
spinner: true,
})
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,
...@@ -37,34 +42,49 @@ class MenuConfirmation extends React.Component { ...@@ -37,34 +42,49 @@ class MenuConfirmation extends React.Component {
order_item: this.props.order_item, order_item: this.props.order_item,
delivery_charge: this.props.grabamount, delivery_charge: this.props.grabamount,
voucher: [], voucher: [],
payment: { payment: {
balance: this.props.route.params.balanceUsed, balance: this.props.route.params.balanceUsed,
point: this.props.route.params.pointused point: this.props.route.params.pointused
} }
} }
console.log("INI PARAMETER UNTUK ORDER : " + JSON.stringify())
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => {
Alert.alert( 'Transaksi Anda Berhasil')
this.props.navigation.navigate('Order History'); this.setState({
spinner: false,
})
Alert.alert(
"Berhasil",
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi",
[
{ text: "OK", onPress: () => this.props.navigation.reset({
routes: [{ name: 'Home' }]
})}
],
{ cancelable: false }
);
// let typeProps = { let typeProps = {
// type_pickup: false, type_pickup: false,
// } }
// this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
// console.log('error') // console.log('error')
Alert.alert(response.msg); Alert.alert(response.msg);
this.setState({
spinner: false,
})
}) })
} }
setPickup() { setPickup() {
this.setState({
spinner: true,
})
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,
...@@ -81,18 +101,34 @@ class MenuConfirmation extends React.Component { ...@@ -81,18 +101,34 @@ class MenuConfirmation extends React.Component {
console.log("INI params : " + JSON.stringify(params) ) console.log("INI params : " + JSON.stringify(params) )
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => {
Alert.alert( 'Transaksi Anda Berhasil') this.setState({
this.props.navigation.navigate('Order History'); spinner: false,
})
Alert.alert(
"Berhasil",
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi",
[
{ text: "OK", onPress: () => this.props.navigation.reset({
routes: [{ name: 'Home' }]
})}
],
{ cancelable: false }
);
let typeProps = { let typeProps = {
type_pickup: false, type_pickup: false,
} }
this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
console.log('ini error ' + error) // console.log('error')
Alert.alert(response.msg); Alert.alert(response.msg);
this.setState({
spinner: false,
})
}) })
} }
...@@ -101,6 +137,11 @@ class MenuConfirmation extends React.Component { ...@@ -101,6 +137,11 @@ class MenuConfirmation extends React.Component {
let total = 0 let total = 0
return ( return (
<ScrollView style={styles.container}> <ScrollView style={styles.container}>
<Spinner
visible={this.state.spinner}
textContent={'Sedang Proses...'}
textStyle={styles.spinnerTextStyle}
/>
{ {
this.props.order_item.map((item, index) => { this.props.order_item.map((item, index) => {
total = total + item.quantity * item.price total = total + item.quantity * item.price
...@@ -192,11 +233,11 @@ class MenuConfirmation extends React.Component { ...@@ -192,11 +233,11 @@ class MenuConfirmation extends React.Component {
</View> </View>
</View> </View>
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
{/* {this.props.type_pickup == true ? ( {this.props.type_pickup == true ? (
<Button title='order' onPress={() => this.setPickup()}/> <Button title='order' onPress={() => this.setPickup()}/>
):( */} ):(
<Button title='order' onPress={() => this.setOrder()}/> <Button title='order' onPress={() => this.setOrder()}/>
{/* )} */} )}
</View> </View>
</ScrollView> </ScrollView>
...@@ -265,5 +306,4 @@ const mapStateToProps = (state) => { ...@@ -265,5 +306,4 @@ const mapStateToProps = (state) => {
} }
} }
export default connect(mapStateToProps,mapDispatchToProps)(MenuConfirmation) export default connect(mapStateToProps,mapDispatchToProps)(MenuConfirmation)
...@@ -30,7 +30,6 @@ class OrderHistory extends React.Component { ...@@ -30,7 +30,6 @@ class OrderHistory extends React.Component {
this.setState({ this.setState({
order_list: data order_list: data
}) })
// console.log(this.state.order_list)
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
Alert.alert(response.msg); Alert.alert(response.msg);
...@@ -49,7 +48,7 @@ class OrderHistory extends React.Component { ...@@ -49,7 +48,7 @@ class OrderHistory extends React.Component {
<Text>OUTLET : {item.outlet}</Text> <Text>OUTLET : {item.outlet}</Text>
<Text>TGL TRANSAKSI : {item.trans_date}</Text> <Text>TGL TRANSAKSI : {item.trans_date}</Text>
<Text>TOTAL : {item.trans_total}</Text> <Text>TOTAL : {item.trans_total}</Text>
<Text>STATUS : {item.trans_status}</Text> <Text>STATUS : {item.trans_status_display}</Text>
</Card> </Card>
</View> </View>
......
...@@ -75,6 +75,12 @@ class PickupName extends React.Component { ...@@ -75,6 +75,12 @@ class PickupName extends React.Component {
type_pickup: true, type_pickup: true,
} }
let recalculateProps = {
order_total: 0,
order_quantity:0,
order_item:[]
}
this.props.setRecalculate(recalculateProps)
this.props.setChangeOutletProps(OutletChange); this.props.setChangeOutletProps(OutletChange);
this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Menu Select') this.props.navigation.navigate('Menu Select')
...@@ -180,6 +186,7 @@ class PickupName extends React.Component { ...@@ -180,6 +186,7 @@ class PickupName extends React.Component {
name_outlet: item.name, name_outlet: item.name,
} }
this.props.setChangeOutletProps(OutletChange) this.props.setChangeOutletProps(OutletChange)
this.props.navigation.navigate('Home', { screen: 'MENU' }); this.props.navigation.navigate('Home', { screen: 'MENU' });
} }
...@@ -303,6 +310,16 @@ const mapDispatchToProps = (dispacth) => { ...@@ -303,6 +310,16 @@ const mapDispatchToProps = (dispacth) => {
} }
}), }),
setRecalculate: (recalculateProps) => dispacth({
type: ActionType.SET_RECALCULATE,
data: {
order_total : recalculateProps.order_total,
order_quantity: recalculateProps.order_quantity,
order_item: recalculateProps.order_item
}
}),
} }
} }
......
This diff is collapsed.
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