|
@@ -193,19 +193,6 @@ if (localStorage.authToken) {
|
|
|
//const store = createStore(combineReducers({promise: promiseReducer, auth: authReducer, cart: cartReducer}))
|
|
|
store.subscribe(() => console.log(store.getState()));
|
|
|
|
|
|
-//store.dispatch(actionPromise('delay1000', delay(1000)))
|
|
|
-//store.dispatch(actionPromise('delay3000', delay(3000)))
|
|
|
-
|
|
|
-//store.dispatch(actionPending('delay1000'))
|
|
|
-
|
|
|
-//delay(1000).then(result => store.dispatch(actionFulfilled('delay1000', result)),
|
|
|
-//error => store.dispatch(actionRejected('delay1000', error)))
|
|
|
-
|
|
|
-//store.dispatch(actionPending('delay3000'))
|
|
|
-
|
|
|
-//delay(3000).then(result => store.dispatch(actionFulfilled('delay3000', result)),
|
|
|
-//error => store.dispatch(actionRejected('delay3000', error)))
|
|
|
-
|
|
|
const gql = (url, query, variables) =>
|
|
|
fetch(url, {
|
|
|
method: "POST",
|
|
@@ -216,23 +203,6 @@ const gql = (url, query, variables) =>
|
|
|
body: JSON.stringify({ query, variables }),
|
|
|
}).then((res) => res.json());
|
|
|
|
|
|
-// const getGQL = url =>
|
|
|
-// (query, variables) => fetch(url, {
|
|
|
-// method: 'POST',
|
|
|
-// headers: {
|
|
|
-// "Content-Type": "application/json",
|
|
|
-// // 'Accept' : 'application/json',
|
|
|
-// ...(localStorage.authToken ? {"Authorization": "Bearer " + localStorage.authToken} : {})
|
|
|
-// },
|
|
|
-// body: JSON.stringify({query, variables})
|
|
|
-// }).then(res => res.json())
|
|
|
-// .then(data => {
|
|
|
-// if (data.data){
|
|
|
-// return Object.values(data.data)[0]
|
|
|
-// }
|
|
|
-// else throw new Error(JSON.stringify(data.errors))
|
|
|
-// })
|
|
|
-
|
|
|
const actionRootCats = () =>
|
|
|
actionPromise(
|
|
|
"rootCats",
|
|
@@ -299,7 +269,6 @@ const actionGoodById = (_id) =>
|
|
|
);
|
|
|
|
|
|
store.dispatch(actionRootCats());
|
|
|
-// store.dispatch(actionLogin("illiaKozyr", "qwerty123456"));
|
|
|
|
|
|
const actionFullLogin = (login, password) => async (dispatch) => {
|
|
|
let result = await dispatch(actionLogin(login, password));
|
|
@@ -412,9 +381,6 @@ store.subscribe(() => {
|
|
|
addToCartButton.innerText = "click to buy";
|
|
|
addToCartButton.className = "addToCartButton";
|
|
|
textBlock.append(addToCartButton);
|
|
|
-
|
|
|
- // var elem = document.getElementById("productBlock");
|
|
|
- // elem.parentNode.removeChild(elem);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -448,15 +414,20 @@ bPoputContainer.append(buttonCloseCart);
|
|
|
|
|
|
const divToCardBlock = document.createElement("div");
|
|
|
|
|
|
+
|
|
|
store.subscribe(() => {
|
|
|
+ divToCardBlock.innerHTML = ""
|
|
|
toCartById = store.getState().cart;
|
|
|
for (let value of Object.values(toCartById)) {
|
|
|
+
|
|
|
|
|
|
const { count, good } = value;
|
|
|
console.log(count, "its cartbyid")
|
|
|
|
|
|
divToCardBlock.id = "divToCartBlock";
|
|
|
const divToCart = document.createElement("div");
|
|
|
+
|
|
|
+
|
|
|
const goodByIdImage = document.createElement("img");
|
|
|
const goodByIdName = document.createElement("h2");
|
|
|
const goodByIdCount = document.createElement("h2");
|
|
@@ -493,8 +464,6 @@ store.subscribe(() => {
|
|
|
} else {
|
|
|
shoppingCart.style.display = "none";
|
|
|
}
|
|
|
-
|
|
|
- // bPoputContainer.append(buttonGoodDelete);
|
|
|
});
|
|
|
|
|
|
buttonGoodDelete.onclick = () => {
|
|
@@ -568,11 +537,6 @@ store.subscribe(() => {
|
|
|
if (catById && route === "good") {
|
|
|
const { name, price, description, images } = catById;
|
|
|
categoryName.innerHTML = `<h1>${name}</h1>`;
|
|
|
-
|
|
|
- // var element = document.getElementById("productBlock");
|
|
|
- // while (element.firstChild) {
|
|
|
- // element.removeChild(element.firstChild);
|
|
|
- // }
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -693,30 +657,6 @@ reg.onclick = () => {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-// store.subscribe(() => {
|
|
|
-// dashboardUl.innerHTML = ''
|
|
|
-// const {orders} = store.getState().promise;
|
|
|
-// const [,route, _id] = location.hash.split('/');
|
|
|
-// if(orders?.payload && route === 'dashboard'){
|
|
|
-// for(let {createdAt, total, orderGoods} of orders.payload){
|
|
|
-// let date = new Date(+createdAt);
|
|
|
-// let li = document.createElement("li");
|
|
|
-// for(let {count, good} of orderGoods){
|
|
|
-// let div = document.createElement("div");
|
|
|
-// div.innerHTML = `<strong>${good.name}</strong>
|
|
|
-// <span>${count} ✖ ${good.price}</span>
|
|
|
-// `
|
|
|
-// li.append(div);
|
|
|
-// }
|
|
|
-// li.innerHTML += `<div>${total}</div>
|
|
|
-// <div>${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}</div>
|
|
|
-// <hr>`
|
|
|
-// dashboardUl.append(li)
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// })
|
|
|
-
|
|
|
logoutButton.onclick = () => {
|
|
|
store.dispatch(actionAuthLogout());
|
|
|
login.style.display = "block";
|