|
@@ -392,8 +392,8 @@ bPoput.id = "b-popup";
|
|
|
const bPoputContainer = document.createElement("div");
|
|
|
bPoputContainer.className = "b-popup-content";
|
|
|
bPoputContainer.id = "b-popup-content";
|
|
|
-const buttonGoodDeleteBlock = document.createElement('div')
|
|
|
-buttonGoodDeleteBlock.id = "buttonGoodDeleteBlock"
|
|
|
+const buttonGoodDeleteBlock = document.createElement("div");
|
|
|
+buttonGoodDeleteBlock.id = "buttonGoodDeleteBlock";
|
|
|
|
|
|
const buttonCloseCart = document.createElement("button");
|
|
|
buttonCloseCart.innerText = `×`;
|
|
@@ -408,25 +408,21 @@ shoppingCart.onclick = () => {
|
|
|
};
|
|
|
|
|
|
bPoputContainer.append(buttonGoodDeleteBlock);
|
|
|
-buttonGoodDeleteBlock.append(buttonGoodDelete)
|
|
|
+buttonGoodDeleteBlock.append(buttonGoodDelete);
|
|
|
bPoputContainer.append(buttonCloseCart);
|
|
|
|
|
|
-
|
|
|
const divToCardBlock = document.createElement("div");
|
|
|
|
|
|
-
|
|
|
store.subscribe(() => {
|
|
|
- divToCardBlock.innerHTML = ""
|
|
|
+ divToCardBlock.innerHTML = "";
|
|
|
toCartById = store.getState().cart;
|
|
|
+ let countSum = 0;
|
|
|
for (let value of Object.values(toCartById)) {
|
|
|
-
|
|
|
-
|
|
|
const { count, good } = value;
|
|
|
- console.log(count, "its cartbyid")
|
|
|
+ countSum += count;
|
|
|
|
|
|
divToCardBlock.id = "divToCartBlock";
|
|
|
const divToCart = document.createElement("div");
|
|
|
-
|
|
|
|
|
|
const goodByIdImage = document.createElement("img");
|
|
|
const goodByIdName = document.createElement("h2");
|
|
@@ -450,8 +446,12 @@ store.subscribe(() => {
|
|
|
goodByIdImage.src = `${backendURLNotGraphQL}/${value.good.images[0].url}`;
|
|
|
goodByIdName.innerText = good.name;
|
|
|
goodByIdCount.innerText = count;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ shoppingCart.innerHTML = "Cart: " + countSum;
|
|
|
+
|
|
|
buttonCloseCart.onclick = () => {
|
|
|
var parent = document.getElementById("header");
|
|
|
var child = document.getElementById("b-popup");
|
|
@@ -468,10 +468,10 @@ store.subscribe(() => {
|
|
|
|
|
|
buttonGoodDelete.onclick = () => {
|
|
|
store.dispatch(actionCartClear());
|
|
|
- let a = document.getElementById('divToCartBlock')
|
|
|
+ let a = document.getElementById("divToCartBlock");
|
|
|
a.innerHTML = "";
|
|
|
- let b = document.getElementById('shoppingCart')
|
|
|
- b.innerHTML = "Cart"
|
|
|
+ let b = document.getElementById("shoppingCart");
|
|
|
+ b.innerHTML = "Cart";
|
|
|
};
|
|
|
|
|
|
const buyButtom = document.createElement("button");
|
|
@@ -482,7 +482,6 @@ const textBlock = document.createElement("div");
|
|
|
const flexBlock = document.createElement("div");
|
|
|
const productDescription = document.createElement("p");
|
|
|
|
|
|
-let number = 0;
|
|
|
store.subscribe(() => {
|
|
|
const goodById =
|
|
|
store.getState().promise.GoodFineOne?.payload?.data.GoodFindOne;
|
|
@@ -494,7 +493,6 @@ store.subscribe(() => {
|
|
|
element.removeChild(element.firstChild);
|
|
|
}
|
|
|
const { name, price, description, images } = goodById;
|
|
|
-
|
|
|
|
|
|
flexBlock.id = "flexBlock";
|
|
|
|
|
@@ -518,17 +516,20 @@ store.subscribe(() => {
|
|
|
textBlock.append(productDescription);
|
|
|
|
|
|
buyButtom.id = "buyButtom";
|
|
|
- buyButtom.innerHTML = "Buy";
|
|
|
+ buyButtom.innerHTML = "Add to cart";
|
|
|
textBlock.append(buyButtom);
|
|
|
buyButtom.onclick = () => {
|
|
|
store.dispatch(actionCartAdd(goodById));
|
|
|
- let a = document.getElementById('shoppingCart')
|
|
|
- number += 1
|
|
|
- a.innerHTML = "Cart: " + number;
|
|
|
};
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
store.subscribe(() => {
|
|
|
const catById =
|
|
|
store.getState().promise.catById?.payload?.data.CategoryFindOne;
|