diff --git a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor index caf57600..47cd3be5 100644 --- a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor +++ b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor @@ -19,79 +19,100 @@ @attribute [Authorize(Roles = "EShop")] @page "/b2b/{countryCode}/{companyId}" -
-
- @if (!string.IsNullOrWhiteSpace(_businessInfo.Name)) - { -
-
-
- @_businessInfo.Name -
-

- @_businessInfo.Address1
- @_businessInfo.Address2
- @_businessInfo.ZipCode @_businessInfo.City
-

-

- @_businessInfo.Account
- @_businessInfo.Phone
- @_businessInfo.Email
-

-
-
- } +
+
+
+
+ @_businessInfo.Name +
+

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

+
+
+
+
+
+ Leveringsadresse +
+

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

+
+
+
+
+
+ @_advisorInfo.Name +
+

+ @_advisorInfo.Phone
+ @_advisorInfo.Email
+

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

- @_advisorInfo.Phone
- @_advisorInfo.Email
-

-
-
- } -
-
- @if (_productInventory.Any()) - { - - - - - - - - @foreach (var product in _productInventory) - { - - - - - - - - } - -
Produkter
- @product.Description + @foreach (var product in _productInventory) + { +
+
+
+ @product.Description -
@product.LastInvoiceDate@product.Description@product.Quantity - -
- - } - else - { - - } -
\ No newline at end of file +
+
+
+
+ @product.Description +
+ + + + + + + + + + + + + + + +
Sidste købForbrug
+ @product.LastInvoiceDate + + @product.Quantity + + + Historik + +
+
+ +
+
+
+
+ + } + + +} +else +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs index 34466e4e..0640faa5 100644 --- a/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs +++ b/Wonky.Client/Pages/BusinessCustomerLandingPage.razor.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Options; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; +using Wonky.Client.Models; using Wonky.Client.OverlayB2B; using Wonky.Client.Shared; using Wonky.Entity.Configuration; @@ -18,11 +19,14 @@ public partial class BusinessCustomerLandingPage : IDisposable // ############################################################## [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IB2BRepository B2BRepo { get; set; } + + [Inject] + public ICountryCatalogRepository Catalog { get; set; } [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; } = ""; @@ -32,10 +36,13 @@ 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"; - - + private B2BProductPriceHistoryOverlay PriceHistoryOverlay { get; set; } + private string _price = "0"; + private string _quantity = "1"; + private ItemSelect _selectedItem = new(); + private string _sku = ""; + + protected override async Task OnInitializedAsync() { Interceptor.RegisterEvent(); @@ -47,15 +54,37 @@ public partial class BusinessCustomerLandingPage : IDisposable if (_productInventory.Any()) { _productInventory = _productInventory - .OrderByDescending(x => x.LastInvoiceDate) + .OrderByDescending(x => x.Quantity) .ToList(); } } - - private void ShowPriceHistoryOverlay() + + private async Task AddItemToOrder(string sku) { - PriceOverlay.Show(); + var item = await Catalog.GetSalesItemSku(CountryCode, sku); + var history = await B2BRepo.GetCustomerProductHistory(CompanyId, sku); + var line = history + .OrderByDescending(x => x.DeliveryDate) + .Where(x => x.Price != 0).Take(1).ToList()[0]; + DraftProvider.Draft.DraftId = CompanyId; + DraftProvider.Draft.Items.Add( + new DraftItem() + { + Price = line.Price, + Quantity = line.Quantity, + Discount = 0, + Sas = false, + Item = item + }); + await DraftProvider.SaveChangesAsync(); + } + + + private void ShowProductHistoryOverlay(string sku) + { + _sku = sku; + PriceHistoryOverlay.Show(); } @@ -73,18 +102,18 @@ public partial class BusinessCustomerLandingPage : IDisposable // StateHasChanged(); // } - + private void PriceHistoryOverlayCallback(decimal price) { if (price == 0) { return; } - Price = price.ToString("N2", CultureInfo.InvariantCulture); + + _price = price.ToString("N2", CultureInfo.InvariantCulture); StateHasChanged(); } - - + public void Dispose() {