From 9b64d515c35bd6440b3b2c5500b371d469301cca Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Mon, 28 Aug 2023 08:25:46 +0200 Subject: [PATCH] check fetching of customer inventory from office customer list page --- .../OfficeCountryCustomerListComponent.razor.cs | 16 +++++++++++----- .../HttpRepository/CountryCustomerRepository.cs | 12 +++++++----- Wonky.Client/wwwroot/appsettings.json | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs index 1fe2f634..5dd9398d 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs @@ -32,6 +32,13 @@ namespace Wonky.Client.Components; public partial class OfficeCountryCustomerListComponent { + // ****************************************************** + // injects + [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; } + + [Inject] public ILogger Logger { get; set; } + // ****************************************************** // parameters [Parameter] public string CountryCode { get; set; } = ""; @@ -39,11 +46,6 @@ public partial class OfficeCountryCustomerListComponent // [Parameter] public EventCallback OnOrderItem { get; set; } [CascadingParameter] public DraftStateProvider DraftProvider { get; set; } - // ****************************************************** - // injects - [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } - [Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; } - // ****************************************************** // overlays private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new(); @@ -102,12 +104,16 @@ public partial class OfficeCountryCustomerListComponent SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); // call erp to crm sync before requesting products var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync); + // give the script time to execute await Task.Delay(500); if (!string.IsNullOrWhiteSpace(newSyncDate)) { + SelectedCompany.HistorySync = newSyncDate; } + // request inventory ProductList = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); + // show the overlay InventoryListOverlay.Show(); } diff --git a/Wonky.Client/HttpRepository/CountryCustomerRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerRepository.cs index cc57f63f..88fd6b7e 100644 --- a/Wonky.Client/HttpRepository/CountryCustomerRepository.cs +++ b/Wonky.Client/HttpRepository/CountryCustomerRepository.cs @@ -70,14 +70,16 @@ public class CountryCustomerRepository : ICountryCustomerRepository }; var endpoint = WebUtils.QueryHelper($"{_api.OfficeCustomers}/{countryCode}", queryDictionary); - var response = await _client.GetAsync(endpoint.ToString()); - + var response = await _client.GetAsync(endpoint); + if (!response.IsSuccessStatusCode) + { + return new PagingResponse(); + } var content = await response.Content.ReadAsStringAsync(); - var pagingResponse = new PagingResponse { - Items = JsonSerializer.Deserialize>(content, _options), - MetaData = JsonSerializer.Deserialize(response.Headers.GetValues("X-Pagination").First(), _options) + Items = JsonSerializer.Deserialize>(content, _options) ?? new List(), + MetaData = JsonSerializer.Deserialize(response.Headers.GetValues("X-Pagination").First(), _options) ?? new MetaData() }; return pagingResponse; } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index cec924de..fa88baf9 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Online", - "version": "227.0", + "version": "228.0", "rc": true, "sandBox": true, "image": "grumpy-coder.png",