311 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			311 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| import axios from "axios";
 | |
| import I18n from 'react-native-i18n';
 | |
| import {store} from "../redux/store";
 | |
| import {envoieCommissionUrl, envoieUserWalletToWallet} from "./IlinkConstants";
 | |
| import {
 | |
|     fetchEnvoieUserWalletToCardError,
 | |
|     fetchEnvoieUserWalletToCardGetCommissionError,
 | |
|     fetchEnvoieUserWalletToCardGetCommissionSuccess,
 | |
|     fetchEnvoieUserWalletToCardGetCommissiontPending,
 | |
|     fetchEnvoieUserWalletToCardGetCommissiontReset,
 | |
|     fetchEnvoieUserWalletToCardPending,
 | |
|     fetchEnvoieUserWalletToCardReset,
 | |
|     fetchEnvoieUserWalletToCardSuccess,
 | |
|     fetchEnvoieUserWalletToCashError,
 | |
|     fetchEnvoieUserWalletToCashGetCommissionError,
 | |
|     fetchEnvoieUserWalletToCashGetCommissionSuccess,
 | |
|     fetchEnvoieUserWalletToCashGetCommissiontPending,
 | |
|     fetchEnvoieUserWalletToCashGetCommissiontReset,
 | |
|     fetchEnvoieUserWalletToCashPending,
 | |
|     fetchEnvoieUserWalletToCashReset,
 | |
|     fetchEnvoieUserWalletToCashSuccess,
 | |
|     fetchEnvoieUserWalletToWalleGetCommissiontPending,
 | |
|     fetchEnvoieUserWalletToWalleGetCommissiontReset,
 | |
|     fetchEnvoieUserWalletToWalletError,
 | |
|     fetchEnvoieUserWalletToWalletGetCommissionError,
 | |
|     fetchEnvoieUserWalletToWalletGetCommissionSuccess,
 | |
|     fetchEnvoieUserWalletToWalletPending,
 | |
|     fetchEnvoieUserWalletToWalletReset,
 | |
|     fetchEnvoieUserWalletToWalletSuccess
 | |
| } from "../redux/actions/EnvoieUserType";
 | |
| import {
 | |
|     fetchEnvoieWalletToBankUserError,
 | |
|     fetchEnvoieWalletToBankUserPending,
 | |
|     fetchEnvoieWalletToBankUserReset,
 | |
|     fetchEnvoieWalletToBankUserSucsess
 | |
| } from "../redux/actions/BankAction";
 | |
| 
 | |
| export const envoieUserWalletToWalletAction = (data) => {
 | |
| 
 | |
|     const auth = store.getState().authKeyReducer;
 | |
|     const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToWalletPending());
 | |
| 
 | |
|         axios({
 | |
|             url: `${envoieUserWalletToWallet}`,
 | |
|             method: 'POST',
 | |
|             data,
 | |
|             headers: {
 | |
|                 'Authorization': authKey,
 | |
|                 'X-Localization': I18n.currentLocale()
 | |
|             }
 | |
|         })
 | |
|             .then(response => {
 | |
|                 console.log(response);
 | |
|                 dispatch(fetchEnvoieUserWalletToWalletSuccess(response));
 | |
|             })
 | |
|             .catch(error => {
 | |
|                 if (error.response)
 | |
|                     dispatch(fetchEnvoieUserWalletToWalletError(error.response));
 | |
|                 else if (error.request)
 | |
|                     dispatch(fetchEnvoieUserWalletToWalletError(error.request))
 | |
|                 else
 | |
|                     dispatch(fetchEnvoieUserWalletToWalletError(error.message))
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const envoieUserWalletToWalletReset = () => {
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToWalletReset());
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const getCommissionUserWalletToWalletAction = (data) => {
 | |
| 
 | |
|     const auth = store.getState().authKeyReducer;
 | |
|     const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToWalleGetCommissiontPending());
 | |
| 
 | |
|         axios({
 | |
|             url: `${envoieCommissionUrl}`,
 | |
|             method: 'POST',
 | |
|             data,
 | |
|             headers: {
 | |
|                 'Authorization': authKey,
 | |
|                 'X-Localization': I18n.currentLocale()
 | |
|             }
 | |
|         })
 | |
|             .then(response => {
 | |
|                 console.log(response);
 | |
|                 dispatch(fetchEnvoieUserWalletToWalletGetCommissionSuccess(response));
 | |
|             })
 | |
|             .catch(error => {
 | |
|                 if (error.response)
 | |
|                     dispatch(fetchEnvoieUserWalletToWalletGetCommissionError(error.response));
 | |
|                 else if (error.request)
 | |
|                     dispatch(fetchEnvoieUserWalletToWalletGetCommissionError(error.request))
 | |
|                 else
 | |
|                     dispatch(fetchEnvoieUserWalletToWalletGetCommissionError(error.message))
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const getCommissionUserWalletToWalletReset = () => {
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToWalleGetCommissiontReset());
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| /**
 | |
|  * -------------------------------------------------------
 | |
|  */
 | |
| 
 | |
| export const envoieUserWalletToCashAction = (data) => {
 | |
| 
 | |
|     const auth = store.getState().authKeyReducer;
 | |
|     const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCashPending());
 | |
| 
 | |
|         axios({
 | |
|             url: `${envoieUserWalletToWallet}`,
 | |
|             method: 'POST',
 | |
|             data,
 | |
|             headers: {
 | |
|                 'Authorization': authKey,
 | |
|                 'X-Localization': I18n.currentLocale()
 | |
|             }
 | |
|         })
 | |
|             .then(response => {
 | |
|                 console.log(response);
 | |
|                 dispatch(fetchEnvoieUserWalletToCashSuccess(response));
 | |
|             })
 | |
|             .catch(error => {
 | |
|                 if (error.response)
 | |
|                     dispatch(fetchEnvoieUserWalletToCashError(error.response));
 | |
|                 else if (error.request)
 | |
|                     dispatch(fetchEnvoieUserWalletToCashError(error.request))
 | |
|                 else
 | |
|                     dispatch(fetchEnvoieUserWalletToCashError(error.message))
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const envoieUserWalletToCashReset = () => {
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCashReset());
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const getCommissionUserWalletToCashAction = (data) => {
 | |
| 
 | |
|     const auth = store.getState().authKeyReducer;
 | |
|     const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCashGetCommissiontPending());
 | |
| 
 | |
|         axios({
 | |
|             url: `${envoieCommissionUrl}`,
 | |
|             method: 'POST',
 | |
|             data,
 | |
|             headers: {
 | |
|                 'Authorization': authKey,
 | |
|                 'X-Localization': I18n.currentLocale()
 | |
|             }
 | |
|         })
 | |
|             .then(response => {
 | |
|                 console.log(response);
 | |
|                 dispatch(fetchEnvoieUserWalletToCashGetCommissionSuccess(response));
 | |
|             })
 | |
|             .catch(error => {
 | |
|                 if (error.response)
 | |
|                     dispatch(fetchEnvoieUserWalletToCashGetCommissionError(error.response));
 | |
|                 else if (error.request)
 | |
|                     dispatch(fetchEnvoieUserWalletToCashGetCommissionError(error.request))
 | |
|                 else
 | |
|                     dispatch(fetchEnvoieUserWalletToCashGetCommissionError(error.message))
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const getCommissionUserWalletToCashReset = () => {
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCashGetCommissiontReset());
 | |
|     }
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * -------------------------------------------------------
 | |
|  */
 | |
| 
 | |
| export const envoieUserWalletToCardAction = (data) => {
 | |
| 
 | |
|     const auth = store.getState().authKeyReducer;
 | |
|     const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCardPending());
 | |
| 
 | |
|         axios({
 | |
|             url: `${envoieUserWalletToWallet}`,
 | |
|             method: 'POST',
 | |
|             data,
 | |
|             headers: {
 | |
|                 'Authorization': authKey,
 | |
|                 'X-Localization': I18n.currentLocale()
 | |
|             }
 | |
|         })
 | |
|             .then(response => {
 | |
|                 console.log(response);
 | |
|                 dispatch(fetchEnvoieUserWalletToCardSuccess(response));
 | |
|             })
 | |
|             .catch(error => {
 | |
|                 if (error.response)
 | |
|                     dispatch(fetchEnvoieUserWalletToCardError(error.response));
 | |
|                 else if (error.request)
 | |
|                     dispatch(fetchEnvoieUserWalletToCardError(error.request))
 | |
|                 else
 | |
|                     dispatch(fetchEnvoieUserWalletToCardError(error.message))
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const envoieUserWalletToCardReset = () => {
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCardReset());
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const getCommissionUserWalletToCardAction = (data) => {
 | |
| 
 | |
|     const auth = store.getState().authKeyReducer;
 | |
|     const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCardGetCommissiontPending());
 | |
| 
 | |
|         axios({
 | |
|             url: `${envoieCommissionUrl}`,
 | |
|             method: 'POST',
 | |
|             data,
 | |
|             headers: {
 | |
|                 'Authorization': authKey,
 | |
|                 'X-Localization': I18n.currentLocale()
 | |
|             }
 | |
|         })
 | |
|             .then(response => {
 | |
|                 console.log(response);
 | |
|                 dispatch(fetchEnvoieUserWalletToCardGetCommissionSuccess(response));
 | |
|             })
 | |
|             .catch(error => {
 | |
|                 if (error.response)
 | |
|                     dispatch(fetchEnvoieUserWalletToCardGetCommissionError(error.response));
 | |
|                 else if (error.request)
 | |
|                     dispatch(fetchEnvoieUserWalletToCardGetCommissionError(error.request))
 | |
|                 else
 | |
|                     dispatch(fetchEnvoieUserWalletToCardGetCommissionError(error.message))
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const getCommissionUserWalletToCardReset = () => {
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieUserWalletToCardGetCommissiontReset());
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const envoieUserWalletToBankAction = (data) => {
 | |
| 
 | |
|     const auth = store.getState().authKeyReducer;
 | |
|     const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieWalletToBankUserPending());
 | |
| 
 | |
|         axios({
 | |
|             url: `${envoieUserWalletToWallet}`,
 | |
|             method: 'POST',
 | |
|             data,
 | |
|             headers: {
 | |
|                 'Authorization': authKey,
 | |
|                 'X-Localization': I18n.currentLocale()
 | |
|             }
 | |
|         })
 | |
|             .then(response => {
 | |
|                 console.log(response);
 | |
|                 dispatch(fetchEnvoieWalletToBankUserSucsess(response));
 | |
|             })
 | |
|             .catch(error => {
 | |
|                 if (error.response)
 | |
|                     dispatch(fetchEnvoieWalletToBankUserError(error.response));
 | |
|                 else if (error.request)
 | |
|                     dispatch(fetchEnvoieWalletToBankUserError(error.request))
 | |
|                 else
 | |
|                     dispatch(fetchEnvoieWalletToBankUserError(error.message))
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const envoieUserWalletToBankReset = () => {
 | |
|     return dispatch => {
 | |
|         dispatch(fetchEnvoieWalletToBankUserReset());
 | |
|     }
 | |
| } |