PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / src / package / gateways / hooks / withSelectGateways.js
jetformbuilder / assets / src / package / gateways / hooks Last commit date
withDispatchGateways.js 2 years ago withSelectGateways.js 2 years ago
withSelectGateways.js
66 lines
1 import gatewayAttr from '../helpers/gatewayAttr';
2 import gatewayLabel from '../helpers/gatewayLabel';
3 import globalTab from '../../actions/helpers/globalTab';
4
5 function withSelectGateways( select ) {
6 const store = select( 'jet-forms/gateways' );
7
8 const gatewayRequestId = store.getCurrentRequestId();
9 const gatewaySpecific = store.getGatewaySpecific();
10 const scenario = store.getScenario();
11
12 const CURRENT_GATEWAY = store.getGatewayId();
13 const { id: CURRENT_SCENARIO = 'PAY_NOW' } = scenario;
14
15 const {
16 use_global = false,
17 } = gatewaySpecific;
18
19 const currentTab = globalTab( { slug: CURRENT_GATEWAY } );
20
21 const getSpecificOrGlobal = ( key, ifEmpty = '' ) => {
22 return (
23 use_global ? (
24 currentTab[ key ] || ifEmpty
25 ) : (
26 gatewaySpecific[ key ] || ifEmpty
27 )
28 );
29 };
30
31 const callableGateway = gatewayAttr( 'additional' );
32 const additionalSourceGateway = callableGateway( CURRENT_GATEWAY );
33
34 const loadingGateway = select( 'jet-forms/actions' ).
35 getLoading( gatewayRequestId );
36
37 const globalGatewayLabel = gatewayAttr( 'labels' );
38 const specificGatewayLabel = gatewayLabel( CURRENT_GATEWAY );
39
40 const customGatewayLabel = function ( key ) {
41 return globalGatewayLabel( `${ CURRENT_GATEWAY }.${ key }` );
42 };
43 const scenarioLabel = function ( key ) {
44 return customGatewayLabel( `scenario.${ CURRENT_SCENARIO }.${ key }` );
45 };
46
47 return {
48 gatewayGeneral: store.getGateway(),
49 gatewayRequest: store.getCurrentRequest(),
50 scenarioSource: additionalSourceGateway[ CURRENT_SCENARIO ] || {},
51 currentScenario: scenario[ CURRENT_SCENARIO ] || {},
52 CURRENT_SCENARIO,
53 gatewayScenario: scenario,
54 additionalSourceGateway,
55 gatewaySpecific,
56 gatewayRequestId,
57 loadingGateway,
58 getSpecificOrGlobal,
59 globalGatewayLabel,
60 specificGatewayLabel,
61 customGatewayLabel,
62 scenarioLabel,
63 };
64 }
65
66 export default withSelectGateways;