feature/footer #4

Merged
ViniciusDeniz merged 3 commits from feature/footer into main 2022-12-19 02:35:14 +00:00
Showing only changes of commit fb3b5ddb5b - Show all commits

View File

@ -5,14 +5,16 @@ export default class Footer {
this.init();
}
async Init() {
this.list = await this.fetchPrat();
async init() {
this.list = await this.fetchPrateleira();
await this.selectors();
// this.onUpdate();
this.createPrat();
this.createPrateleira();
this.prateleira = await waitElement(".footerCheckout__carrossel-itens");
this.itensPrat();
this.itensPrateleira();
this.addCarrossel();
this.creditCardIconsHTML();
this.developedByIconsHTML();
}
@ -26,29 +28,22 @@ export default class Footer {
this.developedByIcons = await waitElement(".footerCheckout__developedBy");
}
// onUpdate() {
// let target = this.checkoutVazio;
// let config = { childList: true, attributes: true };
// let observer = new MutationObserver((mutations) => {
// let removeClassh3 = document.getElementById("removeClassh3");
// let removeClassul = document.getElementById("removeClassul");
// mutations.forEach(function (mutation) {
// const checkoutTarget = mutation.target.attributes.style.nodeValue;
// console.log(checkoutTarget);
// if (checkoutTarget === "display: none;") {
// removeClassh3.classList.remove("displayNone");
// removeClassul.classList.remove("displayNone");
// } else if (checkoutTarget === "display: block;") {
// removeClassh3.classList.add("displayNone");
// removeClassul.classList.add("displayNone");
// }
// });
// });
onUpdate() {
//Função qeu fará a verificação se o carrinho está vazio para remover a prateleira de produtos:
// vocês devem olhar a doc fornecida no Desafio para aprender a usar a MutationObserver
// sempre que o carrinho estiver vazio o elemento chcekoutVazio fica display: none e isso pode ser usado como atributo para a MutationObserver
let target = this.checkoutVazio;
letconfig = { childList: true, attributes: true };
letobserver = new MutationObserver((mutations) => {
mutations.forEach(function (mutation) {
console.log(mutation.type);
});
});
// observer.observe(target, config);
// }
observer.observe(target, config);
}
createPrat() {
createPrateleira() {
if (this.itensShelf) {
this.itensShelf.innerHTML = `
<div class="footerCheckout__prateleira-title">
@ -59,7 +54,7 @@ export default class Footer {
}
}
async itensPrat() {
async itensPrateleira() {
letstructure = "";
this.list.forEach((response) => {
@ -77,7 +72,7 @@ export default class Footer {
this.prateleira.innerHTML = structure;
}
async fetchPrat() {
async fetchPrateleira() {
constapi =
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319";
return fetch(api)