check fetching of customer inventory from office customer list page

This commit is contained in:
Frede Hundewadt 2023-08-28 08:25:46 +02:00
parent c929e7e17a
commit 9b64d515c3
3 changed files with 19 additions and 11 deletions

View file

@ -32,6 +32,13 @@ namespace Wonky.Client.Components;
public partial class OfficeCountryCustomerListComponent public partial class OfficeCountryCustomerListComponent
{ {
// ******************************************************
// injects
[Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; }
[Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; }
[Inject] public ILogger<OfficeCountryCustomerListComponent> Logger { get; set; }
// ****************************************************** // ******************************************************
// parameters // parameters
[Parameter] public string CountryCode { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = "";
@ -39,11 +46,6 @@ public partial class OfficeCountryCustomerListComponent
// [Parameter] public EventCallback<DraftItem> OnOrderItem { get; set; } // [Parameter] public EventCallback<DraftItem> OnOrderItem { get; set; }
[CascadingParameter] public DraftStateProvider DraftProvider { get; set; } [CascadingParameter] public DraftStateProvider DraftProvider { get; set; }
// ******************************************************
// injects
[Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; }
[Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; }
// ****************************************************** // ******************************************************
// overlays // overlays
private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new(); private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new();
@ -102,12 +104,16 @@ public partial class OfficeCountryCustomerListComponent
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
// call erp to crm sync before requesting products // call erp to crm sync before requesting products
var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync); var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync);
// give the script time to execute
await Task.Delay(500); await Task.Delay(500);
if (!string.IsNullOrWhiteSpace(newSyncDate)) if (!string.IsNullOrWhiteSpace(newSyncDate))
{ {
SelectedCompany.HistorySync = newSyncDate; SelectedCompany.HistorySync = newSyncDate;
} }
// request inventory
ProductList = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); ProductList = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId);
// show the overlay
InventoryListOverlay.Show(); InventoryListOverlay.Show();
} }

View file

@ -70,14 +70,16 @@ public class CountryCustomerRepository : ICountryCustomerRepository
}; };
var endpoint = WebUtils.QueryHelper($"{_api.OfficeCustomers}/{countryCode}", queryDictionary); 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<CompanyDto>();
}
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<CompanyDto> var pagingResponse = new PagingResponse<CompanyDto>
{ {
Items = JsonSerializer.Deserialize<List<CompanyDto>>(content, _options), Items = JsonSerializer.Deserialize<List<CompanyDto>>(content, _options) ?? new List<CompanyDto>(),
MetaData = JsonSerializer.Deserialize<MetaData>(response.Headers.GetValues("X-Pagination").First(), _options) MetaData = JsonSerializer.Deserialize<MetaData>(response.Headers.GetValues("X-Pagination").First(), _options) ?? new MetaData()
}; };
return pagingResponse; return pagingResponse;
} }

View file

@ -1,7 +1,7 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Online", "name": "Wonky Online",
"version": "227.0", "version": "228.0",
"rc": true, "rc": true,
"sandBox": true, "sandBox": true,
"image": "grumpy-coder.png", "image": "grumpy-coder.png",