Commit fa14074c authored by Trisno's avatar Trisno

tampilkan dialog saat belum ada alamat

parent 83f1850c
import React from 'react'; import React from 'react';
import { View, Text, StyleSheet, Button, FlatList, Alert, TextInput, Image,ScrollView,ActivityIndicator } from 'react-native'; import { View, Text, StyleSheet, Button, FlatList, Alert, TextInput, Image, ScrollView, ActivityIndicator } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler'; import { TouchableOpacity } from 'react-native-gesture-handler';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { CheckBox, Icon } from 'react-native-elements'; import { CheckBox, Icon } from 'react-native-elements';
...@@ -41,7 +41,7 @@ class DeliveryAddrees extends React.Component { ...@@ -41,7 +41,7 @@ class DeliveryAddrees extends React.Component {
} }
// console.log(params) // console.log(params)
Axios.post(this.props.BASE_URL+'crm/v2/member/get_address', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/member/get_address', params).then(res => {
const dataAlamat = res.data.data; const dataAlamat = res.data.data;
console.log("INI DATA :" + JSON.stringify(dataAlamat)) console.log("INI DATA :" + JSON.stringify(dataAlamat))
let address = [] let address = []
...@@ -82,7 +82,7 @@ class DeliveryAddrees extends React.Component { ...@@ -82,7 +82,7 @@ class DeliveryAddrees extends React.Component {
// console.log("INI PRAMETER NYA : " + JSON.stringify(params)) // console.log("INI PRAMETER NYA : " + JSON.stringify(params))
Axios.post(this.props.BASE_URL+'crm/v2/delivery/rate', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/delivery/rate', params).then(res => {
// this.setState({ // this.setState({
// grabamount: res.data.data.amount, // grabamount: res.data.data.amount,
...@@ -162,7 +162,7 @@ class DeliveryAddrees extends React.Component { ...@@ -162,7 +162,7 @@ class DeliveryAddrees extends React.Component {
address_id: id, address_id: id,
} }
Axios.post(this.props.BASE_URL+'crm/v2/delivery/rate', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/delivery/rate', params).then(res => {
let setGrabProps = { let setGrabProps = {
// grabdestination: this.state.grabdestination, // grabdestination: this.state.grabdestination,
...@@ -222,7 +222,7 @@ class DeliveryAddrees extends React.Component { ...@@ -222,7 +222,7 @@ class DeliveryAddrees extends React.Component {
renderItem = ({ item }) => { renderItem = ({ item }) => {
return ( return (
<View style={styles.list_addrees}> <View style={styles.list_addrees}>
<TouchableOpacity onPress={() => this.onSave(item.address, item.id , item.name)}> <TouchableOpacity onPress={() => this.onSave(item.address, item.id, item.name)}>
<View style={{ flex: 1, flexDirection: 'row', margin: 5, }}> <View style={{ flex: 1, flexDirection: 'row', margin: 5, }}>
<View style={{ flex: 1, justifyContent: 'center' }}> <View style={{ flex: 1, justifyContent: 'center' }}>
<View> <View>
...@@ -241,13 +241,13 @@ class DeliveryAddrees extends React.Component { ...@@ -241,13 +241,13 @@ class DeliveryAddrees extends React.Component {
</View> </View>
<View style={{ flex: 3, justifyContent: 'center' }}> <View style={{ flex: 3, justifyContent: 'center' }}>
<View> <View>
<Text style={{ fontFamily: 'Gotham-Black', color: '#838383', fontSize: 15,margin:1 }}>{item.name}</Text> <Text style={{ fontFamily: 'Gotham-Black', color: '#838383', fontSize: 15, margin: 1 }}>{item.name}</Text>
</View> </View>
<Text style={{ fontFamily: 'Gotham-Light', color: '#838383', fontSize: 15 }}>{item.address}</Text> <Text style={{ fontFamily: 'Gotham-Light', color: '#838383', fontSize: 15 }}>{item.address}</Text>
</View> </View>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
); );
...@@ -259,39 +259,45 @@ class DeliveryAddrees extends React.Component { ...@@ -259,39 +259,45 @@ class DeliveryAddrees extends React.Component {
<View style={styles.container}> <View style={styles.container}>
<MyStatusBar /> <MyStatusBar />
<ScrollView> <ScrollView>
<View style={{ height: 45, borderRadius: 10, borderColor: '#ccb46c', borderWidth: 1, flexDirection: 'row', marginTop: 15, marginLeft: 20, marginRight: 20 }}> <View style={{ height: 45, borderRadius: 10, borderColor: '#ccb46c', borderWidth: 1, flexDirection: 'row', marginTop: 15, marginLeft: 20, marginRight: 20 }}>
<View style={{ flex: 1, top: 5 }}> <View style={{ flex: 1, top: 5 }}>
<MaterialCommunityIcons name="map-marker" size={32} color="#ccb46c" /> <MaterialCommunityIcons name="map-marker" size={32} color="#ccb46c" />
</View>
<View style={{ flex: 6 }}>
<TextInput style={{ height: 45 }} placeholder={i18n.t('searchaddress')}
onChangeText={text => this.filterData(text)}
onClear={text => this.filterData('')}
value={this.state.search}></TextInput>
</View>
<View style={{ flex: 1, margin: 5 }}>
<Ionicons name="ios-search" size={32} color="#ccb46c" />
</View>
</View> </View>
<View style={{ flex: 6 }}> <View style={styles.btn_addreess}>
<TextInput style={{ height: 45 }} placeholder={i18n.t('searchaddress')} <TouchableOpacity onPress={() => this.addAdreess()}>
onChangeText={text => this.filterData(text)} <View style={{ height: 40, borderRadius: 10, marginRight: 70, marginLeft: 70, backgroundColor: '#CFB368', justifyContent: 'center', alignContent: 'center' }}>
onClear={text => this.filterData('')} <Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', color: 'white', fontSize: 16 }}> {i18n.t('addaddress')} </Text>
value={this.state.search}></TextInput> </View>
</TouchableOpacity>
</View> </View>
<View style={{ flex: 1, margin: 5 }}> <View style={styles.listAddress}>
<Ionicons name="ios-search" size={32} color="#ccb46c" /> {this.state.indicator == true ? (
<ActivityIndicator size="large" color="#c9af6d" />
) : (this.state.data.length ? (
<FlatList style={{ marginBottom: 25 }}
data={this.state.data}
renderItem={this.renderItem}
keyExtractor={item => item.id}
/>
) : (
<View style={{ margin: 20 }}>
<Text style={{ fontFamily: 'Gotham-Light', textAlign: 'center', fontSize: 16 }}>{i18n.t('noAddressSaved')}</Text>
</View>
)
)}
</View> </View>
</View>
<View style={styles.btn_addreess}>
<TouchableOpacity onPress={() => this.addAdreess()}>
<View style={{ height: 40, borderRadius: 10, marginRight: 70, marginLeft: 70, backgroundColor: '#CFB368', justifyContent: 'center', alignContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', color: 'white', fontSize: 16 }}> {i18n.t('addaddress')} </Text>
</View>
</TouchableOpacity>
</View>
<View style={styles.listAddress}>
{this.state.indicator == true ? (
<ActivityIndicator size="large" color="#c9af6d" />
) : (
<FlatList style={{marginBottom:25}}
data={this.state.data}
renderItem={this.renderItem}
keyExtractor={item => item.id}
/>
)}
</View>
</ScrollView> </ScrollView>
</View> </View>
...@@ -324,10 +330,10 @@ const styles = StyleSheet.create({ ...@@ -324,10 +330,10 @@ const styles = StyleSheet.create({
list_addrees: { list_addrees: {
flex: 1, flex: 1,
top:20, top: 20,
marginLeft:20, marginLeft: 20,
marginRight:20, marginRight: 20,
marginBottom:20, marginBottom: 20,
borderWidth: 1, borderWidth: 1,
borderColor: '#838383', borderColor: '#838383',
borderRadius: 10, borderRadius: 10,
......
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