Skip to content

Commit

Permalink
MongoDB's zero storing problem FIXED
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-orug committed Feb 26, 2023
1 parent 5fa0b0c commit 6fd0f49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion client/src/views/Cart/Cart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ const MainCart = ({ currentUser }) => {
if (currentUser && currentUser.length !== 0) {
console.log(currentBalance);
if (currentBalance - calculatePrice(books, booksCartNames) >= 0) {
data.balance = currentBalance - calculatePrice(books, booksCartNames);
if (currentBalance - calculatePrice(books, booksCartNames) === 0) {
data.balance = "0";
} else {
data.balance = currentBalance - calculatePrice(books, booksCartNames);
}
console.log(data.balance);
localStorage.setItem("books_cart", JSON.stringify([]));
localStorage.setItem("booksCartNames", JSON.stringify({}));
handleChange();
Expand Down

0 comments on commit 6fd0f49

Please sign in to comment.