"use strict";(self.webpackChunkgravityforms=self.webpackChunkgravityforms||[]).push([[376],{1154:function(n,e,t){t.r(e),t.d(e,{default:function(){return m}});var o,s=t(5518),i=t(191),c=t.n(i),r=t(2340),p=t.n(r),a=t(7329),d=t.n(a),l=(null===d()||void 0===d()||null===(o=d().components)||void 0===o?void 0:o.post_select)||{},u=function(n){var e=(0,s.getClosest)(n,".gform-settings-field"),t=n.dataset.postType,o=l[t],i=o.endpoints,r=o.data;p().instances.postSelects.push(new(c())({container:e.id,selector:"gform-settings-field-select",render:!1,renderListData:!0,searchType:"async",onItemSelect:function(n){return function(n,e){(0,s.getNodes)("gf-post-select-input",!0,e,!1)[0].value=n}(n,e)},baseUrl:i.get,endpoints:i,endpointKey:"get",endpointRequestOptions:{method:"GET"},endpointUseRest:!0,listData:r}))},f=function(n){!function(n){p().components.Dropdown||(p().components.Dropdown=c()),p().instances.postSelects=[],n.forEach((function(n){u(n)}))}(n)},m=function(n){f(n),(0,s.consoleInfo)("Gravity Forms Admin: Initialized post select dropdown component.")}}}]);import { Select2 } from '@elementor/app-ui';
/**
* Main component.
*
* @param {any} props
* @return {any} -
* @class
*/
export default function ConditionSubId( props ) {
if ( ! props.sub || ! Object.keys( props.subIdAutocomplete ).length ) {
return '';
}
const settings = React.useMemo( () => getSettings( props.subIdAutocomplete ), [ props.subIdAutocomplete ] );
const onChange = ( e ) => props.updateConditions( props.id, { subId: e.target.value } );
return (
);
}
/**
* Get settings for the select2 base on the autocomplete settings,
* that passes as a prop
*
* @param {any} autocomplete
* @return {Object} -
*/
function getSettings( autocomplete ) {
return {
allowClear: false,
placeholder: __( 'All', 'elementor-pro' ),
dir: elementorCommon.config.isRTL ? 'rtl' : 'ltr',
ajax: {
transport( params, success, failure ) {
return elementorCommon.ajax.addRequest( 'pro_panel_posts_control_filter_autocomplete', {
data: {
q: params.data.q,
autocomplete,
},
success,
error: failure,
} );
},
data( params ) {
return {
q: params.term,
page: params.page,
};
},
cache: true,
},
escapeMarkup( markup ) {
return markup;
},
minimumInputLength: 1,
};
}
ConditionSubId.propTypes = {
subIdAutocomplete: PropTypes.object,
id: PropTypes.string.isRequired,
sub: PropTypes.string,
subId: PropTypes.string,
updateConditions: PropTypes.func,
subIdOptions: PropTypes.array,
};
ConditionSubId.defaultProps = {
subId: '',
subIdOptions: [],
};
( function ( $ ) {
CartAbandonmentSettings = {
init() {
$( '#wcf_ca_custom_filter_from' )
.datepicker( {
dateFormat: 'yy-mm-dd',
maxDate: '0',
onClose( selectedDate ) {
jQuery( '#wcf_ca_custom_filter_to' ).datepicker(
'option',
'minDate',
selectedDate
);
},
} )
.attr( 'readonly', 'readonly' )
.css( 'background', 'white' );
$( '#wcf_ca_custom_filter_to' )
.datepicker( {
dateFormat: 'yy-mm-dd',
maxDate: '0',
onClose( selectedDate ) {
jQuery( '#wcf_ca_custom_filter_from' ).datepicker(
'option',
'maxDate',
selectedDate
);
},
} )
.attr( 'readonly', 'readonly' )
.css( 'background', 'white' );
$( '#wcf_ca_custom_filter' ).on( 'click', function () {
const from = $( '#wcf_ca_custom_filter_from' ).val().trim();
const to = $( '#wcf_ca_custom_filter_to' ).val().trim();
let url = window.location.search;
url =
url +
'&from_date=' +
from +
'&to_date=' +
to +
'&filter=custom';
window.location.href = url;
} );
$( '#wcf_search_id_submit' ).on( 'click', function () {
const search = $( '#wcf_search_id_search_input' ).val().trim();
window.location.href =
window.location.search + '&search_term=' + search;
} );
// Hide initially.
$(
'#wcf_ca_discount_type, #wcf_ca_coupon_amount, #wcf_ca_coupon_expiry, #wcf_ca_zapier_cart_abandoned_webhook, #wcf_ca_coupon_code_status, #wcf_ca_gdpr_message'
)
.closest( 'tr' )
.hide();
if ( $( '#wcf_ca_gdpr_status:checked' ).length ) {
$( '#wcf_ca_gdpr_message' ).closest( 'tr' ).show();
}
if ( $( '#wcf_ca_zapier_tracking_status:checked' ).length ) {
$(
'#wcf_ca_zapier_cart_abandoned_webhook, #wcf_ca_coupon_code_status'
)
.closest( 'tr' )
.show();
}
if (
$( '#wcf_ca_coupon_code_status:checked' ).length &&
$( '#wcf_ca_zapier_tracking_status:checked' ).length
) {
$(
'#wcf_ca_discount_type, #wcf_ca_coupon_amount, #wcf_ca_coupon_expiry'
)
.closest( 'tr' )
.show();
}
$( '#wcf_ca_coupon_code_status' ).on( 'click', function () {
if ( ! $( '#wcf_ca_coupon_code_status:checked' ).length ) {
$(
'#wcf_ca_discount_type, #wcf_ca_coupon_amount, #wcf_ca_coupon_expiry'
)
.closest( 'tr' )
.fadeOut();
} else {
$(
'#wcf_ca_discount_type, #wcf_ca_coupon_amount, #wcf_ca_coupon_expiry'
)
.closest( 'tr' )
.fadeIn();
}
} );
$( '#wcf_ca_gdpr_status' ).on( 'click', function () {
if ( ! $( '#wcf_ca_gdpr_status:checked' ).length ) {
$( '#wcf_ca_gdpr_message' ).closest( 'tr' ).fadeOut();
} else {
$( '#wcf_ca_gdpr_message' ).closest( 'tr' ).fadeIn();
}
} );
$( '#wcf_ca_zapier_tracking_status' ).on( 'click', function () {
if ( ! $( '#wcf_ca_zapier_tracking_status:checked' ).length ) {
$(
'#wcf_ca_zapier_cart_abandoned_webhook, #wcf_ca_coupon_code_status'
)
.closest( 'tr' )
.fadeOut();
} else {
$(
'#wcf_ca_zapier_cart_abandoned_webhook, #wcf_ca_coupon_code_status'
)
.closest( 'tr' )
.fadeIn();
}
if (
$( '#wcf_ca_coupon_code_status:checked' ).length &&
$( '#wcf_ca_zapier_tracking_status:checked' ).length
) {
$(
'#wcf_ca_discount_type, #wcf_ca_coupon_amount, #wcf_ca_coupon_expiry'
)
.closest( 'tr' )
.fadeIn();
} else {
$(
'#wcf_ca_discount_type, #wcf_ca_coupon_amount, #wcf_ca_coupon_expiry'
)
.closest( 'tr' )
.fadeOut();
}
} );
if (
! $( '#wcf_ca_send_recovery_report_emails_to_admin:checked' )
.length
) {
$( '#wcf_ca_admin_email' ).closest( 'tr' ).hide();
}
$( '#wcf_ca_send_recovery_report_emails_to_admin' ).on(
'click',
function () {
if (
! $(
'#wcf_ca_send_recovery_report_emails_to_admin:checked'
).length
) {
$( '#wcf_ca_admin_email' ).closest( 'tr' ).fadeOut();
} else {
$( '#wcf_ca_admin_email' ).closest( 'tr' ).fadeIn();
}
}
);
},
};
ZapierSettings = {
init() {
$( document ).on(
'click',
'#wcf_ca_trigger_web_hook_abandoned_btn',
{ order_status: 'abandoned' },
ZapierSettings.zapier_trigger_sample
);
},
zapier_trigger_sample( event ) {
const zapier_webhook_url = $(
'#wcf_ca_zapier_cart_' + event.data.order_status + '_webhook'
)
.val()
.trim();
if ( ! zapier_webhook_url.length ) {
$( '#wcf_ca_' + event.data.order_status + '_btn_message' )
.text( wcf_ca_details.strings.verify_url_error )
.fadeIn()
.css( 'color', '#dc3232' )
.delay( 2000 )
.fadeOut();
return;
}
$( '#wcf_ca_' + event.data.order_status + '_btn_message' )
.text( wcf_ca_details.strings.trigger_process )
.fadeIn();
if ( $.trim( zapier_webhook_url ) !== '' ) {
const sample_data = {
first_name: wcf_ca_details.name,
last_name: wcf_ca_details.surname,
email: wcf_ca_details.email,
phone: wcf_ca_details.phone,
order_status: event.data.order_status,
checkout_url:
window.location.origin +
'/checkout/?wcf_ac_token=something',
coupon_code: 'abcgefgh',
product_names: 'Product1, Product2 & Product3',
cart_total: wcf_ca_details.woo_currency_symbol + '20',
product_table:
' Item | Name | Quantity | Price | Line Subtotal |
 | Product1 | 1 | £85.00 | £85.00 |
',
};
$.ajax( {
url: zapier_webhook_url,
type: 'POST',
data: sample_data,
success( data ) {
const response = ZapierSettings.handle_zapier_response(
data
);
if ( response ) {
$(
'#wcf_ca_' +
event.data.order_status +
'_btn_message'
)
.text( wcf_ca_details.strings.trigger_success )
.css( 'color', '#46b450' );
} else {
$(
'#wcf_ca_' +
event.data.order_status +
'_btn_message'
)
.text( wcf_ca_details.strings.trigger_failed )
.css( 'color', '#dc3232' );
}
$(
'#wcf_ca_' +
event.data.order_status +
'_btn_message'
)
.fadeIn()
.delay( 2000 )
.fadeOut();
},
error() {
$(
'#wcf_ca_' +
event.data.order_status +
'_btn_message'
)
.text( wcf_ca_details.strings.trigger_failed )
.css( 'color', '#dc3232' );
},
} );
} else {
$( 'wcf_ca' + event.data.order_status + '_btn_message' )
.text( wcf_ca_details.strings.verify_url )
.fadeIn()
.delay( 2000 )
.fadeOut();
}
},
handle_zapier_response( data ) {
let status = false;
if (
typeof data === 'object' &&
[ 'success', 'accepted' ].includes( data.status )
) {
status = true;
} else if ( typeof data === 'string' ) {
const resp_string = data.toLowerCase();
if ( [ 'success', 'accepted' ].includes( resp_string ) ) {
status = true;
}
}
return status;
},
};
ToolTipHover = {
init() {
$( '.wcf-ca-report-table-row .wcf-ca-icon-row' ).on(
'hover',
function () {
$( this )
.find( '.wcf-ca-tooltip-text' )
.toggleClass( 'display_tool_tip' );
}
);
},
};
$( function () {
CartAbandonmentSettings.init();
ZapierSettings.init();
ToolTipHover.init();
} );
} )( jQuery );