From 71a75845756649891943fbdb6844f6ffc60ba39e Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 19 Sep 2023 17:58:48 +0200 Subject: [PATCH] WIP b2b --- .../Components/TopbarNavigation.razor | 15 ++- .../OverlayB2B/B2BProductHistoryOverlay.razor | 62 +++++++++++++ .../B2BProductHistoryOverlay.razor.cs | 63 +++++++++++++ .../Pages/BusinessCustomerLandingPage.razor | 92 +++++++++---------- .../BusinessCustomerLandingPage.razor.cs | 41 +++++++++ .../BusinessCustomerWebShopPage.razor.cs | 23 ----- .../Pages/BusinessCustomerWebshopPage.razor | 20 ---- Wonky.Client/Shared/MainLayout.razor | 2 +- Wonky.Client/Wonky.Client.csproj | 1 + Wonky.Entity/DTO/B2BBusinessInfo.cs | 1 + 10 files changed, 227 insertions(+), 93 deletions(-) create mode 100644 Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor create mode 100644 Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor.cs delete mode 100644 Wonky.Client/Pages/BusinessCustomerWebShopPage.razor.cs delete mode 100644 Wonky.Client/Pages/BusinessCustomerWebshopPage.razor diff --git a/Wonky.Client/Components/TopbarNavigation.razor b/Wonky.Client/Components/TopbarNavigation.razor index ffee20ce..61142949 100644 --- a/Wonky.Client/Components/TopbarNavigation.razor +++ b/Wonky.Client/Components/TopbarNavigation.razor @@ -15,12 +15,21 @@ @using System.Security.Claims - + + + + + + \ No newline at end of file diff --git a/Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor b/Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor new file mode 100644 index 00000000..2febbd93 --- /dev/null +++ b/Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor @@ -0,0 +1,62 @@ +@* Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +*@ + +@using Wonky.Client.Components +@using Wonky.Client.Helpers + +@if (_showBackdrop) +{ + +} \ No newline at end of file diff --git a/Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor.cs b/Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor.cs new file mode 100644 index 00000000..a5a5ee49 --- /dev/null +++ b/Wonky.Client/OverlayB2B/B2BProductHistoryOverlay.razor.cs @@ -0,0 +1,63 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpRepository; +using Wonky.Entity.Views; + +namespace Wonky.Client.OverlayB2B; +#pragma warning disable CS8618 + +public partial class B2BProductHistoryOverlay +{ + // ############################################################## + [Inject] public IB2BRepository HistoryRepo { get; set; } + + // ############################################################## + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public string ItemSku { get; set; } = ""; + + // ############################################################## + private List? History { get; set; } + private string ProductName { get; set; } = ""; + private string _modalDisplay = ""; + private bool _showBackdrop; + + + protected override async Task OnParametersSetAsync() + { + History = await HistoryRepo.GetCustomerProductHistory(CompanyId, ItemSku); + if (History.Any()) + { + ProductName = History[0].Description; + } + } + + + public void Show() + { + _modalDisplay = "block;"; + _showBackdrop = true; + StateHasChanged(); + } + + + private void Hide() + { + _modalDisplay = "none;"; + _showBackdrop = false; + StateHasChanged(); + } +} diff --git a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor index aef20667..cd055847 100644 --- a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor +++ b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor @@ -18,51 +18,48 @@ @attribute [Authorize(Roles = "EShop")] @page "/b2b/{countryCode}/{companyId}" -
- @if (!string.IsNullOrWhiteSpace(_businessInfo.Name)) - { - - - - - - - - - - - - - - - - - - - -
@_businessInfo.Name
@_businessInfo.Address1
@_businessInfo.Address2
@_businessInfo.ZipCode @_businessInfo.City
@_businessInfo.Phone
@_businessInfo.Email
- - } -
-
- @if (!string.IsNullOrWhiteSpace(_advisorInfo.Name)) - { - - - - - - - - - - - - - -
Konsulent
@_advisorInfo.Name@_advisorInfo.Email@_advisorInfo.Phone
- } +
+
+ @if (!string.IsNullOrWhiteSpace(_businessInfo.Name)) + { +
+
+
+ @_businessInfo.Name +
+

+ @_businessInfo.Address1
+ @_businessInfo.Address2
+ @_businessInfo.ZipCode @_businessInfo.City
+

+

+ @_businessInfo.Account
+ @_businessInfo.Phone
+ @_businessInfo.Email
+

+
+
+ } +
+
+ @if (!string.IsNullOrWhiteSpace(_advisorInfo.Name)) + { +
+
+
+ @_advisorInfo.Name +
+

+ @_advisorInfo.Phone
+ @_advisorInfo.Email
+

+
+
+ } + +
+
@if (_productInventory.Any()) { @@ -83,14 +80,17 @@ @product.LastInvoiceDate @product.Description @product.Quantity - + + + } + } else { - + }
\ No newline at end of file diff --git a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs index 24c197ef..34466e4e 100644 --- a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs +++ b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs @@ -1,7 +1,10 @@ +using System.Globalization; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Options; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; +using Wonky.Client.OverlayB2B; +using Wonky.Client.Shared; using Wonky.Entity.Configuration; using Wonky.Entity.DTO; using Wonky.Entity.Views; @@ -18,6 +21,8 @@ public partial class BusinessCustomerLandingPage : IDisposable [Inject] private IOptions Config { get; set; } // ############################################################## + [CascadingParameter] private DraftStateProvider DraftProvider { get; set; } = new(); + [Parameter] public string CountryCode { get; set; } = ""; [Parameter] public string CompanyId { get; set; } = ""; @@ -27,6 +32,9 @@ public partial class BusinessCustomerLandingPage : IDisposable private List _productHistory = new(); private List _productInventory = new(); private ApiConfig _config = new(); + private B2BProductHistoryOverlay PriceOverlay { get; set; } + private string Price { get; set; } = "0"; + protected override async Task OnInitializedAsync() { @@ -44,6 +52,39 @@ public partial class BusinessCustomerLandingPage : IDisposable } } + + private void ShowPriceHistoryOverlay() + { + PriceOverlay.Show(); + } + + + // private async Task PriceCatalogOverlayCallback(ItemSelect selectedItem) + // { + // // get selected item + // if (string.IsNullOrWhiteSpace(selectedItem.ItemNo)) + // { + // return; + // } + // _selectedItem = await CatalogRepo.GetSalesItemSku(_company.CountryCode, selectedItem.ItemNo); + // ShowItem = true; + // Price = selectedItem.Rate; + // Quantity = selectedItem.Quantity; + // StateHasChanged(); + // } + + + private void PriceHistoryOverlayCallback(decimal price) + { + if (price == 0) + { + return; + } + Price = price.ToString("N2", CultureInfo.InvariantCulture); + StateHasChanged(); + } + + public void Dispose() { diff --git a/Wonky.Client/Pages/BusinessCustomerWebShopPage.razor.cs b/Wonky.Client/Pages/BusinessCustomerWebShopPage.razor.cs deleted file mode 100644 index 1a412866..00000000 --- a/Wonky.Client/Pages/BusinessCustomerWebShopPage.razor.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -namespace Wonky.Client.Pages; - -#pragma warning disable CS8618 - -public partial class BusinessCustomerWebShopPage -{ - -} \ No newline at end of file diff --git a/Wonky.Client/Pages/BusinessCustomerWebshopPage.razor b/Wonky.Client/Pages/BusinessCustomerWebshopPage.razor deleted file mode 100644 index 460a870a..00000000 --- a/Wonky.Client/Pages/BusinessCustomerWebshopPage.razor +++ /dev/null @@ -1,20 +0,0 @@ -@* Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -*@ - - -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "EShop")] -@page "/b2b/{countryCode}/{companyId}/webshop" -

BusinessCustomerWebshopPage

diff --git a/Wonky.Client/Shared/MainLayout.razor b/Wonky.Client/Shared/MainLayout.razor index a27bee75..c2adde5a 100644 --- a/Wonky.Client/Shared/MainLayout.razor +++ b/Wonky.Client/Shared/MainLayout.razor @@ -34,7 +34,7 @@
@Body
- +
diff --git a/Wonky.Client/Wonky.Client.csproj b/Wonky.Client/Wonky.Client.csproj index 84bb4aee..0b3fd748 100644 --- a/Wonky.Client/Wonky.Client.csproj +++ b/Wonky.Client/Wonky.Client.csproj @@ -3800,4 +3800,5 @@ + diff --git a/Wonky.Entity/DTO/B2BBusinessInfo.cs b/Wonky.Entity/DTO/B2BBusinessInfo.cs index dbc7addc..cd851bbe 100644 --- a/Wonky.Entity/DTO/B2BBusinessInfo.cs +++ b/Wonky.Entity/DTO/B2BBusinessInfo.cs @@ -2,6 +2,7 @@ namespace Wonky.Entity.DTO; public class B2BBusinessInfo { + public string Account { get; set; } = ""; public string Address1 { get; set; } = ""; public string Address2 { get; set; } = ""; public string City { get; set; } = "";