Commit 9ca2ec6b authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

ini perubahan tapi belum bisa

parent 5dddbe28
...@@ -34,21 +34,20 @@ class Account extends React.Component { ...@@ -34,21 +34,20 @@ class Account extends React.Component {
account_number: "", account_number: "",
expire_date: "", expire_date: "",
premium: "", premium: "",
my_lat:0, my_lat: 0,
my_long:0 my_long: 0
} }
} }
componentDidMount() { componentDidMount() {
this._getPermissions() this._getPermissions()
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
// do something this._getPermissions()
console.log('DISINI DI RELOAD ULANG "ACCOUNT"') });
});
} }
componentWillUnmount() { componentWillUnmount() {
this._unsubscribe(); this._unsubscribe();
} }
_getPermissions = async () => { _getPermissions = async () => {
...@@ -56,7 +55,7 @@ class Account extends React.Component { ...@@ -56,7 +55,7 @@ class Account extends React.Component {
if (status !== 'granted') { if (status !== 'granted') {
Alert.alert('Akses tidak dizinkan!') Alert.alert('Akses tidak dizinkan!')
} else if (Platform.OS === 'android' && !Device.isDevice) { } else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert('Silahkan anda coba di real Device') Alert.alert('Silahkan anda coba di real Device')
} else { } else {
this._getCurrentPosisition() this._getCurrentPosisition()
...@@ -69,15 +68,15 @@ class Account extends React.Component { ...@@ -69,15 +68,15 @@ class Account extends React.Component {
let location = await Location.getCurrentPositionAsync({ let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest accuracy: Location.Accuracy.Highest
}) })
let latitude = location.coords.latitude; let latitude = location.coords.latitude;
let longitude = location.coords.longitude; let longitude = location.coords.longitude;
this.setState({ this.setState({
my_lat: latitude, my_lat: latitude,
my_long: longitude my_long: longitude
}) })
this._getProfile() this._getProfile()
} }
...@@ -298,17 +297,17 @@ class Account extends React.Component { ...@@ -298,17 +297,17 @@ class Account extends React.Component {
</View> </View>
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center', top: 10 }}> <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center', top: 10 }}>
{this.state.premium === false ? ( {this.state.premium === false ? (
<TouchableOpacity onPress={() => this.props.navigation.navigate('Upgrade Premium')} style={{ marginBottom: 20, marginRight: 5, marginLeft: 5 }}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Upgrade Premium')} style={{ marginBottom: 20, marginRight: 5, marginLeft: 5 }}>
<Card style={{ height: 100, width: 160 }}> <Card style={{ height: 100, width: 160 }}>
<View style={{ height: 50, alignItems: 'center' }}> <View style={{ height: 50, alignItems: 'center' }}>
<MaterialIcons name="autorenew" size={30} color="gray" style={{ top: 20 }} /> <MaterialIcons name="autorenew" size={30} color="gray" style={{ top: 20 }} />
<Text style={{ textAlign: 'center', top: 30, fontSize: 14 }}>UPGRADE PREMIUM</Text> <Text style={{ textAlign: 'center', top: 30, fontSize: 14 }}>UPGRADE PREMIUM</Text>
</View> </View>
</Card> </Card>
</TouchableOpacity> </TouchableOpacity>
):( ) : (
null null
)} )}
<TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')} style={{ marginBottom: 10 }}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')} style={{ marginBottom: 10 }}>
<Card style={{ height: 100, width: 160 }}> <Card style={{ height: 100, width: 160 }}>
<View style={{ height: 50, alignItems: 'center' }}> <View style={{ height: 50, alignItems: 'center' }}>
......
...@@ -35,7 +35,9 @@ class Home extends React.Component { ...@@ -35,7 +35,9 @@ class Home extends React.Component {
this._account(); this._account();
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
// do something // do something
console.log('DISINI DI RELOAD ULANG "HOME"') // this._getPermissions()
this._renderCarousell()
this._account();
}); });
} }
...@@ -144,15 +146,15 @@ class Home extends React.Component { ...@@ -144,15 +146,15 @@ class Home extends React.Component {
type_pickup: true, type_pickup: true,
} }
this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Pickup Name', {from : 'home'}); this.props.navigation.navigate('Pickup Name', { from: 'home' });
} }
_order(){ _order() {
let typeProps = { let typeProps = {
type_pickup: false, type_pickup: false,
} }
this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Delivery Address', {from : 'home'}); this.props.navigation.navigate('Delivery Address', { from: 'home' });
} }
...@@ -198,7 +200,7 @@ class Home extends React.Component { ...@@ -198,7 +200,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._order()}>
<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()}>
...@@ -215,7 +217,11 @@ class Home extends React.Component { ...@@ -215,7 +217,11 @@ class Home extends React.Component {
Excelso {this.props.name_outlet} Excelso {this.props.name_outlet}
</Text> </Text>
)} )}
<TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={() => this.props.navigation.navigate("Menu Select")}> <TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={() =>
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>
......
...@@ -109,8 +109,9 @@ class MenuConfirmation extends React.Component { ...@@ -109,8 +109,9 @@ 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.props.navigation.navigate('Home', {
routes: [{ name: 'Home' }] screen: 'ORDER',
params: { user: 'jane' },
})} })}
], ],
......
...@@ -23,9 +23,17 @@ class MenuSelection extends React.Component { ...@@ -23,9 +23,17 @@ class MenuSelection extends React.Component {
} }
} }
componentDidMount() { componentDidMount() {
this.getMenuList() this.getMenuList()
console.log("INI OUTLET : "+ this.props.outlet_id) this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.getMenuList()
console.log("INI DI RELOAD");
});
}
componentWillUnmount() {
this._unsubscribe();
} }
getMenuList() { getMenuList() {
...@@ -186,7 +194,7 @@ class MenuSelection extends React.Component { ...@@ -186,7 +194,7 @@ class MenuSelection extends React.Component {
</View> </View>
<View style={{ flex: 3 }}> <View style={{ flex: 3 }}>
{this.state.indicator == true ? ( {this.state.indicator == true ? (
<ActivityIndicator style={{top:10}} size="large" color="#c9af6d" /> <ActivityIndicator style={{ top: 10 }} size="large" color="#c9af6d" />
) : ( ) : (
<FlatList <FlatList
......
import React from 'react'; import React from 'react';
import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity } from 'react-native'; import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity,ActivityIndicator } from 'react-native';
import { Card } from 'react-native-shadow-cards' import { Card } from 'react-native-shadow-cards'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
...@@ -9,17 +9,31 @@ class OrderHistory extends React.Component { ...@@ -9,17 +9,31 @@ class OrderHistory extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
order_list: [] order_list: [],
indicator: true
} }
} }
componentDidMount() { componentDidMount() {
this.getOrderHistory() this.getOrderHistory()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
return (
this.getOrderHistory()
)
});
}
componentWillUnmount() {
this._unsubscribe();
} }
// componentDidMount() {
// this.getOrderHistory()
// }
getOrderHistory() { getOrderHistory() {
let params = { let params = {
session_id: this.props.session_id session_id: this.props.session_id
...@@ -28,11 +42,15 @@ class OrderHistory extends React.Component { ...@@ -28,11 +42,15 @@ class OrderHistory extends React.Component {
let data = res.data.data let data = res.data.data
console.log(data) console.log(data)
this.setState({ this.setState({
order_list: data order_list: data,
indicator: false,
}) })
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
Alert.alert(response.msg); Alert.alert(response.msg);
this.setState({
indicator: false,
})
}) })
} }
...@@ -41,18 +59,18 @@ class OrderHistory extends React.Component { ...@@ -41,18 +59,18 @@ class OrderHistory extends React.Component {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ScrollView style={styles.body}> <ScrollView style={styles.body}>
{ {this.state.indicator == true ? (<ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" />) :
this.state.order_list.map((item, key) => ( this.state.order_list.map((item, key) => (
<TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Order Detail', {idTrans:item.id})}> <TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Order Detail', { idTrans: item.id })}>
<View key={key}> <View key={key}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}> <Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<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_display}</Text> <Text>STATUS : {item.trans_status_display}</Text>
</Card> </Card>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
)) ))
} }
......
...@@ -87,7 +87,11 @@ class PickupName extends React.Component { ...@@ -87,7 +87,11 @@ class PickupName extends React.Component {
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')
} else { } else {
this.props.navigation.navigate("Menu Select")
this.props.navigation.navigate('Home', {
screen: 'MENU',
params: { user: 'jane' },
})
} }
} }
......
...@@ -105,6 +105,7 @@ class ShoppingCart extends React.Component { ...@@ -105,6 +105,7 @@ class ShoppingCart extends React.Component {
} }
if (quantity == 0) { if (quantity == 0) {
Alert.alert("Apakah anda akan menghapus pesanan?");
const order_item = { const order_item = {
id: item.id, id: item.id,
name: item.name, name: item.name,
...@@ -757,5 +758,4 @@ const mapStateToProps = (state) => { ...@@ -757,5 +758,4 @@ const mapStateToProps = (state) => {
} }
} }
export default connect(mapStateToProps, mapDispatchToProps)(ShoppingCart) export default connect(mapStateToProps, mapDispatchToProps)(ShoppingCart)
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