diff --git a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js index 50f2b48..5266fee 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js +++ b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js @@ -9,7 +9,7 @@ if (!liveScreen) { toastr.info(`
${myObject.message}
`, myObject.title, { "closeButton": true, - "positionClass": "toast-bottom-right", + "positionClass": "toast-top-right", "newestOnTop": true, "progressBar": true, "preventDuplicates": false, @@ -47,7 +47,7 @@ if (!liveScreen) { toastr.success(`

${myObject.currentPrice}

${myObject.productName}

`, "New bid arrived", { "closeButton": true, - "positionClass": "toast-bottom-right", + "positionClass": "toast-top-right", "newestOnTop": true, "progressBar": true, "preventDuplicates": false, @@ -74,7 +74,7 @@ if (!liveScreen) { toastr.success(`

${productToAuctionDto.auctionStatus}

${productToAuctionDto.id}

`, "Status changed", { "closeButton": true, - "positionClass": "toast-bottom-right", + "positionClass": "toast-top-right", "newestOnTop": true, "progressBar": true, "preventDuplicates": false, @@ -107,7 +107,7 @@ var myObject = JSON.parse(data); toastr.success(`

${myObject.nextBidPrice}

${myObject.productName}

`, "Item auction is OPENED!", { "closeButton": true, - "positionClass": "toast-bottom-right", + "positionClass": "toast-top-right", "newestOnTop": true, "progressBar": true, "preventDuplicates": false, diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml index 349f3dc..63a70ea 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml @@ -9,93 +9,97 @@ @{ if (!Model.IsGuest) { -
-

This item is under auction!

-
-
- Base Price: - - @($"{Model.BasePrice:c}") - @* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@ - -
-
- Bid Step: - @($"{Model.LicitStep:c}") -
-
- - @* + @* *@ -
-
+
+ - @* *@ -
- +
+ if (Model.IsAdmin) { -
-

Manage auction!

-
+
+

Manage auction!

+
-
- - - - -
-
- - - -
+
+ + + + +
+
+ + + +
-
-
+
+
} else { -

No access to admin level buttons

+

No access to admin level buttons

} } else { -
-

This item is under auction!

-
+
+

This item is under auction!

+
-

Please log in or register to participate!

-
-
+

Please log in or register to participate!

+
+
} } @@ -118,12 +122,12 @@ document.getElementById("signalRBidButton").disabled = true; event.preventDefault(); - + if (!bidBoxPageViewModel) { console.log("we need viewmodel data"); bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model)); } - + var bidMessage = { ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId, AuctionId: bidBoxPageViewModel.AuctionId, @@ -190,12 +194,12 @@ event.preventDefault(); if (!bidBoxPageViewModel) { - console.log("we need viewmodel data"); - bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model)); + console.log("we need viewmodel data"); + bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model)); } var revertMessage = { - ProductToAuctionId: bidBoxPageViewModel.ProductToAuctionId, + ProductToAuctionId: bidBoxPageViewModel.ProductToAuctionId, }; var content = JSON.stringify(revertMessage); @@ -206,13 +210,15 @@ }); $("#signalRResetItemButton").on("click", function () { - document.getElementById("signalRResetItemButton").disabled = true; - event.preventDefault(); + document.getElementById("signalRResetItemButton").disabled = true; + event.preventDefault(); - sendAuctionStatusChange(AuctionStatus.None); + sendAuctionStatusChange(AuctionStatus.None); - return false; + return false; }); + //var status = bidBoxPageViewModel.auctionDto.productToAuctionDtos[0].auctionStatus; + //setButtons(status); }); function sendAuctionStatusChange(auctionStatus) { @@ -250,10 +256,20 @@ var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId); var budButtonElement = 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; + var isMyBid; + + if (winnerId == bidBoxPageViewModel.CustomerId) { + isMyBid = true; + + } + console.log(productAuctionMappingId); - + //TODO: TESZT STATUS!!! - JTEST. var status = data.auctionDto.productToAuctionDtos[0].auctionStatus; //var status = AuctionStatus.TEST; @@ -274,16 +290,34 @@ widgetPriceElement.textContent = HUFFormatter.format(data.currentPrice); // Update the price licitStepElement.textContent = HUFFormatter.format(data.nextStepAmount); bidBoxPageViewModel.NextBidPrice = Number(data.nextBidPrice); + budButtonElement.disabled = false; + if (isMyBid) { + console.log("This is my bid"); + const list = bidBox.classList; + list.add("bg-success"); + list.remove("bg-primary"); + budButtonElement.textContent = "Good job"; + bidBoxTitle.textContent="Your bid is leading!" + if (bidBoxPageViewModel.IsAdmin) { + console.log("I AM WEASEL!!! " + bidBoxPageViewModel.IsAdmin); + budButtonElement.disabled = false; + } + else { + console.log("I AM NOT WEASEL!!! " + bidBoxPageViewModel.IsAdmin); + budButtonElement.disabled = true; + } + } + else { + const list = bidBox.classList; + list.add("bg-primary"); + list.remove("bg-success"); + bidBoxTitle.textContent = "Place a bid!" + budButtonElement.textContent = "Bid " + HUFFormatter.format(bidBoxPageViewModel.NextBidPrice); - budButtonElement.textContent = "Bid " + HUFFormatter.format(bidBoxPageViewModel.NextBidPrice); - - - // if (bidBoxPageViewModel.CustomerId == data.CustomerId) { - - // } + } console.log(`WidgetPrice updated to: ${data.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`); - budButtonElement.disabled = false; + //budButtonElement.disabled = false; } @@ -299,12 +333,13 @@ function handleAuctionUpdate(data) { var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId); + var bidBoxTitle = document.getElementById("bidBoxTitle"); var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id; //TODO: TESZT STATUS!!! - JTEST. var itemStatus = data.auctionDto.productToAuctionDtos[0].auctionStatus; //var itemStatus = AuctionStatus.TEST; - + console.log("handle auction update called" + productAuctionMappingId); console.log("auction status:" + itemStatus); if (widgetPriceElement) { @@ -312,6 +347,19 @@ if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) { console.log("THIS IS FOR US! SORRY FOR SHOUTING"); + if (itemStatus == AuctionStatus.None) { + bidBoxTitle.textContent = "The auction has not started yet"; + } + else if (itemStatus == AuctionStatus.Pause) { + bidBoxTitle.textContent = "The auction is paused! Please hold on..."; + } + else if (itemStatus == AuctionStatus.FirstWarning) { + bidBoxTitle.textContent = "First warning!"; + } + else if (itemStatus == AuctionStatus.SecondWarning) { + bidBoxTitle.textContent = "Secnod warning! Hurry up!"; + } + setButtons(itemStatus); console.log(`WidgetPrice updated to: ${data.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`); @@ -407,14 +455,14 @@ signalRResetItemButton: false, }, [AuctionStatus.TEST]: { - signalRBidButton: false, - signalRFirstWarningButton: false, - signalRSecondWarningButton: false, - signalROpenItemButton: false, - signalRCloseItemButton: false, - signalRPauseItemButton: false, - signalRRevertBidButton: false, - signalRResetItemButton: false, + signalRBidButton: false, + signalRFirstWarningButton: false, + signalRSecondWarningButton: false, + signalROpenItemButton: false, + signalRCloseItemButton: false, + signalRPauseItemButton: false, + signalRRevertBidButton: false, + signalRResetItemButton: false, }, }; @@ -431,7 +479,7 @@ const button = document.getElementById(buttonId); if (button) { button.disabled = states[buttonId]; - // button.hidden = states[buttonId]; + button.hidden = states[buttonId]; } else { console.warn(`Button with ID ${buttonId} not found.`); }