resolution du bug lier au bouton retour de credit management lors de la connection en tant que agent

This commit is contained in:
novic-djef 2023-04-21 07:23:36 +01:00
parent 78f21b52f4
commit ce4897eaa2
19 changed files with 24179 additions and 13122 deletions

View File

@ -8,8 +8,8 @@
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home
# org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
# org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects

View File

@ -7,39 +7,39 @@
*/
import React from 'react';
import {ActionSheetProvider} from '@expo/react-native-action-sheet'
import {ActionSheetProvider} from '@expo/react-native-action-sheet';
import {AsyncStorage, Platform, StyleSheet, Text} from 'react-native';
import {
createAppContainer,
createBottomTabNavigator,
createDrawerNavigator,
createStackNavigator,
createSwitchNavigator
createSwitchNavigator,
} from 'react-navigation';
import OneSignal from 'react-native-onesignal';
import Connect from "./screens/login/Connect";
import SplashScreen from "./screens/splashscreen/SplashScreen";
import HelpMenu from "./screens/help/HelpMenu";
import Help from "./screens/help/Help";
import ForgottenPassword from "./screens/login/ForgottenPassword";
import TypeChoiser from "./screens/login/TypeChoiser";
import CreateUserStep2 from "./screens/login/createUserStep2";
import createAccount from "./screens/login/createAccount";
import UpdateInformations from "./screens/account/UpdateInformations";
import UserAccount from "./screens/account/UserAccount";
import ActivateAccount from "./screens/login/ActivateAccount";
import Notifications from "./screens/notifications/Notifications";
import About from "./screens/configurations/About";
import Configurations from "./screens/configurations/Configurations";
import OptionsMenu from "./screens/optionMenu/OptionsMenu";
import Home from "./screens/home/Home";
import HistoryItemDetails from "./screens/history-request/HistoryItemDetails";
import SuperViseurGroupeHome from "./screens/groupes/SuperViseurGroupeHome";
import HistoryRequester from "./screens/history-request/HistoryRequester";
import AddNetwork from "./screens/account/AddNetwork";
import MyHistory from "./screens/history-request/MyHistory";
import Icon from "react-native-vector-icons/FontAwesome5";
import I18n from "react-native-i18n";
import Connect from './screens/login/Connect';
import SplashScreen from './screens/splashscreen/SplashScreen';
import HelpMenu from './screens/help/HelpMenu';
import Help from './screens/help/Help';
import ForgottenPassword from './screens/login/ForgottenPassword';
import TypeChoiser from './screens/login/TypeChoiser';
import CreateUserStep2 from './screens/login/createUserStep2';
import createAccount from './screens/login/createAccount';
import UpdateInformations from './screens/account/UpdateInformations';
import UserAccount from './screens/account/UserAccount';
import ActivateAccount from './screens/login/ActivateAccount';
import Notifications from './screens/notifications/Notifications';
import About from './screens/configurations/About';
import Configurations from './screens/configurations/Configurations';
import OptionsMenu from './screens/optionMenu/OptionsMenu';
import Home from './screens/home/Home';
import HistoryItemDetails from './screens/history-request/HistoryItemDetails';
import SuperViseurGroupeHome from './screens/groupes/SuperViseurGroupeHome';
import HistoryRequester from './screens/history-request/HistoryRequester';
import AddNetwork from './screens/account/AddNetwork';
import MyHistory from './screens/history-request/MyHistory';
import Icon from 'react-native-vector-icons/FontAwesome5';
import I18n from 'react-native-i18n';
import WalletDetail from './screens/wallet/WalletDetail';
import WalletSelect from './screens/wallet/WalletSelect';
@ -81,28 +81,27 @@ import CautionNanoCreditAgent from './screens/nano-credit/CautionNanoCreditAgent
import EpargnerArgentUser from './screens/nano-credit/EpargnerArgentUser';
import CasserEpargneUser from './screens/nano-credit/CasserEpargneUser';
import {IlinkEmitter} from './utils/events';
import EnvoieWalletToBankAgent from "./screens/wallet/agent/EnvoieWalletToBankAgent";
import ReattachAccountUser from "./screens/wallet/user/ReattachAccountUser";
import InsuranceSubscriptionScreen from "./screens/wallet/user/InsuranceSubscriptionScreen";
import AddBeneficiaryScreen from "./screens/wallet/user/AddBeneficiaryScreen";
import ActivateBuySubscriptionScreen from "./screens/wallet/user/ActivateBuySubscriptionScreen";
import SaisirFeuilleSoinScreen from "./screens/wallet/agent/SaisirFeuilleSoinScreen";
import ValidateConsultationScreen from "./screens/wallet/user/ValidateConsultationScreen";
import ValidateConsultationDetailScreen from "./screens/wallet/user/ValidateConsultationDetailScreen";
import ExecuterPrescriptionScreen from "./screens/wallet/agent/ExecuterPrescriptionScreen";
import ModifierFeuilleSoinScreen from "./screens/wallet/agent/ModifierFeuilleSoinScreen";
import ModifierExecutionPrescriptionScreen from "./screens/wallet/agent/ModifierExecutionPrescriptionScreen";
import HistoriqueNanoSanteUserScreen from "./screens/wallet/user/HistoriqueNanoSanteUserScreen";
import DemandeAutorisationSoinScreen from "./screens/wallet/user/DemandeAutorisationSoinScreen";
import DeleteBeneficiaryScreen from "./screens/wallet/user/DeleteBeneficiaryScreen";
import StopSubscriptionScreen from "./screens/wallet/user/StopSubscriptionScreen";
import RenewAssuranceScreen from "./screens/wallet/user/RenewAssuranceScreen";
import WebviewScreen from "./screens/WebviewScreen";
import HistoriqueNanoSanteAgentScreen from "./screens/wallet/agent/HistoriqueNanoSanteAgentScreen";
import HistoriqueNanoSanteSuperHyperScreen from "./screens/wallet/agent/HistoriqueNanoSanteSuperHyperScreen";
import PDFViewerScreen from "./screens/PdfViewerScreen";
import UbaFormScreen from "./screens/wallet/user/UbaForm";
import EnvoieWalletToBankAgent from './screens/wallet/agent/EnvoieWalletToBankAgent';
import ReattachAccountUser from './screens/wallet/user/ReattachAccountUser';
import InsuranceSubscriptionScreen from './screens/wallet/user/InsuranceSubscriptionScreen';
import AddBeneficiaryScreen from './screens/wallet/user/AddBeneficiaryScreen';
import ActivateBuySubscriptionScreen from './screens/wallet/user/ActivateBuySubscriptionScreen';
import SaisirFeuilleSoinScreen from './screens/wallet/agent/SaisirFeuilleSoinScreen';
import ValidateConsultationScreen from './screens/wallet/user/ValidateConsultationScreen';
import ValidateConsultationDetailScreen from './screens/wallet/user/ValidateConsultationDetailScreen';
import ExecuterPrescriptionScreen from './screens/wallet/agent/ExecuterPrescriptionScreen';
import ModifierFeuilleSoinScreen from './screens/wallet/agent/ModifierFeuilleSoinScreen';
import ModifierExecutionPrescriptionScreen from './screens/wallet/agent/ModifierExecutionPrescriptionScreen';
import HistoriqueNanoSanteUserScreen from './screens/wallet/user/HistoriqueNanoSanteUserScreen';
import DemandeAutorisationSoinScreen from './screens/wallet/user/DemandeAutorisationSoinScreen';
import DeleteBeneficiaryScreen from './screens/wallet/user/DeleteBeneficiaryScreen';
import StopSubscriptionScreen from './screens/wallet/user/StopSubscriptionScreen';
import RenewAssuranceScreen from './screens/wallet/user/RenewAssuranceScreen';
import WebviewScreen from './screens/WebviewScreen';
import HistoriqueNanoSanteAgentScreen from './screens/wallet/agent/HistoriqueNanoSanteAgentScreen';
import HistoriqueNanoSanteSuperHyperScreen from './screens/wallet/agent/HistoriqueNanoSanteSuperHyperScreen';
import PDFViewerScreen from './screens/PdfViewerScreen';
import UbaFormScreen from './screens/wallet/user/UbaForm';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
@ -111,9 +110,10 @@ const instructions = Platform.select({
'Shake or press menu button for dev menu',
});
const theme = require("./utils/theme")
const theme = require('./utils/theme');
const AuthStack = createStackNavigator({
const AuthStack = createStackNavigator(
{
login: Connect,
helpMenu: HelpMenu,
help: Help,
@ -121,12 +121,14 @@ const AuthStack = createStackNavigator({
typeaccountcreate: TypeChoiser,
simpleusercreate: createAccount,
step2: CreateUserStep2,
activateaccout: ActivateAccount
}, {
headerMode: 'none'
})
const AppStack = createDrawerNavigator({
activateaccout: ActivateAccount,
},
{
headerMode: 'none',
},
);
const AppStack = createDrawerNavigator(
{
sta: createStackNavigator({
home: Home,
/* filtre:Filter,
@ -149,30 +151,48 @@ const AppStack = createDrawerNavigator({
envoieWalletToCashUser: EnvoieWalletToCashUser,
envoieWalletToCardUser: EnvoieWalletToCardUser,
envoieWalletToBankUser: EnvoieWalletToBankUser,
insuranceSubscriptionScreen: {screen: InsuranceSubscriptionScreen, navigationOptions: ()=> ({
insuranceSubscriptionScreen: {
screen: InsuranceSubscriptionScreen,
navigationOptions: () => ({
headerTitle: I18n.t('SUBSCRIBE_ASSURANCE'),
title: I18n.t('SUBSCRIBE_ASSURANCE'),
})},
addBeneficiaryScreen: {screen: AddBeneficiaryScreen, navigationOptions: ()=> ({
}),
},
addBeneficiaryScreen: {
screen: AddBeneficiaryScreen,
navigationOptions: () => ({
headerTitle: I18n.t('ADD_SUBSCRIBE'),
title: I18n.t('ADD_SUBSCRIBE'),
})},
activateBuySubscriptionScreen: {screen: ActivateBuySubscriptionScreen, navigationOptions: ()=> ({
}),
},
activateBuySubscriptionScreen: {
screen: ActivateBuySubscriptionScreen,
navigationOptions: () => ({
headerTitle: I18n.t('ACTIVATE_INSSURANCE'),
title: I18n.t('ACTIVATE_INSSURANCE'),
})},
renewAssuranceScreen: {screen: RenewAssuranceScreen, navigationOptions: ()=> ({
}),
},
renewAssuranceScreen: {
screen: RenewAssuranceScreen,
navigationOptions: () => ({
headerTitle: I18n.t('RENEW_INSSURANCE'),
title: I18n.t('RENEW_INSSURANCE'),
})},
deleteBeneficiaryScreen: {screen: DeleteBeneficiaryScreen, navigationOptions: ()=> ({
}),
},
deleteBeneficiaryScreen: {
screen: DeleteBeneficiaryScreen,
navigationOptions: () => ({
headerTitle: I18n.t('DELETE_SUBSCRIBE'),
title: I18n.t('DELETE_SUBSCRIBE'),
})},
stopSubscriptionScreen: {screen: StopSubscriptionScreen, navigationOptions: ()=> ({
}),
},
stopSubscriptionScreen: {
screen: StopSubscriptionScreen,
navigationOptions: () => ({
headerTitle: I18n.t('STOP_SUBSCRIBE'),
title: I18n.t('STOP_SUBSCRIBE'),
})},
}),
},
validateConsultationScreen: ValidateConsultationScreen,
validateConsultationDetailScreen: ValidateConsultationDetailScreen,
historiqueNanoSanteUserScreen: HistoriqueNanoSanteUserScreen,
@ -184,35 +204,41 @@ const AppStack = createDrawerNavigator({
epargnerArgentUser: EpargnerArgentUser,
createGroupNanoCredit: CreateGroupNanoCredit,
groupNanoCredit: {
screen: createBottomTabNavigator({
screen: createBottomTabNavigator(
{
demandeValidationGroupe: {
screen: DemandValidationGroup,
navigationOptions: {
tabBarLabel: I18n.t('DEMAND_VALIDATION_GROUP_RECEIVE'),
tabBarIcon: ({focused, horizontal, tintColor}) => {
return (<Icon
return (
<Icon
size={20}
name={"users-cog"}
color={focused ? tintColor : "grey"}
/>)
}
}
name={'users-cog'}
color={focused ? tintColor : 'grey'}
/>
);
},
},
},
myNanoCreditGroup: {
screen: MyNanoCreditGroup,
navigationOptions: {
tabBarLabel: I18n.t('MY_GROUP'),
tabBarIcon: ({focused, horizontal, tintColor}) => {
return (<Icon
return (
<Icon
size={20}
name={"users"}
color={focused ? tintColor : "grey"}
/>)
}
}
name={'users'}
color={focused ? tintColor : 'grey'}
/>
);
},
}, {
headerMode: "none",
},
},
},
{
headerMode: 'none',
header: null,
headerTitle: null,
title: I18n.t('MANAGE_GROUP'),
@ -220,8 +246,9 @@ const AppStack = createDrawerNavigator({
labelStyle: {
fontSize: 13,
},
}
}),
},
},
),
navigationOptions: () => ({
header: null,
headerMode: 'none',
@ -232,10 +259,8 @@ const AppStack = createDrawerNavigator({
drawerLabel: I18n.t('MANAGE_GROUP'),
drawerIcon: ({tintColor}) => (
<Icon
name={'account-multiple'}
size={24}
/>)
<Icon name={'account-multiple'} size={24} />
),
}),
},
demandeValidationGroupe: DemandGroupNanoCreditDetail,
@ -245,22 +270,27 @@ const AppStack = createDrawerNavigator({
casserEpargneUser: CasserEpargneUser,
webviewScreen: WebviewScreen,
PDFViewerScreen: PDFViewerScreen,
ubaFormScreen: {screen: UbaFormScreen, navigationOptions: ()=> ({
ubaFormScreen: {
screen: UbaFormScreen,
navigationOptions: () => ({
headerTitle: I18n.t('ENREGISTREMENT_UBA'),
title: I18n.t('ENREGISTREMENT_UBA'),
headerStyle: {
marginTop: 20
marginTop: 20,
},
})},
})
}, {
}),
},
}),
},
{
contentComponent: OptionsMenu,
headerMode: 'none',
contentOptions: {activeTintColor: theme.accent},
})
},
);
const AppAgentStack = createDrawerNavigator({
const AppAgentStack = createDrawerNavigator(
{
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
@ -268,19 +298,21 @@ const AppAgentStack = createDrawerNavigator({
walletSelect: WalletSelect,
createIdentification: CreateIdentification,
validateIdentification: ValidateIdentification,
Historique:
Historique: {
screen: createBottomTabNavigator(
{myDemand: MyHistory},
{
screen: createBottomTabNavigator({myDemand: MyHistory}, {
headerMode: "none",
headerMode: 'none',
header: null,
headerTitle: I18n.t('CREDIT_MANAGE'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
fontWeight: "bold"
fontWeight: 'bold',
},
}
}),
},
},
),
navigationOptions: () => ({
header: null,
headerMode: 'none',
@ -288,60 +320,74 @@ const AppAgentStack = createDrawerNavigator({
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: {backgroundColor: '#694fad'},
/* headerLeft: (<HeaderBackButton />), */
// headerLeft: <HeaderBackButton />,
drawerLabel: I18n.t('CREDIT_MANAGE'),
drawerIcon: ({tintColor}) => (
<Icon
name={'credit-card'}
size={24}
/>)
drawerIcon: ({tintColor}) => <Icon name={'credit-card'} size={24} />,
}),
},
historyItemDetails: HistoryItemDetails,
creditrequest: HistoryRequester,
saisirFeuilleSoinScreen: {screen: SaisirFeuilleSoinScreen, navigationOptions: ()=> ({
saisirFeuilleSoinScreen: {
screen: SaisirFeuilleSoinScreen,
navigationOptions: () => ({
headerTitle: I18n.t('SAISIR_FEUILLE_SOIN'),
title: I18n.t('SAISIR_FEUILLE_SOIN'),
headerStyle: {
marginTop: 20
marginTop: 20,
},
})},
executerPrescriptionScreen: {screen: ExecuterPrescriptionScreen, navigationOptions: ()=> ({
}),
},
executerPrescriptionScreen: {
screen: ExecuterPrescriptionScreen,
navigationOptions: () => ({
headerTitle: I18n.t('EXECUTER_PRESCRIPTION'),
title: I18n.t('EXECUTER_PRESCRIPTION'),
headerStyle: {
marginTop: 20
marginTop: 20,
},
})},
modifierExecutionPrescriptionScreen: {screen: ModifierExecutionPrescriptionScreen, navigationOptions: ()=> ({
}),
},
modifierExecutionPrescriptionScreen: {
screen: ModifierExecutionPrescriptionScreen,
navigationOptions: () => ({
headerTitle: I18n.t('MODIFY_CONSULTATION'),
title: I18n.t('MODIFY_CONSULTATION'),
headerStyle: {
marginTop: 20
marginTop: 20,
},
})},
modifierFeuilleSoinScreen: {screen: ModifierFeuilleSoinScreen, navigationOptions: ()=> ({
}),
},
modifierFeuilleSoinScreen: {
screen: ModifierFeuilleSoinScreen,
navigationOptions: () => ({
headerTitle: I18n.t('MODIFY_EXECUTION'),
title: I18n.t('MODIFY_EXECUTION'),
headerStyle: {
marginTop: 20
marginTop: 20,
},
})},
demandeAutorisationSoinScreen: {screen: DemandeAutorisationSoinScreen, navigationOptions: ()=> ({
}),
},
demandeAutorisationSoinScreen: {
screen: DemandeAutorisationSoinScreen,
navigationOptions: () => ({
headerTitle: I18n.t('DEMAND_AUTORIZATION_HEALTH'),
title: I18n.t('DEMAND_AUTORIZATION_HEALTH'),
headerStyle: {
marginTop: 20
marginTop: 20,
},
})},
historiqueNanoSanteAgentScreen: {screen: HistoriqueNanoSanteAgentScreen, navigationOptions: ()=> ({
}),
},
historiqueNanoSanteAgentScreen: {
screen: HistoriqueNanoSanteAgentScreen,
navigationOptions: () => ({
headerTitle: I18n.t('HISTORY'),
title: I18n.t('HISTORY'),
headerStyle: {
marginTop: 20
marginTop: 20,
},
}),
},
})},
addNetwork: AddNetwork,
updateinformation: UpdateInformations,
notificationview: Notifications,
@ -363,24 +409,31 @@ const AppAgentStack = createDrawerNavigator({
createGroupNanoCredit: CreateGroupNanoCredit,
cautionNanoCreditAgent: CautionNanoCreditAgent,
PDFViewerScreen: PDFViewerScreen,
})
}, {
}),
},
{
contentComponent: OptionsMenu,
backBehavior: "none",
backBehavior: 'none',
lazy: false,
headerMode: 'none', contentOptions: {activeTintColor: theme.accent}
});
headerMode: 'none',
contentOptions: {activeTintColor: theme.accent},
},
);
const AppAdministratorStack = createDrawerNavigator({
const AppAdministratorStack = createDrawerNavigator(
{
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
walletSelect: WalletSelect,
Historique: {
screen: createBottomTabNavigator({
myDemand: MyHistory, OthersDemand: MyHistory
}, {
headerMode: "none",
screen: createBottomTabNavigator(
{
myDemand: MyHistory,
OthersDemand: MyHistory,
},
{
headerMode: 'none',
header: null,
headerTitle: null,
title: I18n.t('CREDIT_MANAGE'),
@ -388,8 +441,9 @@ const AppAdministratorStack = createDrawerNavigator({
labelStyle: {
fontSize: 13,
},
}
}),
},
},
),
navigationOptions: () => ({
header: null,
headerMode: 'none',
@ -399,11 +453,7 @@ const AppAdministratorStack = createDrawerNavigator({
barStyle: {backgroundColor: '#694fad'},
drawerLabel: I18n.t('CREDIT_MANAGE'),
drawerIcon: ({tintColor}) => (
<Icon
name={'credit-card'}
size={24}
/>)
drawerIcon: ({tintColor}) => <Icon name={'credit-card'} size={24} />,
}),
},
creditrequest: HistoryRequester,
@ -419,43 +469,43 @@ const AppAdministratorStack = createDrawerNavigator({
historiqueNanoSanteSuperHyperScreen: HistoriqueNanoSanteSuperHyperScreen,
webviewScreen: WebviewScreen,
PDFViewerScreen: PDFViewerScreen,
})
}),
},
{
contentComponent: OptionsMenu,
backBehavior: "none",
headerMode: 'none'
});
backBehavior: 'none',
headerMode: 'none',
},
);
const AppSuperAdministrator = createDrawerNavigator({
const AppSuperAdministrator = createDrawerNavigator(
{
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
walletSelect: WalletSelect,
Historique: {
screen: createBottomTabNavigator({OthersDemand: MyHistory}, {
headerMode: "none",
screen: createBottomTabNavigator(
{OthersDemand: MyHistory},
{
headerMode: 'none',
header: null,
headerTitle: null,
title: I18n.t('CREDIT_MANAGE'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
fontWeight: "bold"
fontWeight: 'bold',
},
}
}),
},
},
),
navigationOptions: () => ({
title: I18n.t('CREDIT_MANAGE'),
headerMode: "none",
headerMode: 'none',
header: null,
headerTitle: null,
drawerIcon: ({tintColor}) => (
<Icon
name={'credit-card'}
size={24}
/>)
drawerIcon: ({tintColor}) => <Icon name={'credit-card'} size={24} />,
}),
},
creditrequest: HistoryRequester,
@ -470,43 +520,45 @@ const AppSuperAdministrator = createDrawerNavigator({
historiqueNanoSanteSuperHyperScreen: HistoriqueNanoSanteSuperHyperScreen,
webviewScreen: WebviewScreen,
PDFViewerScreen: PDFViewerScreen,
})
}, {
}),
},
{
contentComponent: OptionsMenu,
backBehavior: "none",
headerMode: 'none'
});
backBehavior: 'none',
headerMode: 'none',
},
);
const AppNavigator = createSwitchNavigator({
const AppNavigator = createSwitchNavigator(
{
first: {
screen: SplashScreen
screen: SplashScreen,
},
App: AppStack,
AgentApp: AppAgentStack,
adminApp: AppAdministratorStack,
supAdminApp: AppSuperAdministrator,
Auth: AuthStack
}, {
initialRouteName: 'first'
});
Auth: AuthStack,
},
{
initialRouteName: 'first',
},
);
const AppContainer = createAppContainer(AppNavigator);
export default class App extends React.Component {
constructor(props) {
super(props);
console.log("APP PROPS", this.props);
console.log('APP PROPS', this.props);
global.appHasLoaded = false;
//Remove this method to stop OneSignal Debugging
OneSignal.setLogLevel(6, 0);
IlinkEmitter.on("langueChange", this.updateLangue.bind(this))
IlinkEmitter.on('langueChange', this.updateLangue.bind(this));
// Replace 'YOUR_ONESIGNAL_APP_ID' with your OneSignal App ID.
OneSignal.init("ab02121a-ecec-424f-910a-2709ef85698d", {
OneSignal.init('ab02121a-ecec-424f-910a-2709ef85698d', {
kOSSettingsKeyAutoPrompt: false,
kOSSettingsKeyInAppLaunchURL: false,
kOSSettingsKeyInFocusDisplayOption: 2
kOSSettingsKeyInFocusDisplayOption: 2,
});
OneSignal.inFocusDisplaying(2); // Controls what should happen if a notification is received while the app is open. 2 means that the notification will go directly to the device's notification center.
@ -519,7 +571,7 @@ export default class App extends React.Component {
}
updateLangue() {
this.forceUpdate()
this.forceUpdate();
}
_getOneSignalIds = () => {
@ -531,26 +583,25 @@ export default class App extends React.Component {
reject(error);
}
});
}
};
_saveOneSignalIds = async (ids) => {
_saveOneSignalIds = async ids => {
try {
await AsyncStorage.setItem('@config:onesignalIds', ids);
} catch (error) {
console.warn(error);
}
}
};
goToScreen = (routeName, params, isReset = true) => {
const {navigator} = this.refs;
if (typeof navigator !== 'undefined') {
console.log("APP HAS LOADED", global.appHasLoaded);
console.log('APP HAS LOADED', global.appHasLoaded);
if (global.appHasLoaded) {
navigator.dispatch({
type: "Navigation/NAVIGATE",
type: 'Navigation/NAVIGATE',
routeName,
params
params,
});
/* readUser().then((result) => {
if (result === null || result === undefined) {
@ -571,30 +622,30 @@ export default class App extends React.Component {
}); */
} else {
navigator.dispatch({
type: "Navigation/NAVIGATE",
routeName: "first",
params: {routeName, params}
type: 'Navigation/NAVIGATE',
routeName: 'first',
params: {routeName, params},
});
}
}
};
handleDeepLink = (openResult) => {
handleDeepLink = openResult => {
const data = openResult.notification.payload.additionalData;
//const dataParse = data.replace("'", "\"");
console.warn("HANDLE DEEP LINK", data);
console.warn('HANDLE DEEP LINK', data);
switch (data.screen) {
case 'historyItemDetails':
console.log("History Item");
console.log('History Item');
this.goToScreen(data.screen, {
item: data.data
item: data.data,
});
break;
default:
console.log("Not History Item");
console.log('Not History Item');
this.goToScreen(data.screen, {
id: data.data.id
id: data.data.id,
});
break;
}
@ -616,17 +667,17 @@ export default class App extends React.Component {
}
onReceived(notification) {
console.log("Notification received: ", notification);
console.log('Notification received: ', notification);
}
onOpened = (openResult) => {
onOpened = openResult => {
let data = openResult.notification.payload.additionalData;
this.handleDeepLink(openResult);
console.log('Message: ', openResult.notification.payload.body);
console.log('Data: ', openResult.notification.payload.additionalData);
console.log('isActive: ', openResult.notification.isAppInFocus);
console.log('openResult: ', openResult);
}
};
render() {
return (

View File

@ -16,6 +16,7 @@
"modalhistoryfilter": "filterhistory",
"superviseurgroup": "superviseurgroup",
"historyItemDetails": "historyItemDetails",
"myHistory": "MyHistory",
"forgotpass": "forgottenpass",
"confirmcode": "confirmcode",
"creationstep2": "step2",

View File

@ -1,22 +1,24 @@
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable prettier/prettier */
import React, {Component} from 'react';
import {Alert, Image, ProgressBarAndroid, ScrollView, StatusBar, StyleSheet, Text, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons';
import {deleteUser, readUser} from './../../webservice/AuthApi';
import {getAgentNetworksList} from './../../webservice/NetworkApi'
import {getAgentNetworksList} from './../../webservice/NetworkApi';
import {responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions';
import MapView, {Marker} from 'react-native-maps';
import * as Utils from '../../utils/DeviceUtils';
import CardView from "react-native-cardview";
import I18n from 'react-native-i18n'
import {IlinkEmitter} from "../../utils/events";
import {Card, CardAction, CardButton, CardContent, CardTitle} from 'react-native-material-cards'
import CardView from 'react-native-cardview';
import I18n from 'react-native-i18n';
import {IlinkEmitter} from '../../utils/events';
import {Card, CardAction, CardButton, CardContent, CardTitle} from 'react-native-material-cards';
import {Color} from '../../config/Color';
import Fontisto from "react-native-vector-icons/Fontisto";
import Fontisto from 'react-native-vector-icons/Fontisto';
let theme = require('./../../utils/theme.json');
let route = require('../../route.json');
require('./../../utils/Translations')
require('./../../utils/Translations');
const height = responsiveHeight(100) - 250;
/*
var Fabric = require('react-native-fabric');
@ -36,10 +38,10 @@ export default class UserAccount extends Component {
headerTitle: I18n.t('USER_ACCOUNT'),
headerStyle: {
backgroundColor: theme.primary,
paddingTop: 10
paddingTop: 10,
},
headerTitleStyle: {
color: "white"
color: 'white',
},
drawerIcon: ({tintColor}) => (
<Icon
@ -47,7 +49,7 @@ export default class UserAccount extends Component {
size={24}
/>
),
}
};
};
static options(passProps) {
@ -60,49 +62,49 @@ export default class UserAccount extends Component {
background: {
color: theme.primaryDark,
},
rightButtons: []
rightButtons: [],
},
backButton: {
visible: true,
color: "white"
color: 'white',
},
buttonColor: "white",
buttonColor: 'white',
background: {
color: theme.primaryDark
color: theme.primaryDark,
},
statusBar: {
drawBehind: false,
visible: true,
}
},
};
}
constructor(props) {
super(props)
super(props);
this.state = this.initState();
IlinkEmitter.on("langueChange", this.updateLangue.bind(this))
IlinkEmitter.on('langueChange', this.updateLangue.bind(this));
readUser().then((user) => {
if (user !== null) {
this.setState({user: user})
this.setState({user: user});
this.updateContent(user)
this.updateContent(user);
}
})
});
}
updateLangue() {
this.props.navigation.setParams({name: I18n.t('USER_ACCOUNT')})
this.forceUpdate()
this.props.navigation.setParams({name: I18n.t('USER_ACCOUNT')});
this.forceUpdate();
}
updateContent(user) {
getAgentNetworksList(user.agentId).then((networks) => {
console.log("networks", networks.networks);
if (networks['success'] !== undefined) {
this.setState({mynetworks: networks.networks})
console.log('networks', networks.networks);
if (networks.success !== undefined) {
this.setState({mynetworks: networks.networks});
}
});
@ -112,22 +114,22 @@ export default class UserAccount extends Component {
initState() {
return {
user: {},
mynetworks: []
}
mynetworks: [],
};
}
render() {
let cat = "";
let cat = '';
const {user} = this.state
const {user} = this.state;
if (user.category !== undefined || user.category !== null)
cat = user.category === 'super' ? I18n.t("ADMIN") : user.category === 'hyper' ?
I18n.t("SUPER_ADMIN") : user.category === 'geolocated' ?
I18n.t("GEOLOCATED") : I18n.t("SIMPLE_USER")
{cat = user.category === 'super' ? I18n.t('ADMIN') : user.category === 'hyper' ?
I18n.t('SUPER_ADMIN') : user.category === 'geolocated' ?
I18n.t('GEOLOCATED') : I18n.t('SIMPLE_USER');}
return (
<View style={styles.container}>
<StatusBar
@ -137,7 +139,7 @@ export default class UserAccount extends Component {
/>
<ScrollView style={{
flex: 1,
marginTop: -5
marginTop: -5,
}}>
<View style={styles.userInformation}>
<ScrollView>
@ -156,7 +158,7 @@ export default class UserAccount extends Component {
color: 'white',
fontSize: 17,
fontWeight: 'bold',
textAlign: 'center'
textAlign: 'center',
}}>{cat}</Text>
}
@ -173,29 +175,29 @@ export default class UserAccount extends Component {
<Text style={{
marginLeft: 10, marginRight: 10, marginTop: 15, marginBottom: 5, fontSize: 17,
fontWeight: 'bold', color: 'black'
}}>{I18n.t("ACCOUNT_INFO")}</Text>
fontWeight: 'bold', color: 'black',
}}>{I18n.t('ACCOUNT_INFO')}</Text>
<CardView style={{marginLeft: 10, marginRight: 10, paddingBottom: 20}}>
<ScrollView>
{user.category !== undefined && user.category !== null ? this
.addAgentInformation(user) : null}
<Text style={styles.textInformation2}>
<Icon name={"location-on"} size={18}/>{" " + this.state.user.country}</Text>
<Icon name={'location-on'} size={18}/>{' ' + this.state.user.country}</Text>
{user.balance !== undefined && user.balance !== null ? this.showBalance(user) : null}
<Text style={styles.textInformation2}>
<Icon name={"mail"} size={18}/>{" " + this.state.user.email}</Text>
<Icon name={'mail'} size={18}/>{' ' + this.state.user.email}</Text>
<Text style={styles.textInformation2}>
<Icon name={"phone"} size={18}/>
{" " + this.state.user.phone}</Text>
<Icon name={'phone'} size={18}/>
{' ' + this.state.user.phone}</Text>
{this.showPhoneSup()}
<Text style={styles.textInformation2}>
<Icon name={"account-balance-wallet"} size={18}/>
{" " + this.state.user.network}</Text>
<Icon name={'account-balance-wallet'} size={18}/>
{' ' + this.state.user.network}</Text>
</ScrollView>
</CardView>
@ -207,8 +209,8 @@ export default class UserAccount extends Component {
marginBottom: 5,
fontSize: 17,
fontWeight: 'bold',
color: 'black'
}}>{I18n.t("MY_NETWORK")}</Text>)
color: 'black',
}}>{I18n.t('MY_NETWORK')}</Text>)
: null}
{user.category === 'geolocated' ? (this.state.mynetworks.length > 0 ? this.state.mynetworks.map(item => this.generateItemNetwork(item)) : this.showLoader()) : null}
@ -216,7 +218,7 @@ export default class UserAccount extends Component {
</ScrollView>
</View>
)
);
}
showPhoneSup() {
@ -224,9 +226,9 @@ export default class UserAccount extends Component {
return (<Text style={styles.textInformation2}>
<Icon name={"phone"} size={18}/>
{" " + this.state.user.phoneTransaction}</Text>
)
<Icon name={'phone'} size={18}/>
{' ' + this.state.user.phoneTransaction}</Text>
);
}
}
@ -236,15 +238,14 @@ export default class UserAccount extends Component {
color: 'white',
fontSize: 15,
fontWeight: 'bold',
textAlign: 'center'
}}>{I18n.t("NETWORK")}</Text>
textAlign: 'center',
}}>{I18n.t('NETWORK')}</Text>
<Text style={{color: 'white', fontSize: 15, textAlign: 'center'}}>{user.network}</Text>
</View>)
</View>);
}
getHeaderRight(user) {
return (<View style={{flex: 0}}>
</View>)
return (<View style={{flex: 0}} />);
}
getHeaderRightAgent(user) {
@ -254,10 +255,10 @@ export default class UserAccount extends Component {
color: 'white',
fontSize: 15,
textAlign: 'center',
fontWeight: 'bold'
}}>{I18n.t("MEMBER_CODE")}</Text>
fontWeight: 'bold',
}}>{I18n.t('MEMBER_CODE')}</Text>
<Text style={{color: 'white', fontSize: 13, textAlign: 'center'}}>{user.code_membre}</Text>
</View>)
</View>);
}
@ -267,69 +268,69 @@ export default class UserAccount extends Component {
color: 'white',
fontSize: 15,
fontWeight: 'bold',
textAlign: 'center'
}}>{I18n.t("NETWORK")}</Text>
textAlign: 'center',
}}>{I18n.t('NETWORK')}</Text>
<Text style={{color: 'white', fontSize: 13, textAlign: 'center'}}>{user.network}</Text>
</View>)
</View>);
}
addAgentInformation(user) {
console.log(user)
if (user.category === "geolocated") {
console.log(user);
if (user.category === 'geolocated') {
(<View>
<Text style={{marginLeft: 10, marginTop: 10, color: theme.primaryDark}}>
<Icon name={'code'} size={18} color={theme.primaryDark} style={{paddingRight: 10}}/>
{" " + user.code_parrain}</Text>
</View>)
{' ' + user.code_parrain}</Text>
</View>);
} else
return (<View>
{return (<View>
<Text style={{marginLeft: 10, marginTop: 10, color: theme.primaryDark}}>
<Icon name={'code'} size={18} color={theme.primaryDark} style={{paddingRight: 10}}/>
{" " + user.code_parrain}</Text>
{' ' + user.code_parrain}</Text>
<View style={{
flexDirection: 'row',
justifyContent: 'space-between',
width: responsiveWidth(90),
marginRight: 50
marginRight: 50,
}}>
<Text style={{marginLeft: 12, marginTop: 10, color: theme.primaryDark}}>
<Icon name={"group-work"} color={theme.primaryDark} size={18}/>
{" " + ((user.nbre_reseau === null || user.nbre_reseau === undefined) ? 0 : user.nbre_reseau) + " " + I18n.t("FREE")}
<Icon name={'group-work'} color={theme.primaryDark} size={18}/>
{' ' + ((user.nbre_reseau === null || user.nbre_reseau === undefined) ? 0 : user.nbre_reseau) + ' ' + I18n.t('FREE')}
</Text>
<Text style={{marginLeft: 12, marginTop: 10, color: theme.primaryDark}}>
<Icon name={"book"} color={theme.primaryDark}
size={18}/>{" " + ((user.nbre_reseau === null || user.nbre_membre === undefined) ? 0 : user.nbre_membre) + " " + I18n.t("SAVED")}
<Icon name={'book'} color={theme.primaryDark}
size={18}/>{' ' + ((user.nbre_reseau === null || user.nbre_membre === undefined) ? 0 : user.nbre_membre) + ' ' + I18n.t('SAVED')}
</Text>
</View>
</View>)
</View>);}
}
mapUser(user) {
const myPosition = {latitude: parseFloat(user.latitude), longitude: parseFloat(user.longitude)}
const myPosition = {latitude: parseFloat(user.latitude), longitude: parseFloat(user.longitude)};
return (<MapView
liteMode
ref={(ref) => {
this.mapRef = ref
this.mapRef = ref;
}}
style={styles.map}
>
{this.state.myPosition !== undefined ?
<Marker
title={"Vous êtes ici"}
title={'Vous êtes ici'}
minZoomLevel={10}
coordinate={{longitude: myPosition.longitude, latitude: myPosition.latitude}}
/> :
null}
</MapView>
)
);
}
showBalance(user) {
return <Text style={styles.textInformation2}>
<Icon name={"folder"} size={18}/>{" " + this.state.user.balance + " "}</Text>
<Icon name={'folder'} size={18}/>{' ' + this.state.user.balance + ' '}</Text>;
}
@ -343,10 +344,10 @@ export default class UserAccount extends Component {
marginBottom: 5,
fontSize: 17,
fontWeight: 'bold',
color: 'black'
color: 'black',
}}>Mes reseaux</Text>
</View>)
</View>);
}
generateItemNetwork(item) {
@ -361,13 +362,13 @@ export default class UserAccount extends Component {
<CardContent>
<View Style={{flex: 1}}>
<Text style={styles.textInformation2}>
<Icon name={"code"} size={18}/>{" " + item.code_membre + " "}</Text>
<Icon name={'code'} size={18}/>{' ' + item.code_membre + ' '}</Text>
<Text style={styles.textInformation2}>
<Icon name={"people"} size={18}/>{" " + item.code_parrain + " "}</Text>
<Icon name={'people'} size={18}/>{' ' + item.code_parrain + ' '}</Text>
{item.provider_class !== null && (
<>
<Text style={styles.textInformation2}>
<Fontisto name={"doctor"} size={18}/>{" " + item.provider_class + " "}</Text>
<Fontisto name={'doctor'} size={18}/>{' ' + item.provider_class + ' '}</Text>
</>
)}
@ -380,37 +381,37 @@ export default class UserAccount extends Component {
<CardButton
onPress={() => {
Alert.alert(
I18n.t("TITLE_SUPPRESS_CONFIRM"),
I18n.t("TEXT_SUPPRESS_CONFIRM"),
I18n.t('TITLE_SUPPRESS_CONFIRM'),
I18n.t('TEXT_SUPPRESS_CONFIRM'),
[
{
text: I18n.t('NO'), onPress: () => {
}
},
},
{
text: I18n.t("YES"), onPress: () => {
text: I18n.t('YES'), onPress: () => {
deleteUser(item).then(() => {
this.setState({isLoading: true})
this.updateContent(this.state.user)
})
this.setState({isLoading: true});
this.updateContent(this.state.user);
});
},
style: 'cancel'
style: 'cancel',
},
],
)
);
}}
title={I18n.t('DELETE_GEOLOCATED_USER')}
color="crimson"
/>
</CardAction>
</Card>)
</Card>);
}
showLoader() {
return (<View style={{height: responsiveHeight(20)}}><ProgressBarAndroid
style={{justifyContent: "center", alignItems: "center"}}
/></View>)
style={{justifyContent: 'center', alignItems: 'center'}}
/></View>);
}
}
@ -420,7 +421,7 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'center',
paddingTop: responsiveHeight(2),
paddingBottom: responsiveHeight(5)
paddingBottom: responsiveHeight(5),
},
map: {
height: 200,
@ -431,7 +432,7 @@ const styles = StyleSheet.create({
networkInformation: {
width: responsiveWidth(100),
backgroundColor: '#EEEEEE',
flex: 1
flex: 1,
},
container: {
flex: 1,
@ -458,7 +459,7 @@ const styles = StyleSheet.create({
shadowOpacity: 1.0,
elevation: 5,
borderRadius: 10,
backgroundColor: Color.cardBackgroundColor
backgroundColor: Color.cardBackgroundColor,
},
contain: {
flexDirection: 'row',
@ -468,7 +469,7 @@ const styles = StyleSheet.create({
marginTop: 15,
marginLeft: 5,
width: Utils.scaleWithPixel(30),
height: Utils.scaleWithPixel(30)
height: Utils.scaleWithPixel(30),
},
content: {
height: Utils.scaleWithPixel(60),
@ -483,7 +484,7 @@ const styles = StyleSheet.create({
textInformation: {
fontSize: 16,
color: 'white',
textAlign: 'center'
textAlign: 'center',
},
textInformation2: {
fontSize: 15,
@ -494,12 +495,12 @@ const styles = StyleSheet.create({
textTitle: {
fontSize: 25,
color: 'white',
fontWeight: 'bold'
fontWeight: 'bold',
},
textTitle2: {
fontSize: 25,
color: theme.primaryDark,
fontWeight: 'bold'
}
fontWeight: 'bold',
},
});

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
/**
* Sample React Native App
* https://github.com/facebook/react-native
@ -41,7 +42,7 @@ class History extends BaseScreen {
navBarButtonColor: '#FFFFFF',
contextualMenuStatusBarColor: theme.accent,
contextualMenuBackgroundColor: theme.accentLight,
contextualMenuButtonsColor: '#ffffff'
contextualMenuButtonsColor: '#ffffff',
};
static navigationOptions = ({ navigation }) => {
@ -63,9 +64,9 @@ class History extends BaseScreen {
visible: true,
drawBehind: false,
background: {
color: theme.primaryDark
}
}
color: theme.primaryDark,
},
},
}
}
@ -102,7 +103,6 @@ class History extends BaseScreen {
case 'willAppear':
this.refreshData()
break;
break;
case 'didAppear':
break;
case 'willDisappear':
@ -282,7 +282,7 @@ class History extends BaseScreen {
isLoaded: false,
isSectionned: false,
isDateTimePickerVisible: false,
isDateEndTimePickerVisible: false
isDateEndTimePickerVisible: false,
}
}
@ -491,10 +491,10 @@ class History extends BaseScreen {
_showDateTimePicker = (type) => {
if (type === 1)
this.setState({
isDateTimePickerVisible: true
isDateTimePickerVisible: true,
});
else this.setState({
isDateEndTimePickerVisible: true
isDateEndTimePickerVisible: true,
});
}
_showDateEndPicker = () => this.setState({ isDateEndTimePickerVisible: true });
@ -507,7 +507,7 @@ class History extends BaseScreen {
datestart: fromdate,
datestartformated: moment(fromdate).format('dddd Do ,MMMM YYYY'),
dateend: enddate,
dateendformated: moment(enddate).format('dddd Do ,MMMM YYYY')
dateendformated: moment(enddate).format('dddd Do ,MMMM YYYY'),
});
let startdate = this.state.datestart;
let enddatemo = moment(enddate);
@ -518,7 +518,7 @@ class History extends BaseScreen {
text: I18n.t('DATE_WRONG'),
duration: 'long',
backgroundColor: 'red',
textColor: 'white'
textColor: 'white',
})
} else {
this.setState({ filder_disable: false });
@ -541,7 +541,7 @@ class History extends BaseScreen {
<ActionButton.Item buttonColor={primary} title={I18n.t('MAKE_REQUEST')}
onPress={() => {
this.props.navigation.push(route.credrequester, {
onGoBack: () => this.refreshData()
onGoBack: () => this.refreshData(),
})
}}
>
@ -590,7 +590,7 @@ class History extends BaseScreen {
}]
return <PagerTabIndicator
style={{
height: responsiveHeight(8)
height: responsiveHeight(8),
}}
tabs={tabs} />;
}
@ -601,7 +601,7 @@ class History extends BaseScreen {
}]
return <PagerTabIndicator
style={{
height: responsiveHeight(8)
height: responsiveHeight(8),
}}
tabs={tabs} />;
}
@ -609,14 +609,14 @@ class History extends BaseScreen {
_renderTabs() {
let tabs = [{
text: I18n.t('MY_DEMANDE'),
iconSource: this.state.usersicon
iconSource: this.state.usersicon,
}, {
text: I18n.t('DEMANDE_RECEIVE'),
iconSource: this.state.charticon
iconSource: this.state.charticon,
}]
return <PagerTabIndicator
style={{
height: responsiveHeight(8)
height: responsiveHeight(8),
}}
tabs={tabs} />;
}
@ -653,7 +653,7 @@ const datefilter = StyleSheet.create({
},
datetext: {
fontSize: 16,
marginLeft: responsiveWidth(5)
marginLeft: responsiveWidth(5),
},
content: {
flex: 2,
@ -672,12 +672,12 @@ const datefilter = StyleSheet.create({
},
btntext: {
fontWeight: 'bold',
color: accent
color: accent,
},
container: {
flex: 1,
justifyContent: 'space-evenly'
}
justifyContent: 'space-evenly',
},
})
const styles = StyleSheet.create({
slidingup: {
@ -695,7 +695,7 @@ const styles = StyleSheet.create({
emptylist: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
},
backgroundd_drawer: {
backgroundColor: '#000',
@ -727,10 +727,10 @@ const styles = StyleSheet.create({
fontSize: 17,
marginLeft: responsiveWidth(10),
color: 'black'
color: 'black',
},
content: {
flex: 8
flex: 8,
},
title: {
@ -738,6 +738,6 @@ const styles = StyleSheet.create({
marginLeft: 20,
marginTop: 20,
color: 'black',
fontWeight: 'bold'
fontWeight: 'bold',
},
});

View File

@ -1,8 +1,22 @@
/* eslint-disable react/jsx-no-duplicate-props */
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable no-unused-vars */
import React, {PureComponent} from 'react';
import {FlatList, RefreshControl, SectionList, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {responsiveFontSize, responsiveWidth} from 'react-native-responsive-dimensions';
import {
FlatList,
RefreshControl,
SectionList,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import {
responsiveFontSize,
responsiveWidth,
} from 'react-native-responsive-dimensions';
import Icon from 'react-native-vector-icons/FontAwesome5';
import I18n from "react-native-i18n"
import I18n from 'react-native-i18n';
import 'moment/locale/fr';
import 'moment/locale/es-us';
@ -21,16 +35,15 @@ let route = require('./../../route.json');
var theme = require('./../../utils/theme.json');
export class HistoryItem extends React.Component {
constructor(props) {
super(props);
this.currentLocale = I18n.locale.includes("fr") ? "fr" : "en-gb";
console.log("Current Locale item", this.currentLocale);
this.currentLocale = I18n.locale.includes('fr') ? 'fr' : 'en-gb';
console.log('Current Locale item', this.currentLocale);
moment.locale(this.currentLocale);
this.state = this.initState();
}
statusLabel = (status) => {
statusLabel = status => {
switch (status) {
case '0':
return I18n.t('NO_TREAT');
@ -39,9 +52,9 @@ export class HistoryItem extends React.Component {
case '2':
return I18n.t('REFUSED');
}
}
};
colorLabel = (status) => {
colorLabel = status => {
switch (status) {
case '0':
return Color.accentColor;
@ -50,34 +63,54 @@ export class HistoryItem extends React.Component {
case '2':
return Color.redColor;
}
}
};
descriptionLabelUserType = (user) => {
let textDescription = (this.props.selfData.montant) + ' ' + I18n.t('TO_') + ' ' + this.props.selfData.reseau;
descriptionLabelUserType = user => {
let textDescription =
this.props.selfData.montant +
' ' +
I18n.t('TO_') +
' ' +
this.props.selfData.reseau;
switch (user.category) {
case 'geolocated':
return `${I18n.t('DEMAND_TEXT_FIRST_PART_YOU')} ${textDescription}`;
case 'super':
return this.props.isDemandSend ?
`${I18n.t('DEMAND_TEXT_FIRST_PART_YOU')} ${textDescription}`
:
`${I18n.t('THE_AGENT')} ${this.props.selfData.lastname} (${this.props.selfData.phone}) ${I18n.t('DEMAND_TEXT_FIRST_PART')} ${textDescription}`;
return this.props.isDemandSend
? `${I18n.t('DEMAND_TEXT_FIRST_PART_YOU')} ${textDescription}`
: `${I18n.t('THE_AGENT')} ${this.props.selfData.lastname} (${
this.props.selfData.phone
}) ${I18n.t('DEMAND_TEXT_FIRST_PART')} ${textDescription}`;
case 'hyper':
return `${I18n.t('THE_SUPERVISOR')} ${this.props.selfData.lastname} (${this.props.selfData.phone}) ${I18n.t('DEMAND_TEXT_FIRST_PART')} ${textDescription}`;
}
return `${I18n.t('THE_SUPERVISOR')} ${this.props.selfData.lastname} (${
this.props.selfData.phone
}) ${I18n.t('DEMAND_TEXT_FIRST_PART')} ${textDescription}`;
}
};
initState() {
var textTitle = ' Transaction ' + this.props.selfData.id;
var textDescription = I18n.t('PHONE') + ' ' + this.props.selfData.phone + " " + I18n.t('DEMAND_TEXT_FIRST_PART') + ' ' + (this.props.selfData.montant) + ' ' + I18n.t('TO_') + ' ';
var textDescription =
I18n.t('PHONE') +
' ' +
this.props.selfData.phone +
' ' +
I18n.t('DEMAND_TEXT_FIRST_PART') +
' ' +
this.props.selfData.montant +
' ' +
I18n.t('TO_') +
' ';
textDescription += this.props.selfData.reseau;
var today = new Date();
var l = this.props.selfData.date_creation;
let t = this.props.selfData.status;
var re = moment.tz(this.props.selfData.date_creation, moment.tz.guess()).format();
re = moment(re)
var re = moment
.tz(this.props.selfData.date_creation, moment.tz.guess())
.format();
re = moment(re);
return {
title: textTitle,
description: this.descriptionLabelUserType(this.props.user),
@ -85,61 +118,57 @@ export class HistoryItem extends React.Component {
time: re.fromNow(),
navigator: this.props.navigator,
type: t,
colorstate: this.colorLabel(t)
}
colorstate: this.colorLabel(t),
};
}
render() {
//console.log("ITEM RENDER", this.props.selfData)
return (
<TouchableOpacity onPress={() =>
<TouchableOpacity
onPress={() =>
this.props.navigator.navigate(route.historyItemDetails, {
item: this.props.selfData,
onGoBack: () => this.props.refresh(),
}
)}>
})
}>
<View style={style.content}>
<Text style={style.title}>{this.state.title}</Text>
<Text style={style.description}>{this.state.description}</Text>
<View style={style.timeContent}>
<Text style={{
<Text
style={{
fontWeight: 'bold',
marginLeft: 20,
marginBottom: 10,
color: this.state.colorstate,
}}>{this.statusLabel(this.props.selfData.status)}</Text>
}}>
{this.statusLabel(this.props.selfData.status)}
</Text>
<Text style={style.time}>{this.state.time}</Text>
</View>
<View style={style.bottomSeparator} />
</View>
</TouchableOpacity>
)
);
}
}
export class HistoryItemSectionned extends PureComponent {
_keyExtractor = (item, index) => item.id;
_renderItem = ({item}) => (
<HistoryItem
navigator={this.props.navigator}
selfData={item}
/>
<HistoryItem navigator={this.props.navigator} selfData={item} />
);
constructor(props) {
super(props);
this.state = this.initState();
this.currentLocale = I18n.locale.includes("fr") ? "fr" : "en-gb";
this.currentLocale = I18n.locale.includes('fr') ? 'fr' : 'en-gb';
moment.locale(this.currentLocale);
}
render() {
return (
<SectionList
sections={[
{
@ -147,44 +176,62 @@ export class HistoryItemSectionned extends PureComponent {
type: 0,
data: this.state.treat,
size: this.state.conservetreat.length,
expandState: this.state.istreatexpand
expandState: this.state.istreatexpand,
},
{
title: 'Demande non traité',
type: 1,
data: this.state.untreat,
size: this.state.conserveuntreat.length,
expandState: this.state.isuntreatexpand
}
expandState: this.state.isuntreatexpand,
},
]}
renderSectionHeader={({section: {title, type, data, size, expandState}}) => (
<TouchableOpacity onPress={() => this.onPressedHeader(type)} style={{
renderSectionHeader={({
section: {title, type, data, size, expandState},
}) => (
<TouchableOpacity
onPress={() => this.onPressedHeader(type)}
style={{
backgroundColor: theme.accent,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row', flex: 1, height: 70, width: responsiveWidth(100)
flexDirection: 'row',
flex: 1,
height: 70,
width: responsiveWidth(100),
}}>
<View style={{
<View
style={{
height: 70,
justifyContent: 'center',
flex: 1,
width: responsiveWidth(100),
}}>
<Text style={{
<Text
style={{
fontWeight: 'bold',
marginLeft: 20,
fontSize: 20,
color: 'white'
}}>{title}</Text>
<Text style={{
color: 'white',
}}>
{title}
</Text>
<Text
style={{
fontWeight: 'bold',
marginLeft: 20,
fontSize: 16,
color: 'white'
}}>{size} demande(s)</Text>
color: 'white',
}}>
{size} demande(s)
</Text>
</View>
<Icon name={expandState ? 'sort-up' : 'sort-down'} size={30} color={'white'}
style={{marginRight: 20}}/>
<Icon
name={expandState ? 'sort-up' : 'sort-down'}
size={30}
color={'white'}
style={{marginRight: 20}}
/>
</TouchableOpacity>
)}
style={style.listStyle}
@ -199,19 +246,18 @@ export class HistoryItemSectionned extends PureComponent {
if (type === 0) {
this.setState({
istreatexpand: !this.state.istreatexpand,
treat: this.state.istreatexpand ? [] : this.state.conservetreat
})
treat: this.state.istreatexpand ? [] : this.state.conservetreat,
});
} else {
this.setState({
isuntreatexpand: !this.state.isuntreatexpand,
untreat: this.state.isuntreatexpand ? [] : this.state.conserveuntreat
})
untreat: this.state.isuntreatexpand ? [] : this.state.conserveuntreat,
});
}
}
initState() {
let data = this.props.list
let data = this.props.list;
return {
conservetreat: data.filter(item => item.statut === I18n.t('TREAT')),
@ -219,17 +265,15 @@ export class HistoryItemSectionned extends PureComponent {
istreatexpand: true,
conserveuntreat: data.filter(item => item.statut !== I18n.t('TREAT')),
untreat: data.filter(item => item.statut !== I18n.t('TREAT')),
isuntreatexpand: true
}
isuntreatexpand: true,
};
}
}
export class HistoryListItem extends React.Component {
_keyExtractor = (item, index) => item.id;
_onPressItem = (id: string) => {
};
_onPressItem = id => {};
_renderItem = ({item}) => {
//console.log('ITEM ', item);
return (
@ -239,22 +283,21 @@ export class HistoryListItem extends React.Component {
refresh={this.props.refresh}
navigator={this.props.navigator}
selfData={item}
refresh={this.props.refresh}
/>
)
);
};
constructor(props) {
super(props);
this.state = this.initState();
this.currentLocale = I18n.locale.includes("fr") ? "fr" : "en-gb";
this.currentLocale = I18n.locale.includes('fr') ? 'fr' : 'en-gb';
moment.locale(this.currentLocale);
}
initState() {
return {
refreshing: false,
}
};
}
render() {
@ -268,7 +311,12 @@ export class HistoryListItem extends React.Component {
refreshControl={
<RefreshControl
refreshing={this.props.isRefreshing}
colors={[theme.primary, theme.purpleLight, theme.reddeconnect, theme.accentLight]}
colors={[
theme.primary,
theme.purpleLight,
theme.reddeconnect,
theme.accentLight,
]}
onRefresh={this.props.refreshing}
/>
}
@ -277,9 +325,9 @@ export class HistoryListItem extends React.Component {
}
_onRefresh() {
this.setState({refreshing: true})
this.setState({refreshing: true});
setTimeout(() => {
this.setState({refreshing: false})
this.setState({refreshing: false});
}, 5000);
}
}
@ -291,10 +339,9 @@ const style = StyleSheet.create({
flex: 1,
flexDirection: 'column',
paddingTop: 10,
},
listStyle: {
backgroundColor: 'white'
backgroundColor: 'white',
},
bottomSeparator: {
width: responsiveWidth(100),
@ -306,13 +353,12 @@ const style = StyleSheet.create({
title: {
color: '#000',
paddingLeft: 10,
fontSize: responsiveFontSize(2.2)
fontSize: responsiveFontSize(2.2),
},
description: {
fontSize: responsiveFontSize(1.8),
color: '#4f5b62',
paddingLeft: 10,
},
timeContent: {
justifyContent: 'space-between',
@ -328,5 +374,4 @@ const style = StyleSheet.create({
color: theme.accent,
},
treat: {},
});

View File

@ -1,21 +1,29 @@
import React, {Component} from 'react'
import {Alert, Platform, StyleSheet, Text, View} from 'react-native'
import CardView from 'react-native-cardview'
import Button from 'apsl-react-native-button'
import {responsiveWidth} from 'react-native-responsive-dimensions'
import Icons from 'react-native-vector-icons/Ionicons'
import {readUser} from "../../webservice/AuthApi";
/* eslint-disable radix */
/* eslint-disable react-native/no-inline-styles */
import React, {Component} from 'react';
import {Alert, Platform, StyleSheet, Text, View} from 'react-native';
import CardView from 'react-native-cardview';
import Button from 'apsl-react-native-button';
import {responsiveWidth} from 'react-native-responsive-dimensions';
import Icons from 'react-native-vector-icons/Ionicons';
import {readUser} from '../../webservice/AuthApi';
import isNil from 'lodash/isNil';
import {creditDemandResetReducer, treatCreditDemand} from '../../webservice/CreditTreatDemandApi';
import {creditCancelResetReducer, treatCancelDemand} from '../../webservice/CreditCancelDemandeApi';
import {getAgentNetworksList} from "../../webservice/NetworkApi";
import {
creditDemandResetReducer,
treatCreditDemand,
} from '../../webservice/CreditTreatDemandApi';
import {
creditCancelResetReducer,
treatCancelDemand,
} from '../../webservice/CreditCancelDemandeApi';
import {getAgentNetworksList} from '../../webservice/NetworkApi';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import Toast from 'react-native-root-toast';
import {Color} from '../../config/Color'
import Dialog from "react-native-dialog";
import {FontWeight} from '../../config/typography'
import I18n from "react-native-i18n";
import {Color} from '../../config/Color';
import Dialog from 'react-native-dialog';
import {FontWeight} from '../../config/typography';
import I18n from 'react-native-i18n';
import 'moment/locale/fr';
import 'moment/locale/es-us';
@ -30,14 +38,13 @@ const momentJS = require('moment');
let typesta = 0;
var colorback = 'white'
var colorback = 'white';
let theme = require('./../../utils/theme.json');
const route = require("./../../route.json");
const route = require('./../../route.json');
class HistoryItemDetails extends Component {
static navigatorStyle = {
navBarBackgroundColor: theme.accentLight,
statusBarColor: theme.accent,
@ -47,37 +54,37 @@ class HistoryItemDetails extends Component {
static navigationOptions = ({navigation}) => {
return {
drawerLabel: () => null,
title: isNil(navigation.getParam("item", null).item) ?
"Transaction N°" + navigation.getParam("item", {id: "-"}).id :
"Transaction N°" + navigation.getParam("item", {id: "-"}).item.id
}
title: isNil(navigation.getParam('item', null).item)
? 'Transaction N°' + navigation.getParam('item', {id: '-'}).id
: 'Transaction N°' + navigation.getParam('item', {id: '-'}).item.id,
};
};
constructor(props) {
super(props);
this.item = this.props.navigation.getParam("item", null);
if (isNil(this.props.navigation.getParam("item", null).item)) {
this.item = this.props.navigation.getParam("item", null);
this.item = this.props.navigation.getParam('item', null);
if (isNil(this.props.navigation.getParam('item', null).item)) {
this.item = this.props.navigation.getParam('item', null);
} else {
this.item = this.props.navigation.getParam("item", null).item;
this.item = this.props.navigation.getParam('item', null).item;
}
this.currentLocale = I18n.locale.includes("fr") ? "fr" : "en-gb";
this.currentLocale = I18n.locale.includes('fr') ? 'fr' : 'en-gb';
moment.locale(this.currentLocale);
let sta = ''
let sta = '';
if (this.item.status === '1') {
typesta = 1
colorback = '#AEAEAE'
sta = I18n.t('TREAT_DEMAND')
typesta = 1;
colorback = '#AEAEAE';
sta = I18n.t('TREAT_DEMAND');
} else if (this.item.status === '0') {
colorback = 'green'
typesta = 2
sta = I18n.t('ACCEPTER_DEMANDE')
colorback = 'green';
typesta = 2;
sta = I18n.t('ACCEPTER_DEMANDE');
} else {
colorback = '#AEAEAE'
typesta = 2
sta = I18n.t('REFUSED')
colorback = '#AEAEAE';
typesta = 2;
sta = I18n.t('REFUSED');
}
this.state = {
@ -91,37 +98,33 @@ class HistoryItemDetails extends Component {
triggerCancelClick: false,
color: colorback,
montant: null,
isBtnModifyAmountEnabled: false
}
readUser().then(async (user) => {
let networks = []
isBtnModifyAmountEnabled: false,
};
readUser().then(async user => {
let networks = [];
networks = await getAgentNetworksList(user.agentId);
this.setState({user: user, networks: networks.networks})
this.setState({user: user, networks: networks.networks});
});
}
isNormalInteger = (str) => {
return (/[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/.test(str)) ? false : true;
}
isNormalInteger = str => {
return /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/.test(str) ? false : true;
};
isMontantValid = () => {
const {montant} = this.state;
if ((parseInt(montant) == 0 || montant < 0))
if (parseInt(montant) == 0 || montant < 0) {
return false;
else if (!this.isNormalInteger(montant))
} else if (!this.isNormalInteger(montant)) {
return false;
else if (parseInt(montant) > parseInt(this.item.montant))
} else if (parseInt(montant) > parseInt(this.item.montant)) {
return false;
else
} else {
return true;
}
};
displayToast = (message) => {
displayToast = message => {
Toast.show(message, {
duration: Toast.durations.SHORT,
position: Toast.positions.BOTTOM,
@ -141,12 +144,12 @@ class HistoryItemDetails extends Component {
},
onHidden: () => {
// calls on toast\`s hide animation end.
}
},
});
}
};
onTreatDemand() {
if (this.item !== "1") {
if (this.item !== '1') {
this.props.creditDemandResetReducer();
this.props.treatCreditDemand(this.item.id);
/* updateCreditDemand(this.item.phone, this.item.id).then((data) => {
@ -163,94 +166,117 @@ class HistoryItemDetails extends Component {
}
onCancelDemand = () => {
if (this.item !== "1") {
if (this.item !== '1') {
this.props.treatCancelDemand(this.item.id);
}
}
};
renderPromptModifyAmountToSend = () => {
return (
<Dialog.Container useNativeDriver={true} visible={this.state.displayAmountModifyDialog}>
<Dialog.Container
useNativeDriver={true}
visible={this.state.displayAmountModifyDialog}>
<Dialog.Title>{I18n.t('MODIFY_AMOUNT')}</Dialog.Title>
<Dialog.Description style={[FontWeight.bold]}>
{I18n.t('ENTER_NEW_AMOUNT_TO_SEND')}
</Dialog.Description>
<Dialog.Input style={styles.inputAmountText}
<Dialog.Input
style={styles.inputAmountText}
value={this.state.montant}
keyboardType="numeric"
onChangeText={(montant) => {
onChangeText={montant => {
this.setState({montant}, () => {
if (this.isMontantValid(montant)) {
this.setState({
isBtnModifyAmountEnabled: true
})
} else
isBtnModifyAmountEnabled: true,
});
} else {
this.setState({
isBtnModifyAmountEnabled: false
isBtnModifyAmountEnabled: false,
});
}
console.log("this.isMontantValid().isValid", this.isMontantValid());
console.log("isBtnModifyAmountEnabled", this.state.isBtnModifyAmountEnabled);
console.log(
'this.isMontantValid().isValid',
this.isMontantValid(),
);
console.log(
'isBtnModifyAmountEnabled',
this.state.isBtnModifyAmountEnabled,
);
});
}}
/>
}}/>
<Dialog.Button bold={true} label={I18n.t('CANCEL_LABEL')}
onPress={() => this.setState({displayAmountModifyDialog: false})}/>
<Dialog.Button bold={true} label={I18n.t('SEND')} disable={this.state.isBtnModifyAmountEnabled}
<Dialog.Button
bold={true}
label={I18n.t('CANCEL_LABEL')}
onPress={() => this.setState({displayAmountModifyDialog: false})}
/>
<Dialog.Button
bold={true}
label={I18n.t('SEND')}
disable={this.state.isBtnModifyAmountEnabled}
onPress={() => {
this.props.creditDemandResetReducer();
this.props.treatCreditDemand(this.item.id, this.state.montant);
}}/>
}}
/>
</Dialog.Container>
)
}
);
};
renderAlertErrorTreatOrCancelDemand = () => {
const {errorTreatDemand, resultTreatDemand, resultCancelDemand, errorCancelDemand} = this.props;
const {
errorTreatDemand,
resultTreatDemand,
resultCancelDemand,
errorCancelDemand,
} = this.props;
if (errorTreatDemand !== null) {
if (typeof errorTreatDemand.data !== 'undefined') {
if (errorTreatDemand.status === 426) {
Alert.alert(
I18n.t("ERROR_TREATMENT_DEMAND"),
I18n.t('ERROR_TREATMENT_DEMAND'),
errorTreatDemand.data.error,
[{
[
{
text: I18n.t('CANCEL_LABEL'),
onPress: () => {
},
style: 'cancel'
onPress: () => {},
style: 'cancel',
},
{
text: I18n.t("OK"), onPress: () => {
text: I18n.t('OK'),
onPress: () => {
setTimeout(() => {
this.setState({
displayAmountModifyDialog: true
displayAmountModifyDialog: true,
});
}, 10);
this.props.creditDemandResetReducer();
this.props.creditCancelResetReducer();
}
}],
{cancelable: false}
},
},
],
{cancelable: false},
);
} else {
Alert.alert(
I18n.t("ERROR_TREATMENT_DEMAND"),
I18n.t('ERROR_TREATMENT_DEMAND'),
errorTreatDemand.data.error,
[
{
text: I18n.t("OK"), onPress: () => {
text: I18n.t('OK'),
onPress: () => {
this.props.creditDemandResetReducer();
this.props.creditCancelResetReducer();
}
}
},
},
],
{cancelable: false}
{cancelable: false},
);
}
}
@ -259,101 +285,103 @@ class HistoryItemDetails extends Component {
if (errorCancelDemand !== null) {
if (typeof errorCancelDemand.data !== 'undefined') {
Alert.alert(
I18n.t("ERROR_TREATMENT_DEMAND"),
I18n.t('ERROR_TREATMENT_DEMAND'),
errorCancelDemand.data.error,
[
{
text: I18n.t("OK"), onPress: () => {
text: I18n.t('OK'),
onPress: () => {
this.props.creditCancelResetReducer();
this.props.creditDemandResetReducer();
}
}
},
},
],
{cancelable: false}
)
{cancelable: false},
);
}
}
if (resultTreatDemand !== null) {
console.log("resultTreatDemand", resultTreatDemand);
console.log('resultTreatDemand', resultTreatDemand);
if (resultTreatDemand.status === 200) {
this.displayToast(resultTreatDemand.response);
this.props.navigation.goBack();
if (!isNil(this.props.navigation.state.params.onGoBack))
if (!isNil(this.props.navigation.state.params.onGoBack)) {
this.props.navigation.state.params.onGoBack();
}
this.props.creditCancelResetReducer();
this.props.creditDemandResetReducer();
}
}
if (resultCancelDemand !== null) {
console.log("resultCancelDemand", resultCancelDemand);
console.log('resultCancelDemand', resultCancelDemand);
if (resultCancelDemand.status === 200) {
this.displayToast(resultCancelDemand.response);
this.props.navigation.goBack();
if (!isNil(this.props.navigation.state.params.onGoBack))
if (!isNil(this.props.navigation.state.params.onGoBack)) {
this.props.navigation.state.params.onGoBack();
}
this.props.creditCancelResetReducer();
this.props.creditDemandResetReducer();
}
}
}
};
renderBtn() {
const {user} = this.state;
console.warn("ITEM ITEM", this.item);
console.warn("Code Membre", user.code_membre);
console.warn('ITEM ITEM', this.item);
console.warn('Code Membre', user.code_membre);
if (user) {
if (this.item.code_parrain.toLowerCase() === user.code_membre.toLowerCase()) {
console.warn("Conditions vérifié");
if (
this.item.code_parrain.toLowerCase() === user.code_membre.toLowerCase()
) {
console.warn('Conditions vérifié');
if (this.item.status === '1') {
return (<Button
return (
<Button
style={{
borderColor: 'transparent',
borderRadius: 6,
marginLeft: 5,
marginRight: 5,
backgroundColor: this.state.color
backgroundColor: this.state.color,
}}
isLoading={this.props.loadingTreatDemand}
onPress={() => {
}}
onPress={() => {}}
disabled={true}
textStyle={styles.textbtnstyle}
>
textStyle={styles.textbtnstyle}>
{this.state.statut}
</Button>
)
);
}
if (this.item.status === '2') {
return (<Button
return (
<Button
style={{
borderColor: 'transparent',
borderRadius: 6,
marginLeft: 5,
marginRight: 5,
backgroundColor: this.state.color
}}
onPress={() => {
backgroundColor: this.state.color,
}}
onPress={() => {}}
disabled={true}
textStyle={styles.textbtnstyle}
>
textStyle={styles.textbtnstyle}>
{this.state.statut}
</Button>
)
);
} else {
return (<View style={{
return (
<View
style={{
flexDirection: 'row',
paddingTop: 10
paddingTop: 10,
}}>
<View style={{
<View
style={{
flex: 1,
alignItems: 'center'
alignItems: 'center',
}}>
<Button
style={{
@ -361,24 +389,25 @@ class HistoryItemDetails extends Component {
borderRadius: 6,
marginLeft: 5,
marginRight: 5,
backgroundColor: this.state.color
backgroundColor: this.state.color,
}}
isLoading={this.props.loadingTreatDemand}
onPress={() => {
this.setState({
triggerTreatmentClick: true
triggerTreatmentClick: true,
});
this.onTreatDemand()
this.onTreatDemand();
}}
textStyle={styles.textbtnstyle}
>
textStyle={styles.textbtnstyle}>
{this.state.statut}
</Button>
</View>
<View style={{
<View
style={{
flex: 1,
alignItems: 'center'
alignItems: 'center',
}}>
<Button
style={{
@ -386,21 +415,21 @@ class HistoryItemDetails extends Component {
borderRadius: 6,
marginLeft: 5,
marginRight: 5,
backgroundColor: Color.redColor
backgroundColor: Color.redColor,
}}
isLoading={this.props.loadingCancelDemand}
onPress={() => {
this.setState({
triggerCancelClick: true
triggerCancelClick: true,
});
this.onCancelDemand();
}}
textStyle={styles.textbtnstyle}
>
textStyle={styles.textbtnstyle}>
{I18n.t('REFUSER_DEMANDE')}
</Button>
</View>
</View>)
</View>
);
}
}
}
@ -410,174 +439,201 @@ class HistoryItemDetails extends Component {
let ago = moment.tz(this.item.date_creation, moment.tz.guess()).format();
ago = moment(ago);
let cancelDate = "";
let cancelDate = '';
if (parseInt(this.item.canceled_by_hypervisor) === 1) {
console.log("CANCEL DATE", this.item.cancellation_date);
cancelDate = moment.tz(this.item.cancellation_date, moment.tz.guess()).format();
console.log('CANCEL DATE', this.item.cancellation_date);
cancelDate = moment
.tz(this.item.cancellation_date, moment.tz.guess())
.format();
cancelDate = moment(cancelDate);
}
return (
<View style={styles.container}>
{this.renderPromptModifyAmountToSend()}
{(this.state.triggerTreatmentClick || this.state.triggerCancelClick) && this.renderAlertErrorTreatOrCancelDemand()}
<CardView
style={styles.cardcontainer1}
><Text style={{
{(this.state.triggerTreatmentClick || this.state.triggerCancelClick) &&
this.renderAlertErrorTreatOrCancelDemand()}
<CardView style={styles.cardcontainer1}>
<Text
style={{
fontSize: 17,
fontWeight: 'bold',
color: 'black',
marginLeft: responsiveWidth(5)
}}>{I18n.t('MEMBER_INFO')}</Text>
<View style={{
flexDirection: 'row',
justifyContent: 'flex-start'
marginLeft: responsiveWidth(5),
}}>
<Icons name='md-call'
{I18n.t('MEMBER_INFO')}
</Text>
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start',
}}>
<Icons
name="md-call"
size={28}
color={theme.accent}
style={{
marginLeft: 20
marginLeft: 20,
}}
/>
<Text style={styles.simpleuser}>{this.item.phone}</Text>
</View>
<View style={{
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start'
justifyContent: 'flex-start',
}}>
<Icons name='md-person'
<Icons
name="md-person"
size={28}
color={theme.accent}
style={{
marginLeft: 20
marginLeft: 20,
}}
/>
<Text style={styles.simpleuser}>{this.item.code_membre}</Text>
</View>
</CardView>
<CardView
style={styles.cardcontainer}
>
<Text style={{
<CardView style={styles.cardcontainer}>
<Text
style={{
fontSize: 17,
fontWeight: 'bold',
color: 'black',
marginLeft: responsiveWidth(5)
}}>{I18n.t('DEMAND_INFO')}</Text>
<View style={{
flexDirection: 'row',
justifyContent: 'flex-start'
marginLeft: responsiveWidth(5),
}}>
<Icons name='md-git-branch'
{I18n.t('DEMAND_INFO')}
</Text>
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start',
}}>
<Icons
name="md-git-branch"
size={28}
color={theme.accent}
style={{
marginLeft: 20
marginLeft: 20,
}}
/>
<Text style={styles.simpleuser}>{this.item.code_parrain}</Text>
</View>
<View style={{
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start'
justifyContent: 'flex-start',
}}>
<Icons name='md-code-working'
<Icons
name="md-code-working"
size={28}
color={theme.accent}
style={{
marginLeft: 20
marginLeft: 20,
}}
/>
<Text style={styles.simpleuser}>{this.item.reseau}</Text>
</View>
<View style={{
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start'
justifyContent: 'flex-start',
}}>
<Icons name='md-wallet'
<Icons
name="md-wallet"
size={28}
color={theme.accent}
style={{
marginLeft: 20
marginLeft: 20,
}}
/>
<Text style={styles.simpleuser}>{this.item.montant}</Text>
</View>
<View style={{
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start'
justifyContent: 'flex-start',
}}>
<Icons name='md-calendar'
<Icons
name="md-calendar"
size={28}
color={theme.accent}
style={{
marginLeft: 20
marginLeft: 20,
}}
/>
<Text style={styles.simpleuser}>{ago.format(" Do MMMM YYYY à HH:mm")}</Text>
<Text style={styles.simpleuser}>
{ago.format(' Do MMMM YYYY à HH:mm')}
</Text>
</View>
<View style={{
<View
style={{
flexDirection: 'row',
alignSelf: 'flex-end',
marginRight: 20,
justifyContent: 'flex-start'
justifyContent: 'flex-start',
}}>
<Icons name='md-time'
size={28}
color={theme.accent}
/>
<Text style={{
<Icons name="md-time" size={28} color={theme.accent} />
<Text
style={{
marginLeft: responsiveWidth(2),
fontSize: 16,
color: theme.accent
}}>{ago.fromNow()}</Text>
color: theme.accent,
}}>
{ago.fromNow()}
</Text>
</View>
</CardView>
{
parseInt(this.item.canceled_by_hypervisor) === 1 &&
{parseInt(this.item.canceled_by_hypervisor) === 1 && (
<CardView style={styles.cardcontainer}>
<Text style={{
<Text
style={{
fontSize: 17,
fontWeight: 'bold',
color: 'black',
marginLeft: responsiveWidth(5)
marginLeft: responsiveWidth(5),
}}>
{I18n.t('DEMAND_STATE')}
</Text>
<View style={{
flexDirection: 'row',
justifyContent: 'flex-start'
}}>
<Icons name='md-git-branch'
size={28}
color={theme.accent}
style={{marginLeft: 20}}/>
<Text style={styles.simpleuser}>{I18n.t('CANCEL_BY_HYPERVISOR')}</Text>
</View>
<View style={{
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start',
marginTop: -20
}}>
<Icons name='md-calendar'
<Icons
name="md-git-branch"
size={28}
color={theme.accent}
style={{marginLeft: 20}}
/>
<Text style={styles.simpleuser}>
{I18n.t('CANCEL_BY_HYPERVISOR')}
</Text>
</View>
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start',
marginTop: -20,
}}>
<Icons
name="md-calendar"
size={28}
color={theme.accent}
style={{
marginLeft: 20
marginLeft: 20,
}}
/>
<Text
style={styles.simpleuser}>{`${I18n.t('CANCEL_ON')} ${cancelDate.format(" Do MMMM YYYY à HH:mm")}`}</Text>
<Text style={styles.simpleuser}>{`${I18n.t(
'CANCEL_ON',
)} ${cancelDate.format(' Do MMMM YYYY à HH:mm')}`}</Text>
</View>
</CardView>
}
)}
{this.state.user ? this.renderBtn() : null}
</View>)
</View>
);
}
}
const mapStateToProps = state => ({
@ -587,16 +643,20 @@ const mapStateToProps = state => ({
loadingCancelDemand: state.creditCancelDemandReducer.loadingCancelDemand,
resultCancelDemand: state.creditCancelDemandReducer.resultCancelDemand,
errorCancelDemand: state.creditCancelDemandReducer.errorCancelDemand
errorCancelDemand: state.creditCancelDemandReducer.errorCancelDemand,
});
const mapDispatchToProps = dispatch => bindActionCreators({
const mapDispatchToProps = dispatch =>
bindActionCreators(
{
treatCreditDemand: treatCreditDemand,
creditDemandResetReducer: creditDemandResetReducer,
treatCancelDemand: treatCancelDemand,
creditCancelResetReducer: creditCancelResetReducer
}, dispatch);
creditCancelResetReducer: creditCancelResetReducer,
},
dispatch,
);
export default connect(mapStateToProps, mapDispatchToProps)(HistoryItemDetails);
@ -611,30 +671,29 @@ const styles = StyleSheet.create({
android: {
borderBottomColor: Color.borderColor,
borderBottomWidth: 0.5,
}
})
},
}),
},
simpleuser: {
marginLeft: responsiveWidth(2),
fontSize: 16,
color: '#3E3E3E'
color: '#3E3E3E',
},
textbtnstyle: {
color: "white",
fontWeight: "bold",
fontSize: 18
color: 'white',
fontWeight: 'bold',
fontSize: 18,
},
cardcontainer1: {
justifyContent: 'space-evenly',
flex: 2,
marginRight: 3,
marginLeft: 3,
},
cardcontainer: {
justifyContent: 'space-evenly',
flex: 3,
margin: 3,
}
})
},
});

View File

@ -1,3 +1,5 @@
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable no-sequences */
/**
* Sample React Native App
* https://github.com/facebook/react-native
@ -7,12 +9,26 @@
*/
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,ScrollView,
import {
Platform,
StyleSheet,
Text,
View,
ScrollView,
Alert,
FlatList,ProgressViewIOS,ProgressBarAndroid,PickerIOS,StatusBar} from 'react-native';
FlatList,
ProgressViewIOS,
ProgressBarAndroid,
PickerIOS,
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 {
responsiveHeight,
responsiveWidth,
responsiveFontSize,
} from 'react-native-responsive-dimensions';
import CardView from 'react-native-cardview';
import {Sae} from 'react-native-textinput-effects';
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
@ -20,16 +36,24 @@ import Button from 'apsl-react-native-button';
import {primary, primaryDark, accent} 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} from 'react-native-paper'
import I18n from "react-native-i18n"
import { Dropdown } from "react-native-material-dropdown-v2"
type Props = {}
const route=require('../../route.json')
import { Card, CardTitle, CardContent, CardAction, CardButton, CardImage,Title } from 'react-native-material-cards'
import {readUser} from './../../webservice/AuthApi';
import {sendDemande} from './../../webservice/HistoryRequestApi';
import {sendDemandeSpecificque} from '../../webservice/HistoryRequestApi';
import {getAgentNetworksList} from '../../webservice/NetworkApi';
import {HelperText, TextInput} from 'react-native-paper';
import I18n from 'react-native-i18n';
import {Dropdown} from 'react-native-material-dropdown-v2';
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,
@ -37,15 +61,15 @@ export default class HistoryRequester extends Component {
static navigationOptions = {
drawerLabel: () => null,
headerTitle: I18n.t('ASK_CREDIT'),
title:I18n.t('ASK_CREDIT')
title: I18n.t('ASK_CREDIT'),
};
constructor(props) {
super(props);
this.state = this.initState();
this.updateState()
this.updateState();
}
handleViewRef=ref=>this.numberView=ref;
handleMontantRef=ref=>this.montantView=ref;
handleViewRef = ref => (this.numberView = ref);
handleMontantRef = ref => (this.montantView = ref);
initState() {
return {
phone: null,
@ -56,157 +80,168 @@ export default class HistoryRequester extends Component {
user: null,
visibleError: false,
currentNetwork: {nt: 1},
errorAnimation:"",
}
errorAnimation: '',
};
}
onUserCancel() {
this.props.navigation.goBack()
this.props.navigation.goBack();
}
onUserSend() {
var validMontant=true
var validMontant = true;
if (!isNumber(this.state.montant) || this.state.montant > 1000000) {
validMontant=false
validMontant = false;
}
this.setState({visibleError:!validMontant})
this.setState({visibleError: !validMontant});
if (!validMontant) {
this.montantView.shake(800)
this.montantView.shake(800);
setTimeout(() => {
this.setState({visibleError:false})
},3000)
}
else {
this.setState({isSending:true})
let title=""
let message=""
sendDemandeSpecificque(this.state.montant,this.state.user.phoneTransaction,this.state.user.code_membre).then((data)=> {
this.setState({visibleError: false});
}, 3000);
} else {
this.setState({isSending: true});
let title = '';
let message = '';
sendDemandeSpecificque(
this.state.montant,
this.state.user.phoneTransaction,
this.state.user.code_membre,
)
.then(data => {
if (data.success !== undefined) {
if (data.success === 1) {
title= I18n.t('DEMAND_SEND'),
message=I18n.t('DEMAND_SEND_SUCCESFUL')
(title = I18n.t('DEMAND_SEND')),
(message = I18n.t('DEMAND_SEND_SUCCESFUL'));
} else {
title= "Erreur survenu lors de l'envoie ",
message="Une erreur est survenu lors de l'envoie de la demande"
(title = "Erreur survenu lors de l'envoie "),
(message =
"Une erreur est survenu lors de l'envoie de la demande");
}
} else {
title= "Erreur survenu lors de l'envoie ",
message="Une erreur est survenu lors de l'envoie de la demande"
(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',onPress:()=>{
this.setState({montant: ""})
}}])
Alert.alert(title, message, [
{
text: 'Ok',
onPress: () => {
this.setState({montant: ''});
},
},
]);
setTimeout(() => {
this.setState({isSending: false})
}, 800)
}).catch((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'}])
this.setState({isSending: false});
}, 800);
})
.catch(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'}]);
});
}
}
render() {
const {user}=this.state
const {user} = this.state;
return (
<View style={{flex:1,alignItems:'center',backgroundColor:"lightgrey",paddingTop:responsiveHeight(10)}}>
<StatusBar
translucent={false}
/>
{user?((user.category === "geolocated")?
this.multiNetwork(): this.simpleAgent()):
<ProgressBarAndroid/>
}
</View>
<View
style={{
flex: 1,
alignItems: 'center',
backgroundColor: 'lightgrey',
paddingTop: responsiveHeight(10),
}}>
<StatusBar translucent={false} />
{user ? (
user.category === 'geolocated' ? (
this.multiNetwork()
) : (
this.simpleAgent()
)
) : (
<ProgressBarAndroid />
)}
</View>
);
}
simpleAgent() {
let montant=0
let montant = 0;
if (true) {
return (<View style={{height:200}}>
return (
<View style={{height: 200}}>
<Card style={{width: responsiveWidth(96), paddingTop: 20}}>
<CardContent>
<View>
<Animatable.View
ref={this.handleMontantRef}
>
<Animatable.View ref={this.handleMontantRef}>
<TextInput
label={I18n.t('AMOUNT')}
keyboardType={"numeric"}
keyboardType={'numeric'}
style={input.selfitem}
ref={(ref)=> {
this.refInp = ref
ref={ref => {
this.refInp = ref;
}}
mode={"outlined"}
mode={'outlined'}
inputStyle={input.style}
onChangeText={(text) => {
onChangeText={text => {
try {
let neb=parseInt(text)
this.setState({montant:neb,isDisabled:isNaN(neb)})
}catch (e) {
}
let neb = parseInt(text);
this.setState({montant: neb, isDisabled: isNaN(neb)});
} catch (e) {}
}}
value={this.state.montant}
/>
<HelperText
type="error"
visible={this.state.visibleError}>
<HelperText type="error" visible={this.state.visibleError}>
{I18n.t('INVALID_MONTANT')}
</HelperText>
</Animatable.View>
</View>
</CardContent>
<CardAction
separator={true}
inColumn={false}>
<CardAction 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"
/>
</CardAction>
</Card>
</View>)
}else
return ( <View style={styles.container}>
</View>
);
} else {
return (
<View style={styles.container}>
<CardView style={styles.cardInput}>
<View>
<Text style={styles.title}>Demande de credit</Text>
<Animatable.View
ref={this.handleMontantRef}
>
<Animatable.View ref={this.handleMontantRef}>
<Sae
label={I18n.t('AMOUNT')}
iconClass={FontAwesomeIcon}
iconName={'dollar'}
iconColor={primary}
inputStyle={input.style}
keyboardType={"numeric"}
keyboardType={'numeric'}
value={this.state.montant}
ref={(ref)=> {
this.refInp = ref
ref={ref => {
this.refInp = ref;
}}
onChangeText={(text) => {
onChangeText={text => {
if (text.length > 0) {
try {
montant = parseFloat(text);
this.setState({isDisabled:montant>0,montant:montant})
} catch (e) {
}
this.setState({
isDisabled: montant > 0,
montant: montant,
});
} catch (e) {}
}
}}
style={input.selfitem}
@ -215,103 +250,112 @@ export default class HistoryRequester extends Component {
autoCorrect={false}
/>
</Animatable.View>
</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}}
textStyle={styles.button_2_text} onPress={()=>{
this.onUserSend()
<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();
}}>
{I18n.t('SEND')}
</Button>
</View>
</CardView>
</View>
)
);
}
}
multiNetwork() {
if (true) {
return (<View style={{height:250,justifyContent:'center'}}>
return (
<View style={{height: 250, justifyContent: 'center'}}>
<Card style={{width: responsiveWidth(96), justifyContent: 'center'}}>
<CardContent>
<View style={{flex: 1}}>
<Dropdown
label={I18n.t("SELECT_NETWORK")}
label={I18n.t('SELECT_NETWORK')}
style={{flex: 1, width: responsiveWidth(70)}}
labelExtractor={(item, index) => {
return (item)?I18n.t("FOR_NUMB")+item.phone +" ("+item.name+")":I18n.t("SELECT_NETWORK")
return item
? I18n.t('FOR_NUMB') + item.phone + ' (' + item.name + ')'
: I18n.t('SELECT_NETWORK');
}}
valueExtractor={(item, index) => {
return item.phone +" ("+item.name+")"
return item.phone + ' (' + item.name + ')';
}}
onChangeText={(value, index, data) => {
this.setState({currentNetwork: data[index]})
this.setState({currentNetwork: data[index]});
}}
data={this.state.networks}
/>
<Animatable.View
ref={this.handleMontantRef}
>
<Animatable.View ref={this.handleMontantRef}>
<TextInput
label={I18n.t('AMOUNT')}
keyboardType={"numeric"}
keyboardType={'numeric'}
style={input.selfitem}
ref={(ref)=> {
this.refInp = ref
ref={ref => {
this.refInp = ref;
}}
mode={"outlined"}
mode={'outlined'}
inputStyle={input.style}
onChangeText={(text) => {
onChangeText={text => {
try {
let neb=parseInt(text)
this.setState({montant:neb,isDisabled:isNaN(neb)})
}catch (e) {
}
let neb = parseInt(text);
this.setState({montant: neb, isDisabled: isNaN(neb)});
} catch (e) {}
}}
value={this.state.montant}
/>
<HelperText
type="error"
visible={this.state.visibleError}>
<HelperText type="error" visible={this.state.visibleError}>
{I18n.t('INVALID_MONTANT')}
</HelperText>
</Animatable.View>
</View>
</CardContent>
<CardAction
separator={true}
inColumn={false}>
<CardAction separator={true} inColumn={false}>
<CardButton
onPress={() => {this.onUserCancel()}}
onPress={() => {
this.onUserCancel();
}}
title={I18n.t('CANCEL')}
color="crimson"
/>
<CardButton
onPress={() => { const {currentNetwork,montant}=this.state
if(currentNetwork!==undefined && currentNetwork.nt===undefined) {
this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant)
}}}
onPress={() => {
const {currentNetwork, montant} = this.state;
if (
currentNetwork !== undefined &&
currentNetwork.nt === undefined
) {
this.onNetworkSend(
currentNetwork.phone,
currentNetwork.code_membre,
montant,
);
}
}}
title={I18n.t('SEND')}
color="steelblue"
/>
</CardAction>
</Card>
</View>)
}
else
</View>
);
} else {
return (
<View style={styles.container2}>
<CardView style={styles.cardInput2}>
@ -319,37 +363,41 @@ export default class HistoryRequester extends Component {
<Text style={styles.title}>{I18n.t('ASK_CREDIT')}</Text>
<Picker
selectedValue={this.state.currentNetwork}
prompt={"Selectionner un reseau"}
prompt={'Selectionner un reseau'}
style={{height: 50, width: responsiveWidth(100)}}
itemStyle={styles.subtitle}
onValueChange={(itemValue, itemIndex) =>
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>
<Animatable.View
ref={this.handleMontantRef}
>
<Animatable.View ref={this.handleMontantRef}>
<Sae
label={I18n.t('AMOUNT')}
iconClass={FontAwesomeIcon}
iconName={'dollar'}
iconColor={primary}
ref={(ref)=> {
this.refInp = ref
ref={ref => {
this.refInp = ref;
}}
inputStyle={input.style}
keyboardType={"numeric"}
onChangeText={(text) => {
keyboardType={'numeric'}
onChangeText={text => {
try {
let neb=parseInt(text)
this.setState({montant:neb,isDisabled:isNaN(neb)})
}catch (e) {
}
let neb = parseInt(text);
this.setState({montant: neb, isDisabled: isNaN(neb)});
} catch (e) {}
}}
style={input.selfitem}
labelStyle={input.label}
@ -357,72 +405,82 @@ export default class HistoryRequester extends Component {
autoCorrect={false}
/>
</Animatable.View>
</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
ref={ref => {
this.refBtn=ref
this.refBtn = ref;
}}
isDisabled={this.state.isDisabled}
style={styles.button_2}
textStyle={styles.button_2_text}
onPress={() => {
const {currentNetwork,montant}=this.state
if(currentNetwork!==undefined && currentNetwork.nt===undefined) {
this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant, this.refInp, this.refBtn)
const {currentNetwork, montant} = this.state;
if (
currentNetwork !== undefined &&
currentNetwork.nt === undefined
) {
this.onNetworkSend(
currentNetwork.phone,
currentNetwork.code_membre,
montant,
this.refInp,
this.refBtn,
);
}
}}>
{I18n.t('SEND')}
</Button>
</View>
</CardView>
</View>)
</View>
);
}
}
renderSingleNetwork(item) {
const itm=item.item
console.log(item)
let refInp=null,refBtn=null
let montant=0
return ( <View style={styles.container2}>
const itm = item.item;
console.log(item);
let refInp = null,
refBtn = null;
let montant = 0;
return (
<View style={styles.container2}>
<CardView style={styles.cardInput2}>
<View>
<Text style={styles.title}>{I18n.t('ASK_CREDIT')}</Text>
<Text style={styles.subtitle}>{I18n.t("FOR_NUMB")} {itm.phone} ({itm.name})</Text>
<Animatable.View
ref={this.handleMontantRef}
>
<Text style={styles.subtitle}>
{I18n.t('FOR_NUMB')} {itm.phone} ({itm.name})
</Text>
<Animatable.View ref={this.handleMontantRef}>
<Sae
label={I18n.t('AMOUNT')}
iconClass={FontAwesomeIcon}
iconName={'dollar'}
iconColor={primary}
ref={(ref)=> {
refInp = ref
this.setState({refIn:refInp})
ref={ref => {
refInp = ref;
this.setState({refIn: refInp});
}}
inputStyle={input.style}
value={this.state.montant}
keyboardType={"numeric"}
onChangeText={(text) => {
keyboardType={'numeric'}
onChangeText={text => {
if (text.length > 0) {
try {
montant = parseFloat(text);
this.setStat({montant:montant})
this.setStat({montant: montant});
if (refBtn) {
refBtn.setState({isDisabled:montant>0})
refBtn.isDisabled=montant>0
}} catch (e) {
refBtn.setState({isDisabled: montant > 0});
refBtn.isDisabled = montant > 0;
}
} catch (e) {}
}
}}
style={input.selfitem}
@ -431,100 +489,107 @@ export default class HistoryRequester extends Component {
autoCorrect={false}
/>
</Animatable.View>
</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
ref={ref => {
refBtn=ref
refBtn = ref;
}}
style={styles.button_2}
textStyle={styles.button_2_text}
onPress={() => {
this.onNetworkSend(itm.phone,itm.code_membre,refInp.state.value,refInp,refBtn)
this.onNetworkSend(
itm.phone,
itm.code_membre,
refInp.state.value,
refInp,
refBtn,
);
}}>
{I18n.t('SEND')}
</Button>
</View>
</CardView>
</View>)
</View>
);
}
onNetworkSend(phone, code_membre, text) {
var validMontant=true
let montant=parseFloat(text)
var validMontant = true;
let montant = parseFloat(text);
if (montant === null || !isNumber(montant) || montant > 1000000) {
validMontant=false
validMontant = false;
}
this.setState({visibleError:!validMontant})
this.setState({visibleError: !validMontant});
if (!validMontant) {
this.montantView.shake(800)
this.montantView.shake(800);
setTimeout(() => {
this.setState({visibleError:false})
},3000)
}
else {
sendDemandeSpecificque(montant,phone,code_membre).then((data)=>{
var title=""
var message=""
this.setState({visibleError: false});
}, 3000);
} else {
sendDemandeSpecificque(montant, phone, code_membre).then(data => {
var title = '';
var message = '';
if (data.success !== undefined) {
if (data.success === 1) {
title = I18n.t("DEMAND_SEND")
message = I18n.t('DEMAND_SEND_SUCCESFUL')
title = I18n.t('DEMAND_SEND');
message = I18n.t('DEMAND_SEND_SUCCESFUL');
} else {
title = "Erreur survenu lors de l'envoie "
message = "Une erreur est survenu lors de l'envoie de la demande"
title = "Erreur survenu lors de l'envoie ";
message = "Une erreur est survenu lors de l'envoie de la demande";
}
} else {
title = "Erreur survenu lors de l'envoie "
message = "Une erreur est survenu lors de l'envoie de la demande"
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",onPress:()=>{this.setState({montant:""})}}])
})
Alert.alert(title, message, [
{
text: 'Ok',
onPress: () => {
this.setState({montant: ''});
},
},
]);
});
}
}
async updateState() {
let user = await readUser();
if(user.category==="geolocated"){
if (user.category === 'geolocated') {
let networks = await getAgentNetworksList(user.agentId);
console.log(networks)
console.log(networks);
if (networks.success === 1) {
let net=[this.state.currentNetwork]
networks.networks.forEach((item)=>{
net.push(item)
})
this.setState({networks: net})
let net = [this.state.currentNetwork];
networks.networks.forEach(item => {
net.push(item);
});
this.setState({networks: net});
}
}
this.setState({user:user})
this.setState({user: user});
}
}
const input = StyleSheet.create({
selfitem: {
width: responsiveWidth(70),
alignSelf: 'center',
marginBottom: 20,
},
label: {
color:primary
color: primary,
},
style: {
color:'black'
}
})
color: 'black',
},
});
const styles = StyleSheet.create({
title: {
backgroundColor: primary,
@ -564,7 +629,6 @@ export default class HistoryRequester extends Component {
button_1: {
flex: 1,
borderColor: 'transparent',
},
button_2: {
flex: 1,
@ -583,17 +647,15 @@ button_2_text:{
fontWeight: 'bold',
},
cardInput: {
marginLeft: 10,
marginRight: 10,
marginTop: responsiveHeight(5),
width: responsiveWidth(98),
alignSelf: 'center',
justifyContent: 'space-between',
height:responsiveHeight(40)
height: responsiveHeight(40),
},
cardInput2: {
marginLeft: 10,
marginRight: 10,
marginTop: responsiveHeight(1),
@ -601,5 +663,5 @@ button_2_text:{
height: responsiveHeight(50),
alignSelf: 'center',
justifyContent: 'space-between',
}
},
});

View File

@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
/**
* Sample React Native App
* https://github.com/facebook/react-native
@ -7,8 +8,21 @@
*/
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 {
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 FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
@ -16,16 +30,21 @@ import Button from 'apsl-react-native-button';
import {primary} from '../../utils/theme.json';
import * as Animatable from 'react-native-animatable';
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 {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'
import {
Card,
CardAction,
CardButton,
CardContent,
} from 'react-native-material-cards';
type Props = {}
const route = require('../../route.json')
type Props = {};
const route = require('../../route.json');
export default class HistoryRequester extends Component {
static navigatorStyle = {
@ -34,7 +53,7 @@ export default class HistoryRequester extends Component {
static navigationOptions = {
drawerLabel: () => null,
headerTitle: I18n.t('ASK_CREDIT'),
title: I18n.t('ASK_CREDIT')
title: I18n.t('ASK_CREDIT'),
};
constructor(props) {
@ -56,8 +75,8 @@ export default class HistoryRequester extends Component {
this.props.navigation.state.params.onGoBack();
}
handleViewRef = ref => this.numberView = ref;
handleMontantRef = ref => this.montantView = ref;
handleViewRef = ref => (this.numberView = ref);
handleMontantRef = ref => (this.montantView = ref);
initState() {
return {
@ -69,13 +88,13 @@ export default class HistoryRequester extends Component {
user: null,
visibleError: false,
currentNetwork: {nt: 1},
errorAnimation: "",
}
errorAnimation: '',
};
}
backPressed = () => {
this.props.navigation.state.params.onGoBack();
}
};
onUserCancel() {
console.log(this.props);
@ -84,50 +103,58 @@ export default class HistoryRequester extends Component {
}
onUserSend() {
var validMontant = true
var validMontant = true;
if (!isNumber(this.state.montant) || this.state.montant > 1000000) {
validMontant = false
validMontant = false;
}
this.setState({visibleError: !validMontant})
this.setState({visibleError: !validMontant});
if (!validMontant) {
this.montantView.shake(800)
this.montantView.shake(800);
setTimeout(() => {
this.setState({visibleError: false})
}, 3000)
this.setState({visibleError: false});
}, 3000);
} else {
this.setState({isSending: true});
let title = ""
let message = ""
sendDemandeSpecificque(this.state.montant, this.state.user.phoneTransaction, this.state.user.code_membre).then((data) => {
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'),
message = I18n.t('DEMAND_SEND_SUCCESFUL')
(title = I18n.t('DEMAND_SEND')),
(message = I18n.t('DEMAND_SEND_SUCCESFUL'));
} else {
title = "Erreur survenu lors de l'envoie ",
message = "Une erreur est survenu lors de l'envoie de la demande"
(title = "Erreur survenu lors de l'envoie "),
(message =
"Une erreur est survenu lors de l'envoie de la demande");
}
} else {
title = "Erreur survenu lors de l'envoie ",
message = "Une erreur est survenu lors de l'envoie de la demande"
(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', onPress: () => {
this.setState({montant: ""})
}
}]);
}).catch((error) => {
Alert.alert(title, message, [
{
text: 'Ok',
onPress: () => {
this.setState({montant: ''});
},
},
]);
})
.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'}])
})
(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'}]);
});
}
}
@ -136,107 +163,105 @@ export default class HistoryRequester extends Component {
console.log(this.state);
return (
<View
style={{flex: 1, alignItems: 'center', backgroundColor: "lightgrey", paddingTop: responsiveHeight(10)}}>
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/>
}
</View>
<StatusBar translucent={false} />
{user ? (
user.category === 'geolocated' ? (
this.multiNetwork()
) : (
this.simpleAgent()
)
) : (
<ProgressBarAndroid />
)}
</View>
);
}
simpleAgent() {
let montant = 0
let montant = 0;
if (true) {
return (<View style={{height: 200}}>
return (
<View style={{height: 200}}>
<Card style={{width: responsiveWidth(96), paddingTop: 20}}>
<CardContent>
<View>
<Animatable.View
ref={this.handleMontantRef}
>
<Animatable.View ref={this.handleMontantRef}>
<TextInput
label={I18n.t('AMOUNT')}
keyboardType={"numeric"}
keyboardType={'numeric'}
style={input.selfitem}
ref={(ref) => {
this.refInp = ref
ref={ref => {
this.refInp = ref;
}}
mode={"outlined"}
mode={'outlined'}
inputStyle={input.style}
onChangeText={(text) => {
onChangeText={text => {
try {
let neb = parseInt(text)
this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) {
}
let neb = parseInt(text);
this.setState({montant: neb, isDisabled: isNaN(neb)});
} catch (e) {}
}}
value={this.state.montant}
/>
<HelperText
type="error"
visible={this.state.visibleError}>
<HelperText type="error" visible={this.state.visibleError}>
{I18n.t('INVALID_MONTANT')}
</HelperText>
</Animatable.View>
</View>
</CardContent>
<CardAction
separator={true}
inColumn={false}>
<CardAction separator={true} inColumn={false}>
<CardButton
onPress={() => {
this.onUserCancel()
this.onUserCancel();
}}
title={I18n.t('CANCEL')}
color="crimson"
/>
<CardButton
onPress={() => {
this.onUserSend()
this.onUserSend();
}}
title={I18n.t('SEND')}
color="steelblue"
/>
</CardAction>
</Card>
</View>)
</View>
);
} else
return (<View style={styles.container}>
return (
<View style={styles.container}>
<CardView style={styles.cardInput}>
<View>
<Text style={styles.title}>Demande de credit</Text>
<Animatable.View
ref={this.handleMontantRef}
>
<Animatable.View ref={this.handleMontantRef}>
<Sae
label={I18n.t('AMOUNT')}
iconClass={FontAwesomeIcon}
iconName={'dollar'}
iconColor={primary}
inputStyle={input.style}
keyboardType={"numeric"}
keyboardType={'numeric'}
value={this.state.montant}
ref={(ref) => {
this.refInp = ref
ref={ref => {
this.refInp = ref;
}}
onChangeText={(text) => {
onChangeText={text => {
if (text.length > 0) {
try {
montant = parseFloat(text);
this.setState({isDisabled: montant > 0, montant: montant})
} catch (e) {
}
this.setState({
isDisabled: montant > 0,
montant: montant,
});
} catch (e) {}
}
}}
style={input.selfitem}
@ -245,29 +270,31 @@ export default class HistoryRequester extends Component {
autoCorrect={false}
/>
</Animatable.View>
</View>
<View style={styles.btnContainer}>
<Button style={styles.button_1} textStyle={styles.button_1_text}
<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}
<Button
isLoading={this.state.isSending}
isDisabled={!this.state.isDisabled}
style={styles.button_2}
ref={(r) => {
this.refBtn = r
ref={r => {
this.refBtn = r;
}}
textStyle={styles.button_2_text} onPress={() => {
this.onUserSend()
textStyle={styles.button_2_text}
onPress={() => {
this.onUserSend();
}}>
{I18n.t('SEND')}
</Button>
</View>
</CardView>
</View>
)
);
}
renderLoader = () => {
@ -277,81 +304,87 @@ export default class HistoryRequester extends Component {
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'}}>
<CardContent>
<View style={{flex: 1}}>
<View style={{flexDirection: 'row'}}>
<Picker
selectedValue={this.state.currentNetwork}
prompt={I18n.t("SELECT_NETWORK")}
prompt={I18n.t('SELECT_NETWORK')}
style={{height: 50, flex: 1, marginLeft: 20}}
itemStyle={styles.subtitle}
onValueChange={(itemValue, itemIndex) =>
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>
</View>
<Animatable.View
ref={this.handleMontantRef}
>
<Animatable.View ref={this.handleMontantRef}>
<TextInput
label={I18n.t('AMOUNT')}
keyboardType={"numeric"}
keyboardType={'numeric'}
style={input.selfitem}
ref={(ref) => {
this.refInp = ref
ref={ref => {
this.refInp = ref;
}}
mode={"outlined"}
mode={'outlined'}
inputStyle={input.style}
onChangeText={(text) => {
onChangeText={text => {
try {
let neb = parseInt(text)
this.setState({montant: neb, isDisabled: isNaN(neb)})
} catch (e) {
}
let neb = parseInt(text);
this.setState({montant: neb, isDisabled: isNaN(neb)});
} catch (e) {}
}}
value={this.state.montant}
/>
<HelperText
type="error"
visible={this.state.visibleError}>
<HelperText type="error" visible={this.state.visibleError}>
{I18n.t('INVALID_MONTANT')}
</HelperText>
</Animatable.View>
</View>
</CardContent>
<CardAction
separator={true}
inColumn={false}>
<CardAction separator={true} inColumn={false}>
<CardButton
onPress={() => {
this.onUserCancel()
this.onUserCancel();
}}
title={I18n.t('CANCEL')}
color="crimson"
/>
<CardButton
onPress={() => {
const {currentNetwork, montant} = this.state
if (currentNetwork !== undefined && currentNetwork.nt === undefined) {
this.onNetworkSend(currentNetwork.phone, currentNetwork.code_membre, montant)
const {currentNetwork, montant} = this.state;
if (
currentNetwork !== undefined &&
currentNetwork.nt === undefined
) {
this.onNetworkSend(
currentNetwork.phone,
currentNetwork.code_membre,
montant,
);
}
}}
title={I18n.t('SEND')}
@ -359,9 +392,10 @@ export default class HistoryRequester extends Component {
/>
</CardAction>
</Card>
</View>)
</View>
);
} else
return (
{return (
<View style={styles.container2}>
<CardView style={styles.cardInput2}>
<View>
@ -433,48 +467,47 @@ export default class HistoryRequester extends Component {
</View>
</CardView>
</View>)
</View>)};
}
renderSingleNetwork(item) {
const itm = item.item
console.log(item)
let refInp = null, refBtn = null
let montant = 0
return (<View style={styles.container2}>
const itm = item.item;
console.log(item);
let refInp = null,
refBtn = null;
let montant = 0;
return (
<View style={styles.container2}>
<CardView style={styles.cardInput2}>
<View>
<Text style={styles.title}>{I18n.t('ASK_CREDIT')}</Text>
<Text style={styles.subtitle}>{I18n.t("FOR_NUMB")} {itm.phone} ({itm.name})</Text>
<Animatable.View
ref={this.handleMontantRef}
>
<Text style={styles.subtitle}>
{I18n.t('FOR_NUMB')} {itm.phone} ({itm.name})
</Text>
<Animatable.View ref={this.handleMontantRef}>
<Sae
label={I18n.t('AMOUNT')}
iconClass={FontAwesomeIcon}
iconName={'dollar'}
iconColor={primary}
ref={(ref) => {
refInp = ref
this.setState({refIn: refInp})
ref={ref => {
refInp = ref;
this.setState({refIn: refInp});
}}
inputStyle={input.style}
value={this.state.montant}
keyboardType={"numeric"}
onChangeText={(text) => {
keyboardType={'numeric'}
onChangeText={text => {
if (text.length > 0) {
try {
montant = parseFloat(text);
this.setStat({montant: montant})
this.setStat({montant: montant});
if (refBtn) {
refBtn.setState({isDisabled: montant > 0})
refBtn.isDisabled = montant > 0
}
} catch (e) {
refBtn.setState({isDisabled: montant > 0});
refBtn.isDisabled = montant > 0;
}
} catch (e) {}
}
}}
style={input.selfitem}
@ -483,108 +516,111 @@ export default class HistoryRequester extends Component {
autoCorrect={false}
/>
</Animatable.View>
</View>
<View style={styles.btnContainer}>
<Button style={styles.button_1} textStyle={styles.button_1_text}
<Button
style={styles.button_1}
textStyle={styles.button_1_text}
onPress={() => this.onUserCancel()}>
{I18n.t('CANCEL')}
</Button>
<Button
ref={ref => {
refBtn = ref
refBtn = ref;
}}
style={styles.button_2}
textStyle={styles.button_2_text}
onPress={() => {
this.onNetworkSend(itm.phone, itm.code_membre, refInp.state.value, refInp, refBtn)
this.onNetworkSend(
itm.phone,
itm.code_membre,
refInp.state.value,
refInp,
refBtn,
);
}}>
{I18n.t('SEND')}
</Button>
</View>
</CardView>
</View>)
</View>
);
}
onNetworkSend(phone, code_membre, text) {
var validMontant = true
let montant = parseFloat(text)
var validMontant = true;
let montant = parseFloat(text);
if (montant === null || !isNumber(montant) || montant > 1000000) {
validMontant = false
validMontant = false;
}
this.setState({visibleError: !validMontant})
this.setState({visibleError: !validMontant});
if (!validMontant) {
this.montantView.shake(800)
this.montantView.shake(800);
setTimeout(() => {
this.setState({visibleError: false})
}, 3000)
this.setState({visibleError: false});
}, 3000);
} 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 message = "";
var title = '';
var message = '';
console.warn(data);
if (data.success !== undefined) {
if (data.success === 1) {
title = I18n.t("DEMAND_SEND")
message = I18n.t('DEMAND_SEND_SUCCESFUL')
title = I18n.t('DEMAND_SEND');
message = I18n.t('DEMAND_SEND_SUCCESFUL');
} else {
title = "Erreur survenu lors de l'envoie "
message = "Une erreur est survenu lors de l'envoie de la demande"
title = "Erreur survenu lors de l'envoie ";
message = "Une erreur est survenu lors de l'envoie de la demande";
}
} else {
title = "Erreur survenu lors de l'envoie "
message = "Une erreur est survenu lors de l'envoie de la demande"
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", onPress: () => {
this.setState({montant: ""})
}
}])
})
Alert.alert(title, message, [
{
text: 'Ok',
onPress: () => {
this.setState({montant: ''});
},
},
]);
});
}
}
async updateState() {
let user = await readUser();
if (user.category === "geolocated") {
if (user.category === 'geolocated') {
let networks = await getAgentNetworksList(user.agentId);
console.log(networks)
console.log(networks);
if (networks.success === 1) {
let net = [this.state.currentNetwork]
networks.networks.forEach((item) => {
net.push(item)
})
this.setState({networks: net})
let net = [this.state.currentNetwork];
networks.networks.forEach(item => {
net.push(item);
});
this.setState({networks: net});
}
}
this.setState({user: user})
this.setState({user: user});
}
}
const input = StyleSheet.create({
selfitem: {
width: responsiveWidth(70),
alignSelf: 'center',
marginBottom: 20,
},
label: {
color: primary
color: primary,
},
style: {
color: 'black'
}
})
color: 'black',
},
});
const styles = StyleSheet.create({
title: {
backgroundColor: primary,
@ -624,7 +660,6 @@ const styles = StyleSheet.create({
button_1: {
flex: 1,
borderColor: 'transparent',
},
button_2: {
flex: 1,
@ -643,17 +678,15 @@ const styles = StyleSheet.create({
fontWeight: 'bold',
},
cardInput: {
marginLeft: 10,
marginRight: 10,
marginTop: responsiveHeight(5),
width: responsiveWidth(98),
alignSelf: 'center',
justifyContent: 'space-between',
height: responsiveHeight(40)
height: responsiveHeight(40),
},
cardInput2: {
marginLeft: 10,
marginRight: 10,
marginTop: responsiveHeight(1),
@ -661,5 +694,5 @@ const styles = StyleSheet.create({
height: responsiveHeight(50),
alignSelf: 'center',
justifyContent: 'space-between',
}
},
});

View File

@ -1,14 +1,30 @@
/* eslint-disable no-undef */
/* eslint-disable react-native/no-inline-styles */
import React from 'react';
import {Animated, AppState, ProgressBarAndroid, StatusBar, StyleSheet, Text, View} from 'react-native';
import {
Animated,
AppState,
ProgressBarAndroid,
StatusBar,
StyleSheet,
Text,
View,
} from 'react-native';
import ActionButton from 'react-native-action-button';
import Icon from 'react-native-vector-icons/MaterialIcons';
import {responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions';
import {
responsiveHeight,
responsiveWidth,
} from 'react-native-responsive-dimensions';
import {HistoryItemSectionned, HistoryListItem} from './HistoryItem';
import {loadDemandeCredit, loadMyDemandeCredit} from './../../webservice/HistoryRequestApi';
import Button from 'apsl-react-native-button'
import {readUser} from "../../webservice/AuthApi";
import {
loadDemandeCredit,
loadMyDemandeCredit,
} from './../../webservice/HistoryRequestApi';
import Button from 'apsl-react-native-button';
import {readUser} from '../../webservice/AuthApi';
import Calendar from 'react-native-calendario';
import I18n from "react-native-i18n";
import I18n from 'react-native-i18n';
import 'moment/locale/fr';
import 'moment/locale/es-us';
@ -17,9 +33,14 @@ import 'moment/locale/en-ca';
import 'moment/locale/en-ie';
import 'moment/locale/en-il';
import 'moment/locale/en-nz';
import {accent, primary, primaryDark, purpleLight} from './../../utils/theme.json';
import {PagerTabIndicator} from 'react-native-best-viewpager'
import IconWithBadge from "../IconWithBadge";
import {
accent,
primary,
primaryDark,
purpleLight,
} from './../../utils/theme.json';
import {PagerTabIndicator} from 'react-native-best-viewpager';
import IconWithBadge from '../IconWithBadge';
import {Appbar, Divider, Menu, Provider} from 'react-native-paper';
var moment = require('moment-timezone');
@ -31,10 +52,9 @@ let theme = require('./../../utils/theme.json');
var sortIcons;
var sectionIcons;
require('./../../utils/Translations')
require('./../../utils/Translations');
class MyHistory extends React.Component {
static navigatorStyle = {
navBarBackgroundColor: primary,
statusBarColor: primaryDark,
@ -42,59 +62,53 @@ class MyHistory extends React.Component {
navBarButtonColor: '#FFFFFF',
contextualMenuStatusBarColor: theme.accent,
contextualMenuBackgroundColor: theme.accentLight,
contextualMenuButtonsColor: '#ffffff'
contextualMenuButtonsColor: '#ffffff',
};
static navigationOptions = ({navigation}) => {
const {routeName} = navigation.state
const {routeName} = navigation.state;
return {
tabBarLabel: routeName === "myDemand" ? I18n.t('MY_DEMAND') : I18n.t('DEMAND_RECEIVE'),
tabBarLabel:
routeName === 'myDemand'
? I18n.t('MY_DEMAND')
: I18n.t('DEMAND_RECEIVE'),
tabBarIcon: ({focused, horizontal, tintColor}) => {
return (<IconWithBadge
badgeCount={navigation.getParam("count", 0)}
return (
<IconWithBadge
badgeCount={navigation.getParam('count', 0)}
size={20}
name={routeName === "myDemand" ? "mail" : "inbox"}
color={focused ? tintColor : "grey"}
/>)
name={routeName === 'myDemand' ? 'mail' : 'inbox'}
color={focused ? tintColor : 'grey'}
/>
);
},
drawerLabel: I18n.t('CREDIT_MANAGE'),
drawerIcon: ({tintColor}) => (
<Icon
name={'credit-card'}
size={24}
/>
),
}
drawerIcon: ({tintColor}) => <Icon name={'credit-card'} size={24} />,
};
};
constructor(props) {
super(props, true);
this.currentLocale = I18n.locale.includes("fr") ? "fr" : "en-gb";
this.currentLocale = I18n.locale.includes('fr') ? 'fr' : 'en-gb';
moment.locale(this.currentLocale);
this.state = this.initState();
readUser().then((user) => {
this.setState({user: user})
})
this._populateIcons().then(() => {
readUser().then(user => {
this.setState({user: user});
});
this._populateIcons().then(() => {});
this.navigation = this.props.navigation
};
this.navigation = this.props.navigation;
}
navigationButtonPressed({buttonId}) {
if (buttonId === 'id') {
this.showFilter();
} else if (buttonId === 'sectionned') {
this.setState({isSectionned: !this.state.isSectionned})
this.setState({isSectionned: !this.state.isSectionned});
}
}
showFilter() {
/*if (this.state.filter) {
Navigation.mergeOptions(route.stackRoot,
{
@ -226,19 +240,20 @@ class MyHistory extends React.Component {
_populateIcons = function () {
return new Promise(function (resolve, reject) {
Promise.all(
[
Promise.all([
Icon.getImageSource('sort', 30),
Icon.getImageSource('layer-group', 30),
]
).then((values) => {
])
.then(values => {
sortIcons = values[0];
sectionIcons = values[1];
resolve(true);
}).catch((error) => {
})
.catch(error => {
console.log(error);
reject(error);
}).done();
})
.done();
});
};
@ -263,97 +278,90 @@ class MyHistory extends React.Component {
isLoaded: false,
isSectionned: false,
isDateTimePickerVisible: false,
isDateEndTimePickerVisible: false
}
isDateEndTimePickerVisible: false,
};
}
updateList(data) {
if (!this.state.filter) {
let rev = data.reverse()
let rev = data.reverse();
this.setState({listdata: rev, conserve: rev, isLoaded: true});
}
}
updateMyList(data) {
if (!this.state.filter) {
let rev = data.reverse()
let rev = data.reverse();
this.setState({listdataSend: rev, conserve: rev, isLoaded: true});
}
}
componentDidMount() {
const {routeName} = this.navigation.state
this.setState({position: routeName === "myDemand" ? 0 : 1})
this.refreshData()
const {routeName} = this.navigation.state;
this.setState({position: routeName === 'myDemand' ? 0 : 1});
this.refreshData();
/* this.intervaller = setInterval(() => {
this.refreshData(false)
}, 2000) */
this.animateSlidingUp(false)
this.props.navigation.addListener("didFocus", () => {
this.refreshData(false)
console.warn("loading")
})
this.animateSlidingUp(false);
this.props.navigation.addListener('didFocus', () => {
this.refreshData(false);
console.warn('loading');
});
}
componentWillUnmount() {
clearInterval(this.intervaller)
}
renderOptionsMenu() {
return (
<View
style={{
position: "absolute",
position: 'absolute',
zIndex: 100,
paddingTop: 50,
right: 10,
flexDirection: 'row',
visible: this.state.visibleMenu,
justifyContent: 'center'
justifyContent: 'center',
}}>
<Menu
visible={this.state.visibleMenu}
onDismiss={this._closeMenu}
anchor={
<Button onPress={this._openMenu}>Show menu</Button>
}
>
anchor={<Button onPress={this._openMenu}>Show menu</Button>}>
{/* <Menu.Item onPress={() => {
this.setState({isSectionned: !this.state.isSectionned})
this._closeMenu()
}}
title="Section"/>*/}
<Divider />
<Menu.Item onPress={() => {
this.animateSlidingUp(!this.state.isSliding)
this._closeMenu()
}} title={I18n.t("FILTER_DATE")}/>
<Menu.Item
onPress={() => {
this.animateSlidingUp(!this.state.isSliding);
this._closeMenu();
}}
title={I18n.t('FILTER_DATE')}
/>
</Menu>
</View>
)
);
}
animateSlidingUp(state = false) {
const height = responsiveHeight(100)
const height = responsiveHeight(100);
let initialValue = !state ? 0 : height,
finalValue = !state ? height : 0;
this.setState({isSliding: state})
this.setState({isSliding: state});
this.state.translateAnim.setValue(initialValue); //Step 3
Animated.timing( //Step 4
Animated.timing(
//Step 4
this.state.translateAnim,
{
toValue: finalValue,
duration: 500,
useNativeDriver: true,
}
).start()
},
).start();
}
_openMenu = () => this.setState({visibleMenu: true});
@ -363,8 +371,7 @@ class MyHistory extends React.Component {
render() {
return (
<Provider>
<View style={{flex: 1}}
>
<View style={{flex: 1}}>
<StatusBar
backgroundColor={theme.primaryDark}
barStyle="light-content"
@ -376,35 +383,49 @@ class MyHistory extends React.Component {
<Appbar.Header dark={true} style={{backgroundColor: theme.primary}}>
<Appbar.BackAction
onPress={() => {
this.props.navigation.pop()
// resolution du proble de bug de navigation retour credit management
this.props.navigation.push('home');
//this.props.navigation.pop();
}}
/>
<Appbar.Content
title={I18n.t('CREDIT_MANAGE')}
subtitle={this.state.position === 0 ? I18n.t('MY_DEMAND') : I18n.t('DEMAND_RECEIVE')}
subtitle={
this.state.position === 0
? I18n.t('MY_DEMAND')
: I18n.t('DEMAND_RECEIVE')
}
/>
<Appbar.Action icon="refresh" onPress={() => {
this.refreshData()
}}/>
<Appbar.Action icon="more-vert" onPress={() => {
<Appbar.Action
icon="refresh"
onPress={() => {
this.refreshData();
}}
/>
<Appbar.Action
icon="more-vert"
onPress={() => {
this._openMenu();
this.renderSliding();
}}/>
}}
/>
</Appbar.Header>
{this.renderOptionsMenu()}
{this.state.position === 0 ? this._renderListDemandsSend() : this._renderListDemandReceive()}
{this.state.position === 0
? this._renderListDemandsSend()
: this._renderListDemandReceive()}
</View>
</Provider>
);
}
renderSliding() {
return (
<Animated.View style={[styles.slidingup, {translateY: this.state.translateAnim}]}>
<Animated.View
style={[styles.slidingup, {translateY: this.state.translateAnim}]}>
<Calendar
onChange={(range) => console.log(range)}
onChange={range => console.log(range)}
minDate="2018-04-20"
startDate="2018-04-30"
endDate="2018-05-05"
@ -449,7 +470,7 @@ class MyHistory extends React.Component {
activeDayTextStyle: {
color: 'white',
},
nonTouchableLastMonthDayTextStyle: {}
nonTouchableLastMonthDayTextStyle: {},
}}
style={{height: responsiveHeight(60)}}
/>
@ -457,42 +478,43 @@ class MyHistory extends React.Component {
<Button>{I18n.t('QUIT')}</Button>
<Button>{I18n.t('FILTER')}</Button>
</View>
</Animated.View>)
</Animated.View>
);
}
renderSectionnedList(list) {
if (this.state.isLoaded) {
let data = list;
if (data !== null) {
if (data.length > 0) {
return (<HistoryItemSectionned
return (
<HistoryItemSectionned
user={this.state.user}
list={list}
refresh={() => this.refreshData()}
style={styles.listbackground}/>)
style={styles.listbackground}
/>
);
} else if (this.state.filter) {
return (
<View style={styles.emptyListe}>
<Text>{I18n.t('NO_ITEMS_REQUEST')}</Text>
</View>
)
);
} else {
return (
<View style={styles.emptyListe}>
<ProgressBarAndroid />
<Text>{I18n.t('LOADING_DOTS')}</Text>
</View>
)
);
}
} else {
return (
<View style={styles.emptyListe}>
<Text>{I18n.t('EMPTY_LIST_REQUEST')}</Text>
</View>
)
);
}
}
}
@ -502,62 +524,63 @@ class MyHistory extends React.Component {
let data = list;
if (data !== null) {
if (data.length > 0) {
return (<HistoryListItem
return (
<HistoryListItem
user={this.state.user}
list={list}
refreshing={() => {
this.refreshData()
this.refreshData();
}}
refresh={() => this.refreshData()}
isRefreshing={this.state.isRefreshing}
navigator={this.props.navigation}
style={styles.listbackground}
isDemandSend={this.state.position === 0}/>)
isDemandSend={this.state.position === 0}
/>
);
} else if (this.state.filter) {
return (
<View style={styles.emptyListe}>
<Text>{I18n.t('NO_ITEM_REQUEST')}</Text>
</View>
)
);
} else if (data.length === 0) {
return (
<View style={styles.emptyListe}>
<Text>{I18n.t('NO_ITEM_REQUEST')}</Text>
</View>
)
);
} else {
return (
<View style={styles.emptyListe}>
<ProgressBarAndroid />
<Text>{I18n.t('LOADING_DOTS')}</Text>
</View>
)
);
}
} else {
return (
<View style={styles.emptyListe}>
<Text>{I18n.t('EMPTY_LIST_REQUEST')} </Text>
</View>
)
);
}
} else if (list.length === 0) {
return (
<View style={styles.emptyListe}>
<Text>{I18n.t('NO_ITEM_REQUEST')}</Text>
</View>
)
);
}
}
renderLoading() {
return (<View><ProgressBarAndroid/><Text>{I18n.t('LOADING_DOTS')}</Text></View>)
return (
<View>
<ProgressBarAndroid />
<Text>{I18n.t('LOADING_DOTS')}</Text>
</View>
);
}
showSlidingUpPanel() {
@ -624,18 +647,24 @@ class MyHistory extends React.Component {
}
*/
_showDateTimePicker = (type) => {
if (type === 1)
_showDateTimePicker = type => {
if (type === 1) {
this.setState({
isDateTimePickerVisible: true
isDateTimePickerVisible: true,
});
else this.setState({
isDateEndTimePickerVisible: true
} else {
this.setState({
isDateEndTimePickerVisible: true,
});
}
};
_showDateEndPicker = () => this.setState({isDateEndTimePickerVisible: true});
_hideDateTimePicker = () => this.setState({isDateTimePickerVisible: false, isDateEndTimePickerVisible: false});
_hideDateTimePicker = () =>
this.setState({
isDateTimePickerVisible: false,
isDateEndTimePickerVisible: false,
});
/*
_handleDatePicked = (fromdate, enddate) => {
@ -667,126 +696,156 @@ class MyHistory extends React.Component {
*/
printOptions() {
if (this.state.user.category === "hyper") {
return (<ActionButton buttonColor={accent}>
<ActionButton.Item buttonColor={purpleLight} title={I18n.t('SAVE_HISTORY')} onPress={() => {
}}>
if (this.state.user.category === 'hyper') {
return (
<ActionButton buttonColor={accent}>
<ActionButton.Item
buttonColor={purpleLight}
title={I18n.t('SAVE_HISTORY')}
onPress={() => {}}>
<Icon name="save" style={styles.actionButtonIcon} />
</ActionButton.Item>
</ActionButton>);
</ActionButton>
);
} else {
return (<ActionButton buttonColor={accent}>
<ActionButton.Item buttonColor={primary} title={I18n.t('MAKE_REQUEST')}
return (
<ActionButton buttonColor={accent}>
<ActionButton.Item
buttonColor={primary}
title={I18n.t('MAKE_REQUEST')}
onPress={() => {
this.props.navigation.push(route.credrequester, {
onGoBack: () => this.refreshData()
})
}}
>
onGoBack: () => this.refreshData(),
});
}}>
<Icon name="edit" style={styles.actionButtonIcon} />
</ActionButton.Item>
<ActionButton.Item buttonColor={purpleLight} title={I18n.t('SAVE_HISTORY')} onPress={() => {
}}>
<ActionButton.Item
buttonColor={purpleLight}
title={I18n.t('SAVE_HISTORY')}
onPress={() => {}}>
<Icon name="save" style={styles.actionButtonIcon} />
</ActionButton.Item>
</ActionButton>)
</ActionButton>
);
}
}
_renderListDemandsSend() {
//console.log('this.state', this.state);
return (<View style={styles.container}>
{
this.state.isLoaded ?
this.state.isSectionned ?
this.renderSectionnedList(this.state.listdataSend) :
this.renderList(this.state.listdataSend) : this.renderLoading()
}
return (
<View style={styles.container}>
{this.state.isLoaded
? this.state.isSectionned
? this.renderSectionnedList(this.state.listdataSend)
: this.renderList(this.state.listdataSend)
: this.renderLoading()}
{this.printOptions()}
{this.showSlidingUpPanel()}
</View>
)
);
}
_renderListDemandReceive() {
return (<View style={styles.container}>
{
this.state.isLoaded ?
this.state.isSectionned ?
this.renderSectionnedList(this.state.listdata) :
this.renderList(this.state.listdata) : this.renderLoading()
}
return (
<View style={styles.container}>
{this.state.isLoaded
? this.state.isSectionned
? this.renderSectionnedList(this.state.listdata)
: this.renderList(this.state.listdata)
: this.renderLoading()}
{this.printOptions()}
{this.showSlidingUpPanel()}
</View>
)
);
}
_renderTabGeolocated() {
let tabs = [{
let tabs = [
{
text: I18n.t('DEMAND_SEND'),
}]
return <PagerTabIndicator
},
];
return (
<PagerTabIndicator
style={{
height: responsiveHeight(8)
height: responsiveHeight(8),
}}
tabs={tabs}/>;
tabs={tabs}
/>
);
}
_renderTabHyper() {
let tabs = [{
let tabs = [
{
text: I18n.t('DEMAND_RECEIVE'),
}]
return <PagerTabIndicator
},
];
return (
<PagerTabIndicator
style={{
height: responsiveHeight(8)
height: responsiveHeight(8),
}}
tabs={tabs}/>;
tabs={tabs}
/>
);
}
_renderTabs() {
let tabs = [{
let tabs = [
{
text: I18n.t('MY_DEMAND'),
iconSource: this.state.usersicon
}, {
iconSource: this.state.usersicon,
},
{
text: I18n.t('DEMAND_RECEIVE'),
iconSource: this.state.charticon
}]
return <PagerTabIndicator
iconSource: this.state.charticon,
},
];
return (
<PagerTabIndicator
style={{
height: responsiveHeight(8)
height: responsiveHeight(8),
}}
tabs={tabs}/>;
tabs={tabs}
/>
);
}
refreshData(autoref = true) {
if (autoref)
this.setState({isRefreshing: true})
loadDemandeCredit().then((data) => {
if (data.success !== undefined) {
this.setState({listdata: []})
this.updateList(data.demands);
if (this.state.position !== 0) this.props.navigation.setParams({count: data.demands.length})
this.setState({isRefreshing: false})
if (autoref) {
this.setState({isRefreshing: true});
}
}).catch((e) => {
console.warn(e)
loadDemandeCredit()
.then(data => {
if (data.success !== undefined) {
this.setState({listdata: []});
this.updateList(data.demands);
if (this.state.position !== 0) {
this.props.navigation.setParams({count: data.demands.length});
}
this.setState({isRefreshing: false});
}
})
.catch(e => {
console.warn(e);
});
loadMyDemandeCredit().then((data) => {
loadMyDemandeCredit()
.then(data => {
if (data.success !== undefined) {
this.setState({listdataSend: []})
this.setState({isRefreshing: false})
if (this.state.position === 0) this.props.navigation.setParams({count: data.demands.length})
this.updateMyList(data.demands)
this.setState({listdataSend: []});
this.setState({isRefreshing: false});
if (this.state.position === 0) {
this.props.navigation.setParams({count: data.demands.length});
}
}).catch((e) => {
console.warn(e)
this.updateMyList(data.demands);
}
})
.catch(e => {
console.warn(e);
});
}
}
@ -806,11 +865,10 @@ const datefilter = StyleSheet.create({
},
datetext: {
fontSize: 16,
marginLeft: responsiveWidth(5)
marginLeft: responsiveWidth(5),
},
content: {
flex: 2,
},
btnContainer: {
flexDirection: 'row',
@ -825,21 +883,21 @@ const datefilter = StyleSheet.create({
},
btntext: {
fontWeight: 'bold',
color: accent
color: accent,
},
container: {
flex: 1,
justifyContent: 'space-evenly'
}
})
justifyContent: 'space-evenly',
},
});
const styles = StyleSheet.create({
slidingup: {
position: "absolute",
position: 'absolute',
height: responsiveHeight(84),
bottom: 0,
backgroundColor: 'white',
width: responsiveWidth(100),
zIndex: 1000
zIndex: 1000,
},
root: {
flex: 1,
@ -853,7 +911,7 @@ const styles = StyleSheet.create({
emptylist: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
},
backgroundd_drawer: {
backgroundColor: '#000',
@ -884,10 +942,10 @@ const styles = StyleSheet.create({
fontSize: 17,
marginLeft: responsiveWidth(10),
color: 'black'
color: 'black',
},
content: {
flex: 8
flex: 8,
},
title: {
@ -895,6 +953,6 @@ const styles = StyleSheet.create({
marginLeft: 20,
marginTop: 20,
color: 'black',
fontWeight: 'bold'
fontWeight: 'bold',
},
});

View File

@ -36,6 +36,7 @@ import WalletRetrait from './wallet/WalletRetrait';
import WalletSelect from './wallet/WalletSelect';
import CreateIdentification from './identification/createIdentification';
import DemandGroupNanoCredit from './nano-credit/DemandGroupNanoCredit';
import MyHistory from './history-request/MyHistory';
let route = require('./../route.json')
export function registerScreens() {

View File

@ -1,3 +1,6 @@
/* eslint-disable no-unused-vars */
/* eslint-disable no-shadow */
/* eslint-disable react-native/no-inline-styles */
/**
* Sample React Native App
* https://github.com/facebook/react-native
@ -6,102 +9,111 @@
* @flow
*/
import React, {Component} from 'react';
import {Alert, AsyncStorage, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {
Alert,
AsyncStorage,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
import {responsiveFontSize, responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions';
import {
responsiveFontSize,
responsiveHeight,
responsiveWidth,
} from 'react-native-responsive-dimensions';
import {primary, primaryDarkAdvanced} from './../../utils/theme.json';
import {disconnect, readUser} from './../../webservice/AuthApi';
import I18n from 'react-native-i18n'
import Button from 'apsl-react-native-button'
import {IlinkEmitter} from "./../../utils/events"
import I18n from 'react-native-i18n';
import Button from 'apsl-react-native-button';
import {IlinkEmitter} from './../../utils/events';
import {SafeAreaView} from 'react-navigation';
import DeviceInfo from "react-native-device-info"
import Configuration from "../../webservice/persistences/Configuration";
import DeviceInfo from 'react-native-device-info';
import Configuration from '../../webservice/persistences/Configuration';
import {ScrollView} from 'react-native-gesture-handler';
const route = require("./../../route.json")
require('./../../utils/Translations')
var DBEvents = require('react-native-db-models').DBEvents
let theme = require('./../../utils/theme.json')
const route = require('./../../route.json');
require('./../../utils/Translations');
var DBEvents = require('react-native-db-models').DBEvents;
let theme = require('./../../utils/theme.json');
export default class OptionsMenu extends Component {
static navigatorStyle = {
statusBarColor: primaryDarkAdvanced,
};
commandeListe
commandeListe;
constructor(props) {
super(props);
this.state = this.initState();
IlinkEmitter.on("menuLink", this.onMenuNavigationEvent.bind(this))
IlinkEmitter.on("userconnect", this.onUserConnect.bind(this))
IlinkEmitter.on("userdisconnect", this.hideSideMenu.bind(this))
IlinkEmitter.on("langueChange", this.updateLangue.bind(this))
IlinkEmitter.on('menuLink', this.onMenuNavigationEvent.bind(this));
IlinkEmitter.on('userconnect', this.onUserConnect.bind(this));
IlinkEmitter.on('userdisconnect', this.hideSideMenu.bind(this));
IlinkEmitter.on('langueChange', this.updateLangue.bind(this));
this.configuration = new Configuration();
readUser().then((user) => {
readUser().then(user => {
if (user !== null && user !== undefined) {
this.setState({user});
}
});
}
retrieveAndroidInformation() {
this.configuration._getData().then((lang) => {
this.configuration
._getData()
.then(lang => {
if (lang) {
I18n.locale = lang
readUser().then((result) => {
I18n.locale = lang;
readUser().then(result => {
setTimeout(() => {
this.updateUser(result);
}, 3000)
})
}, 3000);
});
} else {
let code = DeviceInfo.getDeviceLocale();
I18n.locale = code.toLowerCase()
readUser().then((result) => {
I18n.locale = code.toLowerCase();
readUser()
.then(result => {
setTimeout(() => {
this.updateUser(result);
}, 3000)
}).catch((e) => {
this.props.navigation.navigate("Auth")
}, 3000);
})
.catch(e => {
this.props.navigation.navigate('Auth');
});
}
}).catch((e) => {
let code = DeviceInfo.getDeviceLocale()
I18n.locale = code.toLowerCase()
readUser().then((result) => {
})
.catch(e => {
let code = DeviceInfo.getDeviceLocale();
I18n.locale = code.toLowerCase();
readUser()
.then(result => {
setTimeout(() => {
this.updateUser(result);
}, 3000)
}).catch((e) => {
this.props.navigation.navigate("Auth")
}, 3000);
})
.catch(e => {
this.props.navigation.navigate('Auth');
});
});
})
return ""
return '';
}
componentDidMount() {
const items = this.props.navigation.router.childRouters.sta.childRouters;
this.setState({items: items})
this.retrieveAndroidInformation()
this.setState({items: items});
this.retrieveAndroidInformation();
}
updateLangue() {
this.setState({lang: "change"})
this.forceUpdate()
this.setState({lang: 'change'});
this.forceUpdate();
}
componentWillUnmount() {
}
componentWillUnmount() {}
onMenuNavigationEvent(menuOption) {
/* Navigation.mergeOptions(this.props.componentId,{
@ -123,16 +135,14 @@ export default class OptionsMenu extends Component {
}
onUserConnect() {
readUser().then((user) => {
readUser().then(user => {
if (user !== null && user !== undefined) {
this.updateUser(user);
}
});
}
onNavigatorEvent(event) {
}
onNavigatorEvent(event) {}
hideSideMenu() {
/* Navigation.mergeOptions("drawer", {
@ -150,47 +160,161 @@ export default class OptionsMenu extends Component {
user: null,
menu: [],
currentId: 0,
}
};
}
getGeolocatedUserMenu() {
return [
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true}
, {title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false}
, {title: I18n.t('WALLET'), id: 6, key: 6, icon: 'md-wallet-outline', active: false}
, {title: I18n.t('CREDIT_MANAGE'), id: 2, key: 2, icon: 'md-card', active: false}
, {title: I18n.t('ADD_NETWORK'), id: 11, key: 11, icon: 'md-people', active: false}
, {title: I18n.t('CHANGE_INFORMATION'), id: 13, key: 13, icon: 'md-person', active: false}
, {title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false}
, {title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false}]
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('WALLET'),
id: 6,
key: 6,
icon: 'md-wallet-outline',
active: false,
},
{
title: I18n.t('CREDIT_MANAGE'),
id: 2,
key: 2,
icon: 'md-card',
active: false,
},
{
title: I18n.t('ADD_NETWORK'),
id: 11,
key: 11,
icon: 'md-people',
active: false,
},
{
title: I18n.t('CHANGE_INFORMATION'),
id: 13,
key: 13,
icon: 'md-person',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,
},
];
}
getSuperUserMenu() {
return [
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true}
, {title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false}
, {title: I18n.t('WALLET'), id: 6, key: 6, icon: 'md-wallet-outline', active: false}
, {title: I18n.t('CREDIT_MANAGE'), id: 2, key: 2, icon: 'md-card', active: false}
, {title: I18n.t('GROUP_MANAGE'), id: 5, key: 5, icon: 'md-people', active: false}
, {title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false}
, {title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false}]
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('WALLET'),
id: 6,
key: 6,
icon: 'md-wallet-outline',
active: false,
},
{
title: I18n.t('CREDIT_MANAGE'),
id: 2,
key: 2,
icon: 'md-card',
active: false,
},
{
title: I18n.t('GROUP_MANAGE'),
id: 5,
key: 5,
icon: 'md-people',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,
},
];
}
getHyperUsermenu() {
return [
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true}
, {title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false}
, {title: I18n.t('WALLET'), id: 6, key: 6, icon: 'md-wallet-outline', active: false}
, {title: I18n.t('CREDIT_MANAGE'), id: 2, key: 2, icon: 'md-card', active: false}
, {title: I18n.t('GROUP_MANAGE'), id: 5, key: 5, icon: 'md-people', active: false}
, {title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false}
, {title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false}]
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('WALLET'),
id: 6,
key: 6,
icon: 'md-wallet-outline',
active: false,
},
{
title: I18n.t('CREDIT_MANAGE'),
id: 2,
key: 2,
icon: 'md-card',
active: false,
},
{
title: I18n.t('GROUP_MANAGE'),
id: 5,
key: 5,
icon: 'md-people',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,
},
];
}
updateUser(user) {
let menu = [];
if (user !== undefined) {
console.log("USER", user.category);
console.log('USER', user.category);
/* Navigation.mergeOptions("drawer", {
sideMenu: {
left: {
@ -201,13 +325,13 @@ export default class OptionsMenu extends Component {
});*/
if (user.category !== undefined) {
switch (user.category) {
case "geolocated":
case 'geolocated':
menu = this.getGeolocatedUserMenu();
break;
case "super":
case 'super':
menu = this.getSuperUserMenu();
break;
case "hyper":
case 'hyper':
menu = this.getHyperUsermenu();
break;
}
@ -216,108 +340,196 @@ export default class OptionsMenu extends Component {
}
}
this.setState({user: user, menu: menu});
}
getUserMenu() {
return [
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true}
, {title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false}
, {title: I18n.t('WALLET'), id: 6, key: 6, icon: 'md-wallet-outline', active: false}
, {title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false}
, {title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false}]
{
title: I18n.t('MAP'),
id: 0,
key: 0,
icon: 'md-map',
active: true,
},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('WALLET'),
id: 6,
key: 6,
icon: 'md-wallet-outline',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,
},
];
}
redirectToScreen = (item) => {
console.log("Item Menu Click", item);
redirectToScreen = item => {
console.log('Item Menu Click', item);
if (this.state.user === null)
if (this.state.user === null) {
return;
else {
} else {
switch (this.state.user.category) {
case "super":
if (item === "walletSelect")
item = "walletDetail";
this.props.navigation.navigate(item, {agentId: this.state.user.agentId});
case 'super':
if (item === 'walletSelect') {
item = 'walletDetail';
}
this.props.navigation.navigate(item, {
agentId: this.state.user.agentId,
});
break;
case "hyper":
if (item === "walletSelect")
item = "walletDetail";
this.props.navigation.navigate(item, {agentId: this.state.user.agentId});
case 'hyper':
if (item === 'walletSelect') {
item = 'walletDetail';
}
this.props.navigation.navigate(item, {
agentId: this.state.user.agentId,
});
break;
case "geolocated":
case 'geolocated':
this.props.navigation.navigate(item);
break;
default:
if (item === "walletSelect")
item = "walletDetailUser";
if (item === 'walletSelect') {
item = 'walletDetailUser';
}
this.props.navigation.navigate(item, {userId: this.state.user.id});
break;
}
}
}
_renderItem = (item) => {
if (item === "creditrequest" || item === 'historyItemDetails' || item === 'filter' || item === 'networks' || item === 'walletDetail' || item === 'walletDetailUser'
|| item === 'walletDepot' || item === 'walletRetrait' || item === 'createIdentification' || item === 'walletOptionSelect' || item === 'validateIdentification'
|| item === 'createIdentificationUser' || item === 'operateurOptionSelect' || item === 'paiementFacture' || item === 'envoieWalletToWalletUser'
|| item === 'envoieWalletToCashUser' || item === 'linkCard' || item === 'envoieWalletToCardUser' || item === 'envoieWalletToBankUser' || item === 'retraitWalletVersCashUser'
|| item === 'retraitCarteVersWalletUser' || item === 'retraitEnCashAgent' || item === 'retraitCarteVersCashAgent' || item === 'envoieCashVersWalletAgent'
|| item === 'envoieCashVersAutreWalletAgent' || item === 'retraitCarteVersCashUser' || item === 'envoiCashVersCashAgent' || item === 'envoieCashVersCashAgent'
|| item === 'envoieCashVersCarteAgent' || item === 'modifyIdentificationUser' || item === 'createGroupNanoCredit' || item === 'groupNanoCredit' || item === 'demandeValidationGroupe'
|| item === 'adhererGroupNanoCredit' || item === 'myNanoCreditGroup' || item === 'askNanoCredit' || item === 'refundNanoCreditUser' || item === 'cautionNanoCreditAgent'
|| item === 'epargnerArgentUser' || item === 'askNanoCredit' || item === 'casserEpargneUser' || item === 'envoieWalletToBankAgent' || item === 'reattachAccountUser' || item === 'insuranceSubscriptionScreen'
|| item === 'addBeneficiaryScreen' || item === 'activateBuySubscriptionScreen' || item === 'saisirFeuilleSoinScreen' || item === 'validateConsultationScreen' || item === 'validateConsultationDetailScreen'
|| item === 'executerPrescriptionScreen' || item === 'modifierFeuilleSoinScreen' || item === 'modifierExecutionPrescriptionScreen' || item === 'historiqueNanoSanteUserScreen'
|| item === 'demandeAutorisationSoinScreen' || item === 'deleteBeneficiaryScreen' || item === 'StopSubscriptionScreen' || item === 'stopSubscriptionScreen' || item === 'renewAssuranceScreen'
|| item === 'webviewScreen' || item === 'historiqueNanoSanteAgentScreen' || item === 'historiqueNanoSanteSuperHyperScreen' || item === 'PDFViewerScreen' || item === 'ubaFormScreen') {
return null
};
_renderItem = item => {
if (
item === 'creditrequest' ||
item === 'historyItemDetails' ||
item === 'filter' ||
item === 'networks' ||
item === 'walletDetail' ||
item === 'walletDetailUser' ||
item === 'walletDepot' ||
item === 'walletRetrait' ||
item === 'createIdentification' ||
item === 'walletOptionSelect' ||
item === 'validateIdentification' ||
item === 'createIdentificationUser' ||
item === 'operateurOptionSelect' ||
item === 'paiementFacture' ||
item === 'envoieWalletToWalletUser' ||
item === 'envoieWalletToCashUser' ||
item === 'linkCard' ||
item === 'envoieWalletToCardUser' ||
item === 'envoieWalletToBankUser' ||
item === 'retraitWalletVersCashUser' ||
item === 'retraitCarteVersWalletUser' ||
item === 'retraitEnCashAgent' ||
item === 'retraitCarteVersCashAgent' ||
item === 'envoieCashVersWalletAgent' ||
item === 'envoieCashVersAutreWalletAgent' ||
item === 'retraitCarteVersCashUser' ||
item === 'envoiCashVersCashAgent' ||
item === 'envoieCashVersCashAgent' ||
item === 'envoieCashVersCarteAgent' ||
item === 'modifyIdentificationUser' ||
item === 'createGroupNanoCredit' ||
item === 'groupNanoCredit' ||
item === 'demandeValidationGroupe' ||
item === 'adhererGroupNanoCredit' ||
item === 'myNanoCreditGroup' ||
item === 'askNanoCredit' ||
item === 'refundNanoCreditUser' ||
item === 'cautionNanoCreditAgent' ||
item === 'epargnerArgentUser' ||
item === 'askNanoCredit' ||
item === 'casserEpargneUser' ||
item === 'envoieWalletToBankAgent' ||
item === 'reattachAccountUser' ||
item === 'insuranceSubscriptionScreen' ||
item === 'addBeneficiaryScreen' ||
item === 'activateBuySubscriptionScreen' ||
item === 'saisirFeuilleSoinScreen' ||
item === 'validateConsultationScreen' ||
item === 'validateConsultationDetailScreen' ||
item === 'executerPrescriptionScreen' ||
item === 'modifierFeuilleSoinScreen' ||
item === 'modifierExecutionPrescriptionScreen' ||
item === 'historiqueNanoSanteUserScreen' ||
item === 'demandeAutorisationSoinScreen' ||
item === 'deleteBeneficiaryScreen' ||
item === 'StopSubscriptionScreen' ||
item === 'stopSubscriptionScreen' ||
item === 'renewAssuranceScreen' ||
item === 'webviewScreen' ||
item === 'historiqueNanoSanteAgentScreen' ||
item === 'historiqueNanoSanteSuperHyperScreen' ||
item === 'PDFViewerScreen' ||
item === 'ubaFormScreen'
) {
return null;
} else {
const color = this.state.currentId === item.id ? theme.accent : "grey"
const color = this.state.currentId === item.id ? theme.accent : 'grey';
//console.log("ITEM OPTION MENU", item);
return (
<TouchableOpacity onPress={() => {
<TouchableOpacity
onPress={() => {
this.props.navigation.toggleDrawer();
this.setState({currentId: item.id});
this.redirectToScreen(item);
}}
>
<View
style={items.content}
>
<Icon
name={this.getIcon(item)}
size={32}
/>
<Text style={{
}}>
<View style={items.content}>
<Icon name={this.getIcon(item)} size={32} />
<Text
style={{
marginLeft: 20,
fontSize: 16,
}}>{this.getNameItems(item)}
}}>
{this.getNameItems(item)}
</Text>
</View></TouchableOpacity>)
</View>
</TouchableOpacity>
);
}
};
_onPress = ((item) => {
this.setState({currentId: item.id})
let current = this.state.menu.filter((item) => {
return item.active
})[0]
_onPress = item => {
this.setState({currentId: item.id});
let current = this.state.menu.filter(item => {
return item.active;
})[0];
current.active = false;
item.active = true;
let newMenu = [];
this.state.menu.forEach(function (it) {
if (it.id === current.id) newMenu.push(current)
else if (it.id === item.id) newMenu.push(item)
else newMenu.push(it)
if (it.id === current.id) {
newMenu.push(current);
} else if (it.id === item.id) {
newMenu.push(item);
} else {
newMenu.push(it);
}
)
this.setState({menu: newMenu})
});
this.setState({menu: newMenu});
/* switch(item.id){
case 2:
Navigation.push(route.stackRoot,{
@ -462,76 +674,75 @@ export default class OptionsMenu extends Component {
}
})
*/
});
};
getNameItems(item) {
let icon = item
let icon = item;
switch (item) {
case "home":
icon = I18n.t('MAP')
break
case 'home':
icon = I18n.t('MAP');
break;
case 'useraccount':
icon = I18n.t('MY_ACCOUNT')
break
icon = I18n.t('MY_ACCOUNT');
break;
case 'walletSelect':
icon = I18n.t('WALLET')
break
icon = I18n.t('WALLET');
break;
case 'Historique':
icon = I18n.t('CREDIT_MANAGE')
break
case "superviseurgroup":
icon = I18n.t('GROUP_MANAGE')
break
case "updateinformation":
icon = I18n.t("CHANGE_INFORMATION")
break
icon = I18n.t('CREDIT_MANAGE');
break;
case 'superviseurgroup':
icon = I18n.t('GROUP_MANAGE');
break;
case 'updateinformation':
icon = I18n.t('CHANGE_INFORMATION');
break;
case 'notificationview':
icon = I18n.t('NOTIFICATIONS')
break
icon = I18n.t('NOTIFICATIONS');
break;
case 'configuration':
icon = I18n.t('CONFIGURATIONS')
icon = I18n.t('CONFIGURATIONS');
break;
case 'addNetwork':
icon = I18n.t('ADD_NETWORK')
break
icon = I18n.t('ADD_NETWORK');
break;
case 'about':
icon = I18n.t('ABOUT')
break
icon = I18n.t('ABOUT');
break;
}
return icon;
}
getIcon(item) {
let icon = "md-map"
let icon = 'md-map';
switch (item) {
case "home":
icon = "md-map"
break
case 'home':
icon = 'md-map';
break;
case 'useraccount':
icon = "md-person"
break
icon = 'md-person';
break;
case 'walletSelect':
icon = "md-wallet"
break
icon = 'md-wallet';
break;
case 'Historique':
icon = "md-card"
break
case "superviseurgroup":
icon = "md-people"
break
icon = 'md-card';
break;
case 'superviseurgroup':
icon = 'md-people';
break;
case 'notificationview':
icon = "md-notifications";
break
case "updateinformation":
icon = "md-people"
break
icon = 'md-notifications';
break;
case 'updateinformation':
icon = 'md-people';
break;
case 'configuration':
icon = 'md-settings'
icon = 'md-settings';
break;
case 'addNetwork':
icon = "md-people"
break
icon = 'md-people';
break;
case 'about':
icon = 'md-contacts';
break;
@ -543,39 +754,41 @@ export default class OptionsMenu extends Component {
}
render() {
var name = this.state.user ? this.state.user.firstname : "";
const surname = this.state.user ? this.state.user.lastname : "";
if (!this.state.lang && this.state.lang !== "change")
var name = this.state.user ? this.state.user.firstname : '';
const surname = this.state.user ? this.state.user.lastname : '';
if (!this.state.lang && this.state.lang !== 'change') {
return (
<View style={styles.container}>
<View
style={styles.headercontent}
>
<View style={styles.headercontent}>
<Text style={styles.headerTitle}>{name}</Text>
<Text style={styles.headerTitle}>{surname}</Text>
<Text style={styles.headerPhone}>{this.state.user ? "" + this.state.user.phone : ""}</Text>
<Text style={styles.headerPhone}>
{this.state.user ? '' + this.state.user.phone : ''}
</Text>
</View>
<ScrollView style={{
flex: 1, height: responsiveHeight(40)
<ScrollView
style={{
flex: 1,
height: responsiveHeight(40),
}}>
<SafeAreaView forceInset={{top: 'always', horizontal: 'never'}}>
{
this.state.items && Object.keys(this.state.items).map((item, key) => {
return this._renderItem(item)
})
}
{this.state.items &&
Object.keys(this.state.items).map((item, key) => {
return this._renderItem(item);
})}
</SafeAreaView>
</ScrollView>
<Button
textStyle={styles.btntext}
style={styles.btnDeconnect}
onPress={() => this.userDeconnect()}
>{I18n.t('DISCONNEXION')}</Button>
onPress={() => this.userDeconnect()}>
{I18n.t('DISCONNEXION')}
</Button>
</View>
)
else {
setTimeout(() => this.setState({lang: ""}), 500)
return (<View/>)
);
} else {
setTimeout(() => this.setState({lang: ''}), 500);
return <View />;
}
}
@ -585,23 +798,28 @@ export default class OptionsMenu extends Component {
I18n.t('DISCONNEXION_TEXT'),
[
{},
{text: I18n.t('NO'), onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{
text: I18n.t('YES'), onPress: () => {
text: I18n.t('NO'),
onPress: () => console.log('Cancel Pressed'),
style: 'cancel',
},
{
text: I18n.t('YES'),
onPress: () => {
disconnect().then(() => {
IlinkEmitter.emit("userdisconnect");
IlinkEmitter.emit('userdisconnect');
AsyncStorage.removeItem('@config:onesignalIds');
this.props.navigation.navigate("Auth");
})
}
this.props.navigation.navigate('Auth');
});
},
},
],
{cancelable: false}
)
{cancelable: false},
);
}
watchUser() {
readUser().then((user) => {
readUser().then(user => {
if (user !== null && user !== undefined) {
if (user.id !== this.state.user.id) {
this.updateUser(user);
@ -617,42 +835,41 @@ const items = StyleSheet.create({
height: 50,
paddingLeft: 20,
flexDirection: 'row',
alignItems: 'center'
alignItems: 'center',
},
itemText: {
color: '#000000',
marginLeft: 20,
fontSize: responsiveFontSize(2),
}
},
});
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white",
backgroundColor: 'white',
},
btnDeconnect: {
borderColor: "transparent",
borderColor: 'transparent',
marginLeft: 20,
marginRight: 20,
backgroundColor: theme.accent
backgroundColor: theme.accent,
},
btntext: {
color: "white",
color: 'white',
fontSize: 17,
fontWeight: "bold"
fontWeight: 'bold',
},
headerTitle: {
fontSize: 14,
marginBottom: 5,
color: "white",
color: 'white',
fontWeight: 'bold',
},
headerPhone: {
fontSize: 12,
marginBottom: 20,
color: "white",
justifyContent: 'flex-end'
color: 'white',
justifyContent: 'flex-end',
},
listMenu: {
paddingTop: 15,
@ -662,8 +879,7 @@ const styles = StyleSheet.create({
backgroundColor: primary,
justifyContent: 'flex-end',
alignItems: 'flex-start',
paddingLeft: 20
paddingLeft: 20,
},
backgroundd_drawer: {
backgroundColor: '#000',

View File

@ -6,97 +6,116 @@
* @flow
*/
import React, {Component} from 'react';
import { Platform, StyleSheet, Alert, FlatList, Text, View, TouchableOpacity, Linking } from 'react-native';
import {
Platform,
StyleSheet,
Alert,
FlatList,
Text,
View,
TouchableOpacity,
Linking,
} from 'react-native';
import ActionButton from 'react-native-action-button';
import Icon from 'react-native-vector-icons/Ionicons';
import { responsiveFontSize, responsiveHeight, responsiveWidth } from 'react-native-responsive-dimensions';
import {
responsiveFontSize,
responsiveHeight,
responsiveWidth,
} from 'react-native-responsive-dimensions';
import HeaderMenu from './HeaderMenu';
import { historiques as histo, first, useraccount, notification, configurations } from './../../route.json';
import {
historiques as histo,
first,
useraccount,
notification,
configurations,
} from './../../route.json';
import {primary, primaryDarkAdvanced} from './../../utils/theme.json';
import {readUser, disconnect} from './../../webservice/AuthApi';
import I18n from 'react-native-i18n'
const route = require("./../../route.json")
require('./../../utils/Translations')
var DBEvents = require('react-native-db-models').DBEvents
import I18n from 'react-native-i18n';
const route = require('./../../route.json');
require('./../../utils/Translations');
var DBEvents = require('react-native-db-models').DBEvents;
type Props = {};
let theme = require('./../../utils/theme.json')
import Button from 'apsl-react-native-button'
import { IlinkEmitter } from "./../../utils/events"
let theme = require('./../../utils/theme.json');
import Button from 'apsl-react-native-button';
import {IlinkEmitter} from './../../utils/events';;
import {DrawerItems, SafeAreaView} from 'react-navigation';
import RNDeviceInformation from "fm-react-native-device-info"
import AppContainer, { AppNavigator } from "../../App";
import Configuration from "../../webservice/persistences/Configuration";
import RNDeviceInformation from 'fm-react-native-device-info';;
import AppContainer, {AppNavigator} from '../../App';
import Configuration from '../../webservice/persistences/Configuration';
export default class OptionsMenu extends Component<Props> {
static navigatorStyle = {
statusBarColor: primaryDarkAdvanced,
};
commandeListe
commandeListe;
constructor(props) {
super(props);
this.state = this.initState();
IlinkEmitter.on("menuLink", this.onMenuNavigationEvent.bind(this))
IlinkEmitter.on("userconnect", this.onUserConnect.bind(this))
IlinkEmitter.on("userdisconnect", this.hideSideMenu.bind(this))
IlinkEmitter.on("langueChange", this.updateLangue.bind(this))
IlinkEmitter.on('menuLink', this.onMenuNavigationEvent.bind(this));;
IlinkEmitter.on('userconnect', this.onUserConnect.bind(this));;
IlinkEmitter.on('userdisconnect', this.hideSideMenu.bind(this));;
IlinkEmitter.on('langueChange', this.updateLangue.bind(this));;
this.configuration = new Configuration();
}
retrieveAndroidInformation() {
this.configuration._getData().then((lang) => {
this.configuration
._getData()
.then(lang => {
if (lang) {
I18n.locale = lang
readUser().then((result) => {
I18n.locale = lang;;
readUser().then(result => {
setTimeout(() => {
this.updateUser(result);
}, 3000)
})
}, 3000);;
});;
} else {
RNDeviceInformation.getDeviceCountryCode().then((code) => {
I18n.locale = code.toLowerCase()
readUser().then((result) => {
RNDeviceInformation.getDeviceCountryCode().then(code => {
I18n.locale = code.toLowerCase();;
readUser()
.then(result => {
setTimeout(() => {
this.updateUser(result);
}, 3000)
}).catch((e) => {
this.props.navigation.navigate("Auth")
});
}, 3000);;
})
.catch(e => {
this.props.navigation.navigate('Auth');;
});
});;
}
}).catch((e) => {
RNDeviceInformation.getDeviceCountryCode().then((code) => {
I18n.locale = code.toLowerCase()
readUser().then((result) => {
})
.catch(e => {
RNDeviceInformation.getDeviceCountryCode().then(code => {
I18n.locale = code.toLowerCase();;
readUser()
.then(result => {
setTimeout(() => {
this.updateUser(result);
}, 3000)
}).catch((e) => {
this.props.navigation.navigate("Auth")
}, 3000);;
})
.catch(e => {
this.props.navigation.navigate('Auth');;
});
})
});
});;
})
return ""
return '';;
}
componentDidMount() {
const items = this.props.navigation.router.childRouters.sta.childRouters;
// items.filter((item)=>item.)
this.setState({ items: items })
this.retrieveAndroidInformation()
this.setState({items: items});;
this.retrieveAndroidInformation();
}
updateLangue() {
this.setState({ lang: "change" })
this.forceUpdate()
}
componentWillUnmount() {
this.setState({lang: 'change'});;
this.forceUpdate();;
}
componentWillUnmount() {}
onMenuNavigationEvent(menuOption) {
/* Navigation.mergeOptions(this.props.componentId,{
sideMenu: {
@ -116,15 +135,13 @@ export default class OptionsMenu extends Component<Props> {
}*/
}
onUserConnect() {
readUser().then((user) => {
readUser().then(user => {
if (user !== null && user !== undefined) {
this.updateUser(user);
}
});
}
onNavigatorEvent(event) {
}
onNavigatorEvent(event) {}
hideSideMenu() {
/* Navigation.mergeOptions("drawer", {
sideMenu: {
@ -140,35 +157,131 @@ export default class OptionsMenu extends Component<Props> {
user: null,
menu: [],
currentId: 0,
}
};;
}
getGeolocatedUserMenu() {
return [
{ title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true }
, { title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false }
, { title: I18n.t('CREDIT_MANAGE'), id: 2, key: 2, icon: 'md-card', active: false }
, { title: I18n.t('ADD_NETWORK'), id: 11, key: 11, icon: 'md-people', active: false }
, { title: I18n.t('CHANGE_INFORMATION'), id: 13, key: 13, icon: 'md-person', active: false }
, { title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false }
, { title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false }]
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('CREDIT_MANAGE'),
id: 2,
key: 2,
icon: 'md-card',
active: false,
},
{
title: I18n.t('ADD_NETWORK'),
id: 11,
key: 11,
icon: 'md-people',
active: false,
},
{
title: I18n.t('CHANGE_INFORMATION'),
id: 13,
key: 13,
icon: 'md-person',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,;
},
];
}
getSuperUserMenu() {
return [
{ title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true }
, { title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false }
, { title: I18n.t('CREDIT_MANAGE'), id: 2, key: 2, icon: 'md-card', active: false }
, { title: I18n.t('GROUP_MANAGE'), id: 5, key: 5, icon: 'md-people', active: false }
, { title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false }
, { title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false }]
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('CREDIT_MANAGE'),
id: 2,
key: 2,
icon: 'md-card',
active: false,
},
{
title: I18n.t('GROUP_MANAGE'),
id: 5,
key: 5,
icon: 'md-people',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,
},
];
}
getHyperUsermenu() {
return [
{ title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true }
, { title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false }
, { title: I18n.t('CREDIT_MANAGE'), id: 2, key: 2, icon: 'md-card', active: false }
, { title: I18n.t('GROUP_MANAGE'), id: 5, key: 5, icon: 'md-people', active: false }
, { title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false }
, { title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false }]
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('CREDIT_MANAGE'),
id: 2,
key: 2,
icon: 'md-card',
active: false,
},
{
title: I18n.t('GROUP_MANAGE'),
id: 5,
key: 5,
icon: 'md-people',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,;
},
];
}
updateUser(user) {
let menu = [];
@ -183,73 +296,94 @@ export default class OptionsMenu extends Component<Props> {
});*/
if (user.category !== undefined) {
switch (user.category) {
case "geolocated":
case 'geolocated':
menu = this.getGeolocatedUserMenu();
break;
case "super":
case 'super':
menu = this.getSuperUserMenu();
break;
case "hyper":
case 'hyper':
menu = this.getHyperUsermenu();
break;
}
} else {
menu = this.getUserMenu();
}
}
this.setState({user: user, menu: menu});
}
getUserMenu() {
return [
{ title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true }
, { title: I18n.t('MY_ACCOUNT'), id: 1, key: 1, icon: 'md-person', active: false }
, { title: I18n.t('NOTIFICATIONS'), id: 3, key: 3, icon: 'md-notifications', active: false }
, { title: I18n.t('CONFIGURATIONS'), id: 4, icon: 'md-settings', active: false }]
{title: I18n.t('MAP'), id: 0, key: 0, icon: 'md-map', active: true},
{
title: I18n.t('MY_ACCOUNT'),
id: 1,
key: 1,
icon: 'md-person',
active: false,
},
{
title: I18n.t('NOTIFICATIONS'),
id: 3,
key: 3,
icon: 'md-notifications',
active: false,
},
{
title: I18n.t('CONFIGURATIONS'),
id: 4,
icon: 'md-settings',
active: false,
},
];
}
_renderItem = (item) => {
if (item === "creditrequest" || item === 'historyItemDetails' || item === 'filter' || item === 'networks' || item === 'createIdentification') {
return null
_renderItem = item => {
if (
item === 'creditrequest' ||
item === 'historyItemDetails' ||
item === 'filter' ||
item === 'networks' ||
item === 'createIdentification'
) {
return null;;
} else {
const color = this.state.currentId === item.id ? theme.accent : "grey"
const color = this.state.currentId === item.id ? theme.accent : 'grey';;
return (
<TouchableOpacity onPress={() => {
<TouchableOpacity
onPress={() => {
this.props.navigation.toggleDrawer();
this.setState({ currentId: item.id })
this.props.navigation.navigate(item)
}}
>
<View
style={items.content}
>
<Icon
name={this.getIcon(item)}
size={32}
/>
<Text style={{
this.setState({currentId: item.id});;
this.props.navigation.navigate(item);;
}}>
<View style={items.content}>
<Icon name={this.getIcon(item)} size={32} />
<Text
style={{
marginLeft: 20,
fontSize: 16,
}}>{this.getNameItems(item)}
}}>
{this.getNameItems(item)}
</Text>
</View></TouchableOpacity>)
</View>
</TouchableOpacity>;
);
}
};
_onPress = ((item) => {
this.setState({ currentId: item.id })
let current = this.state.menu.filter((item) => { return item.active })[0]
_onPress = item => {
this.setState({currentId: item.id});;
let current = this.state.menu.filter(item => {
return item.active;
})[0];;
current.active = false;
item.active = true;
let newMenu = [];
this.state.menu.forEach(function (it) {
if (it.id === current.id) newMenu.push(current)
else if (it.id === item.id) newMenu.push(item)
else newMenu.push(it)
}
)
this.setState({ menu: newMenu })
if (it.id === current.id) newMenu.push(current);;
else if (it.id === item.id) newMenu.push(item);;
else newMenu.push(it);;
});;
this.setState({menu: newMenu});;
/* switch(item.id){
case 2:
Navigation.push(route.stackRoot,{
@ -393,60 +527,80 @@ export default class OptionsMenu extends Component<Props> {
}
}
})
*/ });
*/
};
getNameItems(item) {
let icon = item
let icon = item;;
switch (item) {
case "home": icon = I18n.t('MAP')
break
case 'useraccount': icon = I18n.t('MY_ACCOUNT')
break
case 'Historique': icon = I18n.t('CREDIT_MANAGE')
break
case "superviseurgroup": icon = I18n.t('GROUP_MANAGE')
break
case "updateinformation": icon = I18n.t("CHANGE_INFORMATION")
break
case 'notificationview': icon = I18n.t('NOTIFICATIONS')
break
case 'configuration': icon = I18n.t('CONFIGURATIONS')
break;
case 'addNetwork': icon = I18n.t('ADD_NETWORK')
break
case 'about': icon = I18n.t('ABOUT_')
case 'home':
icon = I18n.t('MAP');;
break;;
case 'useraccount':
icon = I18n.t('MY_ACCOUNT');;
break;;
case 'Historique':
icon = I18n.t('CREDIT_MANAGE');;
break;;
case 'superviseurgroup':
icon = I18n.t('GROUP_MANAGE');;
break;;
case 'updateinformation':
icon = I18n.t('CHANGE_INFORMATION');;
break;;
case 'notificationview':
icon = I18n.t('NOTIFICATIONS');;
break;;
case 'configuration':
icon = I18n.t('CONFIGURATIONS');;
break;;
case 'addNetwork':
icon = I18n.t('ADD_NETWORK');;
break;;
case 'about':
icon = I18n.t('ABOUT_');;
}
return icon;
}
getIcon(item) {
let icon = "md-map"
let icon = 'md-map';;
switch (item) {
case "home": icon = "md-map"
break
case 'useraccount': icon = "md-person"
break
case 'Historique': icon = "md-card"
break
case "superviseurgroup": icon = "md-people"
break
case 'notificationview': icon = "md-notifications";
break
case "updateinformation": icon = "md-people"
break
case 'configuration': icon = 'md-settings'
case 'home':
icon = 'md-map';;
break;;
case 'useraccount':
icon = 'md-person';;
break;;
case 'Historique':
icon = 'md-card';;
break;;
case 'superviseurgroup':
icon = 'md-people';;
break;;
case 'notificationview':
icon = 'md-notifications';
break;;
case 'updateinformation':
icon = 'md-people';;
break;;
case 'configuration':
icon = 'md-settings';;
break;
case 'addNetwork': icon = "md-people"
break
case 'about': icon = 'md-contacts';
case 'addNetwork':
icon = 'md-people';;
break;;
case 'about':
icon = 'md-contacts';
break;
}
return icon;
}
render() {
var name = this.state.user ? this.state.user.firstname : "";
const surname = this.state.user ? this.state.user.lastname : "";
if (!this.state.lang && this.state.lang !== "change")
return (
var name = this.state.user ? this.state.user.firstname : '';
const surname = this.state.user ? this.state.user.lastname : '';
if (!this.state.lang && this.state.lang !== 'change')
{return (
<View style={styles.container}>
<View
style={styles.headercontent}
@ -470,10 +624,10 @@ export default class OptionsMenu extends Component<Props> {
onPress={() => this.userDeconnect()}
>{I18n.t('DISCONNEXION')}</Button>
</View>
)
)};
else {
setTimeout(() => this.setState({ lang: "" }), 500)
return (<View />)
setTimeout(() => this.setState({lang: ''}), 500);;
return <View />;;
}
}
userDeconnect() {
@ -482,21 +636,26 @@ export default class OptionsMenu extends Component<Props> {
I18n.t('DISCONNEXION_TEXT'),
[
{},
{ text: I18n.t('NO'), onPress: () => console.log('Cancel Pressed'), style: 'cancel' },
{
text: I18n.t('YES'), onPress: () => {
text: I18n.t('NO'),
onPress: () => console.log('Cancel Pressed'),
style: 'cancel',
},
{
text: I18n.t('YES'),
onPress: () => {
disconnect().then(() => {
IlinkEmitter.emit("userdisconnect");
this.props.navigation.navigate("Auth")
})
}
IlinkEmitter.emit('userdisconnect');
this.props.navigation.navigate('Auth');;
});;
},,
},
],
{ cancelable: false }
)
{cancelable: false},
);;
}
watchUser() {
readUser().then((user) => {
readUser().then(user => {
if (user !== null && user !== undefined) {
this.updateUser(user);
}
@ -510,42 +669,41 @@ const items = StyleSheet.create({
height: 50,
paddingLeft: 20,
flexDirection: 'row',
alignItems: 'center'
alignItems: 'center',,
},
itemText: {
color: '#000000',
marginLeft: 20,
fontSize: responsiveFontSize(2),
}
},,
});
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white",
backgroundColor: 'white',
},
btnDeconnect: {
borderColor: "transparent",
borderColor: 'transparent',
marginLeft: 20,
marginRight: 20,
backgroundColor: theme.accent
backgroundColor: theme.accent,,
},
btntext: {
color: "white",
color: 'white',
fontSize: 17,
fontWeight: "bold"
fontWeight: 'bold',,
},
headerTitle: {
fontSize: 14,
marginBottom: 5,
color: "white",
color: 'white',
fontWeight: 'bold',
},
headerPhone: {
fontSize: 12,
marginBottom: 20,
color: "white",
justifyContent: 'flex-end'
color: 'white',
justifyContent: 'flex-end',
},
listMenu: {
paddingTop: 15,
@ -555,14 +713,12 @@ const styles = StyleSheet.create({
backgroundColor: primary,
justifyContent: 'flex-end',
alignItems: 'flex-start',
paddingLeft: 20
paddingLeft: 20,
},
backgroundd_drawer: {
backgroundColor: '#000',
},
listbackground: {
},
listbackground: {},
actionButtonIcon: {
fontSize: 20,
height: 22,

View File

@ -1,15 +1,30 @@
/* eslint-disable react-native/no-inline-styles */
import React, {Component} from 'react';
import {Image, PermissionsAndroid, StatusBar, StyleSheet, View} from 'react-native';
import {responsiveFontSize, responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions';
import I18n from 'react-native-i18n'
import {getPasObject, getPubActiveObject, readUser} from '../../webservice/AuthApi';
import Configuration from "../../webservice/persistences/Configuration";
import '../ads/InterticielAds'
import {
Image,
PermissionsAndroid,
StatusBar,
StyleSheet,
View,
} from 'react-native';
import {
responsiveFontSize,
responsiveHeight,
responsiveWidth,
} from 'react-native-responsive-dimensions';
import I18n from 'react-native-i18n';
import {
getPasObject,
getPubActiveObject,
readUser,
} from '../../webservice/AuthApi';
import Configuration from '../../webservice/persistences/Configuration';
import '../ads/InterticielAds';
import * as Animatable from 'react-native-animatable';
import DeviceInfo from 'react-native-device-info';
import {bindActionCreators} from "redux";
import getAuthApiKey from "../../webservice/AuthKeyApi";
import {connect} from "react-redux";
import {bindActionCreators} from 'redux';
import getAuthApiKey from '../../webservice/AuthKeyApi';
import {connect} from 'react-redux';
const theme = require('./../../utils/theme.json');
const route = require('./../../route.json');
@ -27,70 +42,74 @@ class SplashScreen extends Component {
statusBar: {
visible: false,
style: 'light' | 'dark',
drawBehind: true
drawBehind: true,
},
topBar: {
title: {
text: 'My Screen'
text: 'My Screen',
},
drawBehind: true,
visible: false,
animate: false
}
animate: false,
},
};
}
//
constructor(props) {
super(props);
this.state = {
this.state = {};
}
};
workUserResult(result) {
console.log("SPLASHSCREEN PROPS", this.props);
console.log('SPLASHSCREEN PROPS', this.props);
if (typeof this.props.navigation.state.params !== 'undefined') {
if (result === null || result === undefined) {
this.props.navigation.navigate("Auth");
this.props.navigation.navigate('Auth');
} else {
switch (this.props.navigation.state.params.routeName) {
case 'historyItemDetails':
this.props.navigation.navigate(this.props.navigation.state.params.routeName, {
item: this.props.navigation.state.params.params
});
this.props.navigation.navigate(
this.props.navigation.state.params.routeName,
{
item: this.props.navigation.state.params.params,
},
);
break;
default:
this.props.navigation.navigate(this.props.navigation.state.params.routeName, {
id: this.props.navigation.state.params.params.id
});
this.props.navigation.navigate(
this.props.navigation.state.params.routeName,
{
id: this.props.navigation.state.params.params.id,
},
);
break;
}
}
} else {
var way = "";
var way2 = "";
var way = '';
var way2 = '';
if (result === null || result === undefined) {
way = "Auth"
way2 = route.first
way = 'Auth';
way2 = route.first;
} else {
if (!result.category) {
way = 'App';
} else {
if (!result.category)
way = "App"
else {
switch (result.category) {
case 'geolocated': way = "AgentApp"
case 'geolocated':
way = 'AgentApp';
break;
case 'super':
way = 'adminApp';
break;
case 'super': way = "adminApp"
break
default:
way = "supAdminApp"
way = 'supAdminApp';
}
}
way2 = route.login
way2 = route.login;
}
this.props.navigation.navigate(way)
this.props.navigation.navigate(way);
}
/* Navigation.setStackRoot(route.stackRoot,
@ -112,145 +131,156 @@ class SplashScreen extends Component {
}
}
});*/
}
componentDidMount() {
try {
this.requestCameraPermission()
this.requestCameraPermission();
} catch (e) {
console.log(e)
console.log(e);
}
this.config = new Configuration();
this.retrieveAndroidInformation()
setTimeout(() => this.bounce(), 500)
this.bounce()
readUser().then(async (user) => {
this.retrieveAndroidInformation();
setTimeout(() => this.bounce(), 500);
this.bounce();
readUser().then(async user => {
if (user) {
if (user !== undefined) {
if (user.phone !== undefined)
if (user.phone !== undefined) {
this.props.getAuthApiKey(user.phone);
}
}
}
});
}
async requestCameraPermission() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Cool Photo App Camera Permission',
'message': 'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.'
}
)
title: 'Cool Photo App Camera Permission',
message:
'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
} else {
console.log("try get information else")
console.log('try get information else');
}
} catch (err) {
console.log("try get information error")
console.log(err)
console.log('try get information error');
console.log(err);
}
}
handleViewRef = ref => this.view = ref;
handleViewRef = ref => (this.view = ref);
bounce = () => this.view.transition({translateX: 0}, {translateX: 700}, 5000);
render() {
return (
<View style={styles.container}>
<StatusBar
translucent={true}
<StatusBar translucent={true} />
<Image
style={styles.logo}
source={require('./../../datas/img/icon3up.png')}
/>
<Image style={styles.logo} source={require('./../../datas/img/icon3up.png')} />
<View style={{flexDirection: 'row'}}>
<Image style={styles.logo} source={require('./../../datas/img/iconsub3.png')} />
<Image
style={styles.logo}
source={require('./../../datas/img/iconsub3.png')}
/>
<Animatable.View
style={{ width: responsiveWidth(90), height: 92, backgroundColor: theme.primary, position: 'absolute', zIndex: 100 }}
ref={this.handleViewRef}>
</Animatable.View>
style={{
width: responsiveWidth(90),
height: 92,
backgroundColor: theme.primary,
position: 'absolute',
zIndex: 100,
}}
ref={this.handleViewRef}
/>
</View>
</View>
)
);
}
retreiveIosInformation() {
readUser().then((result) => {
readUser()
.then(result => {
setTimeout(() => {
this.workUserResult(result)
}, 3000)
}).catch((e) => {
this.props.navigation.navigate("Auth")
this.workUserResult(result);
}, 3000);
})
.catch(e => {
this.props.navigation.navigate('Auth');
});
return "";
return '';
}
retrieveAndroidInformation() {
getPasObject().then((data) => {
getPasObject().then(data => {
console.warn(data);
this.config.setCurrentPas(data)
})
this.config.setCurrentPas(data);
});
this.config._getData().then((lang) => {
this.config
._getData()
.then(lang => {
if (lang) {
I18n.locale = lang
readUser().then((result) => {
console.warn(result)
I18n.locale = lang;
readUser().then(result => {
console.warn(result);
if (result) {
getPubActiveObject(result['country_id']).then((data) => {
console.warn(data)
getPubActiveObject(result.country_id).then(data => {
console.warn(data);
this.config.setPubActive(data);
})
});
}
setTimeout(() => {
this.workUserResult(result)
}, 3000)
})
this.workUserResult(result);
}, 3000);
});
} else {
const code = DeviceInfo.getDeviceLocale();
console.warn(code)
I18n.locale = code.toLowerCase()
readUser().then((result) => {
console.warn(result)
console.warn(code);
I18n.locale = code.toLowerCase();
readUser()
.then(result => {
console.warn(result);
if (result) {
getPubActiveObject(result['country_id']).then((data) => {
console.warn(data)
getPubActiveObject(result.country_id).then(data => {
console.warn(data);
this.config.setPubActive(data);
})
});
}
setTimeout(() => {
this.workUserResult(result)
}, 3000)
}).catch((e) => {
this.setPubActive(data)
this.workUserResult(result);
}, 3000);
})
.catch(e => {
this.setPubActive(data);
});
}
}).catch((e) => {
console.warn(e.message)
DeviceInfo.getDeviceLocale().then((code) => {
console.warn(code)
})
.catch(e => {
console.warn(e.message);
DeviceInfo.getDeviceLocale().then(code => {
console.warn(code);
I18n.locale = code.toLowerCase()
readUser().then((result) => {
I18n.locale = code.toLowerCase();
readUser()
.then(result => {
setTimeout(() => {
this.workUserResult(result)
}, 3000)
}).catch((e) => {
this.props.navigation.navigate("Auth")
this.workUserResult(result);
}, 3000);
})
.catch(e => {
this.props.navigation.navigate('Auth');
});
});
});
})
})
return ""
return '';
}
}
@ -260,9 +290,13 @@ const mapStateToProps = state => ({
error: state.authKeyReducer.error,
});
const mapDispatchToProps = dispatch => bindActionCreators({
const mapDispatchToProps = dispatch =>
bindActionCreators(
{
getAuthApiKey,
}, dispatch);
},
dispatch,
);
export default connect(mapStateToProps, mapDispatchToProps)(SplashScreen);
@ -274,7 +308,6 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
logoContaner: {
flexDirection: 'row',
marginTop: responsiveHeight(20),
justifyContent: 'center',
@ -282,12 +315,11 @@ const styles = StyleSheet.create({
},
logo: {
width: responsiveWidth(90),
resizeMode: 'contain'
resizeMode: 'contain',
},
lottie: {
width: 48
,
height: 64
width: 48,
height: 64,
},
title: {
fontSize: responsiveFontSize(4),
@ -295,4 +327,4 @@ const styles = StyleSheet.create({
fontWeight: 'bold',
color: 'white',
},
})
});

19946
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
"debug-build": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res/ ; cd ./android ; sudo ./gradlew clean ; sudo ./gradlew assembleDebug && cd .. && sudo adb install ./android/app/build/outputs/apk/debug/app-debug.apk",
"start-emulator": "emulator -avd Nexus_5X_API_29 -dns-server 8.8.8.8",
"start-emulator-pixel": "emulator -avd Pixel_2_API_29 -dns-server 8.8.8.8",
"run-debug": "cd android && ./gradlew clean && cd .. && react-native run-android",
"run-debug": "cd android && gradlew clean && cd .. && react-native run-android",
"run-release": "cd android && ./gradlew clean && cd .. && react-native run-android --variant=release"
},
"dependencies": {
@ -56,7 +56,7 @@
"react-native-loader": "^1.2.1",
"react-native-loading-spinner-overlay": "^1.0.1",
"react-native-local-mongodb": "^2.2.9",
"react-native-maps": "0.26.1",
"react-native-maps": "^1.4.0",
"react-native-maps-directions": "^1.7.0",
"react-native-material-bottom-navigation": "^1.0.3",
"react-native-material-bottom-navigation-performance": "^0.7.8",

View File

@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
/**
* Sample React Native App
* https://github.com/facebook/react-native
@ -13,37 +14,37 @@ import {
createStackNavigator,
createDrawerNavigator,
createAppContainer,
createBottomTabNavigator
createBottomTabNavigator,
} from 'react-navigation';
import Connect from "./screens/login/Connect";
import SplashScreen from "./screens/splashscreen/SplashScreen";
import HelpMenu from "./screens/help/HelpMenu";
import Help from "./screens/help/Help";
import ForgottenPassword from "./screens/login/ForgottenPassword";
import TypeChoiser from "./screens/login/TypeChoiser";
import CreateUserStep2 from "./screens/login/createUserStep2";
import createAccount from "./screens/login/createAccount";
import UpdateInformations from "./screens/account/UpdateInformations";
import UserAccount from "./screens/account/UserAccount";
import ActivateAccount from "./screens/login/ActivateAccount";
import Notifications from "./screens/notifications/Notifications";
import About from "./screens/configurations/About";
import Configurations from "./screens/configurations/Configurations";
import Connect from './screens/login/Connect';
import SplashScreen from './screens/splashscreen/SplashScreen';
import HelpMenu from './screens/help/HelpMenu';
import Help from './screens/help/Help';
import ForgottenPassword from './screens/login/ForgottenPassword';
import TypeChoiser from './screens/login/TypeChoiser';
import CreateUserStep2 from './screens/login/createUserStep2';
import createAccount from './screens/login/createAccount';
import UpdateInformations from './screens/account/UpdateInformations';
import UserAccount from './screens/account/UserAccount';
import ActivateAccount from './screens/login/ActivateAccount';
import Notifications from './screens/notifications/Notifications';
import About from './screens/configurations/About';
import Configurations from './screens/configurations/Configurations';
import History from './screens/history-request/History'
import OptionsMenu from "./screens/optionMenu/OptionsMenu";
import Home from "./screens/home/Home";
import HistoryItemDetails from "./screens/history-request/HistoryItemDetails";
import SuperViseurGroupeHome from "./screens/groupes/SuperViseurGroupeHome";
import HistoryRequester from "./screens/history-request/HistoryRequester";
import AddNetwork from "./screens/account/AddNetwork";
import MyHistory from "./screens/history-request/MyHistory";
import Icon from "react-native-vector-icons/FontAwesome5";
import History from './screens/history-request/History';
import OptionsMenu from './screens/optionMenu/OptionsMenu';
import Home from './screens/home/Home';
import HistoryItemDetails from './screens/history-request/HistoryItemDetails';
import SuperViseurGroupeHome from './screens/groupes/SuperViseurGroupeHome';
import HistoryRequester from './screens/history-request/HistoryRequester';
import AddNetwork from './screens/account/AddNetwork';
import MyHistory from './screens/history-request/MyHistory';
import Icon from 'react-native-vector-icons/FontAwesome5';
import {GoogleAnalyticsTracker} from 'react-native-google-analytics-bridge';
import {Appbar} from 'react-native-paper';
import IconWithBadge from "./screens/IconWithBadge"
import I18n from "react-native-i18n";
import IconWithBadge from './screens/IconWithBadge';
import I18n from 'react-native-i18n';
import Filter from './screens/home/Filter';
import {createMaterialBottomTabNavigator} from 'react-navigation-material-bottom-tabs';
import Networks from './screens/home/Networks';
@ -56,7 +57,7 @@ const instructions = Platform.select({
});
type Props = {};
const theme = require("./utils/theme")
const theme = require('./utils/theme');
class HomeScreen extends Component<Props> {
render() {
@ -78,11 +79,11 @@ const AuthStack = createStackNavigator({
typeaccountcreate: TypeChoiser,
simpleusercreate: createAccount,
step2: CreateUserStep2,
activateaccout: ActivateAccount
activateaccout: ActivateAccount,
}, {
headerMode: 'none'
})
headerMode: 'none',
});
const AppStack = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
@ -94,10 +95,10 @@ const AppStack = createDrawerNavigator({
},
notificationview: Notifications,
configuration: Configurations,
about: About
about: About,
})
}, {contentComponent: OptionsMenu, headerMode: 'none', contentOptions: {activeTintColor: theme.accent}})
}),
}, {contentComponent: OptionsMenu, headerMode: 'none', contentOptions: {activeTintColor: theme.accent}});
const AppAgentStack = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
@ -105,16 +106,16 @@ const AppAgentStack = createDrawerNavigator({
Historique:
{
screen: createBottomTabNavigator({myDemand: MyHistory}, {
headerMode: "none",
headerMode: 'none',
header: null,
headerTitle: null,
headerTitle: I18n.t('CREDIT_MANAGE'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
fontWeight: "bold"
fontWeight: 'bold',
},
},
}
}),
navigationOptions: ({navigation}) => ({
header: null,
@ -129,7 +130,7 @@ const AppAgentStack = createDrawerNavigator({
<Icon
name={'credit-card'}
size={24}
/>)
/>),
}),
},
@ -139,23 +140,23 @@ const AppAgentStack = createDrawerNavigator({
updateinformation: UpdateInformations,
notificationview: Notifications,
configuration: Configurations,
about: About
})
about: About,
}),
}, {
contentComponent: OptionsMenu,
backBehavior: "none",
backBehavior: 'none',
lazy: false,
headerMode: 'none', contentOptions: {activeTintColor: theme.accent}
})
headerMode: 'none', contentOptions: {activeTintColor: theme.accent},
});
const AppAdministratorStack = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
Historique: {
screen: createBottomTabNavigator({
myDemand: MyHistory, OthersDemand: MyHistory
myDemand: MyHistory, OthersDemand: MyHistory,
}, {
headerMode: "none",
headerMode: 'none',
header: null,
headerTitle: null,
title: I18n.t('CREDIT_MANAGE'),
@ -163,7 +164,7 @@ const AppAdministratorStack = createDrawerNavigator({
labelStyle: {
fontSize: 13,
},
}
},
}),
navigationOptions: ({navigation}) => ({
header: null,
@ -178,7 +179,7 @@ const AppAdministratorStack = createDrawerNavigator({
<Icon
name={'credit-card'}
size={24}
/>)
/>),
}),
},
creditrequest: HistoryRequester,
@ -187,42 +188,42 @@ const AppAdministratorStack = createDrawerNavigator({
superviseurgroup: SuperViseurGroupeHome,
notificationview: Notifications,
configuration: Configurations,
about: About
about: About,
})
}),
},
{
contentComponent: OptionsMenu,
backBehavior: "none",
headerMode: 'none'
})
backBehavior: 'none',
headerMode: 'none',
});
const AppSuperAdministrator = createDrawerNavigator({
sta: createStackNavigator({
home: Home,
useraccount: UserAccount,
Historique: {
screen: createBottomTabNavigator({OthersDemand: MyHistory}, {
headerMode: "none",
headerMode: 'none',
header: null,
headerTitle: null,
title: I18n.t('CREDIT_MANAGE'),
tabBarOptions: {
labelStyle: {
fontSize: 13,
fontWeight: "bold"
fontWeight: 'bold',
},
},
}
}),
navigationOptions: ({navigation}) => ({
title: I18n.t('CREDIT_MANAGE'),
headerMode: "none",
headerMode: 'none',
header: null,
headerTitle: null,
drawerIcon: ({tintColor}) => (
<Icon
name={'credit-card'}
size={24}
/>)
/>),
}),
},
creditrequest: HistoryRequester,
@ -230,25 +231,25 @@ const AppSuperAdministrator = createDrawerNavigator({
superviseurgroup: SuperViseurGroupeHome,
notificationview: Notifications,
configuration: Configurations,
about: About
about: About,
})
}),
}, {
contentComponent: OptionsMenu,
backBehavior: "none",
headerMode: 'none'
})
backBehavior: 'none',
headerMode: 'none',
});
export const AppNavigator = createSwitchNavigator({
first: {
screen: SplashScreen
screen: SplashScreen,
},
App: AppStack,
AgentApp: AppAgentStack,
adminApp: AppAdministratorStack,
supAdminApp: AppSuperAdministrator,
Auth: AuthStack
Auth: AuthStack,
}, {
initialRouteName: 'first'
initialRouteName: 'first',
});
const AppContainer = createAppContainer(AppNavigator);

6327
yarn.lock

File diff suppressed because it is too large Load Diff