GatewayFetchButton.js
37 lines
| 1 | import withSelectGateways from '../hooks/withSelectGateways'; |
| 2 | import FetchApiButton from '../../actions/components/FetchApiButton'; |
| 3 | |
| 4 | const { compose } = wp.compose; |
| 5 | |
| 6 | const { |
| 7 | withSelect, |
| 8 | } = wp.data; |
| 9 | |
| 10 | function GatewayFetchButton( { |
| 11 | initialLabel = 'Valid', |
| 12 | label = 'InValid', |
| 13 | apiArgs = {}, |
| 14 | gatewayRequestId, |
| 15 | loadingGateway, |
| 16 | onLoading = () => {}, |
| 17 | onSuccess = () => {}, |
| 18 | onFail = () => {}, |
| 19 | isHidden = false, |
| 20 | } ) { |
| 21 | |
| 22 | return <FetchApiButton |
| 23 | id={ gatewayRequestId } |
| 24 | loadingState={ loadingGateway } |
| 25 | initialLabel={ initialLabel } |
| 26 | label={ label } |
| 27 | apiArgs={ apiArgs } |
| 28 | onFail={ onFail } |
| 29 | onLoading={ onLoading } |
| 30 | onSuccess={ onSuccess } |
| 31 | isHidden={ isHidden } |
| 32 | />; |
| 33 | } |
| 34 | |
| 35 | export default compose( |
| 36 | withSelect( withSelectGateways ), |
| 37 | )( GatewayFetchButton ); |