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",
"CREATOR": "Créateur",
"NOTIFICATIONS": "Notification",
"NO_NOTIFICATION": "Vous n'avez aucune Fnotification",
"NO_NOTIFICATION": "Vous n'avez aucune notification",
"CONFIGURATIONS": "Configuration",
"LOGOUT": "Déconnexion",
"HINT_HOME_SEARCH": " Chercher un lieu, quartier ou ville ",

View File

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

View File

@ -6,31 +6,27 @@
* @flow
*/
import React, { Component } from 'react';
import {
Platform, StyleSheet, Text, View, ScrollView,
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 React, {Component} from 'react';
import {Alert, BackHandler, Picker, ProgressBarAndroid, StatusBar, StyleSheet, Text, View} from 'react-native';
import {responsiveFontSize, responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions';
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 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 { isNumber } from 'util';
import { readUser } from './../../webservice/AuthApi'
import { sendDemande } from './../../webservice/HistoryRequestApi'
import { sendDemandeSpecificque } from "../../webservice/HistoryRequestApi";
import { getAgentNetworksList } from "../../webservice/NetworkApi";
import { HelperText, TextInput, TextInputMask } from 'react-native-paper'
import {isNumber} from 'util';
import {readUser} from './../../webservice/AuthApi'
import {sendDemandeSpecificque} from "../../webservice/HistoryRequestApi";
import {getAgentNetworksList} from "../../webservice/NetworkApi";
import {HelperText, TextInput} from 'react-native-paper'
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 = {}
const route = require('../../route.json')
import { Card, CardTitle, CardContent, CardAction, CardButton, CardImage, Title } from 'react-native-material-cards'
export default class HistoryRequester extends Component {
static navigatorStyle = {
navBarHidden: true,
@ -40,6 +36,7 @@ export default class HistoryRequester extends Component {
headerTitle: I18n.t('ASK_CREDIT'),
title: I18n.t('ASK_CREDIT')
};
constructor(props) {
super(props);
this.state = this.initState();
@ -61,6 +58,7 @@ export default class HistoryRequester extends Component {
handleViewRef = ref => this.numberView = ref;
handleMontantRef = ref => this.montantView = ref;
initState() {
return {
phone: null,
@ -70,7 +68,7 @@ export default class HistoryRequester extends Component {
networks: [],
user: null,
visibleError: false,
currentNetwork: { nt: 1 },
currentNetwork: {nt: 1},
errorAnimation: "",
}
}
@ -84,23 +82,25 @@ export default class HistoryRequester extends Component {
this.props.navigation.state.params.onGoBack();
this.props.navigation.goBack();
}
onUserSend() {
var validMontant = true
if (!isNumber(this.state.montant) || this.state.montant > 1000000) {
validMontant = false
}
this.setState({ visibleError: !validMontant })
this.setState({visibleError: !validMontant})
if (!validMontant) {
this.montantView.shake(800)
setTimeout(() => {
this.setState({ visibleError: false })
this.setState({visibleError: false})
}, 3000)
}
else {
this.setState({ isSending: true })
} else {
this.setState({isSending: true});
let title = ""
let message = ""
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 === 1) {
title = I18n.t('DEMAND_SEND'),
@ -117,40 +117,43 @@ export default class HistoryRequester extends Component {
}
Alert.alert(title, message, [{
text: 'Ok', onPress: () => {
this.setState({ montant: "" })
this.setState({montant: ""})
}
}])
setTimeout(() => {
this.setState({ isSending: false })
}, 800)
}]);
}).catch((error) => {
this.setState({isSending: false});
console.warn(error);
title = "Erreur survenu lors de l'envoie ",
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() {
const { user } = this.state
const {user} = this.state;
console.log(this.state);
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
translucent={false}
/>
{user ? ((user.category === "geolocated") ?
this.multiNetwork() : this.simpleAgent()) :
<ProgressBarAndroid />
<ProgressBarAndroid/>
}
</View>
)
}
simpleAgent() {
let montant = 0
if (true) {
return (<View style={{ height: 200 }}>
<Card style={{ width: responsiveWidth(96), paddingTop: 20 }}>
return (<View style={{height: 200}}>
<Card style={{width: responsiveWidth(96), paddingTop: 20}}>
<CardContent>
<View>
<Animatable.View
@ -169,7 +172,7 @@ export default class HistoryRequester extends Component {
onChangeText={(text) => {
try {
let neb = parseInt(text)
this.setState({ montant: neb, isDisabled: isNaN(neb) })
this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) {
}
@ -189,12 +192,16 @@ export default class HistoryRequester extends Component {
separator={true}
inColumn={false}>
<CardButton
onPress={() => { this.onUserCancel() }}
onPress={() => {
this.onUserCancel()
}}
title={I18n.t('CANCEL')}
color="crimson"
/>
<CardButton
onPress={() => { this.onUserSend() }}
onPress={() => {
this.onUserSend()
}}
title={I18n.t('SEND')}
color="steelblue"
@ -225,7 +232,7 @@ export default class HistoryRequester extends Component {
if (text.length > 0) {
try {
montant = parseFloat(text);
this.setState({ isDisabled: montant > 0, montant: montant })
this.setState({isDisabled: montant > 0, montant: montant})
} catch (e) {
@ -241,11 +248,15 @@ export default class HistoryRequester extends Component {
</View>
<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')}
</Button>
<Button isLoading={this.state.isSending} isDisabled={!this.state.isDisabled} style={styles.button_2}
ref={(r) => { this.refBtn = r }}
<Button isLoading={this.state.isSending} isDisabled={!this.state.isDisabled}
style={styles.button_2}
ref={(r) => {
this.refBtn = r
}}
textStyle={styles.button_2_text} onPress={() => {
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() {
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>
<View style={{ flex: 1 }}>
<View style={{ flexDirection: 'row' }}>
<View style={{flex: 1}}>
<View style={{flexDirection: 'row'}}>
<Picker
selectedValue={this.state.currentNetwork}
prompt={I18n.t("SELECT_NETWORK")}
style={{ height: 50, flex: 1, marginLeft: 20 }}
style={{height: 50, flex: 1, marginLeft: 20}}
itemStyle={styles.subtitle}
onValueChange={(itemValue, itemIndex) =>
this.setState({ currentNetwork: itemValue })
this.setState({currentNetwork: itemValue})
}>
{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>
@ -299,7 +322,7 @@ export default class HistoryRequester extends Component {
onChangeText={(text) => {
try {
let neb = parseInt(text)
this.setState({ montant: neb, isDisabled: isNaN(neb) })
this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) {
}
@ -318,13 +341,15 @@ export default class HistoryRequester extends Component {
separator={true}
inColumn={false}>
<CardButton
onPress={() => { this.onUserCancel() }}
onPress={() => {
this.onUserCancel()
}}
title={I18n.t('CANCEL')}
color="crimson"
/>
<CardButton
onPress={() => {
const { currentNetwork, montant } = this.state
const {currentNetwork, montant} = this.state
if (currentNetwork !== undefined && currentNetwork.nt === undefined) {
this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant)
}
@ -335,8 +360,7 @@ export default class HistoryRequester extends Component {
</CardAction>
</Card>
</View>)
}
else
} else
return (
<View style={styles.container2}>
<CardView style={styles.cardInput2}>
@ -345,13 +369,15 @@ export default class HistoryRequester extends Component {
<Picker
selectedValue={this.state.currentNetwork}
prompt={"Selectionner un reseau"}
style={{ height: 50, width: responsiveWidth(100) }}
style={{height: 50, width: responsiveWidth(100)}}
itemStyle={styles.subtitle}
onValueChange={(itemValue, itemIndex) =>
this.setState({ currentNetwork: itemValue })
this.setState({currentNetwork: itemValue})
}>
{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>
@ -371,7 +397,7 @@ export default class HistoryRequester extends Component {
onChangeText={(text) => {
try {
let neb = parseInt(text)
this.setState({ montant: neb, isDisabled: isNaN(neb) })
this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) {
}
@ -397,7 +423,7 @@ export default class HistoryRequester extends Component {
style={styles.button_2}
textStyle={styles.button_2_text}
onPress={() => {
const { currentNetwork, montant } = this.state
const {currentNetwork, montant} = this.state
if (currentNetwork !== undefined && currentNetwork.nt === undefined) {
this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant, this.refInp, this.refBtn)
}
@ -430,7 +456,7 @@ export default class HistoryRequester extends Component {
iconColor={primary}
ref={(ref) => {
refInp = ref
this.setState({ refIn: refInp })
this.setState({refIn: refInp})
}}
inputStyle={input.style}
@ -440,9 +466,9 @@ export default class HistoryRequester extends Component {
if (text.length > 0) {
try {
montant = parseFloat(text);
this.setStat({ montant: montant })
this.setStat({montant: montant})
if (refBtn) {
refBtn.setState({ isDisabled: montant > 0 })
refBtn.setState({isDisabled: montant > 0})
refBtn.isDisabled = montant > 0
}
@ -460,7 +486,8 @@ export default class HistoryRequester extends Component {
</View>
<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')}
</Button>
<Button
@ -481,23 +508,26 @@ export default class HistoryRequester extends Component {
</View>)
}
onNetworkSend(phone, code_membre, text) {
var validMontant = true
let montant = parseFloat(text)
if (montant === null || !isNumber(montant) || montant > 1000000) {
validMontant = false
}
this.setState({ visibleError: !validMontant })
this.setState({visibleError: !validMontant})
if (!validMontant) {
this.montantView.shake(800)
setTimeout(() => {
this.setState({ visibleError: false })
this.setState({visibleError: false})
}, 3000)
}
else {
} else {
this.setState({isSending: true});
sendDemandeSpecificque(montant, phone, code_membre).then((data) => {
this.setState({isSending: false});
var title = ""
var message = ""
var message = "";
console.warn(data);
if (data.success !== undefined) {
if (data.success === 1) {
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"
}
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)
})
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 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 () => {
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, {
method: 'POST',
@ -77,7 +77,9 @@ export const updateCreditDemand = (phone, id) => {
.then((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 {
let responseJson = await response.json()
console.log(responseJson)
console.warn("server response", responseJson);
return responseJson
} catch (e) {
console.log(response)
console.warn(e)
console.warn("server response", response);
console.warn("server response", e);
return []
}