Last commit before switching mac

This commit is contained in:
Brice Zele 2020-12-07 10:05:44 +01:00
parent 5bfad5f025
commit 9363fc3f1d
5 changed files with 742 additions and 706 deletions

File diff suppressed because one or more lines are too long

View File

@ -249,7 +249,7 @@
"DELETE_GROUP": "Supprimer le groupe", "DELETE_GROUP": "Supprimer le groupe",
"CREATOR": "Créateur", "CREATOR": "Créateur",
"NOTIFICATIONS": "Notification", "NOTIFICATIONS": "Notification",
"NO_NOTIFICATION": "Vous n'avez aucune Fnotification", "NO_NOTIFICATION": "Vous n'avez aucune notification",
"CONFIGURATIONS": "Configuration", "CONFIGURATIONS": "Configuration",
"LOGOUT": "Déconnexion", "LOGOUT": "Déconnexion",
"HINT_HOME_SEARCH": " Chercher un lieu, quartier ou ville ", "HINT_HOME_SEARCH": " Chercher un lieu, quartier ou ville ",

View File

@ -90,7 +90,7 @@ export class HistoryItem extends React.Component {
}; };
render() { render() {
console.log("ITEM RENDER", this.props.selfData) //console.log("ITEM RENDER", this.props.selfData)
return ( return (
<TouchableOpacity onPress={() => <TouchableOpacity onPress={() =>
this.props.navigator.navigate(route.historyItemDetails, { this.props.navigator.navigate(route.historyItemDetails, {
@ -231,7 +231,7 @@ export class HistoryListItem extends React.Component {
}; };
_renderItem = ({item}) => { _renderItem = ({item}) => {
console.log('ITEM ', item); //console.log('ITEM ', item);
return ( return (
<HistoryItem <HistoryItem
isDemandSend={this.props.isDemandSend} isDemandSend={this.props.isDemandSend}

View File

@ -6,31 +6,27 @@
* @flow * @flow
*/ */
import React, { Component } from 'react'; import React, {Component} from 'react';
import { import {Alert, BackHandler, Picker, ProgressBarAndroid, StatusBar, StyleSheet, Text, View} from 'react-native';
Platform, StyleSheet, Text, View, ScrollView, import {responsiveFontSize, responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions';
Alert,
FlatList, BackHandler, ProgressBarAndroid, Picker, StatusBar
} from 'react-native';
import ActionButton from 'react-native-action-button';
import MapView from 'react-native-maps';
import { responsiveHeight, responsiveWidth, responsiveFontSize } from 'react-native-responsive-dimensions';
import CardView from 'react-native-cardview'; import CardView from 'react-native-cardview';
import { Sae } from 'react-native-textinput-effects'; import {Sae} from 'react-native-textinput-effects';
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import Button from 'apsl-react-native-button'; import Button from 'apsl-react-native-button';
import { primary, primaryDark, accent } from '../../utils/theme.json'; import {primary} from '../../utils/theme.json';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import { isNumber } from 'util'; import {isNumber} from 'util';
import { readUser } from './../../webservice/AuthApi' import {readUser} from './../../webservice/AuthApi'
import { sendDemande } from './../../webservice/HistoryRequestApi' import {sendDemandeSpecificque} from "../../webservice/HistoryRequestApi";
import { sendDemandeSpecificque } from "../../webservice/HistoryRequestApi"; import {getAgentNetworksList} from "../../webservice/NetworkApi";
import { getAgentNetworksList } from "../../webservice/NetworkApi"; import {HelperText, TextInput} from 'react-native-paper'
import { HelperText, TextInput, TextInputMask } from 'react-native-paper'
import I18n from "react-native-i18n" import I18n from "react-native-i18n"
import {ProgressDialog} from 'react-native-simple-dialogs';
import {Card, CardAction, CardButton, CardContent} from 'react-native-material-cards'
type Props = {} type Props = {}
const route = require('../../route.json') const route = require('../../route.json')
import { Card, CardTitle, CardContent, CardAction, CardButton, CardImage, Title } from 'react-native-material-cards'
export default class HistoryRequester extends Component { export default class HistoryRequester extends Component {
static navigatorStyle = { static navigatorStyle = {
navBarHidden: true, navBarHidden: true,
@ -40,6 +36,7 @@ export default class HistoryRequester extends Component {
headerTitle: I18n.t('ASK_CREDIT'), headerTitle: I18n.t('ASK_CREDIT'),
title: I18n.t('ASK_CREDIT') title: I18n.t('ASK_CREDIT')
}; };
constructor(props) { constructor(props) {
super(props); super(props);
this.state = this.initState(); this.state = this.initState();
@ -61,6 +58,7 @@ export default class HistoryRequester extends Component {
handleViewRef = ref => this.numberView = ref; handleViewRef = ref => this.numberView = ref;
handleMontantRef = ref => this.montantView = ref; handleMontantRef = ref => this.montantView = ref;
initState() { initState() {
return { return {
phone: null, phone: null,
@ -70,7 +68,7 @@ export default class HistoryRequester extends Component {
networks: [], networks: [],
user: null, user: null,
visibleError: false, visibleError: false,
currentNetwork: { nt: 1 }, currentNetwork: {nt: 1},
errorAnimation: "", errorAnimation: "",
} }
} }
@ -84,23 +82,25 @@ export default class HistoryRequester extends Component {
this.props.navigation.state.params.onGoBack(); this.props.navigation.state.params.onGoBack();
this.props.navigation.goBack(); this.props.navigation.goBack();
} }
onUserSend() { onUserSend() {
var validMontant = true var validMontant = true
if (!isNumber(this.state.montant) || this.state.montant > 1000000) { if (!isNumber(this.state.montant) || this.state.montant > 1000000) {
validMontant = false validMontant = false
} }
this.setState({ visibleError: !validMontant }) this.setState({visibleError: !validMontant})
if (!validMontant) { if (!validMontant) {
this.montantView.shake(800) this.montantView.shake(800)
setTimeout(() => { setTimeout(() => {
this.setState({ visibleError: false }) this.setState({visibleError: false})
}, 3000) }, 3000)
} } else {
else { this.setState({isSending: true});
this.setState({ isSending: true })
let title = "" let title = ""
let message = "" let message = ""
sendDemandeSpecificque(this.state.montant, this.state.user.phoneTransaction, this.state.user.code_membre).then((data) => { sendDemandeSpecificque(this.state.montant, this.state.user.phoneTransaction, this.state.user.code_membre).then((data) => {
console.warn(data);
this.setState({isSending: false});
if (data.success !== undefined) { if (data.success !== undefined) {
if (data.success === 1) { if (data.success === 1) {
title = I18n.t('DEMAND_SEND'), title = I18n.t('DEMAND_SEND'),
@ -117,40 +117,43 @@ export default class HistoryRequester extends Component {
} }
Alert.alert(title, message, [{ Alert.alert(title, message, [{
text: 'Ok', onPress: () => { text: 'Ok', onPress: () => {
this.setState({ montant: "" }) this.setState({montant: ""})
} }
}]) }]);
setTimeout(() => {
this.setState({ isSending: false })
}, 800)
}).catch((error) => { }).catch((error) => {
this.setState({isSending: false});
console.warn(error);
title = "Erreur survenu lors de l'envoie ", title = "Erreur survenu lors de l'envoie ",
message = "Une erreur est survenu lors de l'envoie de la demande" message = "Une erreur est survenu lors de l'envoie de la demande"
Alert.alert(title, message, [{ text: 'Ok' }]) Alert.alert(title, message, [{text: 'Ok'}])
}) })
} }
} }
render() { render() {
const { user } = this.state const {user} = this.state;
console.log(this.state);
return ( return (
<View style={{ flex: 1, alignItems: 'center', backgroundColor: "lightgrey", paddingTop: responsiveHeight(10) }}> <View
style={{flex: 1, alignItems: 'center', backgroundColor: "lightgrey", paddingTop: responsiveHeight(10)}}>
{this.state.isSending && this.renderLoader()}
<StatusBar <StatusBar
translucent={false} translucent={false}
/> />
{user ? ((user.category === "geolocated") ? {user ? ((user.category === "geolocated") ?
this.multiNetwork() : this.simpleAgent()) : this.multiNetwork() : this.simpleAgent()) :
<ProgressBarAndroid /> <ProgressBarAndroid/>
} }
</View> </View>
) )
} }
simpleAgent() { simpleAgent() {
let montant = 0 let montant = 0
if (true) { if (true) {
return (<View style={{ height: 200 }}> return (<View style={{height: 200}}>
<Card style={{ width: responsiveWidth(96), paddingTop: 20 }}> <Card style={{width: responsiveWidth(96), paddingTop: 20}}>
<CardContent> <CardContent>
<View> <View>
<Animatable.View <Animatable.View
@ -169,7 +172,7 @@ export default class HistoryRequester extends Component {
onChangeText={(text) => { onChangeText={(text) => {
try { try {
let neb = parseInt(text) let neb = parseInt(text)
this.setState({ montant: neb, isDisabled: isNaN(neb) }) this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) { } catch (e) {
} }
@ -189,12 +192,16 @@ export default class HistoryRequester extends Component {
separator={true} separator={true}
inColumn={false}> inColumn={false}>
<CardButton <CardButton
onPress={() => { this.onUserCancel() }} onPress={() => {
this.onUserCancel()
}}
title={I18n.t('CANCEL')} title={I18n.t('CANCEL')}
color="crimson" color="crimson"
/> />
<CardButton <CardButton
onPress={() => { this.onUserSend() }} onPress={() => {
this.onUserSend()
}}
title={I18n.t('SEND')} title={I18n.t('SEND')}
color="steelblue" color="steelblue"
@ -225,7 +232,7 @@ export default class HistoryRequester extends Component {
if (text.length > 0) { if (text.length > 0) {
try { try {
montant = parseFloat(text); montant = parseFloat(text);
this.setState({ isDisabled: montant > 0, montant: montant }) this.setState({isDisabled: montant > 0, montant: montant})
} catch (e) { } catch (e) {
@ -241,11 +248,15 @@ export default class HistoryRequester extends Component {
</View> </View>
<View style={styles.btnContainer}> <View style={styles.btnContainer}>
<Button style={styles.button_1} textStyle={styles.button_1_text} onPress={() => this.onUserCancel()}> <Button style={styles.button_1} textStyle={styles.button_1_text}
onPress={() => this.onUserCancel()}>
{I18n.t('CANCEL')} {I18n.t('CANCEL')}
</Button> </Button>
<Button isLoading={this.state.isSending} isDisabled={!this.state.isDisabled} style={styles.button_2} <Button isLoading={this.state.isSending} isDisabled={!this.state.isDisabled}
ref={(r) => { this.refBtn = r }} style={styles.button_2}
ref={(r) => {
this.refBtn = r
}}
textStyle={styles.button_2_text} onPress={() => { textStyle={styles.button_2_text} onPress={() => {
this.onUserSend() this.onUserSend()
}}> }}>
@ -259,25 +270,37 @@ export default class HistoryRequester extends Component {
) )
} }
renderLoader = () => {
return (
<ProgressDialog
visible={this.state.isSending}
title={I18n.t('LOADING')}
message={I18n.t('LOADING_INFO')}
/>
)
};
multiNetwork() { multiNetwork() {
if (true) { if (true) {
return (<View style={{ height: 250, justifyContent: 'center' }}> return (<View style={{height: 250, justifyContent: 'center'}}>
<Card style={{ width: responsiveWidth(96), justifyContent: 'center' }}> <Card style={{width: responsiveWidth(96), justifyContent: 'center'}}>
<CardContent> <CardContent>
<View style={{ flex: 1 }}> <View style={{flex: 1}}>
<View style={{ flexDirection: 'row' }}> <View style={{flexDirection: 'row'}}>
<Picker <Picker
selectedValue={this.state.currentNetwork} selectedValue={this.state.currentNetwork}
prompt={I18n.t("SELECT_NETWORK")} prompt={I18n.t("SELECT_NETWORK")}
style={{ height: 50, flex: 1, marginLeft: 20 }} style={{height: 50, flex: 1, marginLeft: 20}}
itemStyle={styles.subtitle} itemStyle={styles.subtitle}
onValueChange={(itemValue, itemIndex) => onValueChange={(itemValue, itemIndex) =>
this.setState({ currentNetwork: itemValue }) this.setState({currentNetwork: itemValue})
}> }>
{this.state.networks.map((item, index) => { {this.state.networks.map((item, index) => {
return (<Picker.Item label={item.nt ? I18n.t("SELECT_NETWORK") : I18n.t("FOR_NUMB") + item.phone + " (" + item.name + ")"} value={item} />) return (<Picker.Item
label={item.nt ? I18n.t("SELECT_NETWORK") : I18n.t("FOR_NUMB") + item.phone + " (" + item.name + ")"}
value={item}/>)
})} })}
</Picker> </Picker>
@ -299,7 +322,7 @@ export default class HistoryRequester extends Component {
onChangeText={(text) => { onChangeText={(text) => {
try { try {
let neb = parseInt(text) let neb = parseInt(text)
this.setState({ montant: neb, isDisabled: isNaN(neb) }) this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) { } catch (e) {
} }
@ -318,13 +341,15 @@ export default class HistoryRequester extends Component {
separator={true} separator={true}
inColumn={false}> inColumn={false}>
<CardButton <CardButton
onPress={() => { this.onUserCancel() }} onPress={() => {
this.onUserCancel()
}}
title={I18n.t('CANCEL')} title={I18n.t('CANCEL')}
color="crimson" color="crimson"
/> />
<CardButton <CardButton
onPress={() => { onPress={() => {
const { currentNetwork, montant } = this.state const {currentNetwork, montant} = this.state
if (currentNetwork !== undefined && currentNetwork.nt === undefined) { if (currentNetwork !== undefined && currentNetwork.nt === undefined) {
this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant) this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant)
} }
@ -335,8 +360,7 @@ export default class HistoryRequester extends Component {
</CardAction> </CardAction>
</Card> </Card>
</View>) </View>)
} } else
else
return ( return (
<View style={styles.container2}> <View style={styles.container2}>
<CardView style={styles.cardInput2}> <CardView style={styles.cardInput2}>
@ -345,13 +369,15 @@ export default class HistoryRequester extends Component {
<Picker <Picker
selectedValue={this.state.currentNetwork} selectedValue={this.state.currentNetwork}
prompt={"Selectionner un reseau"} prompt={"Selectionner un reseau"}
style={{ height: 50, width: responsiveWidth(100) }} style={{height: 50, width: responsiveWidth(100)}}
itemStyle={styles.subtitle} itemStyle={styles.subtitle}
onValueChange={(itemValue, itemIndex) => onValueChange={(itemValue, itemIndex) =>
this.setState({ currentNetwork: itemValue }) this.setState({currentNetwork: itemValue})
}> }>
{this.state.networks.map((item, index) => { {this.state.networks.map((item, index) => {
return (<Picker.Item label={item.nt ? "Selectionner un reseau" : "Pour le " + item.phone + " (" + item.name + ")"} value={item} />) return (<Picker.Item
label={item.nt ? "Selectionner un reseau" : "Pour le " + item.phone + " (" + item.name + ")"}
value={item}/>)
})} })}
</Picker> </Picker>
@ -371,7 +397,7 @@ export default class HistoryRequester extends Component {
onChangeText={(text) => { onChangeText={(text) => {
try { try {
let neb = parseInt(text) let neb = parseInt(text)
this.setState({ montant: neb, isDisabled: isNaN(neb) }) this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) { } catch (e) {
} }
@ -397,7 +423,7 @@ export default class HistoryRequester extends Component {
style={styles.button_2} style={styles.button_2}
textStyle={styles.button_2_text} textStyle={styles.button_2_text}
onPress={() => { onPress={() => {
const { currentNetwork, montant } = this.state const {currentNetwork, montant} = this.state
if (currentNetwork !== undefined && currentNetwork.nt === undefined) { if (currentNetwork !== undefined && currentNetwork.nt === undefined) {
this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant, this.refInp, this.refBtn) this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant, this.refInp, this.refBtn)
} }
@ -430,7 +456,7 @@ export default class HistoryRequester extends Component {
iconColor={primary} iconColor={primary}
ref={(ref) => { ref={(ref) => {
refInp = ref refInp = ref
this.setState({ refIn: refInp }) this.setState({refIn: refInp})
}} }}
inputStyle={input.style} inputStyle={input.style}
@ -440,9 +466,9 @@ export default class HistoryRequester extends Component {
if (text.length > 0) { if (text.length > 0) {
try { try {
montant = parseFloat(text); montant = parseFloat(text);
this.setStat({ montant: montant }) this.setStat({montant: montant})
if (refBtn) { if (refBtn) {
refBtn.setState({ isDisabled: montant > 0 }) refBtn.setState({isDisabled: montant > 0})
refBtn.isDisabled = montant > 0 refBtn.isDisabled = montant > 0
} }
@ -460,7 +486,8 @@ export default class HistoryRequester extends Component {
</View> </View>
<View style={styles.btnContainer}> <View style={styles.btnContainer}>
<Button style={styles.button_1} textStyle={styles.button_1_text} onPress={() => this.onUserCancel()}> <Button style={styles.button_1} textStyle={styles.button_1_text}
onPress={() => this.onUserCancel()}>
{I18n.t('CANCEL')} {I18n.t('CANCEL')}
</Button> </Button>
<Button <Button
@ -481,23 +508,26 @@ export default class HistoryRequester extends Component {
</View>) </View>)
} }
onNetworkSend(phone, code_membre, text) { onNetworkSend(phone, code_membre, text) {
var validMontant = true var validMontant = true
let montant = parseFloat(text) let montant = parseFloat(text)
if (montant === null || !isNumber(montant) || montant > 1000000) { if (montant === null || !isNumber(montant) || montant > 1000000) {
validMontant = false validMontant = false
} }
this.setState({ visibleError: !validMontant }) this.setState({visibleError: !validMontant})
if (!validMontant) { if (!validMontant) {
this.montantView.shake(800) this.montantView.shake(800)
setTimeout(() => { setTimeout(() => {
this.setState({ visibleError: false }) this.setState({visibleError: false})
}, 3000) }, 3000)
} } else {
else { this.setState({isSending: true});
sendDemandeSpecificque(montant, phone, code_membre).then((data) => { sendDemandeSpecificque(montant, phone, code_membre).then((data) => {
this.setState({isSending: false});
var title = "" var title = ""
var message = "" var message = "";
console.warn(data);
if (data.success !== undefined) { if (data.success !== undefined) {
if (data.success === 1) { if (data.success === 1) {
title = I18n.t("DEMAND_SEND") title = I18n.t("DEMAND_SEND")
@ -511,7 +541,11 @@ export default class HistoryRequester extends Component {
message = "Une erreur est survenu lors de l'envoie de la demande" message = "Une erreur est survenu lors de l'envoie de la demande"
} }
Alert.alert(title, message, [{ text: "Ok", onPress: () => { this.setState({ montant: "" }) } }]) Alert.alert(title, message, [{
text: "Ok", onPress: () => {
this.setState({montant: ""})
}
}])
}) })
} }
@ -529,10 +563,10 @@ export default class HistoryRequester extends Component {
net.push(item) net.push(item)
}) })
this.setState({ networks: net }) this.setState({networks: net})
} }
} }
this.setState({ user: user }) this.setState({user: user})
} }
} }

View File

@ -1,15 +1,15 @@
import React from 'react';
import I18n from 'react-native-i18n'
import {demandeActionUrl, isDebugMode} from "./IlinkConstants"
import {readUser} from './AuthApi'
import React, { Component } from 'react';
var DBEvents = require('react-native-db-models').DBEvents; var DBEvents = require('react-native-db-models').DBEvents;
var db = require('./persistences/db.js'); var db = require('./persistences/db.js');
import I18n from 'react-native-i18n'
import { isDebugMode, adhesionUrl, locationActionUrl, memberActionUrl, networkActionUrl, demandeActionUrl } from "./IlinkConstants"
import { readUser } from './AuthApi'
export const loadDemandeCredit = async () => { export const loadDemandeCredit = async () => {
const user = await readUser(); const user = await readUser();
const data = { "tag": "credit_demands", 'id': user.code_membre, "lang": I18n.currentLocale(), test: isDebugMode }; const data = {"tag": "credit_demands", 'id': user.code_membre, "lang": I18n.currentLocale(), test: isDebugMode};
const response = await fetch(demandeActionUrl, { const response = await fetch(demandeActionUrl, {
method: 'POST', method: 'POST',
@ -77,7 +77,9 @@ export const updateCreditDemand = (phone, id) => {
.then((responseJson) => { .then((responseJson) => {
return responseJson return responseJson
}) })
.catch((error) => { console.warn(error) }) .catch((error) => {
console.warn(error)
})
} }
@ -136,11 +138,11 @@ export const sendDemandeSpecificque = async (credit, phone, code_membre) => {
}) })
try { try {
let responseJson = await response.json() let responseJson = await response.json()
console.log(responseJson) console.warn("server response", responseJson);
return responseJson return responseJson
} catch (e) { } catch (e) {
console.log(response) console.warn("server response", response);
console.warn(e) console.warn("server response", e);
return [] return []
} }