Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New bucket #84

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

New bucket #84

wants to merge 5 commits into from

Conversation

veirfuna
Copy link
Collaborator

No description provided.

@veirfuna veirfuna requested a review from gavroman December 26, 2020 21:00
default:
console.log(`Uncaught backend http-status: ${response.status}`);
}
let products = JSON.parse(localStorage.getItem('cart'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

}
let products = JSON.parse(localStorage.getItem('cart'));
const total = products.reduce((a, b) => a + b.food_price * b.count, 0);
this.eventBus.call('SHOW_CART', { total: total, products: products, addresses: {} });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ total, products, addresses: {} }

console.log(`Uncaught backend http-status: ${response.status}`);
}
let products = JSON.parse(localStorage.getItem('cart'));
products = products.filter((product) => { return product.id != productId; });
Copy link
Contributor

@gavroman gavroman Dec 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(product) => product.id !== productId

  • давай уберем products = products.filter и сделаем
    localStorage.setItem('cart', JSON.stringify(products.filter(.............)));

const response = await addProductToBucket(productId);
addToCart (product) {
product.count = 1;
let productsJSON = localStorage.getItem('cart');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

if (productsJSON === null) {
let products = [];
products.push(product);
localStorage.setItem('cart', JSON.stringify(products));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.stringify([product]) и без лишних действий тогда

console.log(`Uncaught backend http-status: ${response.status}`);
let products = JSON.parse(productsJSON);
if(products.some(p => p.id === product.id)){
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const + по линтеру траблы

}

products.push(product);
localStorage.setItem('cart', JSON.stringify(products));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вместо того, что бы пушить в массив, можно сделать так JSON.stringify([...products, product])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants