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 = {
SET_GRAB : 'SET_GRAB',
SET_ORDERS : 'SET_ORDERS',
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) => {
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:
return state;
}
......
......@@ -44,6 +44,9 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { enableScreens } from 'react-native-screens';
import MenuDetail from './MenuDetail';
import OrderHistory from './OrderHistory'
import { TouchableOpacity } from 'react-native-gesture-handler';
import { StackActions } from '@react-navigation/native';
import { NavigationActions } from 'react-navigation';
enableScreens();
function Rewards() {
......@@ -73,9 +76,10 @@ function Outlets() {
const Tab = createBottomTabNavigator();
function HomePage() {
function HomePage({navigation}) {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
......@@ -98,12 +102,13 @@ function HomePage() {
// You can return any component that you like here!
return <Ionicons name={iconName} size={size} color={color} />;
},
})}
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="REWARDS" component={Rewards} />
<Tab.Screen name="ORDER" component={TransactionHistory} />
......
......@@ -101,12 +101,20 @@ class DeliveryAddrees extends React.Component {
}
this.props.setAddress(setDataAddress);
let recalculateProps = {
order_total: 0,
order_quantity:0,
order_item:[]
}
this.props.setRecalculate(recalculateProps)
Alert.alert(
'',
'Apakah anda akan memilih alamat untuk pengiriman ?',
[
{text: 'OK', onPress: () => this.getRate() },
{text: 'OK', onPress: () => this.props.navigation.navigate("Menu Select") },
],
{ cancelable: false }
)
......@@ -120,7 +128,6 @@ class DeliveryAddrees extends React.Component {
<View style={styles.list_addrees}>
<TouchableOpacity onPress={()=> this.onSave(item.address,item.id)}>
<View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.id}</Text>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text>
</View>
<Text style={{ margin: 5 }}>
......@@ -152,19 +159,6 @@ class DeliveryAddrees extends React.Component {
renderItem={this.renderItem}
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>
)
......@@ -232,6 +226,16 @@ const mapDispatchToProps = (dispacth) => {
// 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 {
console.log(params);
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/outlet/get_closest', params).then(res => {
let outletId = res.data.data.outlet_id
let outletName = res.data.data.outlet_name
......@@ -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() {
return (
......@@ -178,7 +186,7 @@ class Home extends React.Component {
<TouchableOpacity style={styles.buttonDelivery} onPress={() => this.props.navigation.navigate('Delivery Address')}>
<Text style={{ textAlign: 'center', color: '#354175', fontWeight: 'bold' }}>{i18n.t('delivery')}</Text>
</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>
</TouchableOpacity>
</View>
......@@ -335,6 +343,14 @@ const mapDispatchToProps = (dispacth) => {
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';
import { View, Text, Alert, TextInput, StyleSheet, Button, ScrollView } from 'react-native';
import Axios from 'axios'
import { connect } from 'react-redux'
import Spinner from 'react-native-loading-spinner-overlay';
class MenuConfirmation extends React.Component {
constructor(props) {
super(props)
......@@ -12,7 +13,8 @@ class MenuConfirmation extends React.Component {
pointsused: 0,
ongkir: 0,
diskon: 0,
totalOrder: 0
totalOrder: 0,
spinner: false,
}
}
......@@ -29,6 +31,9 @@ class MenuConfirmation extends React.Component {
}
setOrder() {
this.setState({
spinner: true,
})
let params = {
session_id : this.props.session_id,
outlet_id : this.props.outlet_id,
......@@ -37,34 +42,49 @@ class MenuConfirmation extends React.Component {
order_item: this.props.order_item,
delivery_charge: this.props.grabamount,
voucher: [],
payment: {
balance: this.props.route.params.balanceUsed,
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 => {
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 = {
// type_pickup: false,
// }
// this.props.setTypePickup(typeProps);
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,
})
})
}
setPickup() {
this.setState({
spinner: true,
})
let params = {
session_id : this.props.session_id,
outlet_id : this.props.outlet_id,
......@@ -81,18 +101,34 @@ class MenuConfirmation extends React.Component {
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');
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 = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
}).catch(error => {
let response = error.response.data;
console.log('ini error ' + error)
// console.log('error')
Alert.alert(response.msg);
this.setState({
spinner: false,
})
})
}
......@@ -101,6 +137,11 @@ class MenuConfirmation extends React.Component {
let total = 0
return (
<ScrollView style={styles.container}>
<Spinner
visible={this.state.spinner}
textContent={'Sedang Proses...'}
textStyle={styles.spinnerTextStyle}
/>
{
this.props.order_item.map((item, index) => {
total = total + item.quantity * item.price
......@@ -192,11 +233,11 @@ class MenuConfirmation extends React.Component {
</View>
</View>
<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.setOrder()}/>
{/* )} */}
)}
</View>
</ScrollView>
......@@ -265,5 +306,4 @@ const mapStateToProps = (state) => {
}
}
export default connect(mapStateToProps,mapDispatchToProps)(MenuConfirmation)
......@@ -30,7 +30,6 @@ class OrderHistory extends React.Component {
this.setState({
order_list: data
})
// console.log(this.state.order_list)
}).catch(error => {
let response = error.response.data;
Alert.alert(response.msg);
......@@ -49,7 +48,7 @@ class OrderHistory extends React.Component {
<Text>OUTLET : {item.outlet}</Text>
<Text>TGL TRANSAKSI : {item.trans_date}</Text>
<Text>TOTAL : {item.trans_total}</Text>
<Text>STATUS : {item.trans_status}</Text>
<Text>STATUS : {item.trans_status_display}</Text>
</Card>
</View>
......
......@@ -75,6 +75,12 @@ class PickupName extends React.Component {
type_pickup: true,
}
let recalculateProps = {
order_total: 0,
order_quantity:0,
order_item:[]
}
this.props.setRecalculate(recalculateProps)
this.props.setChangeOutletProps(OutletChange);
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Menu Select')
......@@ -180,6 +186,7 @@ class PickupName extends React.Component {
name_outlet: item.name,
}
this.props.setChangeOutletProps(OutletChange)
this.props.navigation.navigate('Home', { screen: 'MENU' });
}
......@@ -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