feat: Enhance user search functionality with improved payload handling and logging

This commit is contained in:
Don Wilfried 2025-07-09 06:00:55 +01:00
parent 6ab275100e
commit cbe0067fdd
7 changed files with 161 additions and 129 deletions

View File

@ -2429,105 +2429,127 @@ class Home extends BaseScreen {
title={I18n.t("SEARCH")}
visible={this.state.dialogSearchUser}
onCancel={() => this.setState({ dialogSearchUser: false })}
onOk={result => {
onOk={() => {
console.log(
"On ok search user===>>",
this.state.userName,
this.state.indicatif,
this.state.isPhoneAssureSearch,
this.state.isNumeroAssureSearch
);
// Prépare le payload
const payload = { dial_code: this.state.indicatif };
if (this.state.isPhoneAssureSearch) {
this.props.searchUserAction({
dial_code: this.state.indicatif,
phone: this.state.userName,
}, true);
payload.phone = this.state.userName;
} else if (this.state.isNumeroAssureSearch) {
payload.identification_number = this.state.userName;
} else {
this.props.searchUserAction({
dial_code: this.state.indicatif,
name: this.state.userName,
}, true);
payload.name = this.state.userName;
}
// Lance l'action
this.props.searchUserAction(payload, true);
this.setState({ dialogSearchUser: false });
}}
>
<View>
<TextInput
style={{marginTop: 10, height: 46, borderRadius: 5, borderWidth: 1, borderColor: "#ccc"}}
placeholder={this.state.isPhoneAssureSearch ? I18n.t('PHONE') : I18n.t('NAME')}
value={this.state.userName}
keyboardType={this.state.isPhoneAssureSearch ? 'numeric' : 'default'}
onChangeText={(userName) => {
this.setState({userName});
style={{
marginTop: 10, height: 46, borderRadius: 5, borderWidth: 1, borderColor: "#ccc"
}}
placeholder={
this.state.isPhoneAssureSearch
? I18n.t("PHONE")
: this.state.isNumeroAssureSearch
? I18n.t("IMMATRICULATION_DGI") // nouveau libellé à ajouter dans vos traductions
: I18n.t("NAME")
}
value={this.state.userName}
keyboardType={this.state.isPhoneAssureSearch ? "numeric" : "default"}
onChangeText={userName => this.setState({ userName })}
icon={
<FontAwesome
style={{ zIndex: 10 }}
name={this.state.isPhoneAssureSearch ? 'phone' : 'user'}
name={
this.state.isPhoneAssureSearch
? "phone"
: this.state.isNumeroAssureSearch
? "id-card" // icône FontAwesome5 pour le NIU
: "user"
}
size={20}
/>
}
/>
<View style={{
flexDirection: 'row',
position: 'absolute',
<View
style={{
flexDirection: "row",
position: "absolute",
top: 22,
right: 50,
justifyContent: 'space-between',
width: 50
}}>
<FontAwesomeIcon
style={{paddingRight: 5}}
name='phone'
size={20}
color={Color.primaryColor}
onPress={() => {
this.setState({
isNumeroAssureSearch: false,
isPhoneAssureSearch: true
});
right: 20,
}}
/>
>
{/* Mode téléphone */}
<FontAwesomeIcon
style={{paddingRight: 5}}
name='user'
name="phone"
size={20}
color={Color.primaryColor}
onPress={() => {
color={this.state.isPhoneAssureSearch ? Color.primaryColor : "#888"}
onPress={() =>
this.setState({
isNumeroAssureSearch: false,
isPhoneAssureSearch: false
});
}}
isPhoneAssureSearch: true,
isNumeroAssureSearch: false
})
}
style={{ marginHorizontal: 5 }}
/>
{/* Mode nom */}
<FontAwesomeIcon
name="user"
size={20}
color={
!this.state.isPhoneAssureSearch && !this.state.isNumeroAssureSearch
? Color.primaryColor
: "#888"
}
onPress={() =>
this.setState({
isPhoneAssureSearch: false,
isNumeroAssureSearch: false
})
}
style={{ marginHorizontal: 5 }}
/>
{/* Mode NIU */}
<FontAwesomeIcon
name="id-card"
size={20}
color={this.state.isNumeroAssureSearch ? Color.primaryColor : "#888"}
onPress={() =>
this.setState({
isPhoneAssureSearch: false,
isNumeroAssureSearch: true
})
}
style={{ marginHorizontal: 5 }}
/>
{/* Scanner QR */}
<FontAwesomeIcon
style={{paddingRight: 5}}
name="qrcode"
size={20}
color={Color.primaryColor}
onPress={() => {
this.setState({
showQRCodeScanner: true
});
}}
onPress={() => this.setState({ showQRCodeScanner: true })}
style={{ marginHorizontal: 5 }}
/>
</View>
</View>
{/* <Fumi iconClass={FontAwesomeIcon}
label={I18n.t('NAME')}
iconColor={'#f95a25'}
iconSize={20}
iconName={"user"}
value={this.state.userName}
onChangeText={(userName) => {
this.setState({userName});
}}
style={styles.input}
>
</Fumi>*/}
</MaterialDialog>)
</MaterialDialog>
);
}
renderDialogResultSearchUser() {
const {resultSearchUserByName, errorGetAvisImposition} = this.props;

View File

@ -62,7 +62,7 @@ class NumeroQuitance extends Component {
static navigationOptions = () => {
return {
drawerLabel: () => null,
headerTitle: I18n.t('QUITANCE'),
headerTitle: I18n.t('PAYMENT'),
headerTintColor: 'white',
headerStyle: {
backgroundColor: Color.primaryColor,

View File

@ -74,8 +74,8 @@ class NumeroQuitanceDetail extends Component {
return {
drawerLabel: () => null,
title: navigation.getParam("isModify", false) ? I18n.t('QUITANCE')
: I18n.t('QUITANCE'),
title: navigation.getParam("isModify", false) ? I18n.t('PAYMENT')
: I18n.t('PAYMENT'),
headerTintColor: 'white',
headerStyle: {
backgroundColor: Color.primaryColor,
@ -119,15 +119,16 @@ class NumeroQuitanceDetail extends Component {
added_revenue_orders_items: [],
displayAddOrdreRecette: false,
ordreRecetteId: this.props.navigation.getParam("isModify", false) ? this.props.navigation.getParam("item", "-").id_receipt : "",
// Suppression de ces 2 moyens de paiement Wallet et Cash pour laissser uniquement Tresor pay qui lui vient plutot de l'API
paymentMethods: [
{
title: I18n.t('WALLET'),
value: 'wallet'
},
{
title: I18n.t('CASH'),
value: 'cash'
},
// {
// title: I18n.t('WALLET'),
// value: 'wallet'
// },
// {
// title: I18n.t('CASH'),
// value: 'cash'
// },
],
paymentMethod: 'wallet',
paymentUrl: '',
@ -285,15 +286,16 @@ class NumeroQuitanceDetail extends Component {
if (nextProps.paymentMethod !== null) {
if (nextProps.paymentMethod.result !== null) {
console.log("nextProps.paymentMethod", nextProps.paymentMethod);
// Suppression de ces 2 moyens de paiement Wallet et Cash pour laissser uniquement Tresor pay qui lui vient plutot de l'API
const paymentsMethods = [
{
title: I18n.t('WALLET'),
value: 'wallet'
},
{
title: I18n.t('CASH'),
value: 'cash'
},
// {
// title: I18n.t('WALLET'),
// value: 'wallet'
// },
// {
// title: I18n.t('CASH'),
// value: 'cash'
// },
]
this.setState({
paymentMethods: [...paymentsMethods, ...nextProps.paymentMethod.result.response.methods]

View File

@ -491,7 +491,7 @@ export const optionOrdreRecetteScreen = {
export const optionNumeroQuitanceScreen = {
type: 'QUITANCE',
title: 'QUITANCE',
title: 'NUMERO_QUITANCE',
subTitle: 'CHOOSE_OPTION',
options: [
{

View File

@ -757,5 +757,8 @@
"CREATION_DATE": "Creation Date",
"TECHNICAL_APPROVAL": "Technical Approval",
"TRADE_LICENSE": "Business License",
"MERCURIAL_VALUE": "Mercurial Value ",
"CONSTRUCTION_VALUE": "Enter the Construction Value",
"BUILDING_CONSTRUCTED": "Building Constructed",
"PAY": "Pay"
}

View File

@ -45,7 +45,7 @@
"SUCCESS": "Succès",
"ETAT": "Etat",
"MY_ACCOUNT": "Mon compte",
"WALLET": "Wallet",
"WALLET": "Portefeuille",
"DEPOSIT": "Dépôt",
"EN_ATTENTE_DE_VALIDATION": "En attente de validation",
"REMBOURSE": "Remboursé",
@ -601,9 +601,9 @@
"ORDRE_RECETTE": "Ordre recette",
"NO_ORDRE_RECETTE": "Aucun ordre de recette",
"MODIFICATION_ORDRE_RECETTE": "Modifier ordre recette",
"SAISIE_NUMERO_QUITANCE": "Saisir numéro quittance",
"SAISIE_NUMERO_QUITANCE": "Effectuer un paiement",
"MODIFICATION_NUMERO_QUITANCE": "Modifier numéro quittance",
"SAISIR_QUITANCE": "Saisir paiement ou quittance",
"SAISIR_QUITANCE": "Gestion paiement ou quittance",
"CODE_AGENT": "Code agent ",
"AVIS_IMPOSITION": "Déclaration",
"AGENT_INFORMATION": "Informations sur l'agent",
@ -615,8 +615,8 @@
"TAXES_SUR_LA_PROPRETE": "Impôt général synthétique *",
"SAVE": "Enregistrer",
"TEXT_SUPPRESS_CONFIRM_TAXE": "Voulez vous vraiment supprimer cette taxe?",
"NUMERO_QUITANCE": "Numéro quittance",
"QUITANCE": "Quitance",
"NUMERO_QUITANCE": "Gestion quittance",
"QUITANCE": "Quittance",
"ORDRE_DE_RECETTE": "Ordre de recette",
"MODIFY_ORDRE_DE_RECETTE": "Modifier ordre de recette",
"ORDRE_DE_RECETTE_NUMBER": "Numéro d'ordre de recette",
@ -651,8 +651,8 @@
"ORDRE_RECETTE_RECEIPT": "Recette et quittance",
"HISTORY_OF": "Historique des",
"AVIS_IMPOSITIONS": "déclarations",
"ORDRE_RECETTES_RECEIPTS": "recettes et quitances",
"QUITANCES": "quitances",
"ORDRE_RECETTES_RECEIPTS": "recettes et quittances",
"QUITANCES": "quittances",
"PRINCIPAL_AMOUNT": "Montant principal",
"DATE_AVIS_IMPOSITION": "Date avis imposition",
"TEXT_NETWORK_UNABLE_CHOOSE_ANOTHER": "Ce réseau n'est pas actif, veuillez choisir un autre",
@ -662,7 +662,7 @@
"CREATE_ACTIF": "Créer un actif",
"IMPOSSIBLE_TO_CONNECT_INTERNET": "Vérifier votre connexion internet. Voulez-vous réessayer ?",
"REGISTER_OPTIONS": "Options d'enregistrement",
"WOULD_YOU_WANT_TO_REGISTER_OFFLINE": "Voulez-vous enregistrer un usager en ligne ?",
"WOULD_YOU_WANT_TO_REGISTER_OFFLINE": "Voulez-vous enregistrer un contribuable en ligne ?",
"DATA_NOT_SYNCHRONISED_WITH_SERVER": "Les données nécessaires au mode offline n'ont pas été sauvegarder. Voulez-vous vous connecter et réessayez ?",
"CODE_AGENT_NOT_EXIST": "Ce code agent n'existe pas",
"FOR_THIS_KING_OF_USER_PLEASE_CONNECT": "Pour enregistrer ce type d'agent, veuillez vous connecter",
@ -712,10 +712,10 @@
"AMOUNT_ORDRE_RECETTE": "Montant de l'ordre de recette",
"AMOUNT_TAX_NOTICE": "Montant de la déclaration",
"YOU_CANT_DELETE_LAST_TAX_NOTICE": "Une quittance doit contenir au moins un ordre de recette",
"WOULD_YOU_WANT_SEARCH_BY_NAME": "Voulez-vous rechercher l'usager par son nom ?",
"USAGER_NAME": "Nom de l'usager",
"NO_USAGER_CORRESPONDING_TO_SEARCH": "Aucun usager ne correspond à votre recherche",
"USAGER_SEARCH": "Recherche d'un usager",
"WOULD_YOU_WANT_SEARCH_BY_NAME": "Voulez-vous rechercher le contribuable par son nom ?",
"USAGER_NAME": "Nom du contribuable",
"NO_USAGER_CORRESPONDING_TO_SEARCH": "Aucun contribuable ne correspond à votre recherche",
"USAGER_SEARCH": "Recherche d'un contribuable",
"BY_NAME": "Par nom",
"BY_QR_CODE": "Par QR Code",
"SCAN": "Scanner",
@ -757,5 +757,8 @@
"CREATION_DATE": "Date de création",
"TECHNICAL_APPROVAL": "Agrément technique",
"TRADE_LICENSE": "Patente",
"MERCURIAL_VALUE": "Valeur mercuriale ",
"CONSTRUCTION_VALUE": "Saisir la valeur de la construction",
"BUILDING_CONSTRUCTED": "Immeuble bâti",
"PAY": "Payer"
}

View File

@ -604,6 +604,8 @@ export const savePenalityReset = () => {
};
export const searchUserAction = (data, searchFromMap = false) => {
console.log("searchUserAction===>>", data, searchFromMap);
console.log("searchUserActionUrl===>>", searchFromMap ? searchUserHomeUrl : `${searchUserUrl}?name=${data}`);
const auth = store.getState().authKeyReducer;
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';