Skip to content

Commit

Permalink
check fav on load if item is on localStorage.favs
Browse files Browse the repository at this point in the history
  • Loading branch information
HectorVilas committed May 2, 2023
1 parent e072afa commit f17f743
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/shopCard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { addToCart, toggleFavorite } from "./functions.js";
import { storedData } from "./storedData.js";

export default function shopCard(id, imgUrl, category, name, price, amount = 0){
export default function shopCard(id, imgUrl, category, name, price){
const amount = storedData.amountInCart(id);
const card = document.createElement('div');
const img = document.createElement('div');
const imgHover = document.createElement('div');
Expand All @@ -19,6 +21,7 @@ export default function shopCard(id, imgUrl, category, name, price, amount = 0){
namePara.textContent = name;
pricePara.textContent = `$${parseFloat(price).toFixed(2)}`;
favCheckbox.setAttribute('type', 'checkbox');
if (storedData.isFav(id)) favCheckbox.setAttribute('checked', true);
btn.textContent = amount === 0 ? 'Add to Cart'
: `${amount} Item${amount > 1 ? 's' : ''} added`;
btnRemove.textContent = '-';
Expand Down

0 comments on commit f17f743

Please sign in to comment.