From ff1bc216106d6c626e1140f662ed3731202ccd09 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 28 Oct 2021 14:59:19 -0300 Subject: [PATCH] usar window.site --- _packs/controllers/cart_base_controller.js | 16 +--------------- .../controllers/cart_confirmation_controller.js | 2 +- _packs/controllers/cart_controller.js | 2 +- .../cart_payment_methods_controller.js | 2 +- .../cart_paypal_confirmation_controller.js | 2 +- _packs/controllers/cart_shipping_controller.js | 2 +- _packs/controllers/country_controller.js | 2 +- _packs/controllers/order_controller.js | 4 ++-- _packs/controllers/state_controller.js | 2 +- 9 files changed, 10 insertions(+), 24 deletions(-) diff --git a/_packs/controllers/cart_base_controller.js b/_packs/controllers/cart_base_controller.js index 1dcd725..879d30d 100644 --- a/_packs/controllers/cart_base_controller.js +++ b/_packs/controllers/cart_base_controller.js @@ -84,20 +84,6 @@ export class CartBaseController extends Controller { return window.liquid } - /* - * Site config (actually just translation strings) - * - * @return [Object] - */ - async site () { - if (!window.site) { - const data = await fetch('assets/data/site.json') - window.site = await data.json() - } - - return window.site - } - /* * Updates the item counter */ @@ -125,7 +111,7 @@ export class CartBaseController extends Controller { console.error(response.fail()) - const site = await this.site() + const site = window.site switch (response.fail().name) { case 'MisconfigurationError': diff --git a/_packs/controllers/cart_confirmation_controller.js b/_packs/controllers/cart_confirmation_controller.js index 0faf726..c04d763 100644 --- a/_packs/controllers/cart_confirmation_controller.js +++ b/_packs/controllers/cart_confirmation_controller.js @@ -14,7 +14,7 @@ export default class extends CartBaseController { if (this.storage.cart) { const order = this.cart.data.attributes const products = this.products - const site = await this.site() + const site = window.site const shipping_address = JSON.parse(this.storage.getItem('shipping_address')) const data = { order, products, site, shipping_address } diff --git a/_packs/controllers/cart_controller.js b/_packs/controllers/cart_controller.js index 705181b..97b43e2 100644 --- a/_packs/controllers/cart_controller.js +++ b/_packs/controllers/cart_controller.js @@ -181,7 +181,7 @@ export default class extends CartBaseController { this.fireCajon() if (floating_alert) { - const site = await this.site() + const site = window.site const content = site.cart.added window.dispatchEvent(new CustomEvent('floating:alert', { detail: { content }})) } diff --git a/_packs/controllers/cart_payment_methods_controller.js b/_packs/controllers/cart_payment_methods_controller.js index 48f02e9..c9f882e 100644 --- a/_packs/controllers/cart_payment_methods_controller.js +++ b/_packs/controllers/cart_payment_methods_controller.js @@ -16,7 +16,7 @@ export default class extends CartBaseController { } const payment_methods = response.success().data - const site = await this.site() + const site = window.site const cart = this.cart const next = { url: this.data.get('nextUrl') } const back = { url: this.data.get('backUrl') } diff --git a/_packs/controllers/cart_paypal_confirmation_controller.js b/_packs/controllers/cart_paypal_confirmation_controller.js index 3410eb3..9ac2777 100644 --- a/_packs/controllers/cart_paypal_confirmation_controller.js +++ b/_packs/controllers/cart_paypal_confirmation_controller.js @@ -12,7 +12,7 @@ export default class extends CartBaseController { async connect () { if (this.params.PayerID === undefined) return - this.site = await this.site() + this.site = window.site this.element.innerHTML = this.site.i18n.cart.layouts.paypal.confirming fetch(this.executeURL) diff --git a/_packs/controllers/cart_shipping_controller.js b/_packs/controllers/cart_shipping_controller.js index 975663f..64cc33f 100644 --- a/_packs/controllers/cart_shipping_controller.js +++ b/_packs/controllers/cart_shipping_controller.js @@ -68,7 +68,7 @@ export default class extends CartBaseController { const shipping_rates = shippingMethods.included.filter(x => x.type == 'shipping_rate') // XXX: No hay varios paquetes const shipping_method = shippingMethods.data[0] - const site = await this.site() + const site = window.site await this.render({ shipping_method, shipping_rates, site }) diff --git a/_packs/controllers/country_controller.js b/_packs/controllers/country_controller.js index 3f8476f..6becb09 100644 --- a/_packs/controllers/country_controller.js +++ b/_packs/controllers/country_controller.js @@ -23,7 +23,7 @@ export default class extends CartBaseController { this.listTarget.appendChild(option) }) - const site = await this.site() + const site = window.site // Only allow names on this list this.nameTarget.pattern = countries.map(x => x.attributes.name).join('|') diff --git a/_packs/controllers/order_controller.js b/_packs/controllers/order_controller.js index 442e12e..08b7c50 100644 --- a/_packs/controllers/order_controller.js +++ b/_packs/controllers/order_controller.js @@ -10,7 +10,7 @@ export default class extends CartBaseController { async connect () { const products = this.products - const site = await this.site() + const site = window.site this.render({ products, site }) this.subtotalUpdate() @@ -26,7 +26,7 @@ export default class extends CartBaseController { if (!event.key?.startsWith('cart:item:')) return const products = this.products - const site = await this.site() + const site = window.site this.render({ products, site }) this.subtotalUpdate() diff --git a/_packs/controllers/state_controller.js b/_packs/controllers/state_controller.js index b0f3949..e84a0e8 100644 --- a/_packs/controllers/state_controller.js +++ b/_packs/controllers/state_controller.js @@ -25,7 +25,7 @@ export default class extends CartBaseController { if (!statesRequired) return const states = await this.states(event.detail.iso) - const site = await this.site() + const site = window.site states.forEach(state => { let option = document.createElement('option')