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
}
}),
} }
} }
......
...@@ -25,8 +25,6 @@ class ShoppingCart extends React.Component { ...@@ -25,8 +25,6 @@ class ShoppingCart extends React.Component {
pointsused: 0, pointsused: 0,
ongkir: 0, ongkir: 0,
diskon: 0, diskon: 0,
isDelivery: false,
isPickUp: false,
// order_item: this.props.order_item, // order_item: this.props.order_item,
grabtype: '', grabtype: '',
grabamount: '', grabamount: '',
...@@ -36,37 +34,44 @@ class ShoppingCart extends React.Component { ...@@ -36,37 +34,44 @@ class ShoppingCart extends React.Component {
my_lat:0, my_lat:0,
my_long:0, my_long:0,
indicator:true, indicator:true,
// dummyBalance : 155000, // dummyBalance : 155000,
// dummyPoint : 20000 // dummyPoint : 20000
} }
} }
componentDidMount() { componentDidMount() {
this.getRate() this.getRate()
this.getBalance() this.getBalance()
console.log("INI REDUX PROPS BAGIAN ID : " + this.props.addressId)
console.log("INI REDUX PROPS BAGIAN ID : " + this.props.addressId)
} }
checkChangeTrans(val) { checkChangeTrans(val) {
console.log('hai lg di sini')
console.log(val)
if (val == 'delivery') { if (val == 'delivery') {
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
this.setState({ this.setState({
isDelivery: true, checkedBalance: false,
isPickUp: false checkedPoint: false,
checkedBalancePoint: false,
pointsused: 0,
balanceused: 0
}) })
console.log('ini delivery')
} else { } else {
let typeProps = {
type_pickup: true,
}
this.props.setTypePickup(typeProps);
this.setState({ this.setState({
isPickUp: true, checkedBalance: false,
isDelivery: false checkedPoint: false,
checkedBalancePoint: false,
pointsused: 0,
balanceused: 0
}) })
console.log('ini pickup')
} }
} }
...@@ -142,38 +147,70 @@ class ShoppingCart extends React.Component { ...@@ -142,38 +147,70 @@ class ShoppingCart extends React.Component {
checkedSelection(val) { checkedSelection(val) {
// console.log(val) // console.log(val)
if (val == 'balance') { if (val == 'balance') {
this.setState({ if (this.props.type_pickup == true) {
checkedBalance: true, this.setState({
checkedPoint: false, checkedBalance: true,
checkedBalancePoint: false, checkedPoint: false,
balanceused: this.props.order_total + this.props.grabamount, checkedBalancePoint: false,
pointsused: 0 balanceused: this.props.order_total,
}) pointsused: 0
})
} else {
this.setState({
checkedBalance: true,
checkedPoint: false,
checkedBalancePoint: false,
balanceused: this.props.order_total + this.props.grabamount,
pointsused: 0
})
}
} else if (val == 'point') { } else if (val == 'point') {
this.setState({ if (this.props.type_pickup == true) {
checkedBalance: false, this.setState({
checkedPoint: true, checkedBalance: false,
checkedBalancePoint: false, checkedPoint: true,
pointsused: this.props.order_total + this.props.grabamount, checkedBalancePoint: false,
balanceused: 0 pointsused: this.props.order_total,
}) balanceused: 0
})
} else {
this.setState({
checkedBalance: false,
checkedPoint: true,
checkedBalancePoint: false,
pointsused: this.props.order_total + this.props.grabamount,
balanceused: 0
})
}
} else { } else {
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
checkedBalancePoint: true, checkedBalancePoint: true,
// balanceused : this.props.order_total - this.state.dummyPoint,
// pointsused : this.props.order_total,
}) })
if (this.state.kasproPoint - (this.props.order_total + this.props.grabamount) >= -1) {
this.setState({ if (this.props.type_pickup == true) {
pointsused: this.props.order_total + this.props.grabamount if (this.state.kasproPoint - this.props.order_total >= -1) {
}) this.setState({
pointsused: this.props.order_total
})
} else {
this.setState({
balanceused: this.props.order_total - this.state.kasproPoint,
pointsused: this.state.kasproPoint
})
}
} else { } else {
this.setState({ if (this.state.kasproPoint - (this.props.order_total + this.props.grabamount) >= -1) {
balanceused: (this.props.order_total + this.props.grabamount) - this.state.kasproPoint, this.setState({
pointsused: this.state.kasproPoint pointsused: this.props.order_total + this.props.grabamount
}) })
} else {
this.setState({
balanceused: (this.props.order_total + this.props.grabamount) - this.state.kasproPoint,
pointsused: this.state.kasproPoint
})
}
} }
} }
} }
...@@ -216,8 +253,13 @@ class ShoppingCart extends React.Component { ...@@ -216,8 +253,13 @@ class ShoppingCart extends React.Component {
}) })
} }
checkOut(){
this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused }) checkOut() {
if (this.state.checkedBalance == false && this.state.checkedPoint == false && this.state.checkedBalancePoint == false) {
Alert.alert('Error', 'Please insert payment methods')
} else {
this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused })
}
} }
getBalance() { getBalance() {
...@@ -251,16 +293,15 @@ class ShoppingCart extends React.Component { ...@@ -251,16 +293,15 @@ class ShoppingCart extends React.Component {
</View> </View>
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
{ {
this.state.isDelivery == true ? (
<TouchableOpacity onPress={()=>this.props.navigation.navigate("Pickup Name")}> this.props.type_pickup == true ? (
<Card style={{ margin: 5, padding: 10 }}> <TouchableOpacity >
<Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text> <Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> {this.props.addressId}</Text> <Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text>
<Text style={{ textAlign: 'center', fontSize: 12, top: 5, fontWeight: 'bold' }}>Excelso {this.props.name_outlet}</Text>
<Text style={{ textAlign: 'center' }}>{this.props.name_outlet}</Text> </Card>
</Card>
</TouchableOpacity> </TouchableOpacity>
) : ( ) : (
<TouchableOpacity onPress={()=>this.props.navigation.navigate("Delivery Address")}> <TouchableOpacity onPress={()=>this.props.navigation.navigate("Delivery Address")}>
...@@ -268,8 +309,8 @@ class ShoppingCart extends React.Component { ...@@ -268,8 +309,8 @@ class ShoppingCart extends React.Component {
<Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text> <Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text>
<Text style={{ textAlign: 'center' }}>{this.props.address}</Text> <Text style={{ textAlign: 'center' }}>{this.props.address}</Text>
</Card> </Card>
</TouchableOpacity> </TouchableOpacity>
) )
} }
</View> </View>
...@@ -457,17 +498,17 @@ class ShoppingCart extends React.Component { ...@@ -457,17 +498,17 @@ class ShoppingCart extends React.Component {
</View> </View>
{this.props.type_pickup == true ? ( {this.props.type_pickup == true ? (
null null
):( ) : (
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View> <View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text> <Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text>
</View> </View>
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}> <View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>{this.props.grabamount}</Text> <Text style={{ color: 'gray' }}>{this.props.grabamount}</Text>
</View> </View>
</View>)} </View>)}
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View> <View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Diskon</Text> <Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Diskon</Text>
...@@ -482,13 +523,13 @@ class ShoppingCart extends React.Component { ...@@ -482,13 +523,13 @@ class ShoppingCart extends React.Component {
</View> </View>
{this.props.type_pickup == true ? ( {this.props.type_pickup == true ? (
<View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}> <View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total + this.state.diskon}</Text> <Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total + this.state.diskon}</Text>
</View> </View>
): ( ) : (
<View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}> <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.props.grabamount + this.state.diskon}</Text>
</View> </View>
)} )}
</View> </View>
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View> <View>
...@@ -499,7 +540,7 @@ class ShoppingCart extends React.Component { ...@@ -499,7 +540,7 @@ class ShoppingCart extends React.Component {
</View> </View>
</View> </View>
<View style={{ margin: 20, }}> <View style={{ margin: 20, }}>
<Button title='Checkout' color='#ccb46c' onPress={() => this.checkOut() } /> <Button title='Checkout' color='#ccb46c' onPress={() => this.checkOut()} />
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
...@@ -678,12 +719,20 @@ const mapDispatchToProps = (dispacth) => { ...@@ -678,12 +719,20 @@ const mapDispatchToProps = (dispacth) => {
pointused: setOrdersProps.pointused, pointused: setOrdersProps.pointused,
} }
}), }),
setTypePickup: (typeProps) => dispacth({
type: ActionType.SET_TYPE,
data: {
type_pickup: typeProps.type_pickup
}
}),
} }
} }
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
type_pickup : state.type_pickup, type_pickup: state.type_pickup,
session_id: state.session_id, session_id: state.session_id,
outlet_id: state.outlet_id, outlet_id: state.outlet_id,
name_outlet: state.name_outlet, 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