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

benerin bug dan merubah style di delivery address

parent 5a406788
...@@ -137,5 +137,8 @@ ...@@ -137,5 +137,8 @@
"noAddressSaved":"No address saved", "noAddressSaved":"No address saved",
"headerInboxList":"INBOX", "headerInboxList":"INBOX",
"noInboxData":"No incoming message", "noInboxData":"No incoming message",
"headerInboxDetail":"INBOX DETAIL" "headerInboxDetail":"INBOX DETAIL",
"alertdeleteaddress":"Are you sure you want to delete the address ?",
"alertyes":"Yes",
"alertno":"No"
} }
\ No newline at end of file
...@@ -139,5 +139,8 @@ ...@@ -139,5 +139,8 @@
"noAddressSaved":"Tidak ada alamat tersimpan", "noAddressSaved":"Tidak ada alamat tersimpan",
"headerInboxList":"KOTAK MASUK", "headerInboxList":"KOTAK MASUK",
"noInboxData":"Tidak ada pesan masuk", "noInboxData":"Tidak ada pesan masuk",
"headerInboxDetail":"DETAIL KOTAK MASUK" "headerInboxDetail":"DETAIL KOTAK MASUK",
"alertdeleteaddress":"Apakah anda yakin ingin menghapus alamat ?",
"alertyes":"Ya",
"alertno":"Tidak"
} }
\ No newline at end of file
import React from 'react'; import React from 'react';
import { View, Text, TextInput, StyleSheet, Button, Platform, Dimensions, Alert, Image ,ActivityIndicator } from 'react-native'; import { View, Text, TextInput, StyleSheet, Button, Platform, Dimensions, Alert, Image, ActivityIndicator } from 'react-native';
import * as Device from 'expo-device'; import * as Device from 'expo-device';
import * as Permissions from 'expo-permissions'; import * as Permissions from 'expo-permissions';
import * as Location from 'expo-location'; import * as Location from 'expo-location';
...@@ -67,23 +67,87 @@ class AddreesDetail extends React.Component { ...@@ -67,23 +67,87 @@ class AddreesDetail extends React.Component {
}) })
let detail = await Location.reverseGeocodeAsync(location.coords) let detail = await Location.reverseGeocodeAsync(location.coords)
// console.log(" INI DETAIL "+ JSON.stringify(detail) ) //ini benerin bug ketika jalan kosong
let street = detail[0].street
let city = detail[0].city
let region = detail[0].region
let postalCode = detail[0].postalCode
let latitude = location.coords.latitude; let latitude = location.coords.latitude;
let longitude = location.coords.longitude; let longitude = location.coords.longitude;
this.setState({ location, latitude: latitude, longitude: longitude }) this.setState({ location, latitude: latitude, longitude: longitude })
if (street == null) {
let str_city = city.replace('null', '')
let str_region = region.replace('null', '')
let str_postalCode = postalCode.replace('null', '')
this.setState({ this.setState({
street: '',
city: str_city,
region: str_region,
postalCode: str_postalCode,
indicator: false,
street: detail[0].street, })
city: detail[0].city,
// name: detail[0].name, } else if (city == null) {
region: detail[0].region, let str_street = street.replace('null', '')
postalCode: detail[0].postalCode, let str_region = region.replace('null', '')
let str_postalCode = postalCode.replace('null', '')
this.setState({
street: str_street,
city: '',
region: str_region,
postalCode: str_postalCode,
indicator: false, indicator: false,
})
} else if (region == null) {
let str_street = street.replace('null', '')
let str_city = city.replace('null', '')
let str_postalCode = postalCode.replace('null', '')
this.setState({
street: str_street,
city: str_city,
region: '',
postalCode: str_postalCode,
indicator: false,
}) })
} else if (postalCode == null) {
let str_street = street.replace('null', '')
let str_city = city.replace('null', '')
let str_region = region.replace('null', '')
this.setState({
street: str_street,
city: str_city,
region: str_region,
postalCode: '',
indicator: false,
})
} else {
let str_street = street.replace('null', '')
let str_city = city.replace('null', '')
let str_region = region.replace('null', '')
let str_postalCode = postalCode.replace('null', '')
this.setState({
street: str_street,
city: str_city,
region: str_region,
postalCode: str_postalCode,
indicator: false,
})
}
} }
//searchlocation (mencari lokasi) //searchlocation (mencari lokasi)
...@@ -127,7 +191,7 @@ class AddreesDetail extends React.Component { ...@@ -127,7 +191,7 @@ class AddreesDetail extends React.Component {
} }
// console.log(params) // console.log(params)
Axios.post(this.props.BASE_URL+'crm/v2/member/set_address', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/member/set_address', params).then(res => {
Alert.alert( Alert.alert(
'Berhasil', 'Berhasil',
'Berhasil menambahkan Alamat !' 'Berhasil menambahkan Alamat !'
...@@ -228,13 +292,13 @@ class AddreesDetail extends React.Component { ...@@ -228,13 +292,13 @@ class AddreesDetail extends React.Component {
</View> </View>
<View style={styles.field_name_addrees}> <View style={styles.field_name_addrees}>
<Text style={{ fontFamily: 'Gotham-Black', color: "#ccb46c", textAlign: 'center', fontSize: 18 }}>{i18n.t('label')}</Text> <Text style={{ fontFamily: 'Gotham-Black', color: "#ccb46c", textAlign: 'center', fontSize: 18 }}>{i18n.t('label')}</Text>
<TextInput style={{ color:'grey', fontFamily:'Gotham-Black', height: 40, borderWidth: 1, padding: 5, flex: 1, margin: 10, borderRadius: 10, borderColor: 'grey',textAlign:'center' }} onChangeText={(name) => this.setState({ name })} /> <TextInput style={{ color: 'grey', fontFamily: 'Gotham-Black', height: 40, borderWidth: 1, padding: 5, flex: 1, margin: 10, borderRadius: 10, borderColor: 'grey', textAlign: 'center' }} onChangeText={(name) => this.setState({ name })} />
</View> </View>
<View style={styles.field_detail_addrees}> <View style={styles.field_detail_addrees}>
<Text style={{ fontFamily: 'Gotham-Black', color: "#ccb46c",textAlign:'center', fontSize: 18 }}>{i18n.t('detail')}</Text> <Text style={{ fontFamily: 'Gotham-Black', color: "#ccb46c", textAlign: 'center', fontSize: 18 }}>{i18n.t('detail')}</Text>
<TextInput <TextInput
style={{color:'grey', fontFamily:'Gotham-Black', textAlign:'center', height: 70, borderWidth: 1, padding: 5, flex: 1, margin: 10, borderRadius: 10, borderColor: 'grey' }} style={{ color: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', height: 70, borderWidth: 1, padding: 5, flex: 1, margin: 10, borderRadius: 10, borderColor: 'grey' }}
onChangeText={(description) => this.setState({ description })} onChangeText={(description) => this.setState({ description })}
numberOfLines={10} numberOfLines={10}
multiline={true} /> multiline={true} />
...@@ -246,7 +310,7 @@ class AddreesDetail extends React.Component { ...@@ -246,7 +310,7 @@ class AddreesDetail extends React.Component {
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={{ height: 20}}></View> <View style={{ height: 20 }}></View>
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
...@@ -322,5 +386,3 @@ const mapStateToProps = (state) => { ...@@ -322,5 +386,3 @@ const mapStateToProps = (state) => {
export default connect(mapStateToProps)(AddreesDetail) export default connect(mapStateToProps)(AddreesDetail)
\ No newline at end of file
// <TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10,borderRadius:5 }} onChangeText={(address) => this.setState({ address })} />
\ No newline at end of file
...@@ -32,6 +32,9 @@ class DeliveryAddrees extends React.Component { ...@@ -32,6 +32,9 @@ class DeliveryAddrees extends React.Component {
}) })
this.getAddreess() this.getAddreess()
}); });
this.setState({
indicator: true
})
this.getAddreess() this.getAddreess()
} }
...@@ -241,14 +244,14 @@ class DeliveryAddrees extends React.Component { ...@@ -241,14 +244,14 @@ class DeliveryAddrees extends React.Component {
handleDeleteAddress(id) { handleDeleteAddress(id) {
Alert.alert( Alert.alert(
"", "",
"Apakah Anda ingin menghapus Alamat ? ", i18n.t('alertdeleteaddress'),
[ [
{ {
text: "Tidak", text: i18n.t('alertno'),
onPress: () => console.log("Cancel Pressed"), onPress: () => console.log("Cancel Pressed"),
style: "cancel" style: "cancel"
}, },
{ text: "Ya", onPress: () => this.deleteAddress(id) } { text: i18n.t('alertyes'), onPress: () => this.deleteAddress(id) }
], ],
{ cancelable: false } { cancelable: false }
); );
...@@ -282,10 +285,10 @@ class DeliveryAddrees extends React.Component { ...@@ -282,10 +285,10 @@ class DeliveryAddrees extends React.Component {
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={{ flex: 0.5 }}> <View style={{ flex:1}}>
<TouchableOpacity style={{ flex: 1, flexDirection: 'row', margin: 5 }} onPress={() => this.handleDeleteAddress(item.id)}> <TouchableOpacity style={{ flex: 1, flexDirection: 'row',justifyContent:"center" }} onPress={() => this.handleDeleteAddress(item.id)}>
<View style={{ justifyContent: 'center' }}> <View style={{ alignSelf:"center",marginTop:20}}>
<EvilIcons name="trash" size={40} color="black" /> <EvilIcons name="trash" size={40} color="#ccb46c" />
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
......
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