develop #11

Merged
HenriqueSantosSantana merged 37 commits from develop into main 2022-12-26 17:04:35 +00:00
Showing only changes of commit cf15ad2f14 - Show all commits

View File

@ -25,6 +25,7 @@ export default class Footer {
this.paymentContainer = await waitElement(".footerCheckout__stamps"); this.paymentContainer = await waitElement(".footerCheckout__stamps");
this.developedByContainer = await waitElement(".footerCheckout__developedBy"); this.developedByContainer = await waitElement(".footerCheckout__developedBy");
this.checkoutContainer = await waitElement(".container-main"); this.checkoutContainer = await waitElement(".container-main");
this.self = await waitElement(".footerCheckout__prateleira");
} }
innerToPayments() { innerToPayments() {
@ -92,6 +93,15 @@ export default class Footer {
this.checkoutContainer.classList.add("container-cart-fill"); this.checkoutContainer.classList.add("container-cart-fill");
} }
if (
window.location.href.endsWith("#/cart") &&
this.checkoutContainer.classList.contains("container-cart-fill")
) {
console.log("API");
this.innerToSelf();
this.addCarrossel();
}
let target = this.checkoutEmpty; let target = this.checkoutEmpty;
let config = { childList: true, attributes: true }; let config = { childList: true, attributes: true };
let observer = new MutationObserver((mutations) => { let observer = new MutationObserver((mutations) => {
@ -103,6 +113,14 @@ export default class Footer {
this.checkoutContainer.classList.add("container-cart-fill"); this.checkoutContainer.classList.add("container-cart-fill");
} }
if (
window.location.href.endsWith("#/cart") &&
this.checkoutContainer.classList.contains("container-cart-fill")
) {
this.innerToSelf();
this.addCarrossel();
}
break; break;
} }
} }
@ -111,11 +129,70 @@ export default class Footer {
observer.observe(target, config); observer.observe(target, config);
} }
} }
async addCarrossel() {
const elemento = await waitElement("#my-element"); addCarrossel() {
$(elemento).slick({ $(this.self).slick({
slidesToShow: 4, slidesToShow: 4,
slidesToScroll: 1, slidesToScroll: 1,
}); });
} }
async getProducts() {
let url = (name) => {
let domain = "https://m3academy.myvtex.com/";
return domain + name;
};
let API = fetch(url("api/catalog_system/pub/products/search/?fq=productClusterIds:319"));
let response = await API.then((res) => res.json());
return response;
}
async innerToSelf() {
let datas = await this.getProducts();
datas.forEach(() => {
$(this.self).slick("unslick");
this.createdCardsProducts(datas);
this.addCarrossel();
});
}
createdCardsProducts(data) {
let structure = "";
data.forEach((data) => {
structure += `<div>
<div>
<figure>
<img src="${data.items[0].images[0].imageUrl}" alt="">
</figure>
<h3>
${data.productName}
</h3>
</div>
<div>
${data.items.reduce((acc, item) => {
return (acc += `<div>
<span>${item.name}</span>
</div>`);
}, "")}
</div>
<a href="${data.link}">
<span>
Ver Produto
</span>
</a>
</div>`;
});
this.self.innerHTML = structure.trim();
}
} }