diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor
index af0dd978..f8b32ae4 100644
--- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor
+++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor
@@ -18,6 +18,10 @@
@using Wonky.Client.Helpers;
@using Wonky.Client.OverlayOffice
+@if (Working)
+{
+
+}
@if (CompanyList.Any())
{
@@ -92,9 +96,9 @@
-
+
}
else
{
Ingen data
-}
\ No newline at end of file
+}
diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs
index 5dd9398d..534c48c1 100644
--- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs
+++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs
@@ -14,6 +14,7 @@
//
using System.Reflection.Metadata.Ecma335;
+using System.Text.Json;
using Microsoft.AspNetCore.Components;
using Microsoft.VisualBasic.CompilerServices;
using Wonky.Client.Enums;
@@ -21,6 +22,7 @@ using Wonky.Client.OverlayOffice;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
using Wonky.Client.Helpers;
+using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Client.Models;
using Wonky.Client.Shared;
@@ -30,14 +32,14 @@ using Utils = Wonky.Client.Helpers.Utils;
namespace Wonky.Client.Components;
-public partial class OfficeCountryCustomerListComponent
+public partial class OfficeCountryCustomerListComponent : IDisposable
{
// ******************************************************
// injects
[Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; }
- [Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; }
-
+ [Inject] public ICountryCustomerActivityRepository ActivityRepo { get; set; }
[Inject] public ILogger Logger { get; set; }
+ [Inject] public HttpInterceptorService Interceptor { get; set; }
// ******************************************************
// parameters
@@ -51,79 +53,82 @@ public partial class OfficeCountryCustomerListComponent
private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new();
private OfficeCustomerActivityListOverlay ActivityListOverlay { get; set; } = new();
private OfficeCustomerListInventoryOverlay InventoryListOverlay { get; set; } = new();
-
+
// ******************************************************
// variables
private InvoiceListView InvoiceList { get; set; } = new();
private List ActivityList { get; set; } = new();
- private List ProductList { get; set; } = new();
+ private List ProductInventory { get; set; } = new();
private CompanyDto SelectedCompany { get; set; } = new();
- // ******************************************************
- // functions
+ private bool Working { get; set; }
+
+ protected override void OnInitialized()
+ {
+ Interceptor.RegisterEvent();
+ Interceptor.RegisterBeforeSendEvent();
+ }
+
+
private async Task ShowInvoiceList(string companyId)
{
- // check for console manipulation
- if (!Utils.Validate(ValidateType.Id, companyId))
- {
- return;
- }
+ Working = true;
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
-
// call erp to crm sync before requesting invoices
- var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync);
await Task.Delay(500);
-
- InvoiceList = await HistoryRepo.GetInvoiceList(CountryCode, companyId);
- if (!string.IsNullOrWhiteSpace(newSyncDate))
+ var newSyncDate = await HistoryRepo.RequestErpToCrmSync(companyId, SelectedCompany.HistorySync, false);
+ while (string.IsNullOrEmpty(newSyncDate))
{
- SelectedCompany.HistorySync = newSyncDate;
+ await Task.Delay(500);
}
+ InvoiceList = await HistoryRepo.GetInvoiceList(CountryCode, companyId);
InvoiceListOverlay.Show();
+ Working = false;
}
+
private async Task ShowActivityList(string companyId)
{
- // check for console manipulation
- if (!Utils.Validate(ValidateType.Id, companyId))
- {
- return;
- }
+ Working = true;
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
- ActivityList = await CustomerActivityRepo.GetActivityList(companyId);
+ await Task.Delay(500);
+ ActivityList = await ActivityRepo.GetActivityList(companyId);
+ await Task.Delay(500);
ActivityListOverlay.Show();
+ Working = false;
}
+
private async Task ShowInventory(string companyId)
{
- // check for console manipulation
- if (!Utils.Validate(ValidateType.Id, companyId))
- {
- return;
- }
+ Working = true;
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
+ Logger.LogDebug("SelectedCompany => {}", JsonSerializer.Serialize(SelectedCompany));
await Task.Delay(500);
- if (!string.IsNullOrWhiteSpace(newSyncDate))
+ var newSyncDate = await HistoryRepo.RequestErpToCrmSync(companyId, SelectedCompany.HistorySync, true);
+ while (string.IsNullOrEmpty(newSyncDate))
{
-
- SelectedCompany.HistorySync = newSyncDate;
+ await Task.Delay(500);
}
// request inventory
- ProductList = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId);
+ await Task.Delay(500);
+ ProductInventory = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId);
+ await Task.Delay(500);
+ Logger.LogDebug("ProductInventory => {}", JsonSerializer.Serialize(ProductInventory));
// show the overlay
InventoryListOverlay.Show();
+ Working = false;
}
+
private void ShowOrder(string companyId)
{
- // check for console manipulation
- if (!Utils.Validate(ValidateType.Id, companyId))
- {
- return;
- }
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
}
+
+
+ public void Dispose()
+ {
+ Interceptor.DisposeEvent();
+ }
}
\ No newline at end of file
diff --git a/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs
index 85a533f0..84f2c6ae 100644
--- a/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs
+++ b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs
@@ -126,7 +126,8 @@ public class AdvisorCustomerHistoryRepository : IAdvisorCustomerHistoryRepositor
public async Task RequestErpSync(string companyId, string syncDate, bool force)
{
- var x = await _client.GetAsync($"{_api.SyncInvoice}/{companyId}/{syncDate}?force={force}");
+ var x = await _client
+ .GetAsync($"{_api.SyncInvoice}/{companyId}/{syncDate}/?force={force}");
var content = await x.Content.ReadAsStringAsync();
if (!x.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{
diff --git a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs
index 3f071bf7..e44d9844 100644
--- a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs
+++ b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs
@@ -33,7 +33,8 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor
private ILogger _logger;
private readonly HttpClient _client;
private readonly ApiConfig _api;
-
+
+
public CountryCustomerHistoryRepository(
HttpClient client, ILogger logger,
NavigationManager navigation, IOptions configuration)
@@ -43,7 +44,7 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor
_navigation = navigation;
_api = configuration.Value;
}
-
+
public async Task GetInvoiceList(string countryCode, string companyId)
{
@@ -130,18 +131,15 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor
}
- public async Task RequestErpToCrmSync(string countryCode, string companyId, string syncDate)
+ public async Task RequestErpToCrmSync(string companyId, string syncDate, bool force)
{
var response = await _client
- .GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncInvoice}/{syncDate}");
-
+ .GetAsync($"{_api.SyncInvoice}/{companyId}/{syncDate}/?force={force}");
var content = await response.Content.ReadAsStringAsync();
-
if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{
return string.Empty;
}
-
- return content.Replace("\"", "");
+ return content.Trim('"');
}
}
\ No newline at end of file
diff --git a/Wonky.Client/HttpRepository/ICountryCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/ICountryCustomerHistoryRepository.cs
index ac080859..a99e65f2 100644
--- a/Wonky.Client/HttpRepository/ICountryCustomerHistoryRepository.cs
+++ b/Wonky.Client/HttpRepository/ICountryCustomerHistoryRepository.cs
@@ -29,5 +29,5 @@ public interface ICountryCustomerHistoryRepository
Task> GetSkuHistory(string countryCode, string companyId, string sku);
- Task RequestErpToCrmSync(string countryCode, string companyId, string syncDate);
+ Task RequestErpToCrmSync(string companyId, string syncDate, bool force);
}
\ No newline at end of file
diff --git a/Wonky.Client/Pages/OfficeCustomerCountryPagedListPage.razor.cs b/Wonky.Client/Pages/OfficeCustomerCountryPagedListPage.razor.cs
index 67510b5f..3d5b8a75 100644
--- a/Wonky.Client/Pages/OfficeCustomerCountryPagedListPage.razor.cs
+++ b/Wonky.Client/Pages/OfficeCustomerCountryPagedListPage.razor.cs
@@ -71,12 +71,16 @@ public partial class OfficeCustomerCountryPagedListPage : IDisposable
Working = false;
}
+
+ private async Task GetProductHistory(string companyId)
+ {
+ await Task.Delay(1);
+ }
private async Task FetchCustomers()
{
Working = true;
var response = await CustomerRepo.GetCompaniesPaged(CountryCode, Paging);
- Working = false;
if (response.Items.Any())
{
Companies = response.Items;
@@ -87,6 +91,7 @@ public partial class OfficeCustomerCountryPagedListPage : IDisposable
Companies = new List();
PageData = new MetaData();
}
+ Working = false;
}
diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs
index 9692a4e8..7c9a7770 100644
--- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs
+++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs
@@ -111,7 +111,7 @@ public partial class OfficeOrderCreatePage : IDisposable
// initiate a sync to ensure up-to-date product history
if (Company.HistorySync != today)
{
- Company.HistorySync = await HistoryRepo.RequestErpToCrmSync(CountryCode, CompanyId, Company.HistorySync);
+ Company.HistorySync = await HistoryRepo.RequestErpToCrmSync(CompanyId, Company.HistorySync, false);
Logger.LogDebug("OfficeOrderCreate => RequestErpToCrmSync <= {}", Company.HistorySync);
}
// fetch invoices
diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json
index f4394a65..f904a6d6 100644
--- a/Wonky.Client/wwwroot/appsettings.json
+++ b/Wonky.Client/wwwroot/appsettings.json
@@ -1,7 +1,7 @@
{
"appInfo": {
"name": "Wonky Online",
- "version": "230.0",
+ "version": "231.0",
"rc": true,
"sandBox": true,
"image": "grumpy-coder.png",
@@ -42,7 +42,7 @@
"serviceVatDk": "api/v2/services/virk",
"serviceVatEu": "api/v2/services/vies",
"serviceVatNo": "api/v2/services/brReg",
- "serviceVatSe": "api/v2/services/allabolag",
+ "serviceVatSe": "api/v2/services/allaBolag",
"sync": "api/v2/sync",
"syncInvoice": "api/v2/sync/invoices",
"systemDocStringUrl": "api/v2/admin/doc",
diff --git a/Wonky.Client/wwwroot/css/app.css b/Wonky.Client/wwwroot/css/app.css
index 1b7867d7..5b48dd59 100644
--- a/Wonky.Client/wwwroot/css/app.css
+++ b/Wonky.Client/wwwroot/css/app.css
@@ -1,5 +1,6 @@
body {
font-size: 16px;
+ /*background-color: #eeeeee;*/
}
.draft-expires-msg {