99 SHOW_MODAL
1010} from "./types" ;
1111import { parseApiError } from "../utils/parseApiError" ;
12+ import { getGatewayApplicationWallet } from "./gateway-wallet" ;
1213
1314
1415export const fetchGatewayApplications = ( offset = 0 , limit = 10 ) => async dispatch => {
@@ -31,14 +32,14 @@ export const saveGatewayApplication = formValues => async (dispatch) => {
3132 await dispatch ( apiPost ( getGatewayApplicationsPath ( ) , formValues ) ) ;
3233} ;
3334
34- export const fetchGatewayApplicationDetails = ( id ) => async dispatch => {
35+ export const fetchGatewayApplicationDetailsFromApi = ( id ) => async dispatch => {
3536 dispatch ( { type : SET_GATEWAY_APPLICATION_SET , payload : { id, loading : true } } ) ;
3637
3738 try {
3839 const gateway = await dispatch ( apiGet ( getGatewayApplicationsPath ( id ) ) ) ;
39- const wallets = await dispatch ( getGatewayApplicationWallet ( id ) ) ;
40+
4041 const error = '' ;
41- const payload = { id, gateway, wallets , error, loading : false } ;
42+ const payload = { id, gateway, error, loading : false } ;
4243 dispatch ( { type : SET_GATEWAY_APPLICATION_SET , payload } ) ;
4344
4445 } catch ( e ) {
@@ -50,6 +51,11 @@ export const fetchGatewayApplicationDetails = (id) => async dispatch => {
5051 }
5152} ;
5253
54+ export const fetchGatewayApplicationDetails = ( id ) => async dispatch => {
55+ dispatch ( fetchGatewayApplicationDetailsFromApi ( id ) ) ;
56+ dispatch ( getGatewayApplicationWallet ( id ) ) ;
57+ } ;
58+
5359export const removeGatewayApplication = ( id ) => async dispatch => {
5460 try {
5561 await dispatch ( apiDelete ( getGatewayApplicationsPath ( ) + "?id=" + id , { } ) ) ;
@@ -59,23 +65,3 @@ export const removeGatewayApplication = (id) => async dispatch => {
5965 }
6066} ;
6167
62- export const getGatewayApplicationWallet = ( gatewayId ) => async dispatch => {
63- const wallets = await dispatch ( apiGet ( getGatewayApplicationWalletsPath ( gatewayId ) , { } ) ) ;
64- const error = '' ;
65- dispatch ( { type : SET_GATEWAY_APPLICATION_SET , payload : { gatewayId, wallets, error, loading : false } } ) ;
66- return wallets ;
67- } ;
68-
69- export const generateGatewayApplicationWallet = ( wallet , blockchain ) => async ( dispatch ) => {
70- await dispatch ( apiPost ( getGatewayApplicationWalletsPath ( ) , { applicationId : wallet . applicationId , webHook : wallet . webHook , blockchainType : blockchain . blockchain } ) ) ;
71- dispatch ( fetchGatewayApplicationDetails ( wallet . applicationId ) )
72- } ;
73-
74- export const removeGatewayApplicationWallet = ( gatewayId , address ) => async dispatch => {
75- try {
76- await dispatch ( apiDelete ( getGatewayApplicationWalletsPath ( ) + "?applicationId=" + gatewayId + "&address=" + address , { } ) ) ;
77- await dispatch ( fetchGatewayApplicationDetails ( gatewayId ) )
78- } catch ( e ) {
79- throw parseApiError ( e ) ;
80- }
81- } ;
0 commit comments