Run eslint autofix

This commit is contained in:
Emili Castells Guasch 2024-07-12 12:58:34 +02:00
parent 36a13f6500
commit 11105d913b
141 changed files with 14160 additions and 11825 deletions

View file

@ -1,79 +1,68 @@
import ErrorHandler from "../../../../ppcp-button/resources/js/modules/ErrorHandler";
import CartActionHandler
from "../../../../ppcp-button/resources/js/modules/ActionHandler/CartActionHandler";
import ErrorHandler from '../../../../ppcp-button/resources/js/modules/ErrorHandler';
import CartActionHandler from '../../../../ppcp-button/resources/js/modules/ActionHandler/CartActionHandler';
class BaseHandler {
constructor( buttonConfig, ppcpConfig, externalHandler ) {
this.buttonConfig = buttonConfig;
this.ppcpConfig = ppcpConfig;
this.externalHandler = externalHandler;
}
constructor(buttonConfig, ppcpConfig, externalHandler) {
this.buttonConfig = buttonConfig;
this.ppcpConfig = ppcpConfig;
this.externalHandler = externalHandler;
}
validateContext() {
if ( this.ppcpConfig?.locations_with_subscription_product?.cart ) {
return false;
}
return true;
}
validateContext() {
if ( this.ppcpConfig?.locations_with_subscription_product?.cart ) {
return false;
}
return true;
}
shippingAllowed() {
// Status of the shipping settings in WooCommerce.
return this.buttonConfig.shipping.configured;
}
shippingAllowed() {
// Status of the shipping settings in WooCommerce.
return this.buttonConfig.shipping.configured;
}
transactionInfo() {
return new Promise( ( resolve, reject ) => {
fetch( this.ppcpConfig.ajax.cart_script_params.endpoint, {
method: 'GET',
credentials: 'same-origin',
} )
.then( ( result ) => result.json() )
.then( ( result ) => {
if ( ! result.success ) {
return;
}
transactionInfo() {
return new Promise((resolve, reject) => {
// handle script reload
const data = result.data;
fetch(
this.ppcpConfig.ajax.cart_script_params.endpoint,
{
method: 'GET',
credentials: 'same-origin',
}
)
.then(result => result.json())
.then(result => {
if (! result.success) {
return;
}
resolve( {
countryCode: data.country_code,
currencyCode: data.currency_code,
totalPriceStatus: 'FINAL',
totalPrice: data.total_str,
} );
} );
} );
}
// handle script reload
const data = result.data;
createOrder() {
return this.actionHandler().configuration().createOrder( null, null );
}
resolve({
countryCode: data.country_code,
currencyCode: data.currency_code,
totalPriceStatus: 'FINAL',
totalPrice: data.total_str
});
approveOrder( data, actions ) {
return this.actionHandler().configuration().onApprove( data, actions );
}
});
});
}
createOrder() {
return this.actionHandler().configuration().createOrder(null, null);
}
approveOrder(data, actions) {
return this.actionHandler().configuration().onApprove(data, actions);
}
actionHandler() {
return new CartActionHandler(
this.ppcpConfig,
this.errorHandler(),
);
}
errorHandler() {
return new ErrorHandler(
this.ppcpConfig.labels.error.generic,
document.querySelector('.woocommerce-notices-wrapper')
);
}
actionHandler() {
return new CartActionHandler( this.ppcpConfig, this.errorHandler() );
}
errorHandler() {
return new ErrorHandler(
this.ppcpConfig.labels.error.generic,
document.querySelector( '.woocommerce-notices-wrapper' )
);
}
}
export default BaseHandler;