import graphql from '../utils/graphql' ; param { String } id param { Object } args param { String } fields return { Object } export const addCaptcha = ( { id = new Date ( ) . getTime ( ) , args , fields = `success` } ) => { return ( dispatch , getState ) => { return new Promise ( async ( resolve , reject ) => { let accessToken = getState ( ) . user . accessToken || '' ; let [ err , res ] = await graphql ( { type : 'mutation' , apis : [ { api : 'addCaptcha' , args , fields } ] , headers : accessToken ? { 'accessToken' : accessToken } : { } } ) ; if ( res ) { if ( res . _id && res . url ) { dispatch ( { type : 'ADD_CAPTCHA_ID' , id , data : res } ) ; } resolve ( res ) ; } else { reject ( err ) ; } } ) ; } ; } ; param { string } id export const getCaptcha = ( args ) => { return ( dispatch , getState ) => { return new Promise ( async ( resolve , reject ) => { let [ err , res ] = await graphql ( { apis : [ { api : 'getCaptcha' , args , fields : `captcha` } ] } ) ; if ( err ) { reject ( err ) ; } else { resolve ( res ) ; } } ) ; } ; } ;