diff --git a/js/admin.js b/js/admin.js index 87347fd9..2b1d4c47 100644 --- a/js/admin.js +++ b/js/admin.js @@ -39,12 +39,16 @@ function dataListenerCallback(data) { table.appendChild(row); } // Extract bid data + let item = bids[0]; let bidCount = Object.keys(bids).length - 1; - row.children[1].innerText = bids[0].title; - row.children[2].innerText = `£${bids[bidCount].amount.toFixed(2)}`; + let currentBid = bids[bidCount]; + row.children[1].innerText = item.title; + row.children[2].innerText = `${item.currency}${currentBid.amount.toFixed( + 2 + )}`; row.children[3].innerText = bidCount; - if (bids[bidCount].uid) { - getDoc(doc(db, "users", bids[bidCount].uid)).then((user) => { + if (currentBid.uid) { + getDoc(doc(db, "users", currentBid.uid)).then((user) => { row.children[4].innerText = user.get("name"); console.debug("dataListener() read from users"); }); @@ -55,14 +59,14 @@ function dataListenerCallback(data) { if (isDemo) { // Make sure some items always appear active for the demo let now = new Date(); - let endTime = bids[0].endTime.toDate(); + let endTime = item.endTime.toDate(); endTime.setHours(now.getHours()); endTime.setDate(now.getDate()); endTime.setMonth(now.getMonth()); endTime.setFullYear(now.getFullYear()); row.children[5].dataset.endTime = endTime.getTime(); } else { - row.children[5].dataset.endTime = bids[0].endTime.toMillis(); + row.children[5].dataset.endTime = item.endTime.toMillis(); } } } diff --git a/js/auctions.js b/js/auctions.js index 3b695455..05050748 100644 --- a/js/auctions.js +++ b/js/auctions.js @@ -85,7 +85,7 @@ function generateItemCard(auction) { bidRow.appendChild(bidTitle); let bid = document.createElement("td"); - bid.innerHTML = "£-.-- [- bids]"; + bid.innerHTML = "?-.-- [- bids]"; bid.classList.add("current-bid"); bidRow.appendChild(bid); @@ -143,11 +143,12 @@ function dataListenerCallback(data) { let currentBid = card.querySelector(".current-bid"); // Extract bid data let bidCount = Object.keys(bids).length - 1; - let currPound = bids[bidCount].amount.toFixed(2); + let currentAmount = bids[bidCount].amount.toFixed(2); // Add bid data to HTML - currentBid.innerHTML = `£${numberWithCommas(currPound)} [${bidCount} bid${ - bidCount != 1 ? "s" : "" - }]`; + let plural = bidCount != 1 ? "s" : ""; + currentBid.innerHTML = `${item.currency}${numberWithCommas( + currentAmount + )} [${bidCount} bid${plural}]`; // Update everything else if (isDemo) { // Make sure some items always appear active for the demo diff --git a/js/items.js b/js/items.js index 020b6178..940adb51 100644 --- a/js/items.js +++ b/js/items.js @@ -9,6 +9,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 55, endTime: "2023-04-25T00:00:00+00:00", }, @@ -18,6 +19,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 60, endTime: "2023-04-25T00:05:00+00:00", }, @@ -27,6 +29,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 20, endTime: "2023-04-25T00:10:00+00:00", }, @@ -36,6 +39,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 0, endTime: "2023-04-25T00:15:00+00:00", }, @@ -45,6 +49,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 4, endTime: "2023-04-25T00:20:00+00:00", }, @@ -54,6 +59,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 0, endTime: "2023-04-25T00:25:00+00:00", }, @@ -63,6 +69,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 99, endTime: "2023-04-25T00:30:00+00:00", }, @@ -72,6 +79,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 0, endTime: "2023-04-25T00:35:00+00:00", }, @@ -81,6 +89,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 12, endTime: "2023-04-25T00:40:00+00:00", }, @@ -90,6 +99,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 6, endTime: "2023-04-25T00:45:00+00:00", }, @@ -99,6 +109,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 3, endTime: "2023-04-25T00:50:00+00:00", }, @@ -108,6 +119,7 @@ let items = [ subtitle: "", detail: "", secondaryImage: "", + currency: "£", amount: 7, endTime: "2023-04-25T00:55:00+00:00", }, diff --git a/js/popups.js b/js/popups.js index 4ebf19b2..626668c3 100644 --- a/js/popups.js +++ b/js/popups.js @@ -167,6 +167,7 @@ if (bidModal) { let data = doc.data(); let itemId = `item${i.toString().padStart(5, "0")}`; let bids = Object.keys(data).filter((key) => key.includes(itemId)); + let item = data[bids[0]]; let bidId = `bid${bids.length.toString().padStart(5, "0")}`; let currentBid = data[bids[bids.length - 1]].amount; if (amount >= 1 + currentBid) { @@ -186,8 +187,9 @@ if (bidModal) { }, 1000); } else { amountElement.classList.add("is-invalid"); - feedback.innerText = - "You must bid at least £" + (currentBid + 1).toFixed(2) + "!"; + feedback.innerText = `You must bid at least ${item.currency}${( + currentBid + 1 + ).toFixed(2)}!`; bidModalSubmit.removeAttribute("disabled", ""); } });