From a342bc57ad3fdea24786d35497c167b7a76a76de Mon Sep 17 00:00:00 2001 From: Loretta Date: Fri, 29 Nov 2024 16:11:17 +0100 Subject: [PATCH] You're the winner! --- .../Views/PublicInfo.cshtml | 2 +- .../Views/PublicProductBidBox.cshtml | 42 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml index 35303bb..7ccce82 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicInfo.cshtml @@ -63,7 +63,7 @@ '" class="bg-success p-1 text-white text-center" style="position: absolute; width: calc(100% - 1rem); height: 50px; z-index: 1;">

' + 'LIVE RIGTH NOW' + '

' + - productToAuctionDto.sortIndex + + "No.: " + productToAuctionDto.sortIndex + ''); } else { console.log("isActive: " + isActive); diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml index 7f78c43..362fc2b 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml @@ -13,7 +13,15 @@ { var bgClass = Model.FirstProductToAuction.WinnerCustomerId == Model.CustomerId ? "bg-success" : "bg-primary"; var bidButtonActive = Model.IsItemActive && (Model.FirstProductToAuction.WinnerCustomerId != Model.CustomerId || Model.IsAdmin); - var title = Model.FirstProductToAuction.WinnerCustomerId == Model.CustomerId ? "Your bid is leading" : "Place a bid!"; + var auctionStatus = Model.FirstProductToAuction.AuctionStatus; + var lastBidIsMine = Model.FirstProductToAuction.WinnerCustomerId == Model.CustomerId; + + var title = auctionStatus switch + { + AuctionStatus.Sold => lastBidIsMine ? "You're the winner!" : "Sold", + AuctionStatus.NotSold => "Finished", + _ => lastBidIsMine ? "Your bid is leading" : "Place a bid!" + };
@@ -289,13 +297,16 @@ // data.AuctionDto. // } var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId); - var budButtonElement = document.getElementById("signalRBidButton"); + var bidButtonElement = document.getElementById("signalRBidButton"); var licitStepElement = document.getElementById("licitStepText"); var bidBox = document.getElementById("publicProductBidBox"); var bidBoxTitle = document.getElementById("bidBoxTitle"); console.log(data); - var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id; - var winnerId = data.auctionDto.productToAuctionDtos[0].winnerCustomerId; + + let auctionDto = data.auctionDto; + let productToAuction = auctionDto.productToAuctionDtos[0]; + var productAuctionMappingId = productToAuction.id; + var winnerId = productToAuction.winnerCustomerId; var isMyBid; if (winnerId == bidBoxPageViewModel.CustomerId) { @@ -325,34 +336,35 @@ widgetPriceElement.textContent = HUFFormatter.format(data.currentPrice); // Update the price licitStepElement.textContent = HUFFormatter.format(data.nextStepAmount); bidBoxPageViewModel.NextBidPrice = Number(data.nextBidPrice); - budButtonElement.disabled = false; + bidButtonElement.disabled = false; + var list; if (isMyBid) { console.log("This is my bid"); - var list = bidBox.classList; + list = bidBox.classList; list.add("bg-success"); list.remove("bg-primary"); - budButtonElement.textContent = "Good job"; - bidBoxTitle.textContent = "Your bid is leading!" + bidButtonElement.textContent = "Good job"; + bidBoxTitle.textContent = productToAuction.auctionStatus == AuctionStatus.Sold ? "You're the winner!" : "Your bid is leading!"; if (bidBoxPageViewModel.IsAdmin) { console.log("I AM WEASEL!!! " + bidBoxPageViewModel.IsAdmin); - budButtonElement.disabled = false; + bidButtonElement.disabled = false; } else { console.log("I AM NOT WEASEL!!! " + bidBoxPageViewModel.IsAdmin); - budButtonElement.disabled = true; + bidButtonElement.disabled = true; } } else { - var list = bidBox.classList; + list = bidBox.classList; list.add("bg-primary"); list.remove("bg-success"); - bidBoxTitle.textContent = "Place a bid!" - budButtonElement.textContent = "Bid " + HUFFormatter.format(bidBoxPageViewModel.NextBidPrice); + bidBoxTitle.textContent = productToAuction.auctionStatus == AuctionStatus.Sold ? "Sold" : "Place a bid!"; + bidButtonElement.textContent = "Bid " + HUFFormatter.format(bidBoxPageViewModel.NextBidPrice); } console.log(`WidgetPrice updated to: ${data.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`); - //budButtonElement.disabled = false; + //bidButtonElement.disabled = false; } @@ -392,7 +404,7 @@ bidBoxTitle.textContent = "First warning!"; } else if (itemStatus == AuctionStatus.SecondWarning) { - bidBoxTitle.textContent = "Secnod warning! Hurry up!"; + bidBoxTitle.textContent = "Second warning! Hurry up!"; } setButtons(itemStatus);