44 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| 
 | |
| import { transferCommission } from "./IlinkConstants";
 | |
| import { store } from "../redux/store";
 | |
| import axios from "axios";
 | |
| import I18n from 'react-native-i18n'
 | |
| import { fetchWalletTransferCommissionPending, fetchWalletTransferCommissionSuccess, fetchWalletTransferCommssionError, walletTransferCommissionReset } from "../redux/actions/WalletActions";
 | |
| 
 | |
| export const transferCommissionAction = (walletID) => {
 | |
| 
 | |
|      const auth = store.getState().authKeyReducer;
 | |
|      const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
 | |
| 
 | |
|      return dispatch => {
 | |
|           dispatch(fetchWalletTransferCommissionPending());
 | |
| 
 | |
|           axios({
 | |
|                url: `${transferCommission}/${walletID}`,
 | |
|                method: 'PUT',
 | |
|                headers: {
 | |
|                     'Authorization': authKey,
 | |
|                     'X-Localization': I18n.currentLocale()
 | |
|                }
 | |
|           })
 | |
|                .then(response => {
 | |
|                     console.log(response);
 | |
|                     dispatch(fetchWalletTransferCommissionSuccess(response));
 | |
|                })
 | |
|                .catch(error => {
 | |
|                     if (error.response)
 | |
|                          dispatch(fetchWalletTransferCommssionError(error.response));
 | |
|                     else if (error.request)
 | |
|                          dispatch(fetchWalletTransferCommssionError(error.request))
 | |
|                     else
 | |
|                          dispatch(fetchWalletTransferCommssionError(error.message))
 | |
|                });
 | |
|      }
 | |
| }
 | |
| 
 | |
| export const resetCommissionReducer = () => {
 | |
|      return dispatch => {
 | |
|           dispatch(walletTransferCommissionReset());
 | |
|      }
 | |
| }
 |