feat: Add date picker and phone number validation for user input

This commit is contained in:
Don Wilfried 2025-07-01 10:46:41 +01:00
parent 5ff764381d
commit 6ab275100e
7 changed files with 62 additions and 30 deletions

View File

@ -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)}
<Dropdown
label={`${I18n.t('ARRONDISSEMENT')} *`}
data={this.result.districts}
useNativeDriver={true}
disabled={true}
value={this.state.district}
valueExtractor={(value) => {
return value

View File

@ -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)) {

View File

@ -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)) {

View File

@ -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')}
</Button>
</View>

View File

@ -756,5 +756,6 @@
"SIGNBOARD": "Acronym *",
"CREATION_DATE": "Creation Date",
"TECHNICAL_APPROVAL": "Technical Approval",
"TRADE_LICENSE": "Business License"
"TRADE_LICENSE": "Business License",
"PAY": "Pay"
}

View File

@ -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"
}

View File

@ -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';