From 6ab275100eb0cddc14d06dc3e6dd21e5f61df5be Mon Sep 17 00:00:00 2001 From: Don Wilfried Date: Tue, 1 Jul 2025 10:46:41 +0100 Subject: [PATCH] feat: Add date picker and phone number validation for user input --- app/screens/login/CreateUserStep.js | 35 +++++++++++++++++-- app/screens/login/createAccount.js | 8 ++--- app/screens/login/createUserStep2.js | 20 +++++++++++ .../wallet/regisseur/NumeroQuitanceDetail.js | 2 +- app/utils/i18n/en.json | 3 +- app/utils/i18n/fr.json | 3 +- app/webservice/IlinkConstants.js | 21 ----------- 7 files changed, 62 insertions(+), 30 deletions(-) diff --git a/app/screens/login/CreateUserStep.js b/app/screens/login/CreateUserStep.js index 4a4aa34..9e8a4f1 100644 --- a/app/screens/login/CreateUserStep.js +++ b/app/screens/login/CreateUserStep.js @@ -13,6 +13,7 @@ import { TouchableOpacity, View } from 'react-native'; +import DateTimePicker from "@react-native-community/datetimepicker" import CheckBox from '@react-native-community/checkbox'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import {responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions'; @@ -161,7 +162,7 @@ class CreateUserStep extends Component { messageRequiredImage: "", selectedTax: null, accountType:"", - cni_number:"", + cni_number:null, birth_date:new Date(), birth_place:"", birth_country:"", @@ -182,7 +183,36 @@ class CreateUserStep extends Component { this.props.saveActifSocietyReset(); OneSignal.addEventListener('ids', this.onIds); } + // Méthode appelée lors de la sélection d'une date + onChangeDate = (event, selectedDate) => { + // Sur Android, si l'utilisateur annule, event.type sera "dismissed" + if (Platform.OS === 'android' && event.type === 'dismissed') { + this.setState({ showDatePicker: false }); + return; + } + const currentDate = selectedDate || this.state.entreprise_creation_date; + this.setState({ + entreprise_creation_date: currentDate, + showDatePicker: Platform.OS === 'ios' // en iOS, le picker reste affiché + }); + }; + onChangeDate2 = (event, selectedDate) => { + // Sur Android, si l'utilisateur annule, event.type sera "dismissed" + if (Platform.OS === 'android' && event.type === 'dismissed') { + this.setState({ showDatePicker: false }); + return; + } + const currentDate = selectedDate || this.state.birth_date; + this.setState({ + birth_date: currentDate, + showDatePicker: Platform.OS === 'ios' // en iOS, le picker reste affiché + }); + }; + // Afficher le date picker + showDatePicker = () => { + this.setState({ showDatePicker: true }); + }; createFormData = (photo) => { this.dataToSendTemp.append("image", { name: photo.path.split('/').pop(), @@ -1781,11 +1811,12 @@ handleTaxSlection = (selectedTax) => { paddingRight: 20, backgroundColor: 'white' }}> + {console.log("this.result.districts===>>",this.result.districts)} + {console.log("this.state.district===>>",this.state.district)} { return value diff --git a/app/screens/login/createAccount.js b/app/screens/login/createAccount.js index c7e87c2..3f09071 100644 --- a/app/screens/login/createAccount.js +++ b/app/screens/login/createAccount.js @@ -233,7 +233,7 @@ export default class CreateAccount extends Component { labelExtractor={(item, index) => item.label} onChangeText={(value, index, data) => { let user = this.state.user; - user.nationalty_id = value; + user.nationality_id = value; this.setState({user}); }} /> @@ -393,7 +393,7 @@ export default class CreateAccount extends Component { labelExtractor={(item, index) => item.label} onChangeText={(value, index, data) => { let user = this.state.user; - user.nationalty_id = value; // <=== on stocke en integer + user.nationality_id = value; // <=== on stocke en integer this.setState({user}); }} /> @@ -506,7 +506,7 @@ export default class CreateAccount extends Component { if (user !== undefined) { if (this.checkOrShake(user.civility_id, this.civiliteAnim)) { // Vérification Nationalité - if (this.checkOrShake(user.nationalty_id, this.nationalityAnim)) { + if (this.checkOrShake(user.nationality_id, this.nationalityAnim)) { if (this.checkOrShake(user.lastname, this.nameanim)) { if (this.checkOrShake(user.address, this.surnameanim)) { if (this.checkOrShake(user.email, this.mailanim)) { @@ -545,7 +545,7 @@ export default class CreateAccount extends Component { this.setState({isLoging: true}); if (user !== undefined) { if (this.checkOrShake(user.civility_id, this.civiliteAnim)) { - if (this.checkOrShake(user.nationalty_id, this.nationalityAnim)) { + if (this.checkOrShake(user.nationality_id, this.nationalityAnim)) { if (this.checkOrShake(user.lastname, this.nameanim)) { if (this.checkOrShake(user.address, this.surnameanim)) { if (this.checkOrShake(user.email, this.mailanim)) { diff --git a/app/screens/login/createUserStep2.js b/app/screens/login/createUserStep2.js index 49802f4..f655f84 100644 --- a/app/screens/login/createUserStep2.js +++ b/app/screens/login/createUserStep2.js @@ -159,6 +159,17 @@ export default class CreateUserStep2 extends Component { console.log("props", this.props); } + // Fonction de validation pour les numéros de téléphone camerounais + validateCameroonPhoneNumber = (phoneNumber) => { + if (!phoneNumber) { + return false; // Si le numéro est vide, retourne false + } + console.log("Phone number===>>", phoneNumber); + const trimmedPhoneNumber = phoneNumber.trim(); + const phoneRegex = /^\d{9}$/; + return phoneRegex.test(trimmedPhoneNumber); + } + createFormData = (photo) => { this.dataToSendTemp.append("image", { name: photo.path.split('/').pop(), @@ -1255,6 +1266,15 @@ export default class CreateUserStep2 extends Component { checkUserGeolocated() { let {myPosition, textaddress, place, indicatif, user, network, phone, phoneTransaction} = this.state; this.setState({isLoading: true}) + // Validation des numéros de téléphone + const isPhoneValid = this.validateCameroonPhoneNumber(phone); + const isPhoneTransactionValid = this.validateCameroonPhoneNumber(phoneTransaction); + + if (!isPhoneValid || !isPhoneTransactionValid) { + Alert.alert("Erreur", "Les numéros de téléphone doivent être des numéros camerounais valides de 9 chiffres (ex: 656391882)."); + this.setState({isLoading: false}); + return; + } if (user !== undefined) { if (this.checkOrShake(phone, this.numanim)) { if (this.checkOrShake(network, this.networkanim)) { diff --git a/app/screens/wallet/regisseur/NumeroQuitanceDetail.js b/app/screens/wallet/regisseur/NumeroQuitanceDetail.js index dbc47ad..602ce6f 100644 --- a/app/screens/wallet/regisseur/NumeroQuitanceDetail.js +++ b/app/screens/wallet/regisseur/NumeroQuitanceDetail.js @@ -947,7 +947,7 @@ class NumeroQuitanceDetail extends Component { disabled={true} textStyle={styles.textbtnstyle} > - {this.state.isModify ? I18n.t('MODIFY') : I18n.t('SAVE')} + {this.state.isModify ? I18n.t('MODIFY') : I18n.t('PAY')} diff --git a/app/utils/i18n/en.json b/app/utils/i18n/en.json index 7995808..78498d6 100644 --- a/app/utils/i18n/en.json +++ b/app/utils/i18n/en.json @@ -756,5 +756,6 @@ "SIGNBOARD": "Acronym *", "CREATION_DATE": "Creation Date", "TECHNICAL_APPROVAL": "Technical Approval", - "TRADE_LICENSE": "Business License" + "TRADE_LICENSE": "Business License", + "PAY": "Pay" } diff --git a/app/utils/i18n/fr.json b/app/utils/i18n/fr.json index e66edb2..9e9939e 100644 --- a/app/utils/i18n/fr.json +++ b/app/utils/i18n/fr.json @@ -756,5 +756,6 @@ "SIGNBOARD": "Sigle *", "CREATION_DATE": "Date de création", "TECHNICAL_APPROVAL": "Agrément technique", - "TRADE_LICENSE": "Patente" + "TRADE_LICENSE": "Patente", + "PAY": "Payer" } diff --git a/app/webservice/IlinkConstants.js b/app/webservice/IlinkConstants.js index 695ca20..32e6ac9 100644 --- a/app/webservice/IlinkConstants.js +++ b/app/webservice/IlinkConstants.js @@ -1,31 +1,10 @@ export const isDebugMode = false; -//base url test -//export const baseUrl = "https://ilink-app.com/mobilebackendbeta" -//base url production -//export const baseUrl = "https://ilink-app.com/mobilebackend"; -//export const baseUrl = "https://test.ilink-app.com/mobilebackendtest"; -//export const baseUrl = "http://test.ilink-app.com:8080/mobilebackendtest"; -//const baseUrl = "https://ilink-app.com/mobilebackendtest2"; - -/*export const baseUrl = "http://city.ilink-app.com:8080/mobilebackend"; -export const testBaseUrl = "https://city.ilink-app.com:8081";*/ export const baseUrl = 'https://test-cud.ilink-app.com:9080/mobilebackend'; export const testBaseUrl = 'https://test-cud.ilink-app.com:9081'; -//CUD -// export const baseUrl = "https://test-cud.ilink-app.com:9080/mobilebackend"; -// export const testBaseUrl = "https://test-cud.ilink-app.com:9081"; -// les derniers api modifiers commune X -// export const baseUrl = "http://test-city.ilink-app.com:8080/mobilebackend"; -// export const testBaseUrl = "https://test-city.ilink-app.com:8081"; -/* export const baseUrl = "https://preprod.ilink-app.com:8080/mobilebackend"; -export const testBaseUrl = "https://preprod.ilink-app.com"; */ - -//base url agent test -//const baseUrl = "https://ilink-app.com/mobilebackendtest"; export const adhesionUrl = baseUrl + '/interacted/LoginAction.php'; export const memberActionUrl = baseUrl + '/interacted/MembersAction.php';