From f691f020d216db3717a13f97f595c04d825d8911 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Mon, 8 May 2023 09:26:50 +0200 Subject: [PATCH] code quality cleanup - refactor `onclick` events - added demo to kanvas visit --- .../AdvisorCustomerListComponent.razor | 2 +- .../CustomerActivityListComponent.razor | 2 +- .../CustomerInventoryListComponent.razor | 10 +-- .../CustomerInvoiceListComponent.razor | 2 +- .../CustomerProductCheckListComponent.razor | 8 +- .../OfficeCountryCustomerListComponent.razor | 6 +- .../OfficeCustomerActivityListComponent.razor | 2 +- .../OfficeInventoryListComponent.razor | 8 +- .../Components/PageSizeComponent.razor | 2 +- .../Components/PagerPagesComponent.razor | 2 +- .../Components/PagerSimpleComponent.razor | 2 +- .../Components/QuoteListComponent.razor | 8 +- .../Components/ReportListItemComponent.razor | 2 +- .../ReportViewActivityListComponent.razor | 4 +- .../SearchCatalogColumnComponent.razor | 2 +- .../SearchCatalogPhraseComponent.razor | 4 +- .../SearchCatalogSortColumnComponent.razor | 2 +- .../SearchCustomerColumnComponent.razor | 2 +- .../SearchCustomerPhraseComponent.razor | 4 +- .../SearchCustomerSortColumnComponent.razor | 2 +- .../Components/TaskItemTableComponent.razor | 6 +- .../Components/VatAddressInputComponent.razor | 2 +- .../VatCompanyNameInputComponent.razor | 2 +- .../Components/VatNumberInputComponent.razor | 2 +- .../Components/WarehouseListComponent.razor | 4 +- .../Local.Services/AuthenticationService.cs | 33 ++++++--- .../CustomerActivityListOverlay.razor | 2 +- .../CustomerActivityViewOverlay.razor | 2 +- .../CustomerInventoryListOverlay.razor | 2 +- .../CustomerInventoryReorderOverlay.razor | 18 +++-- .../CustomerInvoiceListOverlay.razor | 2 +- .../CustomerInvoiceViewOverlay.razor | 2 +- .../OfficeCustomerActivityListOverlay.razor | 2 +- .../OfficeCustomerActivityViewOverlay.razor | 2 +- ...fficeCustomerInventoryReorderOverlay.razor | 16 ++-- .../OfficeCustomerInvoiceListOverlay.razor | 2 +- .../OfficeCustomerInvoiceViewOverlay.razor | 2 +- .../OfficeCustomerProductListOverlay.razor | 8 +- .../OfficeOrderInventoryListOverlay.razor | 2 +- .../OfficeOrderInventoryReorderOverlay.razor | 18 ++--- .../CatalogPagedOverlay.razor | 4 +- .../ProductCheckConfirmationOverlay.razor | 6 +- .../ProductHistoryOverlay.razor | 2 +- .../ProductPriceHistoryOverlay.razor | 4 +- .../Pages/AdvisorActivityCreatePage.razor | 74 +++++++++++-------- .../Pages/AdvisorActivityViewEditPage.razor | 2 +- .../Pages/AdvisorCustomerCreatePage.razor | 2 +- .../Pages/AdvisorCustomerPagedListPage.razor | 8 +- .../Pages/AdvisorCustomerViewEditPage.razor | 18 ++--- Wonky.Client/Pages/AdvisorQuoteListPage.razor | 2 +- .../Pages/AdvisorReportCreatePage.razor | 6 +- .../Pages/AdvisorReportViewPage.razor | 4 +- .../Pages/CommonReportPrintOrderPage.razor | 4 +- .../Pages/CommonReportPrintSummaryPage.razor | 2 +- Wonky.Client/Pages/ErrorPage404.razor | 2 +- .../OfficeAdvisorCustomerPagedListPage.razor | 2 +- .../Pages/OfficeAdvisorReportViewPage.razor | 6 +- .../OfficeAdvisorReportViewPage.razor.cs | 3 +- .../OfficeCustomerCountryPagedListPage.razor | 2 +- .../Pages/OfficeOrderCreatePage.razor | 24 +++--- .../Pages/OfficeOrderCreatePage.razor.cs | 19 +++-- Wonky.Client/Pages/OfficeOrderViewPage.razor | 2 +- .../SupervisorDocumentViewEditPage.razor | 2 +- .../Pages/SystemShortMessagePage.razor | 2 +- .../Pages/SystemUserViewEditPage.razor | 6 +- .../Pages/WarehouseOrderViewPage.razor | 6 +- Wonky.Client/Shared/AuthStateProvider.cs | 18 ++++- .../Shared/ConfirmWorkDateModal.razor | 6 +- Wonky.Client/Shared/ConfirmationModal.razor | 6 +- Wonky.Client/Shared/ContactModal.razor | 2 +- Wonky.Client/Shared/InformationModal.razor | 6 +- Wonky.Client/Shared/NavMenu-backup.razor | 4 +- Wonky.Client/Shared/NavMenu.razor | 4 +- Wonky.Client/Shared/VatLookupDkModal.razor | 6 +- 74 files changed, 261 insertions(+), 210 deletions(-) diff --git a/Wonky.Client/Components/AdvisorCustomerListComponent.razor b/Wonky.Client/Components/AdvisorCustomerListComponent.razor index 734b3eff..74c64e81 100644 --- a/Wonky.Client/Components/AdvisorCustomerListComponent.razor +++ b/Wonky.Client/Components/AdvisorCustomerListComponent.razor @@ -33,7 +33,7 @@ @foreach (var company in CompanyList) { - + diff --git a/Wonky.Client/Components/CustomerActivityListComponent.razor b/Wonky.Client/Components/CustomerActivityListComponent.razor index 15fd42ae..d4286ca7 100644 --- a/Wonky.Client/Components/CustomerActivityListComponent.razor +++ b/Wonky.Client/Components/CustomerActivityListComponent.razor @@ -37,7 +37,7 @@ { @foreach (var activity in Activities) { -
+
@activity.OrderDate diff --git a/Wonky.Client/Components/CustomerInventoryListComponent.razor b/Wonky.Client/Components/CustomerInventoryListComponent.razor index 142eff7d..45f740ba 100644 --- a/Wonky.Client/Components/CustomerInventoryListComponent.razor +++ b/Wonky.Client/Components/CustomerInventoryListComponent.razor @@ -23,9 +23,9 @@
-
Navn
-
Varenr
-
Antal
+
Navn
+
Varenr
+
Antal
@@ -51,9 +51,9 @@ @product.Quantity
- Genbestil +
-
+
@if (product.Check) { diff --git a/Wonky.Client/Components/CustomerInvoiceListComponent.razor b/Wonky.Client/Components/CustomerInvoiceListComponent.razor index 3352e137..6f49eeb3 100644 --- a/Wonky.Client/Components/CustomerInvoiceListComponent.razor +++ b/Wonky.Client/Components/CustomerInvoiceListComponent.razor @@ -39,7 +39,7 @@
@foreach (var invoice in InvoiceList) { -
+
@invoice.DocumentDate
@invoice.DocumentNumber
diff --git a/Wonky.Client/Components/CustomerProductCheckListComponent.razor b/Wonky.Client/Components/CustomerProductCheckListComponent.razor index c811e6ae..40c7ba08 100644 --- a/Wonky.Client/Components/CustomerProductCheckListComponent.razor +++ b/Wonky.Client/Components/CustomerProductCheckListComponent.razor @@ -22,9 +22,9 @@
-
Navn
-
Varenr
-
Antal
+
Navn
+
Varenr
+
Antal
@@ -44,7 +44,7 @@
-
+
@if (product.Check) { diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor index 459bbdaf..591d301c 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor @@ -51,13 +51,13 @@ \ No newline at end of file diff --git a/Wonky.Client/Components/WarehouseListComponent.razor b/Wonky.Client/Components/WarehouseListComponent.razor index 594043dc..1bbce393 100644 --- a/Wonky.Client/Components/WarehouseListComponent.razor +++ b/Wonky.Client/Components/WarehouseListComponent.razor @@ -42,7 +42,7 @@
@if (ReadyToShip && Orders.Any()) { - + }
@@ -84,7 +84,7 @@ @switch (order.ProcessStatusEnum.ToLower()) { case "none": - + Pluk varer break; case "picked": diff --git a/Wonky.Client/Local.Services/AuthenticationService.cs b/Wonky.Client/Local.Services/AuthenticationService.cs index 5786472c..6ae84127 100644 --- a/Wonky.Client/Local.Services/AuthenticationService.cs +++ b/Wonky.Client/Local.Services/AuthenticationService.cs @@ -72,7 +72,7 @@ public class AuthenticationService : IAuthenticationService if (!response.IsSuccessStatusCode) return new AuthResponseView { - IsSuccess = false, ErrorMessage = $"Kontroller indtastning" + IsSuccess = false, ErrorMessage = "Kontroller indtastning" }; // process response content @@ -99,20 +99,31 @@ public class AuthenticationService : IAuthenticationService public async Task RefreshToken() { var refreshToken = await _infoService.GetRefreshToken(); + await Task.Delay(250); + if (string.IsNullOrWhiteSpace(refreshToken)) + { + return string.Empty; + } + var credentials = new Dictionary { ["grant_type"] = "refresh_token", ["refresh_token"] = refreshToken }; + var response = await _client.PostAsync(_apiConfig.Value.ServicesAuth, new FormUrlEncodedContent(credentials)); - if (!response.IsSuccessStatusCode) + var content = await response.Content.ReadAsStringAsync(); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { return string.Empty; - - var resContent = await response.Content.ReadAsStringAsync(); - var data = JsonSerializer.Deserialize(resContent, _options); - + } + + var data = JsonSerializer.Deserialize(content, _options); + if (string.IsNullOrWhiteSpace(data.AccessToken)) + { return string.Empty; + } // set default request headers using access_token _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", data.AccessToken); @@ -124,12 +135,12 @@ public class AuthenticationService : IAuthenticationService public async Task Logout() { - var profileBackup = await _preference.GetProfile(); - Task.Delay(150); - await _localStorage.ClearAsync(); - Task.Delay(150); - await _preference.SetProfile(profileBackup); _client.DefaultRequestHeaders.Authorization = null; + var profileBackup = await _preference.GetProfile(); + await Task.Delay(150); + await _localStorage.ClearAsync(); + await Task.Delay(150); + await _preference.SetProfile(profileBackup); ((AuthStateProvider)_authStateProvider).NotifyUserLogout(); } diff --git a/Wonky.Client/OverlayCustomer/CustomerActivityListOverlay.razor b/Wonky.Client/OverlayCustomer/CustomerActivityListOverlay.razor index b09c8653..ad144b06 100644 --- a/Wonky.Client/OverlayCustomer/CustomerActivityListOverlay.razor +++ b/Wonky.Client/OverlayCustomer/CustomerActivityListOverlay.razor @@ -18,7 +18,7 @@