Demande nano credit OK
This commit is contained in:
parent
5b0af68c08
commit
ce46111f09
4
App.js
4
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 } })
|
||||
|
|
|
@ -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
|
||||
|
@ -128,3 +161,41 @@ 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
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -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,
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -57,5 +57,6 @@
|
|||
"groupNanoCredit": "groupNanoCredit",
|
||||
"demandGroupNanoCreditDetail": "demandeValidationGroupe",
|
||||
"adhererGroupNanoCredit": "adhererGroupNanoCredit",
|
||||
"myNanoCreditGroup": "myNanoCreditGroup"
|
||||
"myNanoCreditGroup": "myNanoCreditGroup",
|
||||
"askNanoCredit": "askNanoCredit"
|
||||
}
|
||||
|
|
|
@ -1426,7 +1426,7 @@ class Home extends BaseScreen {
|
|||
translucent={true}
|
||||
/>
|
||||
{/* Start here to comment */}
|
||||
{
|
||||
{/* {
|
||||
(this.state.loadingDialog || this.props.loading) ?
|
||||
<View
|
||||
style={{ position: "absolute", zIndex: 1, backgroundColor: "#00000050", width: this.state.loadingDialog ? responsiveWidth(100) : 0, height: this.state.loadingDialog ? responsiveHeight(100) : 0, flex: 1, justifyContent: 'center', alignItems: 'center' }}
|
||||
|
@ -1462,7 +1462,7 @@ class Home extends BaseScreen {
|
|||
this.setState({ showProgress: false })
|
||||
Alert.alert(I18n.t("PROBLEM_OCCUR"), I18n.t("PROBLEM_OCCUR_DIRECTION"), [{ text: "Ok", onPress: () => { } }])
|
||||
}}
|
||||
/>
|
||||
/> */}
|
||||
{this.makeCardSearch()}
|
||||
{this.makeSlidingUp()}
|
||||
{this.makeDialogLoader()}
|
||||
|
|
|
@ -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 (
|
||||
<ProgressDialog
|
||||
visible={this.props.loading || this.props.loadingGetNanoCredit}
|
||||
title={I18n.t('LOADING')}
|
||||
message={I18n.t('LOADING_INFO')}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
{(this.props.loading || this.props.loadingGetNanoCredit || this.state.modalVisible) && this.renderLoader()}
|
||||
{this.state.isDataSubmit && this.renderCreateGroupReponse()}
|
||||
{!this.state.hasLoadDuration && this.renderGetDurationesponse()}
|
||||
<ScrollView style={styles.container}>
|
||||
|
||||
<Text style={styles.subbigtitle}>{I18n.t('DEMAND_NANO_CREDIT')}</Text>
|
||||
|
||||
<Animatable.View ref={(comp) => { this.typeCautionAnim = comp }}
|
||||
style={{
|
||||
width: responsiveWidth(90),
|
||||
height: 60,
|
||||
marginTop: 20,
|
||||
alignSelf: 'center',
|
||||
borderRadius: 10,
|
||||
paddingLeft: 20,
|
||||
paddingRight: 20,
|
||||
backgroundColor: 'white'
|
||||
}}>
|
||||
<Dropdown
|
||||
label={I18n.t('DEMAND_DURATION_IN_MONTH')}
|
||||
data={this.state.durations}
|
||||
useNativeDriver={true}
|
||||
value={this.state.durationSelect !== null ? this.state.durationSelect : ''}
|
||||
onChangeText={(value, index, data) => {
|
||||
this.setState({ durationSelect: value });
|
||||
}}
|
||||
valueExtractor={(value) => { return value.value }}
|
||||
labelExtractor={(value) => { return value.value }}
|
||||
/>
|
||||
</Animatable.View>
|
||||
|
||||
<Animatable.View ref={(comp) => { this.typeCautionAnim = comp }}
|
||||
style={{
|
||||
width: responsiveWidth(90),
|
||||
height: 60,
|
||||
marginTop: 20,
|
||||
alignSelf: 'center',
|
||||
borderRadius: 10,
|
||||
paddingLeft: 20,
|
||||
paddingRight: 20,
|
||||
backgroundColor: 'white'
|
||||
}}>
|
||||
<Dropdown
|
||||
label={I18n.t('CAUTION_TYPE')}
|
||||
data={this.state.typeCaution}
|
||||
useNativeDriver={true}
|
||||
value={this.state.typeCautionName}
|
||||
onChangeText={(value, index, data) => {
|
||||
if (value === I18n.t('INDIVIDUAL'))
|
||||
this.setState({ typeCautionName: 'individual' });
|
||||
else
|
||||
this.setState({ typeCautionName: 'groupe' })
|
||||
}}
|
||||
valueExtractor={(value) => { return value.name }}
|
||||
labelExtractor={(value) => { return value.name }}
|
||||
/>
|
||||
</Animatable.View>
|
||||
|
||||
<Animatable.View ref={(comp) => { this.montantAnim = comp }}>
|
||||
<Fumi iconClass={FontAwesomeIcon} iconName={'money'}
|
||||
label={I18n.t('AMOUNT')}
|
||||
iconColor={'#f95a25'}
|
||||
keyboardType='numeric'
|
||||
iconSize={20}
|
||||
value={this.state.montant}
|
||||
onChangeText={(montant) => {
|
||||
this.setState({ montant })
|
||||
}}
|
||||
style={styles.input}
|
||||
>
|
||||
</Fumi>
|
||||
<View style={{
|
||||
position: 'absolute',
|
||||
left: responsiveWidth(82),
|
||||
top: 35,
|
||||
flexDirection: 'row'
|
||||
}}>
|
||||
<View
|
||||
style={{
|
||||
width: 1,
|
||||
borderLeftColor: '#f0f0f0',
|
||||
height: 40,
|
||||
left: -8,
|
||||
top: -10,
|
||||
borderLeftWidth: 1,
|
||||
|
||||
}}
|
||||
/>
|
||||
<Text style={[Typography.body1, FontWeight.bold]}>{this.state.wallet.currency_code}</Text>
|
||||
</View>
|
||||
</Animatable.View>
|
||||
|
||||
<Animatable.View ref={(comp) => { this.passwordAnim = comp }}>
|
||||
<Fumi iconClass={FontAwesomeIcon} iconName={'lock'}
|
||||
label={I18n.t('PASSWORD')}
|
||||
iconColor={'#f95a25'}
|
||||
iconSize={20}
|
||||
secureTextEntry={true}
|
||||
value={this.state.password}
|
||||
onChangeText={(password) => {
|
||||
this.setState({ password })
|
||||
}}
|
||||
style={styles.input}
|
||||
>
|
||||
</Fumi>
|
||||
</Animatable.View>
|
||||
|
||||
<Button style={styles.btnvalide}
|
||||
textStyle={styles.textbtnvalide}
|
||||
onPress={() => { this.onSubmitSendWalletToCard(); }}>
|
||||
{I18n.t('SUBMIT_LABEL')}</Button>
|
||||
</ScrollView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
});
|
|
@ -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 {
|
|||
</View>
|
||||
</CardView>
|
||||
|
||||
{_.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()
|
||||
}
|
||||
</View>);
|
||||
}
|
||||
|
||||
renderError = () => {
|
||||
|
||||
const { errorGetUniqueDemand } = this.props;
|
||||
if (errorGetUniqueDemand !== null) {
|
||||
if (typeof errorGetUniqueDemand.data !== 'undefined') {
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
<Text style={Typography.body1}>{errorGetUniqueDemand.data.error}</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
<Text style={Typography.body1}>{errorGetUniqueDemand}</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log('MY PROPS', this.props);
|
||||
return (
|
||||
<Provider>
|
||||
<View style={{ flex: 1 }}
|
||||
|
@ -464,7 +487,10 @@ class MyNanoCreditGroup extends Component {
|
|||
this.renderLoader() :
|
||||
this.props.resultGetUniqueDemand != null ?
|
||||
this.renderDetail() :
|
||||
null
|
||||
this.props.errorGetUniqueDemand !== null ?
|
||||
this.renderError() :
|
||||
null
|
||||
|
||||
}
|
||||
</>
|
||||
</View>
|
||||
|
|
|
@ -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 (
|
||||
|
||||
<TouchableOpacity
|
||||
key={item.id}
|
||||
style={[styles.paymentItem, { borderBottomColor: Color.borderColor }]}
|
||||
onPress={() => this.props.navigation.navigate(item.data.screen, {
|
||||
id: item.data.data.id
|
||||
})}>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||
{/* <View style={styles.iconContent}>
|
||||
<Image style={{ width: 48, height: 48 }} source={{ uri: icon }} />
|
||||
</View> */}
|
||||
<View>
|
||||
<Text style={Typography.body1}>{item.message}</Text>
|
||||
<Text style={[Typography.footnote, Color.grayColor]} style={{ marginTop: 5 }}>
|
||||
{this.getCreationDateToHumanFormat(item.date)}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
}
|
||||
|
||||
renderNotificationList = () => {
|
||||
|
||||
const { result, error } = this.props;
|
||||
if (error !== null) {
|
||||
if (typeof error.data !== 'undefined') {
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
<Text style={Typography.body1}>{error.data.error}</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
<Text style={Typography.body1}>{error}</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
if (result !== null) {
|
||||
if (result.response !== null) {
|
||||
return (
|
||||
Array.isArray(result.response) && (result.response.length) > 0 ?
|
||||
(<ScrollView style={{ flex: 1, padding: 20 }}>
|
||||
{
|
||||
result.response.map((item) => (
|
||||
this.renderNotificationItem(item)
|
||||
))
|
||||
}
|
||||
</ScrollView>) :
|
||||
(
|
||||
<View style={{ justifyContent: "center", alignItems: 'center', marginTop: 100 }}>
|
||||
|
||||
<LottieView
|
||||
style={styles.lottie}
|
||||
source={require("./../../datas/json/781-no-notifications.json")}
|
||||
autoPlay
|
||||
loop
|
||||
/>
|
||||
<Text style={styles.text}>{I18n.t('NO_NOTIFICATION')}</Text>
|
||||
</View>
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
renderLoader = () => {
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
|
@ -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 (
|
||||
<View style={styles.container}>
|
||||
|
@ -81,16 +195,12 @@ class Notifications extends BaseScreen {
|
|||
barStyle="light-content"
|
||||
translucent={false}
|
||||
/>
|
||||
<View style={{ justifyContent: "center", alignItems: 'center', marginTop: 100 }}>
|
||||
|
||||
<LottieView
|
||||
style={styles.lottie}
|
||||
source={require("./../../datas/json/781-no-notifications.json")}
|
||||
autoPlay
|
||||
loop
|
||||
/>
|
||||
<Text style={styles.text}>{I18n.t('NO_NOTIFICATION')}</Text>
|
||||
</View>
|
||||
{this.props.loading ?
|
||||
this.renderLoader() :
|
||||
this.renderNotificationList()
|
||||
}
|
||||
|
||||
</View>)
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
})
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -158,3 +159,79 @@ export const joinGroupReset = () => {
|
|||
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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue