diff --git a/checkout/src/arquivos/js/components/CheckoutUI.js b/checkout/src/arquivos/js/components/CheckoutUI.js index f68f3b2..207fb37 100644 --- a/checkout/src/arquivos/js/components/CheckoutUI.js +++ b/checkout/src/arquivos/js/components/CheckoutUI.js @@ -32,13 +32,12 @@ export default class CheckoutUI { toggleFooterDropdown(event) { event.target.classList.toggle("closed"); - event.target.nextElementSibling.classList.toggle( - "dropdown__content--closed" - ); + event.target.nextElementSibling.classList.toggle("dropdown__content--closed"); } init() { this.configThumb(); + this.resetTitle(); waitForEl(".product-image img", this.resizeImages.bind(this)); $(window).on("orderFormUpdated.vtex", this.resizeImages.bind(this)); } @@ -56,14 +55,27 @@ export default class CheckoutUI { resizeImages() { $(".product-image img").each((i, el) => { const $el = $(el); - $el.attr( - "src", - alterarTamanhoImagemSrcVtex( - $el.attr("src"), - this.width, - this.height - ) - ); + $el.attr("src", alterarTamanhoImagemSrcVtex($el.attr("src"), this.width, this.height)); }); } + + async resetTitle() { + const orderForm = await window.vtexjs.checkout.getOrderForm(); + const itemsForm = orderForm.items.length; + const cartId = document.querySelector("#cart-title"); + + $(window).on("orderFormUpdated.vtex", (evt, oF) => { + if (oF.items.length <= 0) { + cartId.style.display = "none"; + } else { + cartId.style.display = "block"; + } + if (window.location.hash === "#/shipping" || window.location.hash === "#/payment") { + cartId.style.display = "none"; + } + }); + if (itemsForm === 0) { + cartId.style.display = "none"; + } + } }