diff --git a/App.js b/App.js
index 9774a87d..3dd656e0 100644
--- a/App.js
+++ b/App.js
@@ -79,6 +79,7 @@ import DemandGroupNanoCreditDetail from './screens/nano-credit/DemandGroupNanoCr
import NavigationService from './utils/NavigationService';
import AdhererGroupNanoCredit from './screens/nano-credit/AdhererGroupNanoCredit';
import MyNanoCreditGroup from './screens/nano-credit/MyNanoCreditGroup';
+import AskNanoCredit from './screens/nano-credit/AskNanoCredit';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
@@ -190,7 +191,8 @@ const AppStack = createDrawerNavigator({
}),
},
demandeValidationGroupe: DemandGroupNanoCreditDetail,
- adhererGroupNanoCredit: AdhererGroupNanoCredit
+ adhererGroupNanoCredit: AdhererGroupNanoCredit,
+ askNanoCredit: AskNanoCredit
})
}, { contentComponent: OptionsMenu, headerMode: 'none', contentOptions: { activeTintColor: theme.accent } })
diff --git a/redux/actions/NanoCreditAction.js b/redux/actions/NanoCreditAction.js
index 9d31cac3..f3db1919 100644
--- a/redux/actions/NanoCreditAction.js
+++ b/redux/actions/NanoCreditAction.js
@@ -1,4 +1,37 @@
-import { CREATE_GROUP_PENDING, CREATE_GROUP_SUCCESS, CREATE_GROUP_ERROR, CREATE_GROUP_RESET, GET_DEMAND_GROUP_PENDING, GET_DEMAND_GROUP_SUCCESS, GET_DEMAND_GROUP_ERROR, GET_DEMAND_GROUP_RESET, GET_UNIQUE_DEMAND_GROUP_PENDING, GET_UNIQUE_DEMAND_GROUP_RESET, GET_UNIQUE_DEMAND_GROUP_ERROR, GET_UNIQUE_DEMAND_GROUP_SUCCESS, TREAT_DEMAND_GROUP_PENDING, TREAT_DEMAND_GROUP_SUCCESS, TREAT_DEMAND_GROUP_ERROR, TREAT_DEMAND_GROUP_RESET, JOIN_GROUP_PENDING, JOIN_GROUP_SUCCESS, JOIN_GROUP_RESET, JOIN_GROUP_ERROR, GET_USER_GROUP_DETAIL_PENDING, GET_USER_GROUP_DETAIL_SUCCESS, GET_USER_GROUP_DETAIL_RESET, GET_USER_GROUP_DETAIL_ERROR, GET_NOTIFICATIONS_ERROR, GET_NOTIFICATIONS_RESET, GET_NOTIFICATIONS_PENDING, GET_NOTIFICATIONS_SUCCESS } from "../types/NanoCreditType";
+import {
+ CREATE_GROUP_PENDING,
+ CREATE_GROUP_SUCCESS,
+ CREATE_GROUP_ERROR,
+ CREATE_GROUP_RESET,
+ GET_DEMAND_GROUP_PENDING,
+ GET_DEMAND_GROUP_SUCCESS,
+ GET_DEMAND_GROUP_ERROR,
+ GET_DEMAND_GROUP_RESET,
+ GET_UNIQUE_DEMAND_GROUP_PENDING,
+ GET_UNIQUE_DEMAND_GROUP_RESET,
+ GET_UNIQUE_DEMAND_GROUP_ERROR,
+ GET_UNIQUE_DEMAND_GROUP_SUCCESS,
+ TREAT_DEMAND_GROUP_PENDING,
+ TREAT_DEMAND_GROUP_SUCCESS,
+ TREAT_DEMAND_GROUP_ERROR,
+ TREAT_DEMAND_GROUP_RESET,
+ JOIN_GROUP_PENDING,
+ JOIN_GROUP_SUCCESS,
+ JOIN_GROUP_RESET,
+ JOIN_GROUP_ERROR,
+ GET_USER_GROUP_DETAIL_PENDING,
+ GET_USER_GROUP_DETAIL_SUCCESS,
+ GET_USER_GROUP_DETAIL_RESET,
+ GET_USER_GROUP_DETAIL_ERROR,
+ GET_NOTIFICATIONS_ERROR,
+ GET_NOTIFICATIONS_RESET,
+ GET_NOTIFICATIONS_PENDING,
+ GET_NOTIFICATIONS_SUCCESS, ASK_NANO_CREDIT_PENDING, ASK_NANO_CREDIT_SUCCESS, ASK_NANO_CREDIT_ERROR, ASK_NANO_CREDIT_RESET,
+ GET_NANO_CREDIT_DEMAND_DURATION_PENDING,
+ GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS,
+ GET_NANO_CREDIT_DEMAND_DURATION_ERROR,
+ GET_NANO_CREDIT_DEMAND_DURATION_RESET
+} from "../types/NanoCreditType";
export const fetchCreateGroupPending = () => ({
type: CREATE_GROUP_PENDING
@@ -127,4 +160,42 @@ export const fetchGetNotificationError = (error) => ({
export const fetchGetNotificationReset = () => ({
type: GET_NOTIFICATIONS_RESET
+});
+
+
+export const fetchAskNanoCreditPending = () => ({
+ type: ASK_NANO_CREDIT_PENDING
+});
+
+export const fetchAskNanoCreditSuccess = (res) => ({
+ type: ASK_NANO_CREDIT_SUCCESS,
+ result: res,
+});
+
+export const fetchAskNanoCreditError = (error) => ({
+ type: ASK_NANO_CREDIT_ERROR,
+ result: error
+});
+
+export const fetchAskNanoCreditReset = () => ({
+ type: ASK_NANO_CREDIT_RESET
+});
+
+
+export const fetchGetNanoCreditDemandDurationPending = () => ({
+ type: GET_NANO_CREDIT_DEMAND_DURATION_PENDING
+});
+
+export const fetchGetNanoCreditDemandDurationSuccess = (res) => ({
+ type: GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS,
+ result: res,
+});
+
+export const fetchGetNanoCreditDemandDurationError = (error) => ({
+ type: GET_NANO_CREDIT_DEMAND_DURATION_ERROR,
+ result: error
+});
+
+export const fetchGetNanoCreditDemandDurationReset = () => ({
+ type: GET_NANO_CREDIT_DEMAND_DURATION_RESET
});
\ No newline at end of file
diff --git a/redux/reducers/AskNanoCreditReducer.js b/redux/reducers/AskNanoCreditReducer.js
new file mode 100644
index 00000000..42cba5f1
--- /dev/null
+++ b/redux/reducers/AskNanoCreditReducer.js
@@ -0,0 +1,33 @@
+import { ASK_NANO_CREDIT_PENDING, ASK_NANO_CREDIT_SUCCESS, ASK_NANO_CREDIT_ERROR, ASK_NANO_CREDIT_RESET } from "../types/NanoCreditType";
+
+const initialState = {
+ loading: false,
+ result: null,
+ error: null
+};
+
+export default (state = initialState, action) => {
+ switch (action.type) {
+ case ASK_NANO_CREDIT_PENDING: return {
+ ...state,
+ loading: true
+ }
+ case ASK_NANO_CREDIT_SUCCESS: return {
+ ...state,
+ loading: false,
+ result: action.result.data,
+ error: null
+ }
+ case ASK_NANO_CREDIT_ERROR: return {
+ ...state,
+ loading: false,
+ result: null,
+ error: action.result
+ }
+ case ASK_NANO_CREDIT_RESET: return initialState;
+
+ default: {
+ return state;
+ }
+ }
+};
diff --git a/redux/reducers/GetNanoCreditDemandDurationReducer.js b/redux/reducers/GetNanoCreditDemandDurationReducer.js
new file mode 100644
index 00000000..ede90c1e
--- /dev/null
+++ b/redux/reducers/GetNanoCreditDemandDurationReducer.js
@@ -0,0 +1,33 @@
+import { GET_NANO_CREDIT_DEMAND_DURATION_PENDING, GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS, GET_NANO_CREDIT_DEMAND_DURATION_ERROR, GET_NANO_CREDIT_DEMAND_DURATION_RESET } from "../types/NanoCreditType";
+
+const initialState = {
+ loading: false,
+ result: null,
+ error: null
+};
+
+export default (state = initialState, action) => {
+ switch (action.type) {
+ case GET_NANO_CREDIT_DEMAND_DURATION_PENDING: return {
+ ...state,
+ loading: true
+ }
+ case GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS: return {
+ ...state,
+ loading: false,
+ result: action.result.data,
+ error: null
+ }
+ case GET_NANO_CREDIT_DEMAND_DURATION_ERROR: return {
+ ...state,
+ loading: false,
+ result: null,
+ error: action.result
+ }
+ case GET_NANO_CREDIT_DEMAND_DURATION_RESET: return initialState;
+
+ default: {
+ return state;
+ }
+ }
+};
diff --git a/redux/reducers/index.js b/redux/reducers/index.js
index de4731fb..26791f6f 100644
--- a/redux/reducers/index.js
+++ b/redux/reducers/index.js
@@ -32,6 +32,8 @@ import TreatDemandGroupReducer from "./TreatDemandGroupReducer";
import JoinGroupReducer from "./JoinGroupReducer";
import GetUserGroupDetailReducer from "./GetUserGroupDetailReducer";
import GetNotificationReducer from "./GetNotificationReducer";
+import AskNanoCreditReducer from "./AskNanoCreditReducer";
+import GetNanoCreditDemandDurationReducer from "./GetNanoCreditDemandDurationReducer";
const persistConfig = {
key: 'root',
@@ -73,7 +75,9 @@ const rootReducer = persistCombineReducers(persistConfig, {
treatDemandGroupReducer: TreatDemandGroupReducer,
joinGroupReducer: JoinGroupReducer,
getUserGroupDetailReducer: GetUserGroupDetailReducer,
- getNotificationReducer: GetNotificationReducer
+ getNotificationReducer: GetNotificationReducer,
+ askNanoCreditReducer: AskNanoCreditReducer,
+ getNanoCreditDemandDurationReducer: GetNanoCreditDemandDurationReducer,
});
diff --git a/redux/types/NanoCreditType.js b/redux/types/NanoCreditType.js
index 4955de95..b178d33b 100644
--- a/redux/types/NanoCreditType.js
+++ b/redux/types/NanoCreditType.js
@@ -32,3 +32,13 @@ export const GET_NOTIFICATIONS_PENDING = 'GET_NOTIFICATIONS_PENDING';
export const GET_NOTIFICATIONS_SUCCESS = 'GET_NOTIFICATIONS_SUCCESS';
export const GET_NOTIFICATIONS_ERROR = 'GET_NOTIFICATIONS_ERROR';
export const GET_NOTIFICATIONS_RESET = 'GET_NOTIFICATIONS_RESET';
+
+export const ASK_NANO_CREDIT_PENDING = 'ASK_NANO_CREDIT_PENDING';
+export const ASK_NANO_CREDIT_SUCCESS = 'ASK_NANO_CREDIT_SUCCESS';
+export const ASK_NANO_CREDIT_ERROR = 'ASK_NANO_CREDIT_ERROR';
+export const ASK_NANO_CREDIT_RESET = 'ASK_NANO_CREDIT_RESET';
+
+export const GET_NANO_CREDIT_DEMAND_DURATION_PENDING = 'GET_NANO_CREDIT_DEMAND_DURATION_PENDING';
+export const GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS = 'GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS';
+export const GET_NANO_CREDIT_DEMAND_DURATION_ERROR = 'GET_NANO_CREDIT_DEMAND_DURATION_ERROR';
+export const GET_NANO_CREDIT_DEMAND_DURATION_RESET = 'GET_NANO_CREDIT_DEMAND_DURATION_RESET';
diff --git a/route.json b/route.json
index 30c7041e..8cbbb59e 100644
--- a/route.json
+++ b/route.json
@@ -57,5 +57,6 @@
"groupNanoCredit": "groupNanoCredit",
"demandGroupNanoCreditDetail": "demandeValidationGroupe",
"adhererGroupNanoCredit": "adhererGroupNanoCredit",
- "myNanoCreditGroup": "myNanoCreditGroup"
+ "myNanoCreditGroup": "myNanoCreditGroup",
+ "askNanoCredit": "askNanoCredit"
}
diff --git a/screens/home/Home.js b/screens/home/Home.js
index 4cb32650..3c16a4c8 100644
--- a/screens/home/Home.js
+++ b/screens/home/Home.js
@@ -1426,7 +1426,7 @@ class Home extends BaseScreen {
translucent={true}
/>
{/* Start here to comment */}
- {
+ {/* {
(this.state.loadingDialog || this.props.loading) ?
{ } }])
}}
- />
+ /> */}
{this.makeCardSearch()}
{this.makeSlidingUp()}
{this.makeDialogLoader()}
diff --git a/screens/nano-credit/AskNanoCredit.js b/screens/nano-credit/AskNanoCredit.js
new file mode 100644
index 00000000..42ecb58f
--- /dev/null
+++ b/screens/nano-credit/AskNanoCredit.js
@@ -0,0 +1,468 @@
+import Button from 'apsl-react-native-button';
+import isEqual from 'lodash/isEqual';
+import isNil from 'lodash/isNil';
+import React, { Component } from 'react';
+import { Alert, ScrollView, StyleSheet, Text, View } from 'react-native';
+import * as Animatable from 'react-native-animatable';
+import I18n from 'react-native-i18n';
+import { responsiveHeight, responsiveWidth } from 'react-native-responsive-dimensions';
+import { ProgressDialog } from 'react-native-simple-dialogs';
+import { Fumi } from 'react-native-textinput-effects';
+import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import { Color } from '../../config/Color';
+import { FontWeight, Typography } from '../../config/typography';
+import { store } from "../../redux/store";
+import { IlinkEmitter } from '../../utils/events';
+import { readUser } from '../../webservice/AuthApi';
+import { typeCaution, isNormalInteger } from '../../utils/UtilsFunction';
+import { joinGroupAction, joinGroupReset, askNanoCreditAction, askNanoCreditReset, getNanoCreditDemandDurationAction, getNanoCreditDemandDurationReset } from '../../webservice/NanoCreditApi';
+import { Dropdown } from 'react-native-material-dropdown';
+let theme = require('../../utils/theme.json');
+let route = require('../../route.json');
+
+
+class AskNanoCredit extends Component {
+
+ static navigatorStyle = {
+ navBarBackgroundColor: Color.primaryColor,
+ statusBarColor: Color.primaryDarkColor,
+ navBarTextColor: '#FFFFFF',
+ navBarButtonColor: '#FFFFFF'
+
+ };
+
+ static navigationOptions = () => {
+ return {
+ drawerLabel: () => null,
+ headerTitle: I18n.t('DEMAND_NANO_CREDIT'),
+ headerTintColor: 'white',
+ headerStyle: {
+ backgroundColor: Color.primaryColor,
+ marginTop: 0,
+ color: 'white'
+ },
+ headerTitleStyle: {
+ color: "white"
+ },
+ title: I18n.t('DEMAND_NANO_CREDIT')
+ }
+ };
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ codeGroupe: null,
+ codeSponsor: null,
+ nomGroupe: null,
+ codeSponsor: null,
+ user: null,
+ montant: null,
+ password: null,
+ durations: [],
+ durationSelect: null,
+ triggerSubmitClick: false,
+ hasLoadDuration: false,
+ modalVisible: false,
+ isSubmitClick: false,
+ isDataSubmit: false,
+ isModalConfirmVisible: false,
+ typeCaution: typeCaution(),
+ typeCautionName: (typeCaution()[0]).name,
+ wallet: store.getState().walletDetailReducer.result.response
+ };
+
+ this.props.getNanoCreditDemandDurationReset();
+
+ readUser().then((user) => {
+ console.log("USER", user);
+ if (user) {
+ if (user !== undefined) {
+ this.props.getNanoCreditDemandDurationAction(user.id);
+ }
+ }
+ })
+
+ }
+
+ componentDidMount() {
+
+ readUser().then((user) => {
+ if (user) {
+ if (user !== undefined) {
+ this.setState({ user });
+ }
+ }
+ });
+
+ }
+
+ ckeckIfFieldIsOK(champ) {
+ return (isNil(champ) || isEqual(champ.length, 0));
+ }
+
+ isMontantValid = () => {
+ const { montant } = this.state;
+ if ((parseInt(isEqual(montant, 0)) || montant < 0))
+ return {
+ errorMessage: I18n.t('ENTER_AMOUNT_SUPERIOR_ZEROR'),
+ isValid: false
+ };
+
+ else if (!isNormalInteger(montant))
+ return {
+ errorMessage: I18n.t('ENTER_VALID_AMOUNT'),
+ isValid: false
+ };
+
+
+ else if (montant > parseInt(this.state.comptePrincipal))
+ return {
+ errorMessage: I18n.t('AMOUNT_SUPERIOR_TO_PRINCIPAL_ACCOUNT'),
+ isValid: false
+ };
+
+ else
+ return {
+ errorMessage: '',
+ isValid: true
+ };
+ }
+
+ renderGetDurationesponse = () => {
+ const { resultGetNanoCreditDuration, errorGetNanoCreditDuration } = this.props;
+ if (resultGetNanoCreditDuration !== null) {
+ if (typeof resultGetNanoCreditDuration.response !== 'undefined') {
+ if (resultGetNanoCreditDuration.response.length > 0) {
+ this.setState({
+ hasLoadDuration: true,
+ durations: resultGetNanoCreditDuration.response,
+ durationSelect: resultGetNanoCreditDuration.response[0].value,
+ modalVisible: false
+ });
+ }
+ else if (resultGetNanoCreditDuration.response.length === 0) {
+ this.setState({
+ hasLoadDuration: true,
+ durations: [],
+ durationSelect: '',
+ modalVisible: false
+ });
+ }
+ }
+ }
+
+ if (errorGetNanoCreditDuration !== null) {
+ if (typeof errorGetNanoCreditDuration.data !== 'undefined') {
+ Alert.alert(
+ I18n.t('ERROR_LABEL'),
+ errorGetNanoCreditDuration.data.error,
+ [
+ {
+ text: I18n.t("OK"), onPress: () => {
+ this.props.getNanoCreditDemandDurationReset();
+ }
+ }
+
+ ],
+ { cancelable: false }
+ )
+ } else {
+ Alert.alert(
+ I18n.t('ERROR_LABEL'),
+ JSON.stringify(errorGetNanoCreditDuration),
+ [
+ {
+ text: I18n.t("OK"), onPress: () => {
+ this.props.getNanoCreditDemandDurationReset();
+ }
+ }
+
+ ],
+ { cancelable: false }
+ )
+ }
+ }
+ }
+
+
+ renderCreateGroupReponse = () => {
+
+ const { result, error } = this.props;
+
+ if (error !== null) {
+ if (typeof error.data !== 'undefined') {
+ Alert.alert(
+ I18n.t("ERROR_JOIN_GROUP"),
+ error.data.error,
+ [
+ {
+ text: I18n.t("OK"), onPress: () => {
+ this.props.askNanoCreditReset();
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }
+
+ if (result !== null) {
+ if (result.response !== null) {
+ Alert.alert(
+ I18n.t("SUCCES_JOIN_GROUP"),
+ result.response,
+ [
+ {
+ text: I18n.t("OK"), onPress: () => {
+ this.props.askNanoCreditReset();
+ //IlinkEmitter.emit("treatNanoGroupDemand");
+ this.props.navigation.pop();
+ }
+ }
+
+ ],
+ { cancelable: false }
+ )
+ }
+ }
+ }
+
+ updateLangue() {
+ this.props.navigation.setParams({ name: I18n.t('DEPOSIT_TO_CARD') })
+ this.forceUpdate()
+ }
+
+
+ onSubmitSendWalletToCard = () => {
+ const { montant, typeCautionName, durationSelect } = this.state;
+
+ if (this.ckeckIfFieldIsOK(typeCautionName))
+ this.typeCautionAnim.shake(800);
+ else if (this.ckeckIfFieldIsOK(durationSelect))
+ this.typeCautionAnim.shake(800);
+ else if (this.ckeckIfFieldIsOK(montant) || !this.isMontantValid().isValid)
+ this.montantAnim.shake(800);
+ else {
+
+ this.props.askNanoCreditAction({
+ id_user: this.state.user.id,
+ type_caution: this.state.typeCautionName === I18n.t('GROUP') ? 'groupe' : 'individuel',
+ duree_mois: this.state.durationSelect,
+ montant: this.state.montant,
+ password: this.state.password
+ });
+
+ }
+ this.setState({
+ isDataSubmit: true
+ });
+ }
+
+
+ renderLoader = () => {
+ return (
+
+ )
+ }
+
+ render() {
+ return (
+ <>
+ {(this.props.loading || this.props.loadingGetNanoCredit || this.state.modalVisible) && this.renderLoader()}
+ {this.state.isDataSubmit && this.renderCreateGroupReponse()}
+ {!this.state.hasLoadDuration && this.renderGetDurationesponse()}
+
+
+ {I18n.t('DEMAND_NANO_CREDIT')}
+
+ { this.typeCautionAnim = comp }}
+ style={{
+ width: responsiveWidth(90),
+ height: 60,
+ marginTop: 20,
+ alignSelf: 'center',
+ borderRadius: 10,
+ paddingLeft: 20,
+ paddingRight: 20,
+ backgroundColor: 'white'
+ }}>
+ {
+ this.setState({ durationSelect: value });
+ }}
+ valueExtractor={(value) => { return value.value }}
+ labelExtractor={(value) => { return value.value }}
+ />
+
+
+ { this.typeCautionAnim = comp }}
+ style={{
+ width: responsiveWidth(90),
+ height: 60,
+ marginTop: 20,
+ alignSelf: 'center',
+ borderRadius: 10,
+ paddingLeft: 20,
+ paddingRight: 20,
+ backgroundColor: 'white'
+ }}>
+ {
+ if (value === I18n.t('INDIVIDUAL'))
+ this.setState({ typeCautionName: 'individual' });
+ else
+ this.setState({ typeCautionName: 'groupe' })
+ }}
+ valueExtractor={(value) => { return value.name }}
+ labelExtractor={(value) => { return value.name }}
+ />
+
+
+ { this.montantAnim = comp }}>
+ {
+ this.setState({ montant })
+ }}
+ style={styles.input}
+ >
+
+
+
+ {this.state.wallet.currency_code}
+
+
+
+ { this.passwordAnim = comp }}>
+ {
+ this.setState({ password })
+ }}
+ style={styles.input}
+ >
+
+
+
+
+
+ >
+ )
+ }
+}
+
+const maptStateToProps = state => ({
+
+ loading: state.askNanoCreditReducer.loading,
+ result: state.askNanoCreditReducer.result,
+ error: state.askNanoCreditReducer.error,
+
+ loadingGetNanoCreditDuration: state.getNanoCreditDemandDurationReducer.loading,
+ resultGetNanoCreditDuration: state.getNanoCreditDemandDurationReducer.result,
+ errorGetNanoCreditDuration: state.getNanoCreditDemandDurationReducer.error,
+});
+
+const mapDispatchToProps = dispatch => bindActionCreators({
+
+ askNanoCreditAction,
+ askNanoCreditReset,
+
+ getNanoCreditDemandDurationAction,
+ getNanoCreditDemandDurationReset
+
+}, dispatch);
+
+export default connect(maptStateToProps, mapDispatchToProps)(AskNanoCredit);
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: Color.primaryDarkColor,
+ },
+ textbtnvalide: {
+ color: 'white',
+ fontWeight: 'bold'
+ },
+ bigtitle: {
+ color: 'white',
+ fontSize: 20,
+ flex: 1,
+ fontWeight: 'bold',
+ textAlign: 'center',
+ margin: 20,
+ },
+ blockView: {
+ paddingVertical: 10,
+ borderBottomWidth: 1
+ },
+ subbigtitle: {
+ color: 'white',
+ fontSize: 17,
+ textAlign: 'center',
+ margin: 5,
+ },
+ btnvalide: {
+ marginTop: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ borderColor: 'transparent',
+ backgroundColor: Color.accentLightColor,
+ height: 52
+ },
+ btnSubmit: {
+ marginTop: 20,
+ borderColor: 'transparent',
+ backgroundColor: Color.accentLightColor,
+ height: 52,
+ width: "30%",
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ input: {
+ height: 60,
+ marginTop: responsiveHeight(2),
+ marginLeft: responsiveWidth(5),
+ marginRight: responsiveWidth(5),
+ borderRadius: 5,
+ }
+});
\ No newline at end of file
diff --git a/screens/nano-credit/MyNanoCreditGroup.js b/screens/nano-credit/MyNanoCreditGroup.js
index 5aa58eef..35f84205 100644
--- a/screens/nano-credit/MyNanoCreditGroup.js
+++ b/screens/nano-credit/MyNanoCreditGroup.js
@@ -22,7 +22,7 @@ import _ from 'lodash';
import { Color } from '../../config/Color'
const route = require("./../../route.json");
import Dialog from "react-native-dialog";
-import { FontWeight } from '../../config/typography'
+import { FontWeight, Typography } from '../../config/typography'
import DeviceInfo from 'react-native-device-info'
import { getNanoCreditUniqueDemandsAction, getNanoCreditUniqueDemandsReset, getUserGroupDetailAction, getUserGroupDetailReset } from '../../webservice/user/NanoCreditApi'
import { treatDemandGroupAction, treatDemandGroupReset, createGroupAction, createGroupReset } from '../../webservice/NanoCreditApi'
@@ -85,9 +85,9 @@ class MyNanoCreditGroup extends Component {
this.currentLocale = DeviceInfo.getDeviceLocale().includes("fr") ? "fr" : "en-gb";
moment.locale(this.currentLocale);
- this.props.getUserGroupDetailAction();
this.props.createGroupReset();
readUser().then((user) => {
+ console.log("USER", user);
if (user) {
if (user !== undefined) {
this.props.getUserGroupDetailAction(user.user_code);
@@ -432,12 +432,35 @@ class MyNanoCreditGroup extends Component {
- {_.isEqual(parseInt(this.state.user.id), resultGetUniqueDemand.response.id_createur) && this.renderBtn()}
+ {!_.isNil(this.state.user) &&
+ _.isEqual(parseInt(this.state.user.id), resultGetUniqueDemand.response.id_createur) &&
+ this.renderBtn()
+ }
);
}
+ renderError = () => {
+
+ const { errorGetUniqueDemand } = this.props;
+ if (errorGetUniqueDemand !== null) {
+ if (typeof errorGetUniqueDemand.data !== 'undefined') {
+ return (
+
+ {errorGetUniqueDemand.data.error}
+
+ )
+ }
+ else {
+ return (
+
+ {errorGetUniqueDemand}
+
+ )
+ }
+ }
+ }
+
render() {
- console.log('MY PROPS', this.props);
return (
diff --git a/screens/notifications/Notifications.js b/screens/notifications/Notifications.js
index a15da02a..07cbd2aa 100644
--- a/screens/notifications/Notifications.js
+++ b/screens/notifications/Notifications.js
@@ -1,15 +1,27 @@
-import React, { Component } from 'react'
-import { StyleSheet, Text, View, StatusBar, Platform, ProgressBarAndroid } from 'react-native'
-import BaseScreen from './../BaseScreen'
-import I18n from "react-native-i18n";
-import Icon from 'react-native-vector-icons/MaterialIcons'
import LottieView from 'lottie-react-native'; // if you have "esModuleInterop": true
-import { Header } from "react-native-elements";
-import { bindActionCreators } from 'redux';
-import { getNotificationAction, getNotificationReset } from '../../webservice/OnesignalApi';
+import 'moment/locale/en-au';
+import 'moment/locale/en-ca';
+import 'moment/locale/en-gb';
+import 'moment/locale/en-ie';
+import 'moment/locale/en-il';
+import 'moment/locale/en-nz';
+import 'moment/locale/es-us';
+import 'moment/locale/fr';
+import React from 'react';
+import { Platform, ProgressBarAndroid, ScrollView, StatusBar, StyleSheet, Text, View, TouchableOpacity } from 'react-native';
+import DeviceInfo from 'react-native-device-info';
+import I18n from "react-native-i18n";
+import Icon from 'react-native-vector-icons/MaterialIcons';
import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import { Color } from '../../config/Color';
+import { Typography } from '../../config/typography';
import { readUser } from '../../webservice/AuthApi';
-const theme = require('./../../utils/theme.json')
+import { getNotificationAction, getNotificationReset } from '../../webservice/OnesignalApi';
+import BaseScreen from './../BaseScreen';
+const theme = require('./../../utils/theme.json');
+let moment = require('moment-timezone');
+
class Notifications extends BaseScreen {
static navigatorStyle = {
navBarBackgroundColor: theme.primaryDark,
@@ -29,6 +41,8 @@ class Notifications extends BaseScreen {
};
constructor(props) {
super(props);
+ this.currentLocale = DeviceInfo.getDeviceLocale().includes("fr") ? "fr" : "en-gb";
+ moment.locale(this.currentLocale);
}
@@ -37,6 +51,121 @@ class Notifications extends BaseScreen {
this.forceUpdate()
}
+ componentDidMount() {
+
+ readUser().then((user) => {
+ if (user) {
+ if (user !== undefined) {
+ if (user.phone !== undefined) {
+ this.props.getNotificationAction({
+ user_code: user.user_code
+ });
+ }
+ }
+ }
+ });
+
+ }
+
+ getCreationDateToHumanFormat = (date) => {
+ let re = moment.tz(date, 'Etc/GMT+0').format();
+ return moment(re).fromNow();
+ }
+
+ getNotificationTypeIcon = (notification) => {
+ switch (notification) {
+ case 'creation': return 'account-multiple-plus';
+ case 'demandeSuppressionGroupe': return 'account-multiple-minus';
+ case 'adhesion': return 'account-multiple-check'
+ case 'nano_credit': return 'cash'
+ default: return 'account-multiple'
+ }
+ }
+
+ getDemandTypeColor = (type) => {
+ switch (type) {
+ case 'creation': return 'green';
+ case 'suppression': return 'red';
+ case 'adhesion': return Color.primaryColor
+ case 'nano_credit': return Color.primaryColor
+ default:
+ return Color.primaryColor
+ }
+ }
+
+
+ renderNotificationItem = (item) => {
+ return (
+
+ this.props.navigation.navigate(item.data.screen, {
+ id: item.data.data.id
+ })}>
+
+ {/*
+
+ */}
+
+ {item.message}
+
+ {this.getCreationDateToHumanFormat(item.date)}
+
+
+
+
+ )
+ }
+
+ renderNotificationList = () => {
+
+ const { result, error } = this.props;
+ if (error !== null) {
+ if (typeof error.data !== 'undefined') {
+ return (
+
+ {error.data.error}
+
+ )
+ }
+ else {
+ return (
+
+ {error}
+
+ )
+ }
+ }
+ if (result !== null) {
+ if (result.response !== null) {
+ return (
+ Array.isArray(result.response) && (result.response.length) > 0 ?
+ (
+ {
+ result.response.map((item) => (
+ this.renderNotificationItem(item)
+ ))
+ }
+ ) :
+ (
+
+
+
+ {I18n.t('NO_NOTIFICATION')}
+
+ )
+ )
+ }
+ }
+
+ }
+
renderLoader = () => {
return (
@@ -58,21 +187,6 @@ class Notifications extends BaseScreen {
)
}
- componentDidMount() {
-
- readUser().then((user) => {
- if (user) {
- if (user !== undefined) {
- if (user.phone !== undefined) {
- this.props.getNotificationAction({
- user_code: user.user_code
- });
- }
- }
- }
- });
-
- }
render() {
return (
@@ -81,16 +195,12 @@ class Notifications extends BaseScreen {
barStyle="light-content"
translucent={false}
/>
-
-
- {I18n.t('NO_NOTIFICATION')}
-
+ {this.props.loading ?
+ this.renderLoader() :
+ this.renderNotificationList()
+ }
+
)
}
}
@@ -121,4 +231,18 @@ const styles = StyleSheet.create({
width: 248,
height: 248
},
+ paymentItem: {
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between",
+ borderBottomWidth: 1,
+ paddingVertical: 5,
+ width: "100%",
+ marginBottom: 15
+ },
+ iconContent: {
+ width: 60,
+ marginRight: 10,
+ alignItems: "center"
+ }
})
\ No newline at end of file
diff --git a/utils/UtilsFunction.js b/utils/UtilsFunction.js
index cb883d2d..41bafb0b 100644
--- a/utils/UtilsFunction.js
+++ b/utils/UtilsFunction.js
@@ -80,6 +80,17 @@ export const identityPieces = () => {
]
}
+export const typeCaution = () => {
+ return [
+ {
+ name: I18n.t('GROUP')
+ },
+ {
+ name: I18n.t('INDIVIDUAL')
+ }
+ ]
+}
+
export const typeIdIDestinataire = () => {
return [
{
@@ -437,7 +448,7 @@ export const optionNanoCreditScreen = {
},
*/
{
- screen: "",
+ screen: route.askNanoCredit,
icon: 'cash',
title: I18n.t('MANAGE_CREDIT'),
},
diff --git a/utils/i18n/en.json b/utils/i18n/en.json
index f96d7f70..517fb4e8 100644
--- a/utils/i18n/en.json
+++ b/utils/i18n/en.json
@@ -113,6 +113,7 @@
"GROUP_CODE": "Group code",
"NOM_GROUP": "Group name",
"GROUP": "Group",
+ "INDIVIDUAL": "Individual",
"LIMIT_OF_CREDIT": "Credit limit",
"CODE_USER_ILINK_SPONSOR_1": "iLink user code sponsor 1",
"CODE_USER_ILINK_SPONSOR_2": "iLink user code sponsor 2",
@@ -138,6 +139,9 @@
"NANO_CREDIT_DESCRIPTION": "Nano credit description",
"NANO_SANTE": "Nano health",
"NANO_SANTE_DESCRIPTION": "Nano health description",
+ "CAUTION_TYPE": "Caution type",
+ "DEMAND_NANO_CREDIT": "Nano credit demand",
+ "DEMAND_DURATION_IN_MONTH": "Duration (in months)",
"PAIEMENT_FACTURE": "Bill payment",
"NUMERO_ABONNE": "Subscriber number",
"IDENTIFIANT_ETUDIANT": "Student ID",
diff --git a/utils/i18n/fr.json b/utils/i18n/fr.json
index 9325bd45..39c1aa8f 100644
--- a/utils/i18n/fr.json
+++ b/utils/i18n/fr.json
@@ -118,6 +118,7 @@
"SUCCES_JOIN_GROUP": "Adhésion réussie",
"NOM_GROUP": "Nom du groupe",
"GROUP": "Groupe",
+ "INDIVIDUAL": "Individuel",
"LIMIT_OF_CREDIT": "Limite du crédit",
"CODE_USER_ILINK_SPONSOR_1": "Code utilisateur iLink Sponsor 1",
"CODE_USER_ILINK_SPONSOR_2": "Code utilisateur iLink Sponsor 2",
@@ -144,6 +145,9 @@
"NANO_CREDIT_DESCRIPTION": "Nano crédit iLink",
"NANO_SANTE": "Nano santé",
"NANO_SANTE_DESCRIPTION": "Nano santé iLink",
+ "CAUTION_TYPE": "Type de caution",
+ "DEMAND_NANO_CREDIT": "Demande de nano crédit",
+ "DEMAND_DURATION_IN_MONTH": "Durée (en mois)",
"PAIEMENT_FACTURE": "Paiement de facture",
"NUMERO_ABONNE": "Numéro d'abonnée",
"IDENTIFIANT_ETUDIANT": "Identifiant étudiant",
diff --git a/webservice/IlinkConstants.js b/webservice/IlinkConstants.js
index 3efef024..b60990d0 100644
--- a/webservice/IlinkConstants.js
+++ b/webservice/IlinkConstants.js
@@ -49,13 +49,15 @@ export const otherPayCountryNetworkUrl = testBaseUrl + '/walletService/other_pay
export const envoieUserWalletToWallet = testBaseUrl + '/walletService/transactions/ilink';
export const envoieCommissionUrl = testBaseUrl + '/walletService/transactions/ilink/commission';
export const idVerificationUrl = testBaseUrl + '/walletService/transactions/ilink/check_retraits';
-export const getCreditDemand = testBaseUrl + '/walletService/groups/demands';
-
export const linkCardUrl = testBaseUrl + '/walletService/identifications/rattach_card';
+
+export const getCreditDemand = testBaseUrl + '/walletService/groups/demands';
export const groupUrl = testBaseUrl + '/walletService/groups';
export const treatDemandUrl = testBaseUrl + '/walletService/groups/demands/validate';
export const cancelDemandUrl = testBaseUrl + '/walletService/groups/demands/cancel';
+export const askNanoCreditUrl = testBaseUrl + '/walletService/groups/nanoCredit/ask';
export const joinGroupUrl = testBaseUrl + '/walletService/groups/join';
+export const getNanoCreditDemandDureationUrl = testBaseUrl + '/walletService/groups/nanoCredit/durations';
export const saveOnesignalIds = testBaseUrl + '/notificationService/onesignal';
export const getNotificationUrl = testBaseUrl + '/notificationService/notifications';
diff --git a/webservice/NanoCreditApi.js b/webservice/NanoCreditApi.js
index 3db61872..ebd4644f 100644
--- a/webservice/NanoCreditApi.js
+++ b/webservice/NanoCreditApi.js
@@ -1,9 +1,10 @@
import axios from "axios";
import I18n from 'react-native-i18n';
-import { fetchCreateGroupError, fetchCreateGroupPending, fetchCreateGroupReset, fetchCreateGroupSuccess, fetchTreatDemandsGroupPending, fetchTreatDemandsGroupSuccess, fetchTreatDemandsGroupError, fetchTreatDemandsGroupReset, fetchJoinGroupPending, fetchJoinGroupSuccess, fetchJoinGroupError, fetchJoinGroupReset } from "../redux/actions/NanoCreditAction";
+import { fetchCreateGroupError, fetchCreateGroupPending, fetchCreateGroupReset, fetchCreateGroupSuccess, fetchTreatDemandsGroupPending, fetchTreatDemandsGroupSuccess, fetchTreatDemandsGroupError, fetchTreatDemandsGroupReset, fetchJoinGroupPending, fetchJoinGroupSuccess, fetchJoinGroupError, fetchJoinGroupReset, fetchAskNanoCreditPending, fetchAskNanoCreditSuccess, fetchAskNanoCreditError, fetchAskNanoCreditReset, fetchGetNanoCreditDemandDurationPending, fetchGetNanoCreditDemandDurationSuccess, fetchGetNanoCreditDemandDurationError, fetchGetNanoCreditDemandDurationReset } from "../redux/actions/NanoCreditAction";
import { store } from "../redux/store";
-import { groupUrl, treatDemandUrl, joinGroupUrl, cancelDemandUrl } from "./IlinkConstants";
+import { groupUrl, getNanoCreditDemandDureationUrl, treatDemandUrl, joinGroupUrl, cancelDemandUrl, askNanoCreditUrl } from "./IlinkConstants";
+import AskNanoCreditReducer from "../redux/reducers/AskNanoCreditReducer";
/**
*
@@ -157,4 +158,80 @@ export const joinGroupReset = () => {
return dispatch => {
dispatch(fetchJoinGroupReset());
}
+}
+
+
+export const askNanoCreditAction = (data) => {
+
+ const auth = store.getState().authKeyReducer;
+ const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
+
+ return dispatch => {
+ dispatch(fetchAskNanoCreditPending());
+
+ axios({
+ url: `${askNanoCreditUrl}`,
+ method: 'POST',
+ data,
+ headers: {
+ 'Authorization': authKey,
+ 'X-Localization': I18n.currentLocale()
+ }
+ })
+ .then(response => {
+ console.log(response);
+ dispatch(fetchAskNanoCreditSuccess(response));
+ })
+ .catch(error => {
+ if (error.response)
+ dispatch(fetchAskNanoCreditError(error.response));
+ else if (error.request)
+ dispatch(fetchAskNanoCreditError(error.request))
+ else
+ dispatch(fetchAskNanoCreditError(error.message))
+ });
+ }
+}
+
+export const askNanoCreditReset = () => {
+ return dispatch => {
+ dispatch(fetchAskNanoCreditReset());
+ }
+}
+
+export const getNanoCreditDemandDurationAction = (id) => {
+
+ const auth = store.getState().authKeyReducer;
+ const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
+
+ return dispatch => {
+ dispatch(fetchGetNanoCreditDemandDurationPending());
+
+ axios({
+ url: `${getNanoCreditDemandDureationUrl}/${id}`,
+ method: 'GET',
+ headers: {
+ 'Authorization': authKey,
+ 'X-Localization': I18n.currentLocale()
+ }
+ })
+ .then(response => {
+ console.log(response);
+ dispatch(fetchGetNanoCreditDemandDurationSuccess(response));
+ })
+ .catch(error => {
+ if (error.response)
+ dispatch(fetchGetNanoCreditDemandDurationError(error.response));
+ else if (error.request)
+ dispatch(fetchGetNanoCreditDemandDurationError(error.request))
+ else
+ dispatch(fetchGetNanoCreditDemandDurationError(error.message))
+ });
+ }
+}
+
+export const getNanoCreditDemandDurationReset = () => {
+ return dispatch => {
+ dispatch(fetchGetNanoCreditDemandDurationReset());
+ }
}
\ No newline at end of file