243 lines
9.3 KiB
JavaScript
243 lines
9.3 KiB
JavaScript
|
|
import axios from "axios";
|
|
import I18n from 'react-native-i18n';
|
|
import { store } from "../redux/store";
|
|
import { envoieUserWalletToWallet, envoieCommissionUrl } from "./IlinkConstants";
|
|
import { fetchEnvoieUserWalletToWalletPending, fetchEnvoieUserWalletToWalletSuccess, fetchEnvoieUserWalletToWalletError, fetchEnvoieUserWalletToCardGetCommissionError, fetchEnvoieUserWalletToWalletReset, fetchEnvoieUserWalletToWalleGetCommissiontPending, fetchEnvoieUserWalletToWalleGetCommissiontReset, fetchEnvoieUserWalletToWalletGetCommissionSuccess, fetchEnvoieUserWalletToWalletGetCommissionError, fetchEnvoieUserWalletToCashPending, fetchEnvoieUserWalletToCashSuccess, fetchEnvoieUserWalletToCashError, fetchEnvoieUserWalletToCashReset, fetchEnvoieUserWalletToCashGetCommissiontPending, fetchEnvoieUserWalletToCashGetCommissiontReset, fetchEnvoieUserWalletToCashGetCommissionError, fetchEnvoieUserWalletToCashGetCommissionSuccess, fetchEnvoieUserWalletToCardPending, fetchEnvoieUserWalletToCardSuccess, fetchEnvoieUserWalletToCardError, fetchEnvoieUserWalletToCardReset, fetchEnvoieUserWalletToCardGetCommissiontPending, fetchEnvoieUserWalletToCardGetCommissionSuccess, fetchEnvoieUserWalletToCardGetCommissiontReset } from "../redux/actions/EnvoieUserType";
|
|
|
|
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());
|
|
}
|
|
} |