This commit is contained in:
Loretta 2024-11-26 16:28:09 +01:00
commit 849c04c10b
2 changed files with 140 additions and 92 deletions

View File

@ -9,7 +9,7 @@
if (!liveScreen) { if (!liveScreen) {
toastr.info(`<div class="item announcemantToast">${myObject.message}</div>`, myObject.title, { toastr.info(`<div class="item announcemantToast">${myObject.message}</div>`, myObject.title, {
"closeButton": true, "closeButton": true,
"positionClass": "toast-bottom-right", "positionClass": "toast-top-right",
"newestOnTop": true, "newestOnTop": true,
"progressBar": true, "progressBar": true,
"preventDuplicates": false, "preventDuplicates": false,
@ -47,7 +47,7 @@
if (!liveScreen) { if (!liveScreen) {
toastr.success(`<div class="item bidToast"><p>${myObject.currentPrice}</p><p>${myObject.productName}</p></div>`, "New bid arrived", { toastr.success(`<div class="item bidToast"><p>${myObject.currentPrice}</p><p>${myObject.productName}</p></div>`, "New bid arrived", {
"closeButton": true, "closeButton": true,
"positionClass": "toast-bottom-right", "positionClass": "toast-top-right",
"newestOnTop": true, "newestOnTop": true,
"progressBar": true, "progressBar": true,
"preventDuplicates": false, "preventDuplicates": false,
@ -74,7 +74,7 @@
if (!liveScreen) { if (!liveScreen) {
toastr.success(`<div class="item bidToast"><p>${productToAuctionDto.auctionStatus}</p><p>${productToAuctionDto.id}</p></div>`, "Status changed", { toastr.success(`<div class="item bidToast"><p>${productToAuctionDto.auctionStatus}</p><p>${productToAuctionDto.id}</p></div>`, "Status changed", {
"closeButton": true, "closeButton": true,
"positionClass": "toast-bottom-right", "positionClass": "toast-top-right",
"newestOnTop": true, "newestOnTop": true,
"progressBar": true, "progressBar": true,
"preventDuplicates": false, "preventDuplicates": false,
@ -107,7 +107,7 @@
var myObject = JSON.parse(data); var myObject = JSON.parse(data);
toastr.success(`<div class="item bidToast"><p>${myObject.nextBidPrice}</p><p>${myObject.productName}</p></div>`, "Item auction is OPENED!", { toastr.success(`<div class="item bidToast"><p>${myObject.nextBidPrice}</p><p>${myObject.productName}</p></div>`, "Item auction is OPENED!", {
"closeButton": true, "closeButton": true,
"positionClass": "toast-bottom-right", "positionClass": "toast-top-right",
"newestOnTop": true, "newestOnTop": true,
"progressBar": true, "progressBar": true,
"preventDuplicates": false, "preventDuplicates": false,

View File

@ -9,8 +9,12 @@
@{ @{
if (!Model.IsGuest) if (!Model.IsGuest)
{ {
<div id="publicProductBidBox" class="p-3 bg-primary text-white"> var bgClass = Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().WinnerCustomerId == Model.CustomerId ? "bg-success" : "bg-primary";
<h4>This item is under auction!</h4> bool bidButtonActive = Model.IsItemActive && (Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().WinnerCustomerId == Model.CustomerId && !Model.IsAdmin) ? true : false;
string title = Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().WinnerCustomerId == Model.CustomerId ? "Your bid is leading" : "Place a bid!";
<div id="publicProductBidBox" class="p-3 @bgClass text-white">
<h4 id="bidBoxTitle">@title</h4>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div> <div>
<strong>Base Price:</strong> <strong>Base Price:</strong>
@ -24,7 +28,7 @@
<span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span> <span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
</div> </div>
<div> <div>
<button id="signalRBidButton" class="btn btn-success" style="text-transform: uppercase;" type="button" disabled="@(!Model.IsItemActive)"> <button id="signalRBidButton" class="btn btn-success" style="text-transform: uppercase;" type="button" disabled="@(bidButtonActive)">
Bid @($"{Model.NextBidPrice:c}") Bid @($"{Model.NextBidPrice:c}")
</button> </button>
@* <button id="bidButton" class="btn btn-success"> @* <button id="bidButton" class="btn btn-success">
@ -51,27 +55,27 @@
<div> <div>
<button id="signalROpenItemButton" class="btn btn-primary" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.None || Model.AuctionStatus == AuctionStatus.Pause ? string.Empty : "disabled")> <button id="signalROpenItemButton" class="btn btn-primary" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.None || Model.AuctionStatus == AuctionStatus.Pause ? string.Empty : "disabled hidden")>
Open item Open item
</button> </button>
<button id="signalRPauseItemButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.Active || Model.AuctionStatus == AuctionStatus.FirstWarning || Model.AuctionStatus == AuctionStatus.SecondWarning ? string.Empty : "disabled")> <button id="signalRPauseItemButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.Active || Model.AuctionStatus == AuctionStatus.FirstWarning || Model.AuctionStatus == AuctionStatus.SecondWarning ? string.Empty : "disabled hidden")>
Pause auction Pause auction
</button> </button>
<button id="signalRRevertBidButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled" : string.Empty)> <button id="signalRRevertBidButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled hidden" : string.Empty)>
Revert bid Revert bid
</button> </button>
<button id="signalRResetItemButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled" : string.Empty)> <button id="signalRResetItemButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled hidden" : string.Empty)>
Reset auction Reset auction
</button> </button>
</div> </div>
<div> <div>
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Active ? "disabled" : string.Empty)> <button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Active ? "disabled hidden" : string.Empty)>
First warning First warning
</button> </button>
<button id="signalRSecondWarningButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.FirstWarning ? "disabled" : string.Empty)> <button id="signalRSecondWarningButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.FirstWarning ? "disabled hidden" : string.Empty)>
Second warning Second warning
</button> </button>
<button id="signalRCloseItemButton" class="btn btn-success" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.SecondWarning ? "disabled" : string.Empty)> <button id="signalRCloseItemButton" class="btn btn-success" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.SecondWarning ? "disabled hidden" : string.Empty)>
Finished Finished
</button> </button>
</div> </div>
@ -213,6 +217,8 @@
return false; return false;
}); });
//var status = bidBoxPageViewModel.auctionDto.productToAuctionDtos[0].auctionStatus;
//setButtons(status);
}); });
function sendAuctionStatusChange(auctionStatus) { function sendAuctionStatusChange(auctionStatus) {
@ -250,8 +256,18 @@
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId); var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
var budButtonElement = document.getElementById("signalRBidButton"); var budButtonElement = document.getElementById("signalRBidButton");
var licitStepElement = document.getElementById("licitStepText"); var licitStepElement = document.getElementById("licitStepText");
var bidBox = document.getElementById("publicProductBidBox");
var bidBoxTitle = document.getElementById("bidBoxTitle");
console.log(data); console.log(data);
var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id; 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); console.log(productAuctionMappingId);
//TODO: TESZT STATUS!!! - JTEST. //TODO: TESZT STATUS!!! - JTEST.
@ -274,16 +290,34 @@
widgetPriceElement.textContent = HUFFormatter.format(data.currentPrice); // Update the price widgetPriceElement.textContent = HUFFormatter.format(data.currentPrice); // Update the price
licitStepElement.textContent = HUFFormatter.format(data.nextStepAmount); licitStepElement.textContent = HUFFormatter.format(data.nextStepAmount);
bidBoxPageViewModel.NextBidPrice = Number(data.nextBidPrice); 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}`); console.log(`WidgetPrice updated to: ${data.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`);
budButtonElement.disabled = false; //budButtonElement.disabled = false;
} }
@ -299,6 +333,7 @@
function handleAuctionUpdate(data) { function handleAuctionUpdate(data) {
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId); var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
var bidBoxTitle = document.getElementById("bidBoxTitle");
var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id; var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id;
//TODO: TESZT STATUS!!! - JTEST. //TODO: TESZT STATUS!!! - JTEST.
@ -312,6 +347,19 @@
if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) { if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {
console.log("THIS IS FOR US! SORRY FOR SHOUTING"); 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); setButtons(itemStatus);
console.log(`WidgetPrice updated to: ${data.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`); console.log(`WidgetPrice updated to: ${data.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`);
@ -431,7 +479,7 @@
const button = document.getElementById(buttonId); const button = document.getElementById(buttonId);
if (button) { if (button) {
button.disabled = states[buttonId]; button.disabled = states[buttonId];
// button.hidden = states[buttonId]; button.hidden = states[buttonId];
} else { } else {
console.warn(`Button with ID ${buttonId} not found.`); console.warn(`Button with ID ${buttonId} not found.`);
} }