|
@@ -7,7 +7,7 @@ import { |
|
|
Image, |
|
|
Image, |
|
|
TouchableOpacity, |
|
|
TouchableOpacity, |
|
|
} from "react-native"; |
|
|
} from "react-native"; |
|
|
import { Container, Left, Icon, Footer, Col,Right } from "native-base"; |
|
|
|
|
|
|
|
|
import { Container, Left, Icon, Footer, Col, Right } from "native-base"; |
|
|
import { Button } from "react-native-elements"; |
|
|
import { Button } from "react-native-elements"; |
|
|
import axios from "axios"; |
|
|
import axios from "axios"; |
|
|
import { connect } from "react-redux"; |
|
|
import { connect } from "react-redux"; |
|
@@ -52,15 +52,15 @@ class AddressList extends Component<Props> { |
|
|
this.getProfile(); |
|
|
this.getProfile(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async componentDidMount() { |
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
this.getProfile(); |
|
|
this.getProfile(); |
|
|
this._unsubscribe = this.props.navigation.addListener("focus", () => { |
|
|
|
|
|
this.address_list(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// this._unsubscribe = this.props.navigation.addListener("focus", () => { |
|
|
|
|
|
// this.address_list(); |
|
|
|
|
|
// }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
componentWillUnmount() { |
|
|
componentWillUnmount() { |
|
|
this._unsubscribe(); |
|
|
|
|
|
|
|
|
// this._unsubscribe(); |
|
|
} |
|
|
} |
|
|
getProfile = async () => { |
|
|
getProfile = async () => { |
|
|
await axios |
|
|
await axios |
|
@@ -70,86 +70,93 @@ class AddressList extends Component<Props> { |
|
|
.then((res) => { |
|
|
.then((res) => { |
|
|
this.setState({ order2: res.data.data.addressess }); |
|
|
this.setState({ order2: res.data.data.addressess }); |
|
|
console.log(res.data.data.addressess); |
|
|
console.log(res.data.data.addressess); |
|
|
// alert(this.state.order2)profilePicture |
|
|
|
|
|
// this.setState({ |
|
|
|
|
|
|
|
|
|
|
|
// // customer_name: res.data.data.username, |
|
|
|
|
|
// // phone_number: res.data.data.number, |
|
|
|
|
|
// // email: res.data.data.email, |
|
|
|
|
|
// // blood_group:res.data.data.blood_group |
|
|
|
|
|
// }) |
|
|
|
|
|
}) |
|
|
}) |
|
|
.catch((res) => { |
|
|
.catch((res) => { |
|
|
console.log(res); |
|
|
console.log(res); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
address_list = async () => { |
|
|
|
|
|
this.setState({ isLoding: true }); |
|
|
|
|
|
this.setState({ dialogVisible: false }); |
|
|
|
|
|
this.props.deleteServiceActionPending(); |
|
|
|
|
|
await axios({ |
|
|
|
|
|
method: "post", |
|
|
|
|
|
url: api_url + address_list, |
|
|
|
|
|
data: { customer_id: global.id }, |
|
|
|
|
|
}) |
|
|
|
|
|
.then(async (response) => { |
|
|
|
|
|
//alert(JSON.stringify(response)); |
|
|
|
|
|
this.setState({ |
|
|
|
|
|
isLoding: false, |
|
|
|
|
|
result: response.data.result, |
|
|
|
|
|
api_status: 1, |
|
|
|
|
|
}); |
|
|
|
|
|
await this.props.deleteServiceActionSuccess(response.data); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
this.setState({ isLoding: false }); |
|
|
|
|
|
this.props.deleteServiceActionError(error); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
// address_list = async () => { |
|
|
|
|
|
// this.setState({ isLoding: true }); |
|
|
|
|
|
// this.setState({ dialogVisible: false }); |
|
|
|
|
|
// this.props.deleteServiceActionPending(); |
|
|
|
|
|
// await axios({ |
|
|
|
|
|
// method: "post", |
|
|
|
|
|
// url: api_url + address_list, |
|
|
|
|
|
// data: { customer_id: global.id }, |
|
|
|
|
|
// }) |
|
|
|
|
|
// .then(async (response) => { |
|
|
|
|
|
// //alert(JSON.stringify(response)); |
|
|
|
|
|
// this.setState({ |
|
|
|
|
|
// isLoding: false, |
|
|
|
|
|
// result: response.data.result, |
|
|
|
|
|
// api_status: 1, |
|
|
|
|
|
// }); |
|
|
|
|
|
// await this.props.deleteServiceActionSuccess(response.data); |
|
|
|
|
|
// }) |
|
|
|
|
|
// .catch((error) => { |
|
|
|
|
|
// this.setState({ isLoding: false }); |
|
|
|
|
|
// this.props.deleteServiceActionError(error); |
|
|
|
|
|
// }); |
|
|
|
|
|
// }; |
|
|
|
|
|
|
|
|
address_delete = async () => { |
|
|
|
|
|
this.setState({ isLoding: true }); |
|
|
|
|
|
this.setState({ dialogVisible: false }); |
|
|
|
|
|
this.props.deleteServiceActionPending(); |
|
|
|
|
|
await axios({ |
|
|
|
|
|
method: "post", |
|
|
|
|
|
url: api_url + address_delete, |
|
|
|
|
|
data: { customer_id: global.id, address_id: this.state.deleting_address }, |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
address_delete = async (id) => { |
|
|
|
|
|
//eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZDhiOGU3MDA5MWUyMDAxNjEzYWVkOSIsImlhdCI6MTY0MTg3OTYwNSwiZXhwIjoxNjUwNTE5NjA1fQ.Dc4VQba1h21Xj-PFI7ln--n1o-l7ilQgv8GlkASziCM |
|
|
|
|
|
// await axios |
|
|
|
|
|
// .delete( |
|
|
|
|
|
// `${api_url1}/clients/address/`, |
|
|
|
|
|
// { _id: id }, |
|
|
|
|
|
// { headers: { Authorization: `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZDhiOGU3MDA5MWUyMDAxNjEzYWVkOSIsImlhdCI6MTY0MTg3OTYwNSwiZXhwIjoxNjUwNTE5NjA1fQ.Dc4VQba1h21Xj-PFI7ln--n1o-l7ilQgv8GlkASziCM` } } |
|
|
|
|
|
// //{ headers: { Authorization: `Bearer ${global.fcm_token}` } } |
|
|
|
|
|
// ) |
|
|
|
|
|
// .then((res) => { |
|
|
|
|
|
// alert(res); |
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await axios |
|
|
|
|
|
.delete( |
|
|
|
|
|
`${api_url1}/clients/address`, |
|
|
|
|
|
{ headers: { Authorization: `Bearer ${global.fcm_token}` } } |
|
|
|
|
|
, { _id: id } |
|
|
|
|
|
) |
|
|
.then(async (response) => { |
|
|
.then(async (response) => { |
|
|
this.setState({ isLoding: false }); |
|
|
|
|
|
await this.props.deleteServiceActionSuccess(response.data); |
|
|
|
|
|
await this.setState({ deleting_address: 0 }); |
|
|
|
|
|
|
|
|
// console.log(response); |
|
|
|
|
|
alert('address deleted'); |
|
|
|
|
|
this.getProfile(); |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
.catch((error) => { |
|
|
|
|
|
this.setState({ isLoding: false }); |
|
|
|
|
|
this.props.deleteServiceActionError(error); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// this.setState({ isLoding: true }); |
|
|
|
|
|
// this.setState({ dialogVisible: false }); |
|
|
|
|
|
// this.props.deleteServiceActionPending(); |
|
|
|
|
|
// await axios.delete(), |
|
|
|
|
|
// url: api_url + address_delete, |
|
|
|
|
|
// data: {address_id: id }, |
|
|
|
|
|
// }) |
|
|
|
|
|
// .then(async (response) => { |
|
|
|
|
|
// // this.setState({ isLoding: false }); |
|
|
|
|
|
// // await this.props.deleteServiceActionSuccess(response.data); |
|
|
|
|
|
// // await this.setState({ deleting_address: 0 }); |
|
|
|
|
|
// }) |
|
|
|
|
|
// .catch((error) => { |
|
|
|
|
|
// this.setState({ isLoding: false }); |
|
|
|
|
|
// this.props.deleteServiceActionError(error); |
|
|
|
|
|
// }); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
open_popup(id) { |
|
|
|
|
|
this.setState({ dialogVisible: true, deleting_address: id }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// open_popup(id) { |
|
|
|
|
|
// this.setState({ dialogVisible: true, deleting_address: id }); |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
close_popup() { |
|
|
|
|
|
this.setState({ dialogVisible: false, deleting_address: 0 }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// close_popup() { |
|
|
|
|
|
// this.setState({ dialogVisible: false, deleting_address: 0 }); |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
handleBackButtonClick = () => { |
|
|
handleBackButtonClick = () => { |
|
|
this.props.navigation.goBack(null); |
|
|
this.props.navigation.goBack(null); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
add_address = () => { |
|
|
add_address = () => { |
|
|
RNAndroidLocationEnabler.promptForEnableLocationIfNeeded({ |
|
|
|
|
|
interval: 10000, |
|
|
|
|
|
fastInterval: 5000, |
|
|
|
|
|
}) |
|
|
|
|
|
.then((data) => { |
|
|
|
|
|
this.props.navigation.navigate("AddressMap"); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((err) => { |
|
|
|
|
|
alert("Please enable your location"); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.props.navigation.navigate("AddressMap"); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
edit_address = (id) => { |
|
|
edit_address = (id) => { |
|
@@ -197,45 +204,45 @@ class AddressList extends Component<Props> { |
|
|
<Text style={styles.add_list_style3}>Address #{key + 1}</Text> |
|
|
<Text style={styles.add_list_style3}>Address #{key + 1}</Text> |
|
|
</Left> |
|
|
</Left> |
|
|
</View> |
|
|
</View> |
|
|
<View style={styles.add_list_style4}> |
|
|
|
|
|
|
|
|
{/* <View style={styles.add_list_style4}> |
|
|
<Image |
|
|
<Image |
|
|
style={styles.add_list_style5} |
|
|
style={styles.add_list_style5} |
|
|
source={{ uri: img_url + row.static_map }} |
|
|
source={{ uri: img_url + row.static_map }} |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
|
|
|
|
|
|
</View> */} |
|
|
<View style={styles.add_list_style6}> |
|
|
<View style={styles.add_list_style6}> |
|
|
<Left> |
|
|
<Left> |
|
|
<Text style={styles.add_list_style7}>{row.addressLine1}</Text> |
|
|
<Text style={styles.add_list_style7}>{row.addressLine1}</Text> |
|
|
<Text style={styles.add_list_style7}> |
|
|
<Text style={styles.add_list_style7}> |
|
|
{row.city},{row.state},{row.country} |
|
|
{row.city},{row.state},{row.country} |
|
|
</Text> |
|
|
</Text> |
|
|
|
|
|
<Text style={styles.add_list_style7}>{row.pincode}</Text> |
|
|
</Left> |
|
|
</Left> |
|
|
</View> |
|
|
</View> |
|
|
<View style={styles.add_list_style8}> |
|
|
<View style={styles.add_list_style8}> |
|
|
<Col style={styles.add_list_style9}> |
|
|
<Col style={styles.add_list_style9}> |
|
|
|
|
|
|
|
|
<View |
|
|
|
|
|
style={{flexDirection:'row',justifyContent:'space-between'}} |
|
|
|
|
|
> |
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
flexDirection: "row", |
|
|
|
|
|
justifyContent: "space-between", |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
{/* <Text |
|
|
// onPress={this.edit_address.bind(this, row.id)} |
|
|
// onPress={this.edit_address.bind(this, row.id)} |
|
|
style={styles.add_list_style10} |
|
|
style={styles.add_list_style10} |
|
|
> |
|
|
> |
|
|
EDIT |
|
|
EDIT |
|
|
</Text> |
|
|
|
|
|
<Text |
|
|
|
|
|
// onPress={this.edit_address.bind(this, row.id)} |
|
|
|
|
|
style={styles.add_list_style10} |
|
|
|
|
|
|
|
|
</Text> */} |
|
|
|
|
|
<TouchableOpacity |
|
|
|
|
|
onPress={() => { |
|
|
|
|
|
this.address_delete(row._id); |
|
|
|
|
|
}} |
|
|
> |
|
|
> |
|
|
Delete |
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
<Text style={styles.add_list_style10}>Delete</Text> |
|
|
|
|
|
</TouchableOpacity> |
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Right> |
|
|
|
|
|
|
|
|
|
|
|
</Right> |
|
|
|
|
|
|
|
|
<Right /> |
|
|
</Col> |
|
|
</Col> |
|
|
{/*<Col style={{ width:'25%' }}> |
|
|
{/*<Col style={{ width:'25%' }}> |
|
|
<Text onPress={this.open_popup.bind(this,row.id)} style={styles.btn} >DELETE</Text> |
|
|
<Text onPress={this.open_popup.bind(this,row.id)} style={styles.btn} >DELETE</Text> |
|
|