Wallet Select OK
This commit is contained in:
parent
94a094317a
commit
ae2f2b91b9
22
index.js
22
index.js
|
@ -12,26 +12,4 @@ import axios from "axios";
|
||||||
YellowBox.ignoredYellowBox = ['Warning: Each', 'Warning: Failed'];
|
YellowBox.ignoredYellowBox = ['Warning: Each', 'Warning: Failed'];
|
||||||
console.disableYellowBox = true;
|
console.disableYellowBox = true;
|
||||||
|
|
||||||
getAuthToken = () => {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
|
|
||||||
try {
|
|
||||||
const data = await AsyncStorage.getItem('persist:root');
|
|
||||||
resolve(JSON.parse(data))
|
|
||||||
} catch (error) {
|
|
||||||
reject(error)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const authToken = await getAuthToken();
|
|
||||||
const auth = JSON.parse(authToken.authKeyReducer);
|
|
||||||
console.log("AUTHTOKEN", auth);
|
|
||||||
axios.defaults.headers.common['Authorization'] = `${auth.authKey.token_type} ${auth.authKey.access_token}`;
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
AppRegistry.registerComponent(appName, () => App);
|
AppRegistry.registerComponent(appName, () => App);
|
||||||
|
|
|
@ -25,6 +25,13 @@ export default (state = initialState, action) => {
|
||||||
error: action.result
|
error: action.result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case REHYDRATE: return {
|
||||||
|
...state,
|
||||||
|
loading: false,
|
||||||
|
authKey: action.payload.authKeyReducer.authKey,
|
||||||
|
error: null
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export default (state = initialState, action) => {
|
||||||
...state,
|
...state,
|
||||||
loading: false,
|
loading: false,
|
||||||
result: null,
|
result: null,
|
||||||
error: action.result,
|
error: action.result
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -12,8 +12,8 @@ const persistConfig = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const rootReducer = persistCombineReducers(persistConfig, {
|
const rootReducer = persistCombineReducers(persistConfig, {
|
||||||
wallet: walletReducer,
|
walletReducer: walletReducer,
|
||||||
authKey: authKeyReducer
|
authKeyReducer: authKeyReducer
|
||||||
});
|
});
|
||||||
|
|
||||||
export default rootReducer;
|
export default rootReducer;
|
|
@ -116,7 +116,6 @@ class Home extends BaseScreen {
|
||||||
let data = await this.loadingMarkers(this.state.myPosition, this.state.filternetwork, this.state.value)
|
let data = await this.loadingMarkers(this.state.myPosition, this.state.filternetwork, this.state.value)
|
||||||
this.treatNewData(pos, data, false)
|
this.treatNewData(pos, data, false)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug(e.message)
|
|
||||||
this.setState({ isNeedLoadMore: false, isLoadingMap: false })
|
this.setState({ isNeedLoadMore: false, isLoadingMap: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,15 +157,15 @@ class Home extends BaseScreen {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
AsyncStorage.getAllKeys((err, keys) => {
|
/* AsyncStorage.getAllKeys((err, keys) => {
|
||||||
AsyncStorage.multiGet(keys, (err, stores) => {
|
AsyncStorage.multiGet(keys, (err, stores) => {
|
||||||
stores.map((result, i, store) => {
|
stores.map((result, i, store) => {
|
||||||
let key = store[i][0];
|
let key = store[i][0];
|
||||||
let value = store[i][1];
|
let value = store[i][1];
|
||||||
console.log('STORAGE VALUE ', `key: ${key} | value: ${value}`);
|
console.log('STORAGE VALUE ', `key: ${key} | value: ${value}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}); */
|
||||||
|
|
||||||
this.mounted = true;
|
this.mounted = true;
|
||||||
this.configuration = new Configuration()
|
this.configuration = new Configuration()
|
||||||
|
@ -214,7 +213,6 @@ class Home extends BaseScreen {
|
||||||
)
|
)
|
||||||
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
||||||
readUser().then((user) => {
|
readUser().then((user) => {
|
||||||
console.log("MAP READY");
|
|
||||||
if (user) {
|
if (user) {
|
||||||
if (user.category !== undefined && user.category !== null) {
|
if (user.category !== undefined && user.category !== null) {
|
||||||
const myPosition = {
|
const myPosition = {
|
||||||
|
@ -251,10 +249,8 @@ class Home extends BaseScreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log("Camera permission granted")
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("Camera permission denied")
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
@ -320,14 +316,12 @@ class Home extends BaseScreen {
|
||||||
return item.name.includes(this.state.network);
|
return item.name.includes(this.state.network);
|
||||||
})
|
})
|
||||||
if (this.state.user.category === undefined || this.state.user.category === null) {
|
if (this.state.user.category === undefined || this.state.user.category === null) {
|
||||||
console.log(this.state.user)
|
|
||||||
if (c.length > 0 && pays) {
|
if (c.length > 0 && pays) {
|
||||||
|
|
||||||
this.setState({ filternetwork: c[0], myNetwork: c[0], filternetworkTemp: c[0] })
|
this.setState({ filternetwork: c[0], myNetwork: c[0], filternetworkTemp: c[0] })
|
||||||
this.retrieveAllPoint(pays)
|
this.retrieveAllPoint(pays)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("on getnetworks", result)
|
|
||||||
if (this.state.user) {
|
if (this.state.user) {
|
||||||
if (!this.state.user.category)
|
if (!this.state.user.category)
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
|
@ -352,7 +346,6 @@ class Home extends BaseScreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
console.log("error getnetwork" + e.message)
|
|
||||||
// Crashlytics.log("get networks"+e.message)
|
// Crashlytics.log("get networks"+e.message)
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
I18n.t("UNABLE_TO_CONNECT_TITLE"),
|
I18n.t("UNABLE_TO_CONNECT_TITLE"),
|
||||||
|
@ -1468,7 +1461,6 @@ class Home extends BaseScreen {
|
||||||
</View>)
|
</View>)
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
console.log("PROPS", this.props);
|
|
||||||
if (false) {
|
if (false) {
|
||||||
return this.renderBottomHome()
|
return this.renderBottomHome()
|
||||||
} else
|
} else
|
||||||
|
@ -2172,9 +2164,9 @@ class Home extends BaseScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
loading: state.loading,
|
loading: state.authKeyReducer.loading,
|
||||||
authKey: state.authKey,
|
authKey: state.authKeyReducer.authKey,
|
||||||
error: state.error
|
error: state.authKeyReducer.error
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => bindActionCreators({
|
const mapDispatchToProps = dispatch => bindActionCreators({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { StyleSheet, View, Image, StatusBar, ScrollView, TouchableOpacity, ActivityIndicator, Platform } from 'react-native';
|
import { StyleSheet, View, Image, StatusBar, ScrollView, TouchableOpacity, ActivityIndicator, Platform, ProgressBarAndroid, Text } from 'react-native';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
const route = require('./../../route.json');
|
const route = require('./../../route.json');
|
||||||
let slugify = require('slugify');
|
let slugify = require('slugify');
|
||||||
|
@ -16,109 +16,6 @@ import { connect } from 'react-redux';
|
||||||
import { readUser } from '../../webservice/AuthApi';
|
import { readUser } from '../../webservice/AuthApi';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
|
|
||||||
const card = [
|
|
||||||
{
|
|
||||||
id: "12",
|
|
||||||
name: "Canal +",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "14",
|
|
||||||
name: "Airtel Money",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "17",
|
|
||||||
name: "SEEG",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "19",
|
|
||||||
name: "Juba",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "77",
|
|
||||||
name: "Mobicash",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "82",
|
|
||||||
name: "Western Union",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "95",
|
|
||||||
name: "MoneyGram",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "100",
|
|
||||||
name: "Express Union",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "109",
|
|
||||||
name: "Money Express",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "118",
|
|
||||||
name: "UBA",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "135",
|
|
||||||
name: "Small World",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "158",
|
|
||||||
name: "Wari",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "171",
|
|
||||||
name: "Ria",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "184",
|
|
||||||
name: "Sigue",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "197",
|
|
||||||
name: "Ecobank",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "209",
|
|
||||||
name: "DHL",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "220",
|
|
||||||
name: "OraBank",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "223",
|
|
||||||
name: "Satcon",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "235",
|
|
||||||
name: "FINAM ",
|
|
||||||
countryId: "78"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "237",
|
|
||||||
name: "UBA fs ilink",
|
|
||||||
countryId: "78"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
class WalletSelect extends Component {
|
class WalletSelect extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -216,9 +113,9 @@ class WalletSelect extends Component {
|
||||||
<ScrollView style={{ flex: 1, padding: 20 }}>
|
<ScrollView style={{ flex: 1, padding: 20 }}>
|
||||||
{
|
{
|
||||||
result != null && (
|
result != null && (
|
||||||
result.map((item, index) => {
|
result.response.map((item, index) => (
|
||||||
this.renderWalletItem(item);
|
this.renderWalletItem(item)
|
||||||
})
|
))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -226,7 +123,7 @@ class WalletSelect extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log("Wallet Props", this.props);
|
console.log("WALLET PROPS", this.props);
|
||||||
return (
|
return (
|
||||||
<Provider>
|
<Provider>
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
|
@ -262,9 +159,9 @@ class WalletSelect extends Component {
|
||||||
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
loading: state.loading,
|
loading: state.walletReducer.loading,
|
||||||
result: state.result,
|
result: state.walletReducer.result,
|
||||||
error: state.error
|
error: state.walletReducer.error
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => bindActionCreators({
|
const mapDispatchToProps = dispatch => bindActionCreators({
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { store } from "../redux/store";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
const auth = store.getState().authKeyReducer;
|
||||||
|
|
||||||
|
console.log("STORE", auth);
|
||||||
|
|
||||||
|
const fetchQuery = axios.create({
|
||||||
|
timeout: 10000,
|
||||||
|
/* headers: {
|
||||||
|
'Authorization': auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : ''
|
||||||
|
} */
|
||||||
|
});
|
||||||
|
|
||||||
|
export default fetchQuery;
|
|
@ -1,25 +1,33 @@
|
||||||
import axios from "axios";
|
|
||||||
import { walletActionUrl } from "./IlinkConstants";
|
import { walletActionUrl } from "./IlinkConstants";
|
||||||
import { fetchWalletListPending, fetchWalletListSuccess, fetchWalletListError } from "../redux/actions/WalletActions";
|
import { fetchWalletListPending, fetchWalletListSuccess, fetchWalletListError } from "../redux/actions/WalletActions";
|
||||||
|
import fetchQuery from "./FetchQuery";
|
||||||
|
import { store } from "../redux/store";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const getWalletActivated = (userID) => {
|
const getWalletActivated = (userID) => {
|
||||||
|
|
||||||
|
const auth = store.getState().authKeyReducer;
|
||||||
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
||||||
|
|
||||||
|
console.log('AUTHKEY', authKey);
|
||||||
|
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(fetchWalletListPending());
|
dispatch(fetchWalletListPending());
|
||||||
|
|
||||||
axios.post(`${walletActionUrl}/${userID}/activated`)
|
axios({
|
||||||
|
url: `${walletActionUrl}/${userID}/activated`,
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Authorization': authKey
|
||||||
|
}
|
||||||
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
dispatch(fetchWalletListSuccess(response));
|
dispatch(fetchWalletListSuccess(response));
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
dispatch(fetchWalletListError(error.message));
|
dispatch(fetchWalletListError(error.message));
|
||||||
if (error.response)
|
|
||||||
dispatch(fetchWalletListError(error.response));
|
|
||||||
else if (error.request)
|
|
||||||
dispatch(fetchWalletListError(error.request))
|
|
||||||
else
|
|
||||||
dispatch(fetchWalletListError(error.message))
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue