diff --git a/src/WebApp/Components/Layout/HeaderBar.razor b/src/WebApp/Components/Layout/HeaderBar.razor index 9f8d1acf8..cf46a2b58 100644 --- a/src/WebApp/Components/Layout/HeaderBar.razor +++ b/src/WebApp/Components/Layout/HeaderBar.razor @@ -1,4 +1,5 @@ @using Microsoft.AspNetCore.Components.Endpoints +@inject PinkPricesState PinkPricesState
@@ -13,6 +14,12 @@ +
+ +
diff --git a/src/WebApp/Components/Layout/HeaderBar.razor.css b/src/WebApp/Components/Layout/HeaderBar.razor.css index 062cf160c..c3829f74a 100644 --- a/src/WebApp/Components/Layout/HeaderBar.razor.css +++ b/src/WebApp/Components/Layout/HeaderBar.razor.css @@ -71,6 +71,26 @@ gap: 1.5rem; } +.pink-prices-toggle { + display: flex; + align-items: center; +} + +.pink-prices-toggle label { + display: flex; + align-items: center; + gap: 0.5rem; + cursor: pointer; + font-size: 0.9rem; + font-weight: 600; +} + +.pink-prices-toggle input[type="checkbox"] { + cursor: pointer; + width: 1.2rem; + height: 1.2rem; +} + @media only screen and (max-width: 480px) { .eshop-header-hero { height: 18rem; diff --git a/src/WebApp/Components/Layout/MainLayout.razor b/src/WebApp/Components/Layout/MainLayout.razor index ab7be4a3b..facca5e5a 100644 --- a/src/WebApp/Components/Layout/MainLayout.razor +++ b/src/WebApp/Components/Layout/MainLayout.razor @@ -1,13 +1,30 @@ @using eShop.WebApp.Components.Chatbot +@using eShop.WebApp.Services @inherits LayoutComponentBase +@inject PinkPricesState PinkPricesState +@implements IDisposable - -@Body - - +
+ + @Body + + +
An unhandled error has occurred. Reload 🗙
+ +@code { + protected override void OnInitialized() + { + PinkPricesState.OnChange += StateHasChanged; + } + + public void Dispose() + { + PinkPricesState.OnChange -= StateHasChanged; + } +} diff --git a/src/WebApp/Components/Pages/Cart/CartPage.razor b/src/WebApp/Components/Pages/Cart/CartPage.razor index bd8ccfab7..fe5732321 100644 --- a/src/WebApp/Components/Pages/Cart/CartPage.razor +++ b/src/WebApp/Components/Pages/Cart/CartPage.razor @@ -51,7 +51,7 @@
-
+
$@((item.UnitPrice * quantity).ToString("0.00"))
@@ -68,7 +68,7 @@
Total
-
$@TotalPrice?.ToString("0.00")
+
$@TotalPrice?.ToString("0.00")
Check out diff --git a/src/WebApp/Components/Pages/User/Orders.razor b/src/WebApp/Components/Pages/User/Orders.razor index 00dd1d533..e7404cdd5 100644 --- a/src/WebApp/Components/Pages/User/Orders.razor +++ b/src/WebApp/Components/Pages/User/Orders.razor @@ -34,7 +34,7 @@ else
@order.Date
-
+
$@order.Total.ToString("0.00")
diff --git a/src/WebApp/Extensions/Extensions.cs b/src/WebApp/Extensions/Extensions.cs index bcfe09a97..e6afba7d0 100644 --- a/src/WebApp/Extensions/Extensions.cs +++ b/src/WebApp/Extensions/Extensions.cs @@ -1,4 +1,5 @@ using eShop.Basket.API.Grpc; +using eShop.WebApp.Services; using eShop.WebApp.Services.OrderStatus.IntegrationEvents; using eShop.WebAppComponents.Services; using Microsoft.AspNetCore.Authentication.Cookies; @@ -22,6 +23,7 @@ public static void AddApplicationServices(this IHostApplicationBuilder builder) // Application services builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/src/WebApp/Services/PinkPricesState.cs b/src/WebApp/Services/PinkPricesState.cs new file mode 100644 index 000000000..ff6c9d858 --- /dev/null +++ b/src/WebApp/Services/PinkPricesState.cs @@ -0,0 +1,21 @@ +namespace eShop.WebApp.Services; + +public class PinkPricesState +{ + private bool _isPinkPricesEnabled; + + public bool IsPinkPricesEnabled + { + get => _isPinkPricesEnabled; + set + { + if (_isPinkPricesEnabled != value) + { + _isPinkPricesEnabled = value; + OnChange?.Invoke(); + } + } + } + + public event Action? OnChange; +} diff --git a/src/WebApp/wwwroot/css/app.css b/src/WebApp/wwwroot/css/app.css index 52c953084..d3323bd86 100644 --- a/src/WebApp/wwwroot/css/app.css +++ b/src/WebApp/wwwroot/css/app.css @@ -288,4 +288,9 @@ h1:focus { .blazor-error-boundary::after { content: "An error has occurred." - } \ No newline at end of file + } + +/* Pink Prices Mode */ +.pink-prices-mode .price { + color: pink !important; +} \ No newline at end of file