From ceaa1696fd1ec9712c1a826cfae6bb837240dae0 Mon Sep 17 00:00:00 2001 From: Tea Date: Wed, 17 Apr 2024 15:09:28 +0200 Subject: [PATCH] Closes #4: Attempting to unlock orders when one has already been marked as payed explains consequences and prompts for confirmation --- PizzaBot/Components/Pages/Admin.razor | 48 ++++++++++++++----- .../Components/PricePerPieceDisplay.razor | 11 +++++ 2 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 PizzaBot/Components/PricePerPieceDisplay.razor diff --git a/PizzaBot/Components/Pages/Admin.razor b/PizzaBot/Components/Pages/Admin.razor index 85498d0..737dba3 100644 --- a/PizzaBot/Components/Pages/Admin.razor +++ b/PizzaBot/Components/Pages/Admin.razor @@ -12,16 +12,24 @@

Order Locking

- +} +else +{ + + +} + +@if (ShowUnlockConfirmation) +{ +

Order(s) have already been marked as payed. If you unlock payment information WILL be lost!

+ +}

Global Message

@@ -136,15 +144,33 @@ bool WrongDeletionPasscode = false; string DeletionPasscode = ""; + bool ShowUnlockConfirmation = false; + void SaveNewPizzaConfig(EditContext editContext) { GlobalStuffService.SetConfig(PConfig); GlobalStuffService.ShouldBalance = true; } - void ToggleOrdersLocked() + void LockOrders() { - GlobalStuffService.SetOrdersLocked(!GlobalStuffService.OrdersLocked); + GlobalStuffService.SetOrdersLocked(true); + } + + void UnlockOrders() + { + if(PizzaDBService.GetAllResults().Where(o => o.hasPaid).Count() > 0) + { + ShowUnlockConfirmation = true; + return; + } + GlobalStuffService.SetOrdersLocked(false); + } + + void ConfirmedUnlockOrders() + { + ShowUnlockConfirmation = false; + GlobalStuffService.SetOrdersLocked(false); } void SetGlobalMessage() @@ -164,4 +190,4 @@ { PConfig = GlobalStuffService.GetConfig() ?? new PizzaConfig(); } -} \ No newline at end of file + } diff --git a/PizzaBot/Components/PricePerPieceDisplay.razor b/PizzaBot/Components/PricePerPieceDisplay.razor new file mode 100644 index 0000000..cbc550d --- /dev/null +++ b/PizzaBot/Components/PricePerPieceDisplay.razor @@ -0,0 +1,11 @@ +@inject GlobalStuffService GlobalStuffService +@using System.Globalization + +

Price per 🍕: @((GlobalStuffService.GetConfig().Price / (GlobalStuffService.GetConfig().Fragments * 100.0f)).ToString("C2", CultureInfo.CreateSpecificCulture("de-DE")))

+ +