Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/app/services/cart-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class CartHandler {
this.currentCartVersion = cartData.version;
this.saveCartToLocalStorage();
}
console.log('Product added to cart:', cartData);
},
(errorMessage) => {
const SUCSESS_MSG = `Error adding product to cart: ${errorMessage}`;
Expand Down
20 changes: 12 additions & 8 deletions src/app/services/current-cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class CurrentCart {
}

public initCurrentCart(userId?: string, sucessCallback?: () => void) {
console.log(`Initializing ID ${userId}`);
if (userId) {
this.loadCustomerCart(userId, sucessCallback);
LocalStorageManager.removeAnonymusCart();
Expand Down Expand Up @@ -73,9 +72,17 @@ class CurrentCart {
}
);
} else {
createAnonymousCart(this.updateCartData.bind(this), () => {
console.log('Problem on creating');
});
createAnonymousCart(
(cart: Cart) => {
this.updateCartData(cart);
if (successCallback) {
successCallback();
}
},
() => {
console.log('Problem on creating');
}
);
}
}

Expand Down Expand Up @@ -169,7 +176,6 @@ class CurrentCart {
}

isProductInside(productId: string) {
console.log(`checking ${productId}`);
const isInside = this.cartData.lineItems.reduce(
(result, product) => result || product.productId === productId,
false
Expand All @@ -195,8 +201,6 @@ class CurrentCart {
}

removeAllPromocodes() {
console.log('removing all promocodes');

this.cartData.discountCodes.forEach((codeId) => {
this.removePromocode(
{ id: codeId.id, typeId: 'discount-code' },
Expand Down Expand Up @@ -234,7 +238,7 @@ class CurrentCart {
);
} else {
localStorage.removeItem('anonymousCart');
this.loadAnonymusCart();
this.loadAnonymusCart(sucessCallback);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/basket/basket-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class BasketSummaryView extends View {
const getTotalPrice = (lineItems: Array<ILineItem>) => {
const totalPrice =
lineItems.reduce(
(sum, currentItem) => sum + currentItem.price.value.centAmount,
(sum, currentItem) => sum + currentItem.totalPrice.centAmount,
0
) / 100;
return totalPrice;
Expand Down
13 changes: 4 additions & 9 deletions src/app/views/product/product-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ export default class ProductPageView extends View {

this.deleteCartButton.node.addEventListener('click', (event) => {
event.preventDefault();
/* TODO: кодить сюда */
const lineItem = currentCart.cartData.lineItems.find(
(item) => item.productId === this.productId
);
Expand All @@ -281,14 +280,10 @@ export default class ProductPageView extends View {
this.deleteCartButton.node.classList.remove('button-visibl');
return;
}
currentCart.removeProduct(
lineItem.id,
() => {
this.addCartButton.node.classList.remove('button-disabled');
this.deleteCartButton.node.classList.remove('button-visibl');
},
1
);
currentCart.removeProduct(lineItem.id, () => {
this.addCartButton.node.classList.remove('button-disabled');
this.deleteCartButton.node.classList.remove('button-visibl');
});
});

detailsProduct.appendChild(cartContainer);
Expand Down