feat: Enhance AddNetwork functionality with neighborhood selection and update AssignAgentGeo to include neighborhood parameter
This commit is contained in:
parent
405c2ce49d
commit
dab2e5e867
|
@ -130,7 +130,7 @@ android {
|
|||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
|
||||
// TODO: Switch from test to prod and vice versa
|
||||
defaultConfig {
|
||||
// applicationId "com.test_city.douala3"
|
||||
applicationId "com.test_city.douala3test"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<resources>
|
||||
<!-- TODO: Switch from test to prod and vice versa -->
|
||||
<string name="app_name">Test SIM_ba mobile CAD3</string>
|
||||
<!-- <string name="app_name">SIM_ba mobile CAD3</string> -->
|
||||
</resources>
|
||||
|
|
|
@ -19,6 +19,7 @@ import {ProgressDialog} from "react-native-simple-dialogs";
|
|||
import axios from "axios";
|
||||
import {uploadImage} from "../../webservice/IlinkConstants";
|
||||
import Dialog from "react-native-dialog";
|
||||
import FilteredList from "../login/FilteredList ";
|
||||
|
||||
let theme = require('./../../utils/theme.json');
|
||||
|
||||
|
@ -115,7 +116,10 @@ export default class AddNetwork extends Component {
|
|||
displayImage: false,
|
||||
loadingUpload: false,
|
||||
item: this.props.navigation.getParam("item", null),
|
||||
password: null
|
||||
password: null,
|
||||
neighborhood: null,
|
||||
building_value: [],
|
||||
built: [false]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,6 +223,14 @@ export default class AddNetwork extends Component {
|
|||
}
|
||||
|
||||
renderTaxesDropdown = (index) => {
|
||||
const selectedNeighbourhood = this.state.result && this.state.result.neighborhoods
|
||||
? this.state.result.neighborhoods.find(n => n.name === this.state.neighborhood)
|
||||
: null;
|
||||
const mercurialValue = selectedNeighbourhood
|
||||
? (this.state.built[index]
|
||||
? selectedNeighbourhood.mercur_built_value
|
||||
: selectedNeighbourhood.mercur_unbuilt_value)
|
||||
: null;
|
||||
return (
|
||||
<>
|
||||
<Animatable.View key={index}>
|
||||
|
@ -348,6 +360,65 @@ export default class AddNetwork extends Component {
|
|||
</> :
|
||||
null
|
||||
}
|
||||
{
|
||||
!isNil(this.state.taxes_selected[index]) &&
|
||||
this.state.taxes_selected[index].name?.toLowerCase() === 'taxe sur la propriété' && (
|
||||
<>
|
||||
<Animatable.View>
|
||||
<View
|
||||
style={{
|
||||
width: responsiveWidth(90),
|
||||
alignSelf: 'center',
|
||||
backgroundColor: 'white',
|
||||
borderRadius: 10,
|
||||
marginTop: 20,
|
||||
paddingLeft: 20,
|
||||
paddingRight: 20,
|
||||
}}>
|
||||
<Dropdown
|
||||
label={I18n.t('BUILDING_CONSTRUCTED')}
|
||||
data={[{value: 'Non'}, {value: 'Oui'}]}
|
||||
value={this.state.built[index] ? 'Oui' : 'Non'}
|
||||
onChangeText={value => {
|
||||
const built = [...this.state.built];
|
||||
built[index] = value === 'Oui';
|
||||
this.setState({built});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</Animatable.View>
|
||||
{mercurialValue != null && (
|
||||
<Text
|
||||
style={{
|
||||
marginTop: 5,
|
||||
marginLeft: responsiveWidth(6),
|
||||
fontSize: 16,
|
||||
color: '#fff',
|
||||
}}>
|
||||
{`${I18n.t('MERCURIAL_VALUE')}: ${mercurialValue}`}
|
||||
</Text>
|
||||
)}
|
||||
{this.state.built[index] && (
|
||||
<Animatable.View>
|
||||
<Fumi
|
||||
iconClass={FontAwesomeIcon}
|
||||
iconName="building"
|
||||
label={I18n.t('CONSTRUCTION_VALUE')}
|
||||
iconColor="#f95a25"
|
||||
iconSize={20}
|
||||
keyboardType="decimal-pad"
|
||||
style={styles.input}
|
||||
onChangeText={value => {
|
||||
const building_value = [...this.state.building_value];
|
||||
building_value[index] = value;
|
||||
this.setState({building_value});
|
||||
}}
|
||||
/>
|
||||
</Animatable.View>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
{
|
||||
!isNil(this.state.taxes_selected[index]) ?
|
||||
this.state.taxes_selected[index].billing_period === 'jour' &&
|
||||
|
@ -408,6 +479,9 @@ export default class AddNetwork extends Component {
|
|||
|
||||
|
||||
render() {
|
||||
const hasPropertyTax = this.state.taxes_selected.some(
|
||||
t => t && t.name?.toLowerCase() === 'taxe sur la propriété'
|
||||
);
|
||||
return (
|
||||
<View style={style.container}>
|
||||
<StatusBar
|
||||
|
@ -443,6 +517,17 @@ export default class AddNetwork extends Component {
|
|||
</> :
|
||||
<>
|
||||
{this.renderTaxesDropdown(0)}
|
||||
{hasPropertyTax && (
|
||||
<Animatable.View>
|
||||
<FilteredList
|
||||
items={this.state.result.neighborhoods}
|
||||
placeholder={I18n.t('FIND_A_NEIGHBORHOOD')}
|
||||
onItemSelect={selectedItem => {
|
||||
this.setState({neighborhood: selectedItem.name});
|
||||
}}
|
||||
/>
|
||||
</Animatable.View>
|
||||
)}
|
||||
{
|
||||
this.state.tabTaxe.map((element, index) => (
|
||||
index > 0 &&
|
||||
|
@ -517,26 +602,38 @@ export default class AddNetwork extends Component {
|
|||
for (let i = 0; i < this.state.tabTaxe.length; i++) {
|
||||
if (this.state.taxes_selected[i].hasOwnProperty("id")) {
|
||||
if (this.state.taxes_selected[i].has_image_capture === "1") {
|
||||
taxes_to_send.push({
|
||||
let taxe = {
|
||||
has_image_capture: this.state.taxes_selected[i].has_image_capture,
|
||||
image: this.state.taxes_selected[i].image,
|
||||
id_network_tax: this.state.taxes_selected[i].id,
|
||||
name: this.state.taxes_selected[i].name,
|
||||
tax_units_count: isNil(this.state.tax_units_count[i]) ? null : this.state.tax_units_count[i],
|
||||
units_per_tax_unit_count: isNil(this.state.units_per_tax_unit_count[i]) ? null : this.state.units_per_tax_unit_count[i],
|
||||
number_of_days: isNil(this.state.number_of_days[i]) ? null : this.state.number_of_days[i],
|
||||
});
|
||||
};
|
||||
if (this.state.taxes_selected[i].name?.toLowerCase() === 'taxe sur la propriété') {
|
||||
taxe.building_value = isNil(this.state.building_value[i]) ? null : this.state.building_value[i];
|
||||
taxe.built = this.state.built[i];
|
||||
}
|
||||
taxes_to_send.push(taxe);
|
||||
} else {
|
||||
taxes_to_send.push({
|
||||
let taxe = {
|
||||
has_image_capture: this.state.taxes_selected[i].has_image_capture,
|
||||
id_network_tax: this.state.taxes_selected[i].id,
|
||||
name: this.state.taxes_selected[i].name,
|
||||
tax_units_count: isNil(this.state.tax_units_count[i]) ? null : this.state.tax_units_count[i],
|
||||
units_per_tax_unit_count: isNil(this.state.units_per_tax_unit_count[i]) ? null : this.state.units_per_tax_unit_count[i],
|
||||
number_of_days: isNil(this.state.number_of_days[i]) ? null : this.state.number_of_days[i],
|
||||
});
|
||||
};
|
||||
if (this.state.taxes_selected[i].name?.toLowerCase() === 'taxe sur la propriété') {
|
||||
taxe.building_value = isNil(this.state.building_value[i]) ? null : this.state.building_value[i];
|
||||
taxe.built = this.state.built[i];
|
||||
}
|
||||
taxes_to_send.push(taxe);
|
||||
}
|
||||
}
|
||||
}
|
||||
let res = await AssignAgentGeo(validateCode, enterPhone, taxes_to_send, item.id_agent, password, item.id);
|
||||
let res = await AssignAgentGeo(validateCode, enterPhone, taxes_to_send, item.id_agent, password, item.id, this.state.neighborhood);
|
||||
this.setState({isLoading: false});
|
||||
if (res) {
|
||||
if (res['success'] !== undefined) {
|
||||
|
@ -600,8 +697,8 @@ const style = StyleSheet.create({
|
|||
marginTop: 20,
|
||||
borderColor: 'transparent',
|
||||
backgroundColor: theme.primaryDarkAdvanced,
|
||||
height: responsiveHeight(8)
|
||||
|
||||
height: responsiveHeight(8),
|
||||
marginBottom: responsiveHeight(8) // espace ajouté en bas
|
||||
},
|
||||
appContainer: {
|
||||
flexDirection: 'row',
|
||||
|
|
|
@ -411,7 +411,7 @@ export const generateAgentGeo = async (newPhone) => {
|
|||
}, memberActionUrl)
|
||||
return items;
|
||||
}
|
||||
export const AssignAgentGeo = async (codeValidation, phone, taxes, id_agent, password, id_tax_notice) => {
|
||||
export const AssignAgentGeo = async (codeValidation, phone, taxes, id_agent, password, id_tax_notice, neighborhood) => {
|
||||
const user = await readUser();
|
||||
const items = await queryData({
|
||||
"type": "assignNetworkAgentToGeo",
|
||||
|
@ -423,7 +423,8 @@ export const AssignAgentGeo = async (codeValidation, phone, taxes, id_agent, pas
|
|||
"lang": I18n.currentLocale(),
|
||||
agentId: id_agent,
|
||||
password,
|
||||
id_tax_notice
|
||||
id_tax_notice,
|
||||
neighborhood
|
||||
}, memberActionUrl)
|
||||
return items;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export const isDebugMode = false
|
||||
|
||||
// TODO: Switch from test to prod and vice versa
|
||||
|
||||
// PROD URL
|
||||
// export const baseUrl = "https://city-douala3.ilink-app.com:8080/mobilebackend";
|
||||
// export const testBaseUrl= "https://city-douala3.ilink-app.com:8081";
|
||||
|
|
Loading…
Reference in New Issue