github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/build-blockchain-insurance-app-master/web/src/police/actions/policeActions.js (about) 1 'use strict'; 2 3 import * as PoliceShopActionType from './policeActionTypes'; 4 import * as Api from '../api'; 5 6 export function loadTheftClaims() { 7 return async dispatch => { 8 let theftClaims; 9 try { 10 theftClaims = await Api.listTheftClaims(); 11 } catch (e) { 12 console.log(e); 13 } 14 if (Array.isArray(theftClaims)) { 15 dispatch(loadTheftClaimsSuccess(theftClaims)); 16 } 17 }; 18 } 19 20 function loadTheftClaimsSuccess(theftClaims) { 21 return { 22 type: PoliceShopActionType.LOAD_THEFT_CLAIMS_SUCCESS, 23 theftClaims 24 }; 25 } 26 27 export function processTheftClaim( 28 { contractUuid, uuid, isTheft, fileReference }) { 29 return async dispatch => { 30 try { 31 await Api.processTheftClaim(contractUuid, uuid, isTheft, fileReference); 32 dispatch(processTheftClaimSuccess(uuid)); 33 } catch (e) { 34 console.log(e); 35 } 36 }; 37 } 38 39 function processTheftClaimSuccess(uuid) { 40 return { 41 type: PoliceShopActionType.PROCESS_THEFT_CLAIM_SUCCESS, 42 uuid 43 }; 44 }