diff --git a/Wonky.Client.sln.DotSettings b/Wonky.Client.sln.DotSettings index 9438812a..95725125 100644 --- a/Wonky.Client.sln.DotSettings +++ b/Wonky.Client.sln.DotSettings @@ -1,6 +1,13 @@  True True + True + True + True True + True + True + True + True True True \ No newline at end of file diff --git a/Wonky.Client/Components/AdvisorActivityKmStartComponent.razor b/Wonky.Client/Components/AdvisorActivityKmStartComponent.razor index 242a2670..749f83e6 100644 --- a/Wonky.Client/Components/AdvisorActivityKmStartComponent.razor +++ b/Wonky.Client/Components/AdvisorActivityKmStartComponent.razor @@ -8,7 +8,7 @@ @code { - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } private int KmMorning { get; set; } private UserPref Prefs { get; set; } = new(); diff --git a/Wonky.Client/Components/ActivityTableCrmComponent.razor b/Wonky.Client/Components/AdvisorActivityListComponent.razor similarity index 92% rename from Wonky.Client/Components/ActivityTableCrmComponent.razor rename to Wonky.Client/Components/AdvisorActivityListComponent.razor index 55626896..6edc5e8e 100644 --- a/Wonky.Client/Components/ActivityTableCrmComponent.razor +++ b/Wonky.Client/Components/AdvisorActivityListComponent.razor @@ -18,7 +18,7 @@ @if (ActivityList.Any()) { - +
@@ -38,7 +38,7 @@ @foreach (var activity in ActivityList) { - + diff --git a/Wonky.Client/Components/ReportActivityLedgerComponent.razor.cs b/Wonky.Client/Components/AdvisorActivityListComponent.razor.cs similarity index 81% rename from Wonky.Client/Components/ReportActivityLedgerComponent.razor.cs rename to Wonky.Client/Components/AdvisorActivityListComponent.razor.cs index 870de4ef..c7c528e9 100644 --- a/Wonky.Client/Components/ReportActivityLedgerComponent.razor.cs +++ b/Wonky.Client/Components/AdvisorActivityListComponent.razor.cs @@ -13,12 +13,14 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using Wonky.Entity.Views; using Microsoft.AspNetCore.Components; +using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class ReportActivityLedgerComponent +public partial class AdvisorActivityListComponent { - [Parameter] public ReportData ReportData { get; set; } = new(); + [Parameter] public List ActivityList { get; set; } = new(); + [Inject] private NavigationManager Navigator { get; set; } + } \ No newline at end of file diff --git a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor b/Wonky.Client/Components/AdvisorCustomerListComponent.razor similarity index 94% rename from Wonky.Client/Components/AdvisorCompanyTableComponent.razor rename to Wonky.Client/Components/AdvisorCustomerListComponent.razor index 6475f738..db093cce 100644 --- a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor +++ b/Wonky.Client/Components/AdvisorCustomerListComponent.razor @@ -42,7 +42,7 @@ diff --git a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor.cs b/Wonky.Client/Components/AdvisorCustomerListComponent.razor.cs similarity index 88% rename from Wonky.Client/Components/AdvisorCompanyTableComponent.razor.cs rename to Wonky.Client/Components/AdvisorCustomerListComponent.razor.cs index f09fd526..4cfb03fb 100644 --- a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor.cs +++ b/Wonky.Client/Components/AdvisorCustomerListComponent.razor.cs @@ -27,13 +27,13 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components { - public partial class AdvisorCompanyTableComponent + public partial class AdvisorCustomerListComponent { [Parameter] public List CompanyList { get; set; } = new(); [Parameter] public EventCallback OnDelete { get; set; } [Parameter] public EventCallback OnSelect { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public IJSRuntime Js { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private IJSRuntime Js { get; set; } private Lazy BsTooltip = new(); @@ -43,7 +43,7 @@ namespace Wonky.Client.Components private void ViewCustomer(string companyId) { - Navigator.NavigateTo($"/companies/{companyId}"); + Navigator.NavigateTo($"/advisor/customers/{companyId}"); } private void CallInformationModal(string info) diff --git a/Wonky.Client/Components/AdvisorReportActivityLedgerComponent.razor b/Wonky.Client/Components/AdvisorReportActivityLedgerComponent.razor new file mode 100644 index 00000000..bb2f8831 --- /dev/null +++ b/Wonky.Client/Components/AdvisorReportActivityLedgerComponent.razor @@ -0,0 +1,93 @@ +@using Wonky.Entity.Views +@using Wonky.Entity.DTO +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +
Kunde
@activity.Company.Name@activity.Company.Name @activity.Company.City @activity.Demo @activity.Sales @if (!string.IsNullOrWhiteSpace(company.Note)) { - + } @@ -58,7 +58,7 @@ @company.City -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Dagens Demo @(ReportData.NewDemoCount + ReportData.RecallDemoCount)Dagens ResultatMåneds Resultat
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@ReportData.NewVisitCount@ReportData.NewDemoCount@ReportData.NewSaleCount@ReportData.NewTurnover@ReportData.NewVisitCountMonth@ReportData.NewDemoCountMonth@ReportData.NewSaleCountMonth@ReportData.NewTurnoverMonth
R@ReportData.RecallVisitCount@ReportData.RecallDemoCount@ReportData.RecallSaleCount@ReportData.RecallTurnover@ReportData.RecallVisitCountMonth@ReportData.RecallDemoCountMonth@ReportData.RecallSaleCountMonth@ReportData.RecallTurnoverMonth
SAS@ReportData.SasCount@ReportData.SasTurnover@ReportData.SasCountMonth@ReportData.SasTurnoverMonth
TOTAL@ReportData.TotalVisitCount@ReportData.TotalDemoCount@ReportData.TotalSaleCount@ReportData.TotalTurnover@ReportData.TotalVisitCountMonth@ReportData.TotalDemoCountMonth@ReportData.TotalSaleCountMonth@ReportData.TotalTurnoverMonth
+ +@code{ + + [Parameter] + public ReportFiguresDto ReportData { get; set; } = new(); + +} \ No newline at end of file diff --git a/Wonky.Client/Components/CatalogGroupComponent.razor.cs b/Wonky.Client/Components/CatalogGroupComponent.razor.cs index cd9a7b30..72f23c18 100644 --- a/Wonky.Client/Components/CatalogGroupComponent.razor.cs +++ b/Wonky.Client/Components/CatalogGroupComponent.razor.cs @@ -22,8 +22,8 @@ namespace Wonky.Client.Components; public partial class CatalogGroupComponent { - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } [Parameter] public EventCallback OnChanged { get; set; } private Dictionary Items { get; set; } = new(); private UserPref Prefs = new(); diff --git a/Wonky.Client/Components/CatalogTableComponent.razor b/Wonky.Client/Components/CatalogListComponent.razor similarity index 100% rename from Wonky.Client/Components/CatalogTableComponent.razor rename to Wonky.Client/Components/CatalogListComponent.razor diff --git a/Wonky.Client/Components/CatalogTableComponent.razor.cs b/Wonky.Client/Components/CatalogListComponent.razor.cs similarity index 83% rename from Wonky.Client/Components/CatalogTableComponent.razor.cs rename to Wonky.Client/Components/CatalogListComponent.razor.cs index ec392daf..1f173552 100644 --- a/Wonky.Client/Components/CatalogTableComponent.razor.cs +++ b/Wonky.Client/Components/CatalogListComponent.razor.cs @@ -21,12 +21,8 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class CatalogTableComponent +public partial class CatalogListComponent { [Parameter] public List ItemList { get; set; } = new(); - [Inject] public IToastService ToastService { get; set; } - private void AddToDraft() - { - ToastService.ShowInfo("TODO: læg til ordre kladde"); - } + [Inject] private IToastService ToastService { get; set; } } \ No newline at end of file diff --git a/Wonky.Client/Components/CatalogTablePrintComponent.razor b/Wonky.Client/Components/CatalogPrintComponent.razor similarity index 100% rename from Wonky.Client/Components/CatalogTablePrintComponent.razor rename to Wonky.Client/Components/CatalogPrintComponent.razor diff --git a/Wonky.Client/Components/CatalogTablePrintComponent.razor.cs b/Wonky.Client/Components/CatalogPrintComponent.razor.cs similarity index 95% rename from Wonky.Client/Components/CatalogTablePrintComponent.razor.cs rename to Wonky.Client/Components/CatalogPrintComponent.razor.cs index 450e2732..b92ff6e7 100644 --- a/Wonky.Client/Components/CatalogTablePrintComponent.razor.cs +++ b/Wonky.Client/Components/CatalogPrintComponent.razor.cs @@ -21,7 +21,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class CatalogTablePrintComponent +public partial class CatalogPrintComponent { [Parameter] public List ItemList { get; set; } = new(); [Parameter] public string CountryName { get; set; } = ""; diff --git a/Wonky.Client/Components/CatalogSearchComponent.razor b/Wonky.Client/Components/CatalogSearchComponent.razor index 64fb9429..e5e76efc 100644 --- a/Wonky.Client/Components/CatalogSearchComponent.razor +++ b/Wonky.Client/Components/CatalogSearchComponent.razor @@ -17,7 +17,7 @@ \ No newline at end of file diff --git a/Wonky.Client/Components/CatalogSearchComponent.razor.cs b/Wonky.Client/Components/CatalogSearchComponent.razor.cs index dee1c3a4..eee8cf03 100644 --- a/Wonky.Client/Components/CatalogSearchComponent.razor.cs +++ b/Wonky.Client/Components/CatalogSearchComponent.razor.cs @@ -24,7 +24,7 @@ public partial class CatalogSearchComponent : IDisposable /// /// User preference service /// - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } /// /// OnChanged event callback diff --git a/Wonky.Client/Components/CatalogSortComponent.razor b/Wonky.Client/Components/CatalogSortComponent.razor index 09dedc9b..6d92ab1e 100644 --- a/Wonky.Client/Components/CatalogSortComponent.razor +++ b/Wonky.Client/Components/CatalogSortComponent.razor @@ -17,6 +17,6 @@ \ No newline at end of file diff --git a/Wonky.Client/Components/CatalogSortComponent.razor.cs b/Wonky.Client/Components/CatalogSortComponent.razor.cs index b009fb81..989c3ee1 100644 --- a/Wonky.Client/Components/CatalogSortComponent.razor.cs +++ b/Wonky.Client/Components/CatalogSortComponent.razor.cs @@ -24,7 +24,7 @@ public partial class CatalogSortComponent : IDisposable /// /// User preference service /// - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } /// /// OnChanged callback function diff --git a/Wonky.Client/Components/ColorCodingComponent.razor.css b/Wonky.Client/Components/ColorCodingComponent.razor.css deleted file mode 100644 index 002017f5..00000000 --- a/Wonky.Client/Components/ColorCodingComponent.razor.css +++ /dev/null @@ -1,4 +0,0 @@ - -.color-code { - max-width: 40px; -} \ No newline at end of file diff --git a/Wonky.Client/Components/CustomerProductTableComponent.razor b/Wonky.Client/Components/CustomerInventoryListComponent.razor similarity index 82% rename from Wonky.Client/Components/CustomerProductTableComponent.razor rename to Wonky.Client/Components/CustomerInventoryListComponent.razor index ab20dff0..35dd233b 100644 --- a/Wonky.Client/Components/CustomerProductTableComponent.razor +++ b/Wonky.Client/Components/CustomerInventoryListComponent.razor @@ -19,7 +19,7 @@
- @if (ProductList.Any()) + @if (Inventory.Any()) {
@@ -31,12 +31,20 @@
- @foreach (var product in ProductList) + @foreach (var product in Inventory) {
- @product.Description @(product.Discontinued ? "(UDGÅET)" : "") +
+ @product.Description + @if (product.Discontinued) + { + Udgået + Produktet er udgået + } +
+ @* @product.Description @(product.Discontinued ? "(UDGÅET)" : "") *@
@product.Sku @@ -66,8 +74,6 @@
}
- - } else { diff --git a/Wonky.Client/Components/CustomerProductTableComponent.razor.cs b/Wonky.Client/Components/CustomerInventoryListComponent.razor.cs similarity index 53% rename from Wonky.Client/Components/CustomerProductTableComponent.razor.cs rename to Wonky.Client/Components/CustomerInventoryListComponent.razor.cs index 136a5094..173b1a55 100644 --- a/Wonky.Client/Components/CustomerProductTableComponent.razor.cs +++ b/Wonky.Client/Components/CustomerInventoryListComponent.razor.cs @@ -25,20 +25,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class CustomerProductTableComponent +public partial class CustomerInventoryListComponent { - [CascadingParameter] public DraftStateProvider DraftStateProvider { get; set; } = new(); - [Parameter] public List ProductList { get; set; } = new(); + [Inject] private ILocalStorageService Storage { get; set; } + // Parameters + [Parameter] public List Inventory { get; set; } = new(); [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICatalogHttpRepository Catalog { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } + [Parameter] public EventCallback OnReorderSelected { get; set; } + // private variables - private SalesItemView SalesItem { get; set; } = new(); - private string Price { get; set; } = "0"; - private string Quantity { get; set; } = "1"; - private string Sku { get; set; } = ""; - private InventoryReorderModal ReorderModal { get; set; } = new(); - private SelectedSku Item { get; set; } = new(); private bool Descending { get; set; } private void SortProducts(PSort column) @@ -49,57 +44,47 @@ public partial class CustomerProductTableComponent case PSort.Desc: if (Descending) { - ProductList = ProductList.OrderByDescending(x => x.Description).ToList(); + Inventory = Inventory.OrderByDescending(x => x.Description).ToList(); break; } - ProductList = ProductList.OrderBy(x => x.Description).ToList(); + Inventory = Inventory.OrderBy(x => x.Description).ToList(); break; case PSort.Sku: if (Descending) { - ProductList = ProductList.OrderByDescending(x => x.Sku).ToList(); + Inventory = Inventory.OrderByDescending(x => x.Sku).ToList(); break; } - ProductList = ProductList.OrderBy(x => x.Sku).ToList(); + Inventory = Inventory.OrderBy(x => x.Sku).ToList(); break; case PSort.Qty: if (Descending) { - ProductList = ProductList.OrderByDescending(x => x.Quantity).ToList(); + Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); break; } - ProductList = ProductList.OrderBy(x => x.Quantity).ToList(); + Inventory = Inventory.OrderBy(x => x.Quantity).ToList(); break; case PSort.None: break; case PSort.Abbr: break; default: - ProductList = ProductList.OrderByDescending(x => x.Quantity).ToList(); + Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); break; } } - private async Task ProductCheck(string sku) - { - var x = ProductList.First(x => x.Sku == sku); - x.Check = !x.Check; - await Storage.SetItemAsync($"{CompanyId}-products", ProductList); - } private async Task CallShowReorderModal(string sku) { - // fetch item from http repo - SalesItem = await Catalog.GetSalesItemSku(sku); - ReorderModal.Show(); + await ProductCheck(sku); + await OnReorderSelected.InvokeAsync(sku); } - - private async Task OnSelectedItem(DraftItem draftItem) + + private async Task ProductCheck(string sku) { - // add item to order draft - DraftStateProvider.Draft.DraftType = "order"; - DraftStateProvider.Draft.Items.Add(draftItem); - // set item checked - await ProductCheck(draftItem.Item.Sku); - await DraftStateProvider.SaveChangesAsync(); + var x = Inventory.First(x => x.Sku == sku); + x.Check = !x.Check; + await Storage.SetItemAsync($"{CompanyId}-products", Inventory); } } \ No newline at end of file diff --git a/Wonky.Client/Components/InvoiceTableComponent.razor b/Wonky.Client/Components/CustomerInvoiceListComponent.razor similarity index 91% rename from Wonky.Client/Components/InvoiceTableComponent.razor rename to Wonky.Client/Components/CustomerInvoiceListComponent.razor index 70da7b47..365e56e3 100644 --- a/Wonky.Client/Components/InvoiceTableComponent.razor +++ b/Wonky.Client/Components/CustomerInvoiceListComponent.razor @@ -37,7 +37,7 @@ {
-
+
@invoice.OrderNote
} @@ -48,5 +48,4 @@ else {
Ingen data
-} - \ No newline at end of file +} \ No newline at end of file diff --git a/Wonky.Client/Components/CustomerInvoiceListComponent.razor.cs b/Wonky.Client/Components/CustomerInvoiceListComponent.razor.cs new file mode 100644 index 00000000..844043b1 --- /dev/null +++ b/Wonky.Client/Components/CustomerInvoiceListComponent.razor.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Client.Shared; +using Wonky.Entity.Views; + +namespace Wonky.Client.Components; + +public partial class CustomerInvoiceListComponent +{ + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public List InvoiceList { get; set; } = new(); + [Parameter] public EventCallback OnShowInvoice { get; set; } + + private async Task ShowInvoice(string invoiceId) + { + await OnShowInvoice.InvokeAsync(invoiceId); + } +} \ No newline at end of file diff --git a/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs b/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs index 57fea05e..9559e57a 100644 --- a/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs +++ b/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs @@ -28,7 +28,7 @@ public partial class CustomerProductCheckListComponent { [Parameter] public List ProductList { get; set; } = new(); [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ILocalStorageService Storage { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } // private variables private bool Descending { get; set; } diff --git a/Wonky.Client/Components/CustomerProductLineTableComponent.razor b/Wonky.Client/Components/CustomerProductLineListComponent.razor similarity index 100% rename from Wonky.Client/Components/CustomerProductLineTableComponent.razor rename to Wonky.Client/Components/CustomerProductLineListComponent.razor diff --git a/Wonky.Client/Components/CustomerProductLineTableComponent.razor.cs b/Wonky.Client/Components/CustomerProductLineListComponent.razor.cs similarity index 94% rename from Wonky.Client/Components/CustomerProductLineTableComponent.razor.cs rename to Wonky.Client/Components/CustomerProductLineListComponent.razor.cs index a846338e..8d7e8ebd 100644 --- a/Wonky.Client/Components/CustomerProductLineTableComponent.razor.cs +++ b/Wonky.Client/Components/CustomerProductLineListComponent.razor.cs @@ -19,7 +19,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class CustomerProductLineTableComponent +public partial class CustomerProductLineListComponent { [Parameter] public List ProductHistory { get; set; } = new(); diff --git a/Wonky.Client/Components/CompanySearchColumnComponent.razor b/Wonky.Client/Components/CustomerSearchColumnComponent.razor similarity index 81% rename from Wonky.Client/Components/CompanySearchColumnComponent.razor rename to Wonky.Client/Components/CustomerSearchColumnComponent.razor index 3d6d41b6..bd08fc0a 100644 --- a/Wonky.Client/Components/CompanySearchColumnComponent.razor +++ b/Wonky.Client/Components/CustomerSearchColumnComponent.razor @@ -17,9 +17,9 @@ diff --git a/Wonky.Client/Components/CompanySearchColumnComponent.razor.cs b/Wonky.Client/Components/CustomerSearchColumnComponent.razor.cs similarity index 90% rename from Wonky.Client/Components/CompanySearchColumnComponent.razor.cs rename to Wonky.Client/Components/CustomerSearchColumnComponent.razor.cs index 3b4777bb..e771be7d 100644 --- a/Wonky.Client/Components/CompanySearchColumnComponent.razor.cs +++ b/Wonky.Client/Components/CustomerSearchColumnComponent.razor.cs @@ -22,10 +22,10 @@ using Wonky.Client.Services; namespace Wonky.Client.Components; -public partial class CompanySearchColumnComponent : IDisposable +public partial class CustomerSearchColumnComponent : IDisposable { - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } [Parameter] public EventCallback OnChanged { get; set; } private Dictionary Items { get; set; } = new(); private UserPref Prefs { get; set; } = new(); diff --git a/Wonky.Client/Components/CompanySearchPhraseComponent.razor b/Wonky.Client/Components/CustomerSearchPhraseComponent.razor similarity index 100% rename from Wonky.Client/Components/CompanySearchPhraseComponent.razor rename to Wonky.Client/Components/CustomerSearchPhraseComponent.razor diff --git a/Wonky.Client/Components/CompanySearchPhraseComponent.razor.cs b/Wonky.Client/Components/CustomerSearchPhraseComponent.razor.cs similarity index 94% rename from Wonky.Client/Components/CompanySearchPhraseComponent.razor.cs rename to Wonky.Client/Components/CustomerSearchPhraseComponent.razor.cs index aceec932..158b33eb 100644 --- a/Wonky.Client/Components/CompanySearchPhraseComponent.razor.cs +++ b/Wonky.Client/Components/CustomerSearchPhraseComponent.razor.cs @@ -20,12 +20,12 @@ using Timer = System.Timers.Timer; namespace Wonky.Client.Components { - public partial class CompanySearchPhraseComponent + public partial class CustomerSearchPhraseComponent { private Timer InputTimer { get; set; } = new(); private string SearchTerm { get; set; } = ""; private UserPref Prefs { get; set; } = new (); - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } [Parameter] public EventCallback OnChanged { get; set; } protected override async Task OnInitializedAsync() diff --git a/Wonky.Client/Components/CompanySortComponent.razor b/Wonky.Client/Components/CustomerSortComponent.razor similarity index 91% rename from Wonky.Client/Components/CompanySortComponent.razor rename to Wonky.Client/Components/CustomerSortComponent.razor index 4540f25c..0fe514a0 100644 --- a/Wonky.Client/Components/CompanySortComponent.razor +++ b/Wonky.Client/Components/CustomerSortComponent.razor @@ -17,6 +17,6 @@ \ No newline at end of file diff --git a/Wonky.Client/Components/CompanySortComponent.razor.cs b/Wonky.Client/Components/CustomerSortComponent.razor.cs similarity index 90% rename from Wonky.Client/Components/CompanySortComponent.razor.cs rename to Wonky.Client/Components/CustomerSortComponent.razor.cs index 045ce0d7..f2f5567f 100644 --- a/Wonky.Client/Components/CompanySortComponent.razor.cs +++ b/Wonky.Client/Components/CustomerSortComponent.razor.cs @@ -21,10 +21,10 @@ using Wonky.Client.Services; namespace Wonky.Client.Components { - public partial class CompanySortComponent : IDisposable + public partial class CustomerSortComponent : IDisposable { - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } [Parameter] public EventCallback OnChanged { get; set; } private Dictionary Items { get; set; } = new(); private UserPref Prefs = new(); diff --git a/Wonky.Client/Components/CustomerVisitListComponent.razor b/Wonky.Client/Components/CustomerVisitListComponent.razor new file mode 100644 index 00000000..2d50f39f --- /dev/null +++ b/Wonky.Client/Components/CustomerVisitListComponent.razor @@ -0,0 +1,75 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +
+
+
+
+

Dato

+
+
+

Demo

+
+
+

Salg

+
+
+

Ordre Note

+
+
+

Ordre Note

+
+
+
+ @if (Activities.Any()) + { + @foreach (var activity in Activities) + { +
+
+
+ @activity.OrderDate +
+
+ @activity.Demo +
+
+ @activity.Sales +
+
+ @activity.OfficeNote +
+
+ @activity.CrmNote +
+
+
+ } + } + else + { +
+
+
+ Ingen data +
+
+
+ } +
+ + \ No newline at end of file diff --git a/Wonky.Client/Components/CustomerVisitListComponent.razor.cs b/Wonky.Client/Components/CustomerVisitListComponent.razor.cs new file mode 100644 index 00000000..e33aaf63 --- /dev/null +++ b/Wonky.Client/Components/CustomerVisitListComponent.razor.cs @@ -0,0 +1,41 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Globalization; +using System.Runtime.InteropServices; +using Blazored.LocalStorage; +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Models; +using Wonky.Client.Shared; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.Components; + +public partial class CustomerVisitListComponent +{ + [Parameter] public List Activities { get; set; } = new(); + private CustomerActivityViewModalOverlay ActivityViewOverlay { get; set; } = new(); + + private ReportItemView Activity { get; set; } = new(); + + private void ShowVisitOverlay(string activityId) + { + Activity = Activities.First(x => x.ActivityId == activityId); + ActivityViewOverlay.Show(); + } + +} \ No newline at end of file diff --git a/Wonky.Client/Components/InfoAdvisorComponent.razor b/Wonky.Client/Components/InfoAdvisorComponent.razor new file mode 100644 index 00000000..092c4913 --- /dev/null +++ b/Wonky.Client/Components/InfoAdvisorComponent.razor @@ -0,0 +1,47 @@ +

Sælger

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
+ + ToDo liste
+ + Pris katalog
+ + Firmaer/Kunder
+ + Aftaler/Tilbud
+ + Aktivitet
+ + Dagsrapporter
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoBrowserComponent.razor b/Wonky.Client/Components/InfoBrowserComponent.razor new file mode 100644 index 00000000..c89a7e63 --- /dev/null +++ b/Wonky.Client/Components/InfoBrowserComponent.razor @@ -0,0 +1,9 @@ +

Testede browsere

+
    +
  • Safari (macOS, iOS)
  • +
  • Chrome (Linux, Windows, Android)
  • +
  • Edge (Linux, Windows, Android)
  • +
  • Firefox (Linux, Windows, Android)
  • +
  • Chromium (Linux)
  • +
  • Vivaldi (Linux)
  • +
\ No newline at end of file diff --git a/Wonky.Client/Components/ColorCodingComponent.razor b/Wonky.Client/Components/InfoColorCustomerComponent.razor similarity index 71% rename from Wonky.Client/Components/ColorCodingComponent.razor rename to Wonky.Client/Components/InfoColorCustomerComponent.razor index c05bd7c7..e4071b09 100644 --- a/Wonky.Client/Components/ColorCodingComponent.razor +++ b/Wonky.Client/Components/InfoColorCustomerComponent.razor @@ -16,14 +16,23 @@ *@ @using Wonky.Client.Components +

Kunde Info

- - + + + + + + - - - - - - - - - - - -
Kunde / Besøg StatusPakning / ForsendelseSymbolBetydning
+ + + Vigtig info registreret +
@@ -31,12 +40,6 @@
Er nylig besøgt -
- -
-
Ubehandlet
@@ -45,12 +48,6 @@ Planlæg -
- -
-
Varer er plukket
@@ -59,12 +56,6 @@ Interval Overskredet -
- -
-
Varer er pakket
@@ -73,12 +64,6 @@ Ajourfør besøgsdato/interval -
- -
-
Varer er afsendt
@@ -87,8 +72,6 @@ Virksomhed ophørt
@@ -97,8 +80,6 @@ CVR/ORG nummer ugyldig
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoColorCustomerComponent.razor.css b/Wonky.Client/Components/InfoColorCustomerComponent.razor.css new file mode 100644 index 00000000..d28e2116 --- /dev/null +++ b/Wonky.Client/Components/InfoColorCustomerComponent.razor.css @@ -0,0 +1,6 @@ +.pictogram { + max-width: 30px; +} +.color-code { + max-width: 30px; +} \ No newline at end of file diff --git a/Wonky.Client/Components/InfoColorPackageComponent.razor b/Wonky.Client/Components/InfoColorPackageComponent.razor new file mode 100644 index 00000000..7b70594e --- /dev/null +++ b/Wonky.Client/Components/InfoColorPackageComponent.razor @@ -0,0 +1,61 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ +@using Wonky.Client.Components + +

Pakning / Forsendelse

+ + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
+
+ +
+
Ubehandlet
+
+ +
+
Varer er plukket
+
+ +
+
Varer er pakket
+
+ +
+
Varer er afsendt
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoColorPackageComponent.razor.css b/Wonky.Client/Components/InfoColorPackageComponent.razor.css new file mode 100644 index 00000000..d28e2116 --- /dev/null +++ b/Wonky.Client/Components/InfoColorPackageComponent.razor.css @@ -0,0 +1,6 @@ +.pictogram { + max-width: 30px; +} +.color-code { + max-width: 30px; +} \ No newline at end of file diff --git a/Wonky.Client/Components/InfoCommonComponent.razor b/Wonky.Client/Components/InfoCommonComponent.razor new file mode 100644 index 00000000..e1f25bd4 --- /dev/null +++ b/Wonky.Client/Components/InfoCommonComponent.razor @@ -0,0 +1,41 @@ +

Fælles

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
Gem data
Søg
Opret
Notat
Udskrivning
Indstillinger
Log af
Hjælp/Info
diff --git a/Wonky.Client/Components/InfoOfficeComponent.razor b/Wonky.Client/Components/InfoOfficeComponent.razor new file mode 100644 index 00000000..abe77131 --- /dev/null +++ b/Wonky.Client/Components/InfoOfficeComponent.razor @@ -0,0 +1,17 @@ +

Kontor

+ + + + + + + + + + + + + +
SymbolBetydning
+ + Brugere
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoOpenSourceComponent.razor b/Wonky.Client/Components/InfoOpenSourceComponent.razor new file mode 100644 index 00000000..ca542448 --- /dev/null +++ b/Wonky.Client/Components/InfoOpenSourceComponent.razor @@ -0,0 +1,12 @@ +

Open Source

+ \ No newline at end of file diff --git a/Wonky.Client/Components/InfoProcessStateComponent.razor b/Wonky.Client/Components/InfoProcessStateComponent.razor new file mode 100644 index 00000000..95e75e79 --- /dev/null +++ b/Wonky.Client/Components/InfoProcessStateComponent.razor @@ -0,0 +1,38 @@ + +

Bestilling Status

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
Ekspress
Telefon
Ubehandlet
Accepteret
Plukket
Pakket
Leveret
diff --git a/Wonky.Client/Components/InfoQuoteToolbarComponent.razor b/Wonky.Client/Components/InfoQuoteToolbarComponent.razor new file mode 100644 index 00000000..5f76cc6e --- /dev/null +++ b/Wonky.Client/Components/InfoQuoteToolbarComponent.razor @@ -0,0 +1,33 @@ +

Aftaler / Tilbud

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
Alle tilbud
Tabte tilbud
Ingen svar
Åbne tilbud
Aktive aftaler
Åbne tilbud / Aktive aftaler
diff --git a/Wonky.Client/Components/InfoWarehouseComponent.razor b/Wonky.Client/Components/InfoWarehouseComponent.razor new file mode 100644 index 00000000..ee8efefd --- /dev/null +++ b/Wonky.Client/Components/InfoWarehouseComponent.razor @@ -0,0 +1,17 @@ +

Lager

+ + + + + + + + + + + + + +
SymbolBetydning
+ + Pakning / Forsendelse
\ No newline at end of file diff --git a/Wonky.Client/Components/InvoiceTableComponent.razor.cs b/Wonky.Client/Components/InvoiceTableComponent.razor.cs deleted file mode 100644 index 8bebb139..00000000 --- a/Wonky.Client/Components/InvoiceTableComponent.razor.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.AspNetCore.Components; -using Wonky.Client.Shared; -using Wonky.Entity.Views; - -namespace Wonky.Client.Components; - -public partial class InvoiceTableComponent -{ - [Parameter] public string CompanyId { get; set; } = ""; - [Parameter] public List InvoiceList { get; set; } = new(); - private InvoiceViewModal InvoiceView { get; set; } = new(); - private string InvoiceId { get; set; } = ""; - private void ShowInvoice(string invoiceId) - { - Console.WriteLine($"invoiceId => {invoiceId}"); - Console.WriteLine($"companyId => {CompanyId}"); - InvoiceId = invoiceId; - InvoiceView.Show(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Components/LandingComponentAdmin.razor b/Wonky.Client/Components/LandingComponentAdmin.razor deleted file mode 100644 index 62f24364..00000000 --- a/Wonky.Client/Components/LandingComponentAdmin.razor +++ /dev/null @@ -1,60 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Microsoft.AspNetCore.Authorization -@using Wonky.Client.Components - -Innotec Admin - -@*
-
-
- -
-
-
- Danmark -
-
-
-
- -
-
-
- -
-
-
- Norge -
-
-
-
- -
-
-
- -
-
-
- Sverige -
-
-
-
*@ \ No newline at end of file diff --git a/Wonky.Client/Components/LandingComponentAdmin.razor.css b/Wonky.Client/Components/LandingComponentAdmin.razor.css deleted file mode 100644 index 6d753f3d..00000000 --- a/Wonky.Client/Components/LandingComponentAdmin.razor.css +++ /dev/null @@ -1,6 +0,0 @@ - -.workDate { - font-size: 1.2em; - font-weight: bold; - font-variant: small-caps; -} \ No newline at end of file diff --git a/Wonky.Client/Components/LandingComponentAdvisor.razor b/Wonky.Client/Components/LandingComponentAdvisor.razor index 5ddd8c37..a97d1535 100644 --- a/Wonky.Client/Components/LandingComponentAdvisor.razor +++ b/Wonky.Client/Components/LandingComponentAdvisor.razor @@ -18,12 +18,8 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components -Innotec Rådgiver -
- +
-
\ No newline at end of file diff --git a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs index c471c4fd..d341023e 100644 --- a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs +++ b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs @@ -30,14 +30,9 @@ using Wonky.Entity.Models; using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class LandingComponentAdvisor : IDisposable +public partial class LandingComponentAdvisor { - [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Inteceptor { get; set; } - [Inject] public IToastService Toaster { get; set; } - [Inject] public ICrmTaskItemHttpRepository TaskItemRepo { get; set; } - [Inject] public NavigationManager Navigator { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } private readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions { @@ -47,59 +42,12 @@ public partial class LandingComponentAdvisor : IDisposable private UserPref Prefs { get; set; } = new(); private DateTime SelectedDate { get; set; } - private List TaskItems { get; set; } = new(); protected override async Task OnInitializedAsync() { Prefs = await ProfileService.GetPreferences(); SelectedDate = string.IsNullOrWhiteSpace(Prefs.WorkDate) ? DateTime.Now : DateTime.Parse(Prefs.WorkDate); - Inteceptor.RegisterEvent(); - Inteceptor.RegisterBeforeSendEvent(); - - //await GetTaskItems(_workDate); - await GetAllTasks(); } - - private async Task GetAllTasks() - { - TaskItems = await TaskItemRepo.GetTaskList(); - } - - private async Task OnCompleteTask(string taskItemId) - { - await ProfileService.SetWorkDate(DateTime.Now); - var item = TaskItems.Find(x => x.TaskItemId == taskItemId); - Navigator.NavigateTo($"/companies/{item.ReferenceId}/activities/new"); - } - - private async Task GetWorkdayTasks(string workDate) - { - SelectedDate = DateTime.Parse(workDate); - TaskItems = new List(); - TaskItems = await TaskItemRepo.GetTaskList($"{SelectedDate:yyyy-MM-dd}"); - } - - private async Task OnTaskCompleted(string taskItemId) - { - var item = TaskItems.Find(x => x.TaskItemId == taskItemId); - item.IsCompleted = true; - await TaskItemRepo.UpdateTaskItem(taskItemId, item); - TaskItems.Remove(item); - Toaster.ShowInfo("Opgaven er markeret som udført."); - } - - private async Task OnDeleteConfirmed(string taskItemId) - { - var item = TaskItems.First(x => x.TaskItemId == taskItemId); - TaskItems.Remove(item); - await TaskItemRepo.DeleteTaskItem(taskItemId); - Toaster.ShowInfo("Opgaven er slettet."); - } - - public void Dispose() - { - Inteceptor.DisposeEvent(); - } } diff --git a/Wonky.Client/Components/LandingComponentOffice.razor b/Wonky.Client/Components/LandingComponentOffice.razor new file mode 100644 index 00000000..8cd7ab49 --- /dev/null +++ b/Wonky.Client/Components/LandingComponentOffice.razor @@ -0,0 +1,91 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components + +
+
+
+
Danmark
+ +
+
+ +
+
+
Norge
+ +
+
+ +
+
+
Sverige
+ +
+
+ +
\ No newline at end of file diff --git a/Wonky.Client/Components/LandingComponentAdmin.razor.cs b/Wonky.Client/Components/LandingComponentOffice.razor.cs similarity index 68% rename from Wonky.Client/Components/LandingComponentAdmin.razor.cs rename to Wonky.Client/Components/LandingComponentOffice.razor.cs index a342cae0..b210bb90 100644 --- a/Wonky.Client/Components/LandingComponentAdmin.razor.cs +++ b/Wonky.Client/Components/LandingComponentOffice.razor.cs @@ -30,14 +30,9 @@ using Wonky.Entity.Models; using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class LandingComponentAdmin : IDisposable +public partial class LandingComponentOffice { - [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IToastService Toaster { get; set; } - [Inject] public ICrmTaskItemHttpRepository CrmTaskItemRepo { get; set; } - [Inject] public NavigationManager Navigator { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -46,23 +41,23 @@ public partial class LandingComponentAdmin : IDisposable }; private UserPref Prefs { get; set; } = new(); - private string WordDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; + private string WorkDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; private string Today { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; - protected override async Task OnInitializedAsync() { + ProfileService.OnChange += ProfileChanged; Prefs = await ProfileService.GetPreferences(); - if(!string.IsNullOrWhiteSpace(Prefs.WorkDate)) - WordDate = Prefs.WorkDate; - - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + if (string.IsNullOrWhiteSpace(Prefs.WorkDate)) + { + await ProfileService.SetWorkDate(DateTime.Now); + } } - - public void Dispose() + + private void ProfileChanged(UserPref newPrefs) { - Interceptor.DisposeEvent(); - } + Prefs = newPrefs; + WorkDate = Prefs.WorkDate; + } } diff --git a/Wonky.Client/Components/OfficeActivityListComponent.razor b/Wonky.Client/Components/OfficeActivityListComponent.razor new file mode 100644 index 00000000..13ed7bfa --- /dev/null +++ b/Wonky.Client/Components/OfficeActivityListComponent.razor @@ -0,0 +1,92 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ +@using Wonky.Entity.Views + +@* Report activities *@ + + + + + + + + + + + + + + + + + + @foreach (var activity in Activities) + { + + + + + + + + + + + + + + } + + + + + + + +
KundeBynavnDemoSalgNotesasBeløb + + + + + + + +
@activity.Company.Name@activity.Company.City@activity.Demo@activity.Sales@activity.OfficeNote@($"{activity.SasAmount:N2}")@(activity.StatusTypeEnum.Contains("Quote") ? $"{0:N2}" : $"{activity.OrderAmount:N2}") + @if (activity.OurRef.Contains("T:")) + { + + } + + @if (activity.Express) + { + + } + + @if (activity.StatusTypeEnum == "Quote") + { + + } + + +
Total@Activities.Where(x => x.StatusTypeEnum != "Quote").Sum(x => x.OrderAmount)
+ +@code { + + [Parameter] + public List Activities { get; set; } = new(); + +} \ No newline at end of file diff --git a/Wonky.Client/Components/OfficeAdvisorTableComponent.razor b/Wonky.Client/Components/OfficeAdvisorTableComponent.razor deleted file mode 100644 index b645e485..00000000 --- a/Wonky.Client/Components/OfficeAdvisorTableComponent.razor +++ /dev/null @@ -1,58 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@if (UserList.Any()) -{ - - - - - - - - - - - - @foreach (var user in UserList) - { - - - - - - - - - } - -
- Navn - - Telefon - - Email - - - - -
@user.FullName@user.PhoneNumber@user.EmailRapporterKunderRediger
-} -else -{ -
Ingen data
-} \ No newline at end of file diff --git a/Wonky.Client/Components/OfficeCountryAdvisorListComponent.razor b/Wonky.Client/Components/OfficeCountryAdvisorListComponent.razor new file mode 100644 index 00000000..63e0165e --- /dev/null +++ b/Wonky.Client/Components/OfficeCountryAdvisorListComponent.razor @@ -0,0 +1,49 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +
+ @if (UserList.Any()) + { + foreach (var user in UserList) + { +
+
+
@user.SalesRep
+
@user.FullName
+
@user.PhoneNumber
+
+ Rapporter +
+
+ Kunder +
+
+ + + Rediger + + +
+
+
+ } + } + else + { +
Ingen data
+ } +
\ No newline at end of file diff --git a/Wonky.Client/Components/OfficeUserTableComponent.razor.cs b/Wonky.Client/Components/OfficeCountryAdvisorListComponent.razor.cs similarity index 94% rename from Wonky.Client/Components/OfficeUserTableComponent.razor.cs rename to Wonky.Client/Components/OfficeCountryAdvisorListComponent.razor.cs index 8c3ff7ec..b8a57bbc 100644 --- a/Wonky.Client/Components/OfficeUserTableComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryAdvisorListComponent.razor.cs @@ -19,7 +19,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class OfficeUserTableComponent +public partial class OfficeCountryAdvisorListComponent { [Parameter] public List UserList { get; set; } = new(); } \ No newline at end of file diff --git a/Wonky.Client/Components/OfficeCustomerTableComponent.razor b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor similarity index 50% rename from Wonky.Client/Components/OfficeCustomerTableComponent.razor rename to Wonky.Client/Components/OfficeCountryCustomerListComponent.razor index 002cd873..6127319b 100644 --- a/Wonky.Client/Components/OfficeCustomerTableComponent.razor +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor @@ -20,19 +20,20 @@ @if (CompanyList.Any()) { + @*
-
+
Sælger
-
+
Konto
-
+
Telefon
-
+
Navn
@@ -40,20 +41,51 @@
+ *@ +
@foreach (var company in CompanyList) { - +
+
+
+
+ @company.Name +
+
+
Konto
+
@company.Account
+ +
CVR / ORG
+
@company.VatNumber
+
+
+
Telefon
+
@company.Phone
+
+
+
Adresse
+
@company.Address1 @(string.IsNullOrWhiteSpace(company.Address2) ? "" : ",") @company.Address2
+
+
+
Post By
+
@company.CountryCode.ToUpper()-@company.ZipCode @company.City
+
+
+
+
+ @* +
-
+
@company.SalesRep
-
+
@company.Account
-
} diff --git a/Wonky.Client/Components/OfficeCustomerTableComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs similarity index 88% rename from Wonky.Client/Components/OfficeCustomerTableComponent.razor.cs rename to Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs index c9ff351b..aa8efc17 100644 --- a/Wonky.Client/Components/OfficeCustomerTableComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs @@ -24,9 +24,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components { - public partial class OfficeCustomerTableComponent + public partial class OfficeCountryCustomerListComponent { - [Parameter] public List CompanyList { get; set; } = new(); + [Parameter] public List CompanyList { get; set; } = new(); + [Parameter] public string CountryCode { get; set; } = ""; } } diff --git a/Wonky.Client/Components/OfficeUserTableComponent.razor b/Wonky.Client/Components/OfficeCountryUserListComponent.razor similarity index 100% rename from Wonky.Client/Components/OfficeUserTableComponent.razor rename to Wonky.Client/Components/OfficeCountryUserListComponent.razor diff --git a/Wonky.Client/Components/OfficeAdvisorTableComponent.razor.cs b/Wonky.Client/Components/OfficeCountryUserListComponent.razor.cs similarity index 92% rename from Wonky.Client/Components/OfficeAdvisorTableComponent.razor.cs rename to Wonky.Client/Components/OfficeCountryUserListComponent.razor.cs index 5d15be7d..1d098669 100644 --- a/Wonky.Client/Components/OfficeAdvisorTableComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryUserListComponent.razor.cs @@ -14,12 +14,11 @@ // using Microsoft.AspNetCore.Components; -using Wonky.Entity.DTO; using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class OfficeAdvisorTableComponent +public partial class OfficeCountryUserListComponent { [Parameter] public List UserList { get; set; } = new(); } \ No newline at end of file diff --git a/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor b/Wonky.Client/Components/OfficeReportActivityListComponent.razor similarity index 83% rename from Wonky.Client/Components/ReportActivityTableOfficeComponent.razor rename to Wonky.Client/Components/OfficeReportActivityListComponent.razor index a9cf370e..cee0fd5a 100644 --- a/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor +++ b/Wonky.Client/Components/OfficeReportActivityListComponent.razor @@ -1,3 +1,4 @@ +@using Wonky.Client.Helpers @* // Copyright (C) 2022 FCS Frede's Computer Services. // This program is free software: you can redistribute it and/or modify @@ -15,9 +16,10 @@ // *@ +@using Wonky.Client.Helpers @if (ActivityList.Any()) { - +
@@ -27,10 +29,10 @@ - - - - + + + + @@ -59,7 +61,7 @@ diff --git a/Wonky.Client/Components/ActivityTableCrmComponent.razor.cs b/Wonky.Client/Components/OfficeReportActivityListComponent.razor.cs similarity index 77% rename from Wonky.Client/Components/ActivityTableCrmComponent.razor.cs rename to Wonky.Client/Components/OfficeReportActivityListComponent.razor.cs index 336fa790..ba5e64e5 100644 --- a/Wonky.Client/Components/ActivityTableCrmComponent.razor.cs +++ b/Wonky.Client/Components/OfficeReportActivityListComponent.razor.cs @@ -18,13 +18,13 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class ActivityTableCrmComponent +public partial class OfficeReportActivityListComponent { [Parameter] public List ActivityList { get; set; } = new(); - [Inject] public NavigationManager Navigator { get; set; } - - // private void ShowOrder(string companyId, string orderId) - // { - // Navigator.NavigateTo($"office/customers/{companyId}/orders/{orderId}"); - // } + [Inject] private NavigationManager Navigator { get; set; } + + private void ShowOrder(string companyId, string orderId) + { + Navigator.NavigateTo($"/office/customers/{companyId}/orders/{orderId}"); + } } \ No newline at end of file diff --git a/Wonky.Client/Components/ReportTableOfficeComponent.razor b/Wonky.Client/Components/OfficeReportListComponent.razor similarity index 100% rename from Wonky.Client/Components/ReportTableOfficeComponent.razor rename to Wonky.Client/Components/OfficeReportListComponent.razor diff --git a/Wonky.Client/Components/ReportTableOfficeComponent.razor.cs b/Wonky.Client/Components/OfficeReportListComponent.razor.cs similarity index 96% rename from Wonky.Client/Components/ReportTableOfficeComponent.razor.cs rename to Wonky.Client/Components/OfficeReportListComponent.razor.cs index 0b29645a..463369d9 100644 --- a/Wonky.Client/Components/ReportTableOfficeComponent.razor.cs +++ b/Wonky.Client/Components/OfficeReportListComponent.razor.cs @@ -18,7 +18,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class ReportTableOfficeComponent +public partial class OfficeReportListComponent { [Parameter] public List ReportList { get; set; } = new(); [Parameter] public string UserId { get; set; } = ""; diff --git a/Wonky.Client/Components/PageSizeComponent.razor.cs b/Wonky.Client/Components/PageSizeComponent.razor.cs index 62f3fe9d..f0ea009b 100644 --- a/Wonky.Client/Components/PageSizeComponent.razor.cs +++ b/Wonky.Client/Components/PageSizeComponent.razor.cs @@ -23,18 +23,20 @@ namespace Wonky.Client.Components { public partial class PageSizeComponent : IDisposable { - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } [Parameter] public EventCallback OnChanged { get; set; } private Dictionary Items { get; set; } = new(); private UserPref Prefs = new(); private string PageSize { get; set; } = ""; + protected override async Task OnInitializedAsync() { ProfileService.OnChange += ProfileServiceOnOnChange; Prefs = await ProfileService.GetPreferences(); PageSize = Prefs.PageSize; } + private async Task OnSelectChanged(ChangeEventArgs e) { var val = e.Value.ToString(); @@ -42,11 +44,13 @@ namespace Wonky.Client.Components await OnChanged.InvokeAsync(val); await ProfileService.SetPageSize(val); } + private void ProfileServiceOnOnChange(UserPref newUserPref) { Prefs = newUserPref; StateHasChanged(); } + public void Dispose() { ProfileService.OnChange -= ProfileServiceOnOnChange; diff --git a/Wonky.Client/Components/ProcessStateComponent.razor b/Wonky.Client/Components/ProcessStateComponent.razor index c28e80ea..11b9d7eb 100644 --- a/Wonky.Client/Components/ProcessStateComponent.razor +++ b/Wonky.Client/Components/ProcessStateComponent.razor @@ -30,6 +30,7 @@ "the-bad" => "file-earmark-check", "the-ugly" => "box2-fill", "the-dead" => "truck", + "accepted" => "hand-thumbs-up", _ => "question-square" }; } diff --git a/Wonky.Client/Components/QuoteListComponent.razor b/Wonky.Client/Components/QuoteListComponent.razor index bac96d51..13248f3f 100644 --- a/Wonky.Client/Components/QuoteListComponent.razor +++ b/Wonky.Client/Components/QuoteListComponent.razor @@ -45,38 +45,38 @@ @switch (quote.QuoteStatusEnum) { case "None": - + break; case "Lose": - + break; case "Note": - + break; case "Archive": - + break; default: - + break; }
@quote.ESalesNumber + href="/advisor/customers/@quote.Company.CompanyId/quotes/@quote.ActivityId">@quote.ESalesNumber
@if (!string.IsNullOrWhiteSpace(quote.OfficeNote)) { -
Note
+
Kontor
- @quote.OfficeNote + @quote.OfficeNote
} @if (!string.IsNullOrWhiteSpace(quote.CrmNote)) { -
CRM note
+
CRM
- @quote.CrmNote + @quote.CrmNote
} @@ -89,19 +89,3 @@ } -@code { - - [Parameter] - public List Quotes { get; set; } = new(); - [Parameter] public EventCallback OnChangedCallback { get; set; } - - private async Task SetQuote(string eSalesNumber, QStatus status) - { - var args = new QuoteCallbackArgs() - { - ESalesNumber = eSalesNumber, - Status = status - }; - await OnChangedCallback.InvokeAsync(args); - } -} diff --git a/Wonky.Client/Components/QuoteListComponent.razor.cs b/Wonky.Client/Components/QuoteListComponent.razor.cs new file mode 100644 index 00000000..d5fcb0d6 --- /dev/null +++ b/Wonky.Client/Components/QuoteListComponent.razor.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Client.Models; +using Wonky.Entity.Views; + +namespace Wonky.Client.Components; + +public partial class QuoteListComponent +{ + [Parameter] + public List Quotes { get; set; } = new(); + [Parameter] public EventCallback OnChangedCallback { get; set; } + + private async Task SetQuote(string eSalesNumber, QStatus status) + { + var args = new QCallbackArgs() + { + ESalesNumber = eSalesNumber, + Status = status + }; + await OnChangedCallback.InvokeAsync(args); + } +} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportActivityLedgerComponent.razor b/Wonky.Client/Components/ReportActivityLedgerComponent.razor index 153d2759..6e804234 100644 --- a/Wonky.Client/Components/ReportActivityLedgerComponent.razor +++ b/Wonky.Client/Components/ReportActivityLedgerComponent.razor @@ -1,3 +1,4 @@ +@using Wonky.Entity.Views @* // Copyright (C) 2022 FCS Frede's Computer Services. // This program is free software: you can redistribute it and/or modify @@ -84,4 +85,8 @@
KundeNote sas Beløb
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order") { - + }
-
\ No newline at end of file +
+ +@code{ + [Parameter] public ReportData ReportData { get; set; } = new(); +} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor.cs b/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor.cs deleted file mode 100644 index 2246eb19..00000000 --- a/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Microsoft.AspNetCore.Components; -using Wonky.Entity.Views; - -namespace Wonky.Client.Components; - -public partial class ReportActivityTableOfficeComponent -{ - [Parameter] public List ActivityList { get; set; } = new(); - [Inject] public NavigationManager Navigator { get; set; } - - private static string GetProcessStatus(string processStatus) - { - return processStatus.ToLower() switch - { - "express" => "the-fast", - "none" => "the-good", - "picked" => "the-bad", - "packed" => "the-ugly", - "shipped" => "the-dead", - _ => "the-draw" - }; - } - - private void ShowOrder(string companyId, string orderId) - { - Navigator.NavigateTo($"office/customers/{companyId}/orders/{orderId}"); - } -} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportItemComponent.razor b/Wonky.Client/Components/ReportItemComponent.razor index 264d686d..d37c73e6 100644 --- a/Wonky.Client/Components/ReportItemComponent.razor +++ b/Wonky.Client/Components/ReportItemComponent.razor @@ -22,7 +22,7 @@ -
+

@ReportItem.Company.Name

@if (ReportItem.Express) { @@ -134,23 +134,10 @@ @if (!string.IsNullOrWhiteSpace(@ReportItem.OfficeNote)) { -
-

+
+

@ReportItem.OfficeNote -

+

}
- -@code{ - - [Parameter] - public ReportItemView ReportItem { get; set; } = new(); - - protected override void OnParametersSet() - { - var lines = ReportItem.Lines.OrderBy(x => x.Location).ToList(); - ReportItem.Lines = lines; - } - -} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportItemComponent.razor.cs b/Wonky.Client/Components/ReportItemComponent.razor.cs new file mode 100644 index 00000000..ff0ea6dc --- /dev/null +++ b/Wonky.Client/Components/ReportItemComponent.razor.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Entity.Views; + +namespace Wonky.Client.Components; + +public partial class ReportItemComponent +{ + [Parameter] + public ReportItemView ReportItem { get; set; } = new(); + + protected override void OnParametersSet() + { + var lines = ReportItem.Lines.OrderBy(x => x.Location).ToList(); + ReportItem.Lines = lines; + } +} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportTableCrmComponent.razor b/Wonky.Client/Components/ReportListComponent.razor similarity index 100% rename from Wonky.Client/Components/ReportTableCrmComponent.razor rename to Wonky.Client/Components/ReportListComponent.razor diff --git a/Wonky.Client/Components/ReportTableCrmComponent.razor.cs b/Wonky.Client/Components/ReportListComponent.razor.cs similarity index 96% rename from Wonky.Client/Components/ReportTableCrmComponent.razor.cs rename to Wonky.Client/Components/ReportListComponent.razor.cs index fef1e042..d8ad3799 100644 --- a/Wonky.Client/Components/ReportTableCrmComponent.razor.cs +++ b/Wonky.Client/Components/ReportListComponent.razor.cs @@ -19,7 +19,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.Components; -public partial class ReportTableCrmComponent +public partial class ReportListComponent { [Parameter] public List ReportList { get; set; } = new(); [Parameter] public EventCallback OnShowReport { get; set; } diff --git a/Wonky.Client/Components/TaskItemTableComponent.razor b/Wonky.Client/Components/TaskItemTableComponent.razor index 6ad590c8..6281fa74 100644 --- a/Wonky.Client/Components/TaskItemTableComponent.razor +++ b/Wonky.Client/Components/TaskItemTableComponent.razor @@ -47,7 +47,7 @@ - + @@ -64,7 +64,7 @@ @if (task.TaskTypeEnum is "Recall") { - + } @@ -81,7 +81,7 @@ } - + } else { diff --git a/Wonky.Client/Components/TaskItemTableComponent.razor.cs b/Wonky.Client/Components/TaskItemTableComponent.razor.cs index 2ee6e492..eb192f1f 100644 --- a/Wonky.Client/Components/TaskItemTableComponent.razor.cs +++ b/Wonky.Client/Components/TaskItemTableComponent.razor.cs @@ -61,6 +61,10 @@ namespace Wonky.Client.Components _confirmationModal.Show(); } + private void OnCancelCallback() + { + _confirmationModal.Hide(); + } /// /// Delete task call back /// diff --git a/Wonky.Client/Components/TopbarNavigation.razor b/Wonky.Client/Components/TopbarNavigation.razor index 98f967d5..d67b2685 100644 --- a/Wonky.Client/Components/TopbarNavigation.razor +++ b/Wonky.Client/Components/TopbarNavigation.razor @@ -19,9 +19,9 @@
- - - + + +
\ No newline at end of file diff --git a/Wonky.Client/Components/WarehouseListComponent.razor b/Wonky.Client/Components/WarehouseListComponent.razor index 283e34ee..552bb7ef 100644 --- a/Wonky.Client/Components/WarehouseListComponent.razor +++ b/Wonky.Client/Components/WarehouseListComponent.razor @@ -1,3 +1,4 @@ +@using Wonky.Client.Models @* // Copyright (C) 2022 FCS Frede's Computer Services. // This program is free software: you can redistribute it and/or modify @@ -15,104 +16,86 @@ // *@ -
-
-
- - +@if (OrderList != null) +{ +
+
+
+ + - - + + - - - - - -
-
-
- -
-
- @if (ReadyToShip && OrderList.Any()) - { - - } -
-
-
-
-
-
-

Ordredato

-
-
-

Kundenavn

-
-
-

Postnr. Bynavn

-
-
-

- -

-
-
-

Status

+ +
+
+ +
+
+ @if (ReadyToShip && Orders.Any()) + { + + } +
- @if (OrderList.Any()) - { - @foreach (var order in OrderList) +
+
+
+
+

Modtager

+
+
+
Post By
+
+
+
Dato
+
+
+
Status
+
+
+
+ @foreach (var order in Orders) { - +
-
- @order.OrderDate -
-
+
@order.Company.Name
-
} - } - else - { -
- Flot klaret - bordet er ryddet -
- } -
\ No newline at end of file +
+} \ No newline at end of file diff --git a/Wonky.Client/Components/WarehouseListComponent.razor.cs b/Wonky.Client/Components/WarehouseListComponent.razor.cs index 90da7c3a..54aeaa61 100644 --- a/Wonky.Client/Components/WarehouseListComponent.razor.cs +++ b/Wonky.Client/Components/WarehouseListComponent.razor.cs @@ -13,131 +13,43 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // - -using System.Text.Json; -using Blazored.Toast.Services; using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; +using Wonky.Client.Models; using Wonky.Entity.Views; namespace Wonky.Client.Components; public partial class WarehouseListComponent { - [Parameter] public string Status { get; set; } = "none"; - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IWarehouseHttpRepository WarehouseRepo { get; set; } - [Inject] public IToastService Toaster { get; set; } - - private string ItemList { get; set; } = ""; - private bool ReadyToShip; - private string Header = "Ubehandlet"; + [Parameter] public string Header { get; set; } = ""; + [Parameter] public List? OrderList { get; set; } + [Parameter] public bool ReadyToShip { get; set; } + [Parameter] public EventCallback OnGetStatus { get; set; } + [Parameter] public EventCallback OnSetShipped { get; set; } + [Parameter] public EventCallback OnQPak { get; set; } - private List OrderList { get; set; } - private bool Working { get; set; } = true; + private List Orders { get; set; } = new(); - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - - switch (Status.ToLower()) - { - case "none": - Header = "Ubehandlede ordrer"; - await GetOrderStatusNone(); - break; - case "picked": - Header = "Plukkede ordrer"; - await GetOrderStatusPicked(); - break; - case "packed": - Header = "Pakkede ordrer"; - await GetOrderStatusPacked(); - break; - case "shipped": - Header = "Afsendte ordrer"; - await GetOrderStatusShipped(); - break; - default: - await GetOrderStatusNone(); - break; - } - } - - private async Task GetOrderStatusNone() - { - Working = true; - OrderList = new List(); - Header = "Ubehandlede ordrer"; - ReadyToShip = false; - Working = true; - OrderList = new List(); - OrderList = await WarehouseRepo.GetWarehouseOrderListByStatus("none"); - if(OrderList.Any(x => x.Express)) - OrderList = OrderList.OrderByDescending(x => x.Express).ToList(); - Working = false; - } - - private async Task GetOrderStatusPicked() - { - Working = true; - OrderList = new List(); - Header = "Plukkede ordrer"; - ReadyToShip = false; - Working = true; - OrderList = new List(); - OrderList = await WarehouseRepo.GetWarehouseOrderListByStatus("picked"); - Working = false; - } - - private async Task GetOrderStatusPacked() - { - Working = true; - OrderList = new List(); - Header = "Pakkede ordrer"; - Working = true; - OrderList = new List(); - OrderList = await WarehouseRepo.GetWarehouseOrderListByStatus("packed"); - ReadyToShip = true; - Working = false; - } - - private async Task GetOrderStatusShipped() - { - Working = true; - OrderList = new List(); - Header = "Afsendte ordrer"; - ReadyToShip = false; - Toaster.ShowWarning("Det kan tage lidt tid at hente alle.\nVent venligst.\nMåske skal vi tænke over hvor mange vi henter?"); - Working = true; - OrderList = new List(); - var orderList = await WarehouseRepo.GetWarehouseOrderListByStatus("shipped"); - OrderList = orderList.OrderByDescending(x => x.OrderDate).ToList(); - Toaster.ShowInfo("Her er de så ...."); - Working = false; + while (OrderList == null) + await Task.Delay(500); + + Orders = OrderList; } - private async Task SetAllPackedStatusToShipped() + private async Task SetShipStatus() { - Working = true; - foreach (var order in OrderList.Where(order => order.ProcessStatusEnum.ToLower() == "packed")) - { - order.ProcessStatusEnum = "shipped"; - var process = new WarehouseProcess - { - OrderId = order.OrderId, - ProcessStatusEnum = "shipped" - }; - await WarehouseRepo.UpdateWarehouseOrderStatus(process); - } - Working = false; + await OnSetShipped.InvokeAsync(); } - public void Dispose() + private async Task GetWithStatus(PStatus status) { - Interceptor.DisposeEvent(); + await OnGetStatus.InvokeAsync(status); + } + + private async Task QuickPak(string orderId) + { + await OnQPak.InvokeAsync(orderId); } } \ No newline at end of file diff --git a/Wonky.Client/Components/WorkDateComponent.razor b/Wonky.Client/Components/WorkDateComponent.razor index e9e1d862..6a10e4f0 100644 --- a/Wonky.Client/Components/WorkDateComponent.razor +++ b/Wonky.Client/Components/WorkDateComponent.razor @@ -21,8 +21,8 @@
-
- @SelectedDate.ToLongDateString() +
+ d. @(SelectedDate.Day)/@(SelectedDate.Month)
diff --git a/Wonky.Client/Components/WorkplaceListComponent.razor b/Wonky.Client/Components/WorkplaceListComponent.razor index 50175aa8..04aedadf 100644 --- a/Wonky.Client/Components/WorkplaceListComponent.razor +++ b/Wonky.Client/Components/WorkplaceListComponent.razor @@ -14,7 +14,7 @@
@foreach (var workplace in Workplaces) { - +
@workplace.Name @@ -31,10 +31,3 @@ else {
Ingen data
} - -@code { - - [Parameter] public List Workplaces { get; set; } = new(); - - [Parameter] public string CompanyId { get; set; } = ""; -} \ No newline at end of file diff --git a/Wonky.Client/Components/WorkplaceListComponent.razor.cs b/Wonky.Client/Components/WorkplaceListComponent.razor.cs new file mode 100644 index 00000000..43dae261 --- /dev/null +++ b/Wonky.Client/Components/WorkplaceListComponent.razor.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Entity.Views; + +namespace Wonky.Client.Components; + +public partial class WorkplaceListComponent +{ + [Parameter] public List Workplaces { get; set; } = new(); + + [Parameter] public string CompanyId { get; set; } = ""; +} \ No newline at end of file diff --git a/Wonky.Client/Features/PagingLink.cs b/Wonky.Client/Features/PagingLink.cs index a4d6c97a..240cb2d5 100644 --- a/Wonky.Client/Features/PagingLink.cs +++ b/Wonky.Client/Features/PagingLink.cs @@ -14,14 +14,34 @@ // namespace Wonky.Client.Features; - +/// +/// PagingLink class +/// public class PagingLink { + /// + /// Text + /// public string Text { get; set; } + /// + /// Page + /// public int Page { get; set; } + /// + /// Enabled + /// public bool Enabled { get; set; } + /// + /// Active + /// public bool Active { get; set; } + /// + /// The paging link + /// + /// + /// + /// public PagingLink(int page, bool enabled, string text) { Page = page; diff --git a/Wonky.Client/Features/PagingResponse.cs b/Wonky.Client/Features/PagingResponse.cs index 5cde91c4..da8245c8 100644 --- a/Wonky.Client/Features/PagingResponse.cs +++ b/Wonky.Client/Features/PagingResponse.cs @@ -18,8 +18,18 @@ using Wonky.Entity.Requests; namespace Wonky.Client.Features; +/// +/// PagingResponse T class +/// +/// public class PagingResponse where T : class { + /// + /// Items + /// public List? Items { get; set; } + /// + /// Meta DAta + /// public MetaData? MetaData { get; set; } } \ No newline at end of file diff --git a/Wonky.Client/Helpers/InputDateTime.cs b/Wonky.Client/Helpers/InputDateTime.cs index 8bf8a65c..5ae2983f 100644 --- a/Wonky.Client/Helpers/InputDateTime.cs +++ b/Wonky.Client/Helpers/InputDateTime.cs @@ -21,73 +21,99 @@ using Microsoft.AspNetCore.Components.Rendering; namespace Wonky.Client.Helpers; +/// +/// InputDateTime Component +/// +/// public class InputDateTime : InputDate { private const string DateFormat = "yyyy-MM-ddTHH:mm"; - /// - protected override void BuildRenderTree ( RenderTreeBuilder builder ) + /// + /// BuildTender + /// + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) { - builder.OpenElement( 0, "input" ); - builder.AddMultipleAttributes( 1, AdditionalAttributes ); - builder.AddAttribute( 2, "type", "datetime-local" ); - builder.AddAttribute( 3, "class", CssClass ); - builder.AddAttribute( 4, "value", BindConverter.FormatValue( CurrentValueAsString ) ); - builder.AddAttribute( 5, "onchange", EventCallback.Factory.CreateBinder( this, __value => CurrentValueAsString = __value, CurrentValueAsString ) ); + builder.OpenElement(0, "input"); + builder.AddMultipleAttributes(1, AdditionalAttributes); + builder.AddAttribute(2, "type", "datetime-local"); + builder.AddAttribute(3, "class", CssClass); + builder.AddAttribute(4, "value", BindConverter.FormatValue(CurrentValueAsString)); + builder.AddAttribute(5, "onchange", + EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, + CurrentValueAsString)); builder.CloseElement(); } - /// - protected override string FormatValueAsString ( TValue value ) + /// + /// Format value as string + /// + /// + /// + protected override string FormatValueAsString(TValue value) { - switch ( value ) + return value switch { - case DateTime dateTimeValue: - return BindConverter.FormatValue( dateTimeValue, DateFormat, CultureInfo.InvariantCulture ); - case DateTimeOffset dateTimeOffsetValue: - return BindConverter.FormatValue( dateTimeOffsetValue, DateFormat, CultureInfo.InvariantCulture ); - default: - return string.Empty; // Handles null for Nullable, etc. - } + DateTime dateTimeValue => + BindConverter.FormatValue(dateTimeValue, DateFormat, CultureInfo.InvariantCulture), + DateTimeOffset dateTimeOffsetValue => BindConverter.FormatValue(dateTimeOffsetValue, DateFormat, + CultureInfo.InvariantCulture), + _ => string.Empty + }; } - /// - protected override bool TryParseValueFromString ( string value, out TValue result, out string validationErrorMessage ) + /// + /// TryParseValueFromString + /// + /// + /// + /// + /// + /// + protected override bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage) { // Unwrap nullable types. We don't have to deal with receiving empty values for nullable // types here, because the underlying InputBase already covers that. - var targetType = Nullable.GetUnderlyingType( typeof( TValue ) ) ?? typeof( TValue ); + var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); bool success; - if ( targetType == typeof( DateTime ) ) + if (targetType == typeof(DateTime)) { - success = TryParseDateTime( value, out result ); + success = TryParseDateTime(value, out result); } - else if ( targetType == typeof( DateTimeOffset ) ) + else if (targetType == typeof(DateTimeOffset)) { - success = TryParseDateTimeOffset( value, out result ); + success = TryParseDateTimeOffset(value, out result); } else { - throw new InvalidOperationException( $"The type '{targetType}' is not a supported date type." ); + throw new InvalidOperationException($"The type '{targetType}' is not a supported date type."); } - if ( success ) + if (success) { validationErrorMessage = null; return true; } else { - validationErrorMessage = string.Format( ParsingErrorMessage, FieldIdentifier.FieldName ); + validationErrorMessage = string.Format(ParsingErrorMessage, FieldIdentifier.FieldName); return false; } } - static bool TryParseDateTime ( string value, out TValue result ) + /// + /// TrypParseDateTime + /// + /// + /// + /// + private static bool TryParseDateTime(string value, out TValue result) { - var success = BindConverter.TryConvertToDateTime( value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue ); - if ( success ) + var success = + BindConverter.TryConvertToDateTime(value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue); + if (success) { result = (TValue)(object)parsedValue; return true; @@ -99,10 +125,18 @@ public class InputDateTime : InputDate } } - static bool TryParseDateTimeOffset ( string value, out TValue result ) + /// + /// TryParseDateTimeOffset + /// + /// + /// + /// + private static bool TryParseDateTimeOffset(string value, out TValue result) { - var success = BindConverter.TryConvertToDateTimeOffset( value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue ); - if ( success ) + var success = + BindConverter.TryConvertToDateTimeOffset(value, CultureInfo.InvariantCulture, DateFormat, + out var parsedValue); + if (success) { result = (TValue)(object)parsedValue; return true; diff --git a/Wonky.Client/Helpers/Squid.cs b/Wonky.Client/Helpers/Squid.cs index aa4a2c56..2283ec17 100644 --- a/Wonky.Client/Helpers/Squid.cs +++ b/Wonky.Client/Helpers/Squid.cs @@ -28,36 +28,79 @@ using System.Diagnostics; namespace Wonky.Client.Helpers { + /// + /// Squid is guid string shortened and url safe + /// [DebuggerDisplay("{" + nameof(Value) + "}")] public readonly struct Squid : IEquatable - { + { + /// + /// Return Empty value + /// + // ReSharper disable once MemberCanBePrivate.Global public static readonly Squid Empty = new(Guid.Empty); + + /// + /// Decode Squid to Guid + /// + /// public Squid(string value) { Value = value; Guid = DecodeSquid(value); } + + /// + /// Generate Squid from Guid object + /// + /// public Squid(Guid obj) { Value = EncodeGuid(obj); Guid = obj; } -#pragma warning disable CA1720 // Identifier contains type name + + /// + /// Guid + /// + // ReSharper disable once MemberCanBePrivate.Global public Guid Guid { get; } -#pragma warning restore CA1720 // Identifier contains type name + public string Value { get; } + + /// + /// ToString() function + /// + /// public override string ToString() { return Value; } - public override bool Equals(object obj) + + /// + /// Equality + /// + /// + /// + public override bool Equals(object? obj) { return obj is Squid other && Equals(other); } + + /// + /// EQuality + /// + /// + /// public bool Equals(Squid obj) { return Guid.Equals(obj.Guid) && Value == obj.Value; } + + /// + /// Get hashcode + /// + /// public override int GetHashCode() { unchecked @@ -65,15 +108,33 @@ namespace Wonky.Client.Helpers return (Guid.GetHashCode() * 397) ^ (Value != null ? Value.GetHashCode() : 0); } } + + /// + /// Create Squid from new Guid + /// + /// public static Squid NewGuid() { - return new(Guid.NewGuid()); + return new Squid(Guid.NewGuid()); } + + /// + /// Encode string + /// + /// + /// public static string EncodeString(string value) { var guid = new Guid(value); return EncodeGuid(guid); } + + /// + /// Encode Guid + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static string EncodeGuid(Guid obj) { var encoded = Convert.ToBase64String(obj.ToByteArray()); @@ -82,25 +143,52 @@ namespace Wonky.Client.Helpers .Replace("+", "-"); return encoded.Substring(0, 22); } + + /// + /// Decode Squid + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static Guid DecodeSquid(string value) { - if (value == null) return Empty; + if (!value.Any()) return Empty; value = value .Replace("_", "/") .Replace("-", "+"); var blob = Convert.FromBase64String(value + "=="); return new Guid(blob); } + + /// + /// Guid From Squid + /// + /// + /// public static Guid FromSquid(Squid obj) { return obj.Guid; } + + /// + /// Squid From String + /// + /// + /// public static Squid FromString(string value) { if (string.IsNullOrEmpty(value)) return Empty; return TryParse(value, out Squid obj) ? obj : Empty; } + + /// + /// TryDecode + /// + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static bool TryDecode(string value, out Guid obj) { try @@ -109,15 +197,21 @@ namespace Wonky.Client.Helpers obj = DecodeSquid(value); return true; } -#pragma warning disable CA1031 // Do not catch general exception types catch (Exception) -#pragma warning restore CA1031 // Do not catch general exception types { // Return empty Guid obj = Guid.Empty; return false; } } + + /// + /// TryParse + /// + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static bool TryParse(string value, out Squid obj) { // Parse as Squid string. @@ -126,15 +220,24 @@ namespace Wonky.Client.Helpers obj = oGuid; return true; } + // Parse as Guid string. if (Guid.TryParse(value, out oGuid)) { obj = oGuid; return true; } + obj = Empty; return false; } + + /// + /// TryParse + /// + /// + /// + /// public static bool TryParse(string value, out Guid obj) { // Try a Squid string. @@ -146,38 +249,98 @@ namespace Wonky.Client.Helpers obj = Guid.Empty; return false; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Squid x, Squid y) { return x.Guid == y.Guid; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Squid x, Guid y) { return x.Guid == y; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Guid x, Squid y) { return y == x; // NB: order of arguments } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Squid x, Squid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Squid x, Guid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Guid x, Squid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// public static implicit operator string(Squid oSquid) { return oSquid.Value; } + + /// + /// Operator + /// + /// + /// public static implicit operator Guid(Squid oSquid) { return oSquid.Guid; } + + /// + /// Operator + /// + /// + /// public static implicit operator Squid(string value) { if (string.IsNullOrEmpty(value)) @@ -185,6 +348,12 @@ namespace Wonky.Client.Helpers return TryParse(value, out Squid oSquid) ? oSquid : Empty; } + + /// + /// Operator + /// + /// + /// public static implicit operator Squid(Guid oGuid) { return oGuid == Guid.Empty ? Empty : new Squid(oGuid); diff --git a/Wonky.Client/Helpers/StringExtensions.cs b/Wonky.Client/Helpers/StringExtensions.cs index e9168eda..51a5c3a4 100644 --- a/Wonky.Client/Helpers/StringExtensions.cs +++ b/Wonky.Client/Helpers/StringExtensions.cs @@ -17,7 +17,13 @@ namespace Wonky.Client.Helpers; public static class StringExtensions { - public static string Left(this string value, int maxLength) + /// + /// Left Pad a string with spaces until maxlength + /// + /// + /// + /// + public static string PadLeft(this string value, int maxLength) { if (string.IsNullOrEmpty(value)) return value; maxLength = Math.Abs(maxLength); diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index 75c75119..58d333b2 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -18,63 +18,125 @@ using System.Net.Mail; using Wonky.Entity.DTO; namespace Wonky.Client.Helpers; - +/// +/// Utilities +/// public static class Utils { + /// + /// return Country Name from countryCode + /// + /// + /// + public static string CountryName(string countryCode) + { + return countryCode.ToLower() switch + { + "dk" => "Danmark", + "no" => "Norge", + "se" => "Sverige", + _ => "" + }; + } + + /// + /// Helper to parse querystring + /// + /// + /// public static Dictionary ParseQuery(string query) { if (string.IsNullOrWhiteSpace(query) || query.Contains("://")) return new Dictionary(); - + // remove the question mark + query = query.Replace("?", ""); + // split into pairs var elements = query.Split("&"); - + // return elements as list return elements.Select( - data - => data.Split("=")) + data + => data.Split("=")) .ToDictionary(element => element[0], element => element[1]); } - + + /// + /// Validate email format + /// + /// + /// public static bool IsValidEmail(string email) { var trimmedEmail = email.Trim(); - if (trimmedEmail.EndsWith(".")) { + if (trimmedEmail.EndsWith(".")) + { return false; // suggested by @TK-421 } - try { + + try + { var addr = new MailAddress(email); return addr.Address == trimmedEmail; } - catch { + catch + { return false; } } - + + /// + /// return enum as the string value + /// + /// + /// public static string EnumToString(Enum value) { return value.ToString(); } - + /// + /// Parse string to enum of T + /// + /// + /// + /// + public static T StringToEnum(string value) + { + return (T)Enum.Parse(typeof(T), value, true); + } + /// + /// Generate unique hashcode from time + /// + /// public static int GetHashFromNow() { return DateTime.Now.ToFileTimeUtc().GetHashCode(); } + /// + /// Get visit state as colored icon + /// + /// + /// public static string GetVisitState(string dtNextVisit) { if (dtNextVisit is "0001-01-01" or "1970-01-01") return "the-draw"; if (!DateTime.TryParse(dtNextVisit, out _)) return "the-draw"; - + var dtNow = DateTime.Now; var dtNext = DateTime.Parse(dtNextVisit); if (dtNow > dtNext) return "the-ugly"; - + return dtNow > dtNext.AddDays(-14) ? "the-bad" : "the-good"; } - + + /// + /// Translate process status to icon + /// + /// + /// public static string GetProcessStatus(string processStatus) { return processStatus.ToLower() switch @@ -84,7 +146,8 @@ public static class Utils "picked" => "the-bad", "packed" => "the-ugly", "shipped" => "the-dead", - _ => "question-square" + "accepted" => "accepted", + _ => "question" }; - } + } } \ No newline at end of file diff --git a/Wonky.Client/Helpers/VatUtils.cs b/Wonky.Client/Helpers/VatUtils.cs index 83f77e9b..d01aa955 100644 --- a/Wonky.Client/Helpers/VatUtils.cs +++ b/Wonky.Client/Helpers/VatUtils.cs @@ -14,6 +14,9 @@ // using System.Globalization; +using System.Reflection.Metadata.Ecma335; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; namespace Wonky.Client.Helpers; @@ -21,10 +24,15 @@ public class VatUtils { // https://ec.europa.eu/taxation_customs/vies/faqvies.do#item_11 // https://ec.europa.eu/taxation_customs/vies/ - + /// + /// Entrypoint for validating vat number + /// + /// + /// + /// public static bool ValidateFormat(string countryCode, string vatNumber) { - if (string.IsNullOrWhiteSpace(vatNumber) || string.IsNullOrWhiteSpace(countryCode) || !IsDigitsOnly(vatNumber)) + if (string.IsNullOrWhiteSpace(vatNumber) || string.IsNullOrWhiteSpace(countryCode)) return false; var sanitisedVat = SanitizeVatNumber(vatNumber); @@ -38,10 +46,34 @@ public class VatUtils }; } + /// + /// Sanitize Vat remove everything but digits + /// + /// + /// + public static string SanitizeVatNumber(string vatNumber) + { + if (string.IsNullOrWhiteSpace(vatNumber)) + return ""; + var regexObj = new Regex(@"[^\d]"); + return regexObj.Replace(vatNumber, ""); + } + + /// + /// Validate string is only numbers + /// + /// + /// private static bool IsDigitsOnly(string check) { return check.All(c => c is >= '0' and <= '9'); } + + /// + /// Validate Danish Vat number format + /// + /// + /// private static bool ValidateFormatDk(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Denmark @@ -57,6 +89,11 @@ public class VatUtils return ValidateMod11(vatNumber); } + /// + /// Validate Norwegian Vat number format + /// + /// + /// private static bool ValidateFormatNo(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Norway @@ -69,7 +106,40 @@ public class VatUtils return long.Parse(vatNumber) != 0 && ValidateMod11(vatNumber); } + /// + /// Validate Swedish Vat number format + /// + /// + /// private static bool ValidateFormatSe(string vatNumber) + { + var vatToCheck = vatNumber; + if (long.Parse(vatToCheck) == 0) + return false; + + switch (vatToCheck.Length) + { + // if less than 10 chars validate as SSI + case 6: + return ValidateFormatSeExt(vatToCheck); + case < 10: + return false; + case > 10: + vatNumber = vatNumber[..10]; + break; + } + // calculate check digit + var c10 = C10(vatToCheck); + // return comparison + return $"{vatToCheck[..9]}{c10}" == vatNumber; + } + + /// + /// Calculate check digit for swedish org number + /// + /// + /// + private static int C10(string orgNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Sweden // 12 digits 0 to 9 @@ -78,22 +148,62 @@ public class VatUtils // Si = int(Ci/5) + (Ci*2)MOD10) // https://www.skatteverket.se/skatter/mervardesskattmoms/momsregistreringsnummer.4.18e1b10334ebe8bc80002649.html // C11 C12 == 01 (De två sista siffrorna är alltid 01) - var vatToCheck = vatNumber; - if (vatToCheck.Length < 10 || long.Parse(vatToCheck) == 0) - return false; - + var r = new[] { 0, 2, 4, 6, 8 } - .Sum(m => (int)char.GetNumericValue(vatToCheck[m]) / 5 + - (int)char.GetNumericValue(vatToCheck[m]) * 2 % 10); - var c1 = new[] { 1, 3, 5, 7 }.Sum(m => (int)char.GetNumericValue(vatToCheck[m])); - var c10 = (10 - (r + c1) % 10) % 10; - if (vatToCheck.Length == 10) + .Sum(m => (int)char.GetNumericValue(orgNumber[m]) / 5 + + (int)char.GetNumericValue(orgNumber[m]) * 2 % 10); + var c1 = new[] { 1, 3, 5, 7 }.Sum(m => (int)char.GetNumericValue(orgNumber[m])); + var c10 = (10 - (r + c1) % 10) % 10; + return c10; + // end check digit calculation + + } + /// + /// + /// + /// + /// + private static bool ValidateFormatSeExt(string data) + { + // Swedish personally held companies uses SSN number + // a relaxed validation is required as only first 6 digits is supplied + // birthday format e.g. 991231 yyMMdd + + var y = int.Parse(data[..2]); + var m = int.Parse(data[2..4]); + var d = int.Parse(data[4..6]); + // this calculation is only valid within 21st century + var leap = y % 4 == 0; // 2000 was a leap year; + // day + if(d is < 1 or > 31) + return false; + // month + switch (m) { - return $"{vatToCheck[..9]}{c10}" == vatNumber; + // feb + case 2: + { + if (leap) + return d <= 29; + return d <= 28; + } + // apr, jun, sep, nov + case 4 or 6 or 9 or 11: + return d <= 30; + // jan, mar, may, july, aug, oct, dec + case 1 or 3 or 5 or 7 or 8 or 10 or 12: + return true; + // does not exist + default: + return false; } - return $"{vatToCheck[..9]}{c10}01" == vatNumber; } + /// + /// Modulus11 validator + /// + /// + /// private static bool ValidateMod11(string number) { if (long.Parse(number) == 0) @@ -107,15 +217,4 @@ public class VatUtils return sum % 11 == 0; } - - private static string SanitizeVatNumber(string vatNumber) - { - return vatNumber.ToUpperInvariant() - .Replace(" ", "") - .Replace("-", "") - .Replace("DK", "") - .Replace("NO", "") - .Replace("SE","") - .Replace("MVA", ""); - } } \ No newline at end of file diff --git a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs index d54f6692..59ea29f4 100644 --- a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs +++ b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs @@ -15,6 +15,7 @@ using System.Net; using System.Net.Http.Headers; +using System.Text.Json; using System.Threading.Tasks; using Blazored.LocalStorage; using Blazored.Toast.Services; @@ -31,9 +32,9 @@ namespace Wonky.Client.HttpInterceptors private readonly NavigationManager _navigation; private readonly IToastService _toast; private readonly RefreshTokenService _refreshTokenService; - private ILogger _logger; + private readonly ILogger _logger; private readonly ILocalStorageService _storage; - private IAuthenticationService _authenticationService; + private readonly IAuthenticationService _authenticationService; public HttpInterceptorService(HttpClientInterceptor interceptor, NavigationManager navigation, IToastService toast, @@ -56,18 +57,18 @@ namespace Wonky.Client.HttpInterceptors public void RegisterBeforeSendEvent() { - _interceptor.BeforeSendAsync += InterceptBeforeSendAsync; + _interceptor.BeforeSendAsync += InterceptBeforeSend; } + public void DisposeEvent() { _interceptor.AfterSend -= AfterSend; - _interceptor.BeforeSendAsync -= InterceptBeforeSendAsync; + _interceptor.BeforeSendAsync -= InterceptBeforeSend; } - private async Task InterceptBeforeSendAsync(object sender, HttpClientInterceptorEventArgs e) + private async Task InterceptBeforeSend(object sender, HttpClientInterceptorEventArgs e) { var absolutePath = e.Request.RequestUri.AbsolutePath; - if (!absolutePath.Contains("token")) { // call TryRefreshToken @@ -86,35 +87,37 @@ namespace Wonky.Client.HttpInterceptors if (e.Response == null || e.Response.IsSuccessStatusCode) return; - var message = "En ukendt fejl er opstået"; + var message = $"En fejl er opstået \n {JsonSerializer.Serialize(e)}"; var currDoc = _navigation.ToBaseRelativePath(_navigation.Uri); if (currDoc.Contains("login/")) currDoc = ""; switch (e.Response.StatusCode) { - case HttpStatusCode.NotFound: - // message = "Der var ingen data ..."; - // _toast.ShowInfo(message); + case HttpStatusCode.NotFound: + _logger.LogDebug("NotFound <= {}", currDoc); break; case HttpStatusCode.BadRequest: - // message = "Der er et problem med data ..."; - // _toast.ShowWarning(message); + _logger.LogDebug("BadRequest <= {}", currDoc); + _logger.LogDebug("{}", message); break; case HttpStatusCode.Unauthorized: + _logger.LogDebug("Unauthorized <= {}", currDoc); + _logger.LogDebug("{}", message); _authenticationService.Logout(); _navigation.NavigateTo($"/login/{currDoc}"); - message = "Venligst login ..."; - _toast.ShowInfo(message); + _toast.ShowInfo("Venligst Login. Tak."); break; case HttpStatusCode.Conflict: + _logger.LogDebug("Conflict <= {}", currDoc); + _logger.LogDebug("{}", message); break; case HttpStatusCode.InternalServerError: - // message = "Der er interne problemer på serveren ..."; - // _toast.ShowError(message); + _logger.LogDebug("InternalServerError <= {}", currDoc); + _logger.LogDebug("{}", message); break; default: - _toast.ShowError(message); + _logger.LogDebug("{}", message); break; } // throw new HttpResponseException(message); diff --git a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorActivityRepository.cs similarity index 95% rename from Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IAdvisorActivityRepository.cs index dbab34d8..1a6ff1bc 100644 --- a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IAdvisorActivityRepository.cs @@ -18,7 +18,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmActivityHttpRepository +/// +/// Interface Activity CRM Http repository +/// +public interface IAdvisorActivityRepository { ///
/// Get a list of open quotes @@ -33,13 +36,6 @@ public interface ICrmActivityHttpRepository /// Task UpdateQuoteStatus(ReportItemView activity); - /// - /// Get activities by date - /// - /// - /// - Task GetActivities(string activityDate); - /// /// Create new activity /// @@ -47,12 +43,26 @@ public interface ICrmActivityHttpRepository /// Task CreateActivity(ActivityDto model); + /// + /// Get activities by date + /// + /// + /// + Task GetActivities(string activityDate); + /// /// Get activity data by id /// /// /// Task GetActivity(string activityId); + + /// + /// Get activities for customer Id + /// + /// + /// + Task> GetCustomerActivities(string customerId); /// /// Get activity by id formatted for report @@ -61,20 +71,13 @@ public interface ICrmActivityHttpRepository /// Task GetReportItem(string activityId); - /// - /// Get activities for customer Id - /// - /// - /// - Task> GetCustomerActivities(string customerId); - /// /// Set backend process state to express /// /// /// ApiResponseView Task GetExpressState(string activityId); - + /// /// Update office note for activity /// diff --git a/Wonky.Client/HttpInterfaces/IAdvisorContactRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorContactRepository.cs new file mode 100644 index 00000000..178358f7 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IAdvisorContactRepository.cs @@ -0,0 +1,47 @@ +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for Contacts CRM Http repository +/// +/// +public interface IAdvisorContactRepository +{ + /// + /// Create Contact + /// + /// + /// + Task CreateContact(ContactDto model); + + /// + /// Get Contact + /// + /// + /// + /// + Task GetContact(string companyId, string contactId); + + /// + /// Get Contacts + /// + /// + /// + Task> GetContacts(string companyId); + + /// + /// Delete Contact + /// + /// + /// + /// + Task DeleteContact(string companyId, string contactId); + + /// + /// Update Contact + /// + /// + /// + Task UpdateContact(ContactDto model); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs new file mode 100644 index 00000000..8233c00d --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs @@ -0,0 +1,70 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface Customer History CRM Http repository +/// +public interface IAdvisorCustomerHistoryRepository +{ + /// + /// Fetch Invoice LIst + /// + /// + /// + Task FetchInvoiceList(string companyId); + + /// + /// Fetch given invoice for given customer + /// + /// + /// + /// + Task FetchInvoice(string companyId, string invoiceId); + + /// + /// Fetch inventory from given customer + /// + /// + /// + Task> FetchInventory(string companyId); + + /// + /// Fetch History for given customer + /// + /// + /// + Task> FetchHistory(string companyId); + + /// + /// Fetch history for given customer and a given product + /// + /// + /// + /// + Task> FetchHistory(string companyId, string sku); + + /// + /// RPC call to initiate remote server sync for given customer + /// + /// + /// + /// + Task InvoiceErpToCrmRpc(string companyId, string syncDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorCustomerRepository.cs similarity index 81% rename from Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IAdvisorCustomerRepository.cs index 4c90faab..7c16359a 100644 --- a/Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IAdvisorCustomerRepository.cs @@ -19,48 +19,57 @@ using Wonky.Entity.Requests; namespace Wonky.Client.HttpInterfaces; -public interface ICrmCompanyHttpRepository +/// +/// Interface Customer CRM Http repository +/// +public interface IAdvisorCustomerRepository { /// - /// Get a list of CRM entities + /// Get a list of CRM customers (SalesRep) /// /// /// A paged response defined by pagingParameters - Task> GetCompanies(CompanyPagingParams pagingParameters); + Task> GetCompanies(CustomerPaging pagingParameters); + /// - /// Get CRM entity by Id + /// Get CRM customer by Id (SalesRep) /// /// /// A CRM Company entity Task GetCompanyById(string companyId); + /// - /// Create new CRM entity + /// Create Customer (SalesRep) /// /// /// The Id of the entity Task CreateCompany(CompanyDto model); + /// - /// Delete the CRM entity + /// Delete the CRM customer (SalesRep) /// /// /// true/false to define success Task DeleteCompany(string companyId); + /// - /// Update CRM entity properties + /// Update CRM customer properties (SalesRep) /// /// /// /// A CRM Company entity Task UpdateCrmData(string companyId, CompanyDto model); + /// - /// Update ERP entity properties + /// Update ERP customer properties (SalesRep) /// /// /// /// A CRM Company entity Task UpdateErpData(string companyId, CompanyDto model); + /// - /// Update Entity Vat Number + /// Update customer Vat Number (SalesRep) /// /// /// diff --git a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorReportRepository.cs similarity index 53% rename from Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IAdvisorReportRepository.cs index d6211053..9827598a 100644 --- a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IAdvisorReportRepository.cs @@ -18,11 +18,43 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmReportHttpRepository +/// +/// Interface Report Http repository +/// +public interface IAdvisorReportRepository { + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// Task ReportExist(string workDate); + + /// + /// Get Reports for (SalesRep) + /// + /// Task> GetReports(); + + /// + /// Get Report for given date (SalesRep) + /// + /// + /// Task GetReport(string workDate); + + /// + /// Initialize Report for given data (SalesRep) + /// + /// + /// Task InitializeReportData(string workDate); - Task PostReport(string workDate, ReportDto reportDto); + + /// + /// Create Report for given data - using reportData + /// + /// + /// + /// + Task CreateReport(string workDate, ReportDto reportDto); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IAdvisorTaskItemRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorTaskItemRepository.cs new file mode 100644 index 00000000..29d17a31 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IAdvisorTaskItemRepository.cs @@ -0,0 +1,66 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for handling CRM Tasks http repository +/// +public interface IAdvisorTaskItemRepository +{ + /// + /// Get Task List (SalesRep) + /// + /// + Task> GetTaskList(); + + /// + /// Get Task List for given workDate (SalesRep) + /// + /// + /// + Task> GetTaskList(string workDate); + + /// + /// Get Task Item by id (SalesRep) + /// + /// + /// + Task GetTaskItem(string taskItemId); + + /// + /// Create task using taskItem (SalesRep) + /// + /// + /// + Task CreateTaskItem(TaskItemDto taskItem); + + /// + /// Delete Task Item (SalesRep + /// + /// + /// + Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem); + + /// + /// Delete Task Item (SalesRep + /// + /// + /// + Task DeleteTaskItem(string taskItemId); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorWorkplaceRepository.cs similarity index 51% rename from Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IAdvisorWorkplaceRepository.cs index 740c3a01..2bbf1c44 100644 --- a/Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IAdvisorWorkplaceRepository.cs @@ -18,11 +18,47 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmWorkplaceHttpRepository +/// +/// Interface for handling Customer Workplaces (chemical document service) +/// +public interface IAdvisorWorkplaceRepository { + /// + /// Get Workplaces for given customer id + /// + /// + /// Task> GetWorkplaces(string companyId); + + /// + /// Get specific workplace using customer id and workplace id + /// + /// + /// + /// Task GetWorkplace(string companyId, string workplaceId); + + /// + /// Create new workplace given the customer id and workplace data + /// + /// + /// + /// Task CreateWorkplace(string companyId, WorkplaceDto workplace); + + /// + /// Update workplace given the customer id and updated data + /// + /// + /// + /// Task UpdateWorkplace(string companyId, WorkplaceDto workplace); + + /// + /// Delete workplace given customer id and workplace id + /// + /// + /// + /// Task DeleteWorkplace(string companyId, string workplaceId); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs deleted file mode 100644 index 685b999f..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Wonky.Entity.DTO; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmContactHttpRepository -{ - Task CreateContact(ContactDto model); - Task GetContact(string companyId, string contactId); - Task> GetContacts(string companyId); - Task DeleteContact(string companyId, string contactId); - Task UpdateContact(ContactDto model); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs deleted file mode 100644 index fc83c7c7..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmHistoryHttpRepository -{ - Task FetchInvoiceList(string companyId); - Task FetchInvoice(string companyId, string invoiceId); - Task> FetchInventory(string companyId); - Task> FetchHistory(string companyId); - Task> FetchHistory(string companyId, string sku); - Task ErpInvoiceToCrmRpc(string companyId, string syncDate); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs deleted file mode 100644 index 3a15fb3c..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using Wonky.Entity.DTO; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmTaskItemHttpRepository -{ - Task?> GetTaskList(); - Task?> GetTaskList(string workDate); - Task GetTaskItem(string taskItemId); - Task CreateTaskItem(TaskItemDto taskItem); - Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem); - Task DeleteTaskItem(string taskItemId); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeCatalogRepository.cs similarity index 64% rename from Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IOfficeCatalogRepository.cs index 3b07d212..f905a02d 100644 --- a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IOfficeCatalogRepository.cs @@ -19,43 +19,47 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICatalogHttpRepository +/// +/// Interface Catalog Http repository +/// +public interface ICountryCatalogRepository { /// /// Get a paged sales item list /// - /// + /// + /// /// - Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters); + Task> GetSalesItemsPaged(string countryCode, CatalogPager pager); /// /// Get sales item by id /// + /// /// /// - Task GetSalesItemId(string salesItemId); + Task GetSalesItemId(string countryCode, string salesItemId); /// - /// Get sales item by sku - /// - /// - /// - Task GetSalesItemSku(string sku); - - /// - /// Overload Get sales item by id and country code + /// Overload Get sales item by sku and country code /// /// /// /// - Task GetSalesItemSku(string sku, string countryCode); + Task GetSalesItemSku(string countryCode, string sku); /// /// Get sales item by variant id /// + /// /// /// - Task GetSalesVariantId(string variantId); - - Task> GetPriceList(); + Task GetSalesVariantId(string countryCode, string variantId); + + /// + /// Complete catalog for print country + /// + /// + /// + Task> GetPriceList(string countryCode); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeCustomerHistoryRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeCustomerHistoryRepository.cs new file mode 100644 index 00000000..1fa695b4 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IOfficeCustomerHistoryRepository.cs @@ -0,0 +1,70 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface Customer History CRM Http repository +/// +public interface ICountryCustomerHistoryRepository +{ + /// + /// Fetch Invoice LIst + /// + /// + /// + Task FetchInvoiceList(string countryCode, string companyId); + + /// + /// Fetch given invoice for given customer + /// + /// + /// + /// + Task FetchInvoice(string countryCode, string companyId, string invoiceId); + + /// + /// Fetch inventory from given customer + /// + /// + /// + Task> FetchInventory(string countryCode, string companyId); + + /// + /// Fetch History for given customer + /// + /// + /// + Task> FetchHistory(string countryCode, string companyId); + + /// + /// Fetch history for given customer and a given product + /// + /// + /// + /// + Task> FetchHistory(string countryCode, string companyId, string sku); + + /// + /// RPC call to initiate remote server sync for given customer + /// + /// + /// + /// + Task InvoiceErpToCrmRpc(string countryCode, string companyId, string syncDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs deleted file mode 100644 index 746c2308..00000000 --- a/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Wonky.Client.Features; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.HttpInterfaces; - -public interface IOfficeCustomerHttpRepository -{ - Task> GetCompaniesPaged(CompanyPagingParams pagingParameters); - Task> GetCompaniesPagedSalesRep(string salesRepId, CompanyPagingParams pagingParameters); - Task GetByCustomerId(string companyId); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeCustomerRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeCustomerRepository.cs new file mode 100644 index 00000000..259e9fab --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IOfficeCustomerRepository.cs @@ -0,0 +1,60 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Wonky.Client.Features; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for Customer Office Http repository +/// +public interface ICountryCustomerRepository +{ + /// + /// Get customers paged for given country + /// + /// + /// + /// + Task> GetCompaniesPaged(string countryCode, CustomerPaging paging); + + /// + /// Get customers paged for given sales rep + /// + /// + /// + /// + /// + Task> GetCompaniesPaged(string countryCode, string salesRepId, CustomerPaging paging); + + /// + /// Get customer by Id + /// + /// + /// + /// + Task GetByCustomerId(string countryCode, string companyId); + + /// + /// Update Company data + /// + /// + /// + /// + /// + Task UpdateCompany(string countryCode, string companyId, CompanyDto model); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs deleted file mode 100644 index bcb6bf69..00000000 --- a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpInterfaces; - -public interface IOfficeReportHttpRepository -{ - Task> GetReports(string userId); - Task GetReport(string userId, string workDate); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeReportRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeReportRepository.cs new file mode 100644 index 00000000..914cd7de --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IOfficeReportRepository.cs @@ -0,0 +1,49 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for Report http repository +/// +/// Possibly duplicated in IReportHttpRepository +public interface ICountryReportRepository +{ + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// + /// + Task ReportExist(string salesRepId, string workDate); + + /// + /// Get Reports for given userId (Office) + /// + /// + /// + Task> GetCountryReports(string userId); + + /// + /// Get Report for given userId and workDate (Office) + /// + /// + /// + /// + Task GetCountryReport(string userId, string workDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs b/Wonky.Client/HttpInterfaces/IOrderProcessRepository.cs similarity index 52% rename from Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IOrderProcessRepository.cs index afa8842b..033184d2 100644 --- a/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IOrderProcessRepository.cs @@ -13,13 +13,42 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using Wonky.Entity.DTO; using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface IWarehouseHttpRepository +/// +/// Interface for processing orders in warehouse +/// +public interface IOrderProcessRepository { + /// + /// Get warehouse order list by date + /// + /// + /// + Task> GetWarehouseOrderListByDate(string date); + + /// + /// Get orders by status + /// + /// + /// + /// Task> GetWarehouseOrderListByStatus(string status, string express = ""); + + /// + /// Get order with orderId + /// + /// + /// Task GetWarehouseOrder(string orderId); - Task UpdateWarehouseOrderStatus(WarehouseProcess process); + + /// + /// Update Order status setting new process status + /// + /// + /// + Task UpdateWarehouseOrderStatus(OrderProcessState processState); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ISendMailService.cs b/Wonky.Client/HttpInterfaces/ISendMailService.cs deleted file mode 100644 index 14d5d163..00000000 --- a/Wonky.Client/HttpInterfaces/ISendMailService.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpInterfaces; - -public interface ISendMailService -{ - Task SendMail(string messageType, EmailMessage message); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ISystemSendMailService.cs b/Wonky.Client/HttpInterfaces/ISystemSendMailService.cs new file mode 100644 index 00000000..2dd82936 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ISystemSendMailService.cs @@ -0,0 +1,18 @@ +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for sending emai +/// +public interface ISystemSendMailService +{ + /// + /// Send Mail + /// + /// + /// + /// + Task SendMail(string messageType, EmailMessage message); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs b/Wonky.Client/HttpInterfaces/ISystemUserRepository.cs similarity index 51% rename from Wonky.Client/HttpInterfaces/IUserHttpRepository.cs rename to Wonky.Client/HttpInterfaces/ISystemUserRepository.cs index 08f17f94..f6e3ecf8 100644 --- a/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ISystemUserRepository.cs @@ -18,13 +18,59 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface IUserHttpRepository +/// +/// Interface for User handling over http +/// +public interface ISystemUserRepository { + /// + /// Get Advisors (Office) + /// + /// Task> GetAdvisors(); + + /// + /// Get Advisor Info for given userId + /// + /// + /// Task GetAdvisorInfo(string userId); + + /// + /// Update Advisor using userId and updated data + /// + /// + /// + /// Task UpdateAdvisor(string userId, UserUpdateDto model); + + /// + /// Get Administrative Users + /// + /// Task> GetAdminUsers(); + + /// + /// Get Admin Info for giver userId + /// + /// + /// Task GetAdminUserInfo(string userId); + + /// + /// Update Admin user using userId and updated data + /// + /// + /// + /// Task UpdateAdminUser(string userId, UserUpdateDto model); + + /// + /// Set new user password + /// + /// + /// + /// + /// Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs b/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs similarity index 86% rename from Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs rename to Wonky.Client/HttpRepository/AdvisorActivityRepository.cs index 2e1d877b..fd63cc42 100644 --- a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs @@ -25,7 +25,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmActivityHttpRepository : ICrmActivityHttpRepository +/// +/// Implementing Interface Activity CRM Http repository +/// +public class AdvisorActivityRepository : IAdvisorActivityRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { @@ -33,12 +36,12 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private readonly ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmActivityHttpRepository(HttpClient client, - ILogger logger, + public AdvisorActivityRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -48,12 +51,18 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository } /// - /// Get a list of quotes + /// Get a list of open quotes /// - /// List of activities with Quote status + /// List of Activities with ActivityStatus == Quote public async Task> GetQuotes() { - return await _client.GetFromJsonAsync>($"{_api.CrmActivities}/quotes", _options); + var result = await _client.GetAsync($"{_api.CrmActivities}/quotes"); + if (!result.IsSuccessStatusCode) + return new List(); + var content = await result.Content.ReadAsStringAsync(); + return string.IsNullOrWhiteSpace(content) + ? new List() + : JsonSerializer.Deserialize>(content, _options); } /// @@ -63,7 +72,7 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository /// public async Task UpdateQuoteStatus(ReportItemView activity) { - var response = await _client.PutAsJsonAsync( + var response = await _client.PutAsJsonAsync( $"{_api.CrmActivities}/quote/{activity.ActivityId}", activity, _options); var content = await response.Content.ReadAsStringAsync(); _logger.LogDebug("UpdateQuote Response Content <= {}", content); @@ -157,7 +166,7 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository { Code = 404, IsSuccess = false, - Message = "Uventet svare fra server", + Message = "Uventet svar fra server", Id = "" }; } diff --git a/Wonky.Client/HttpRepository/CrmContactHttpRepository.cs b/Wonky.Client/HttpRepository/AdvisorContactRepository.cs similarity index 71% rename from Wonky.Client/HttpRepository/CrmContactHttpRepository.cs rename to Wonky.Client/HttpRepository/AdvisorContactRepository.cs index 83e93730..59f962ed 100644 --- a/Wonky.Client/HttpRepository/CrmContactHttpRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorContactRepository.cs @@ -8,7 +8,7 @@ using Wonky.Entity.DTO; namespace Wonky.Client.HttpRepository; -public class CrmContactHttpRepository : ICrmContactHttpRepository +public class AdvisorContactRepository : IAdvisorContactRepository { private readonly JsonSerializerOptions _options = new () { @@ -16,12 +16,12 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _conf; - public CrmContactHttpRepository(HttpClient client, - ILogger logger, + public AdvisorContactRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions apiConfig) { @@ -32,9 +32,10 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository } /// - /// Create contact + /// Create Contact /// /// + /// public async Task CreateContact(ContactDto model) { var response = await _client.PostAsJsonAsync( @@ -42,13 +43,23 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository return await response.Content.ReadAsStringAsync(); } - + /// + /// Get Contact + /// + /// + /// + /// public async Task GetContact(string companyId, string contactId) { return await _client.GetFromJsonAsync( $"{_conf.CrmCustomers}/{companyId}/contacts/{contactId}"); } + /// + /// Get Contacts + /// + /// + /// public async Task> GetContacts(string companyId) { var response = await _client.GetAsync( @@ -58,13 +69,23 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository ? new List() : JsonSerializer.Deserialize>(content, _options); } - + /// + /// Delete Contact + /// + /// + /// + /// public async Task DeleteContact(string companyId, string contactId) { await _client.DeleteAsync( $"{_conf.CrmCustomers}/{companyId}/contacts/{contactId}"); } + /// + /// Update Contact + /// + /// + /// public async Task UpdateContact(ContactDto model) { await _client.PutAsJsonAsync( diff --git a/Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs similarity index 83% rename from Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs rename to Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs index 2d33cbde..fc292b80 100644 --- a/Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs @@ -25,7 +25,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository +public class AdvisorCustomerHistoryRepository : IAdvisorCustomerHistoryRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -33,12 +33,12 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmHistoryHttpRepository( - HttpClient client, ILogger logger, + public AdvisorCustomerHistoryRepository( + HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -48,7 +48,7 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// fetch a list of invoices for CompanyId + /// Fetch Invoice LIst /// /// /// @@ -62,7 +62,7 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch invoice from archiveHeadId + /// Fetch given invoice for given customer /// /// /// @@ -74,10 +74,10 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// fetch inventory - summarized list of products + /// Fetch inventory from given customer /// /// - /// List of products + /// public async Task> FetchInventory(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmInventoryExt}"); @@ -90,10 +90,10 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch history for all products + /// Fetch History for given customer /// /// - /// List of products + /// public async Task> FetchHistory(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}"); @@ -106,11 +106,11 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch history for single product + /// Fetch history for given customer and a given product /// /// /// - /// list of products + /// public async Task> FetchHistory(string companyId, string sku) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}/{sku}"); @@ -123,14 +123,14 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// execute a remote procedure designed to update crm database from erp system based on a date string + /// RPC call to initiate remote server sync for given customer /// /// /// - /// date string - public async Task ErpInvoiceToCrmRpc(string companyId, string syncDate) + /// + public async Task InvoiceErpToCrmRpc(string companyId, string syncDate) { - var x = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmRpcSyncExt}/{syncDate}"); + var x = await _client.GetAsync($"{_api.SyncRpc}/companies/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}"); if (!x.IsSuccessStatusCode) return string.Empty; var content = await x.Content.ReadAsStringAsync(); diff --git a/Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs b/Wonky.Client/HttpRepository/AdvisorCustomerRepository.cs similarity index 83% rename from Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs rename to Wonky.Client/HttpRepository/AdvisorCustomerRepository.cs index 73054895..1c74a002 100644 --- a/Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorCustomerRepository.cs @@ -34,7 +34,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository +public class AdvisorCustomerRepository : IAdvisorCustomerRepository { private readonly JsonSerializerOptions _options = new () { @@ -42,12 +42,12 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _conf; - public CrmCompanyHttpRepository(HttpClient client, - ILogger logger, + public AdvisorCustomerRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions apiConfig) { @@ -58,11 +58,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Get from crm endpoint + /// Get a list of CRM customers (SalesRep) /// /// - /// Paged response - public async Task> GetCompanies(CompanyPagingParams pagingParameters) + /// A paged response defined by pagingParameters + public async Task> GetCompanies(CustomerPaging pagingParameters) { var queryString = new Dictionary { @@ -93,17 +93,21 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository }; return pagingResponse; } - + /// + /// Get CRM customer by Id (SalesRep) + /// + /// + /// A CRM Company entity public async Task GetCompanyById(string companyId) { return await _client.GetFromJsonAsync($"{_conf.CrmCustomers}/{companyId}", _options); } /// - /// Create company from model + /// Create Customer (SalesRep) /// /// - /// company id + /// The Id of the entity public async Task CreateCompany(CompanyDto model) { var response = await _client.PostAsJsonAsync($"{_conf.CrmCustomers}", model, _options); @@ -113,10 +117,10 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Delete company + /// Delete the CRM customer (SalesRep) /// /// - /// + /// true/false to define success public async Task DeleteCompany(string companyId) { var response = await _client.DeleteAsync($"{_conf.CrmCustomers}/{companyId}"); @@ -124,11 +128,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update Company CRM properties + /// Update CRM customer properties (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateCrmData(string companyId, CompanyDto model) { var updateModel = new UpdateCrmDto @@ -146,11 +150,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update Company ERP properties + /// Update ERP customer properties (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateErpData(string companyId, CompanyDto model) { var updateModel = new UpdateErpDto @@ -172,11 +176,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update company VAT number + /// Update customer Vat Number (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateCompanyVat(string companyId, string vatNumber) { var model = new Dictionary @@ -185,6 +189,8 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository }; var response = await _client.PutAsJsonAsync($"{_conf.CrmCustomers}/{companyId}/vat", model, _options); var content = await response.Content.ReadAsStringAsync(); - return JsonSerializer.Deserialize(content); + return response.IsSuccessStatusCode + ? JsonSerializer.Deserialize(content) + : new CompanyDto{Name = "ERROR", VatNumber = vatNumber, CrmNotes = $"FEJL: {content}"}; } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/AdvisorReportRepository.cs b/Wonky.Client/HttpRepository/AdvisorReportRepository.cs new file mode 100644 index 00000000..03454ca0 --- /dev/null +++ b/Wonky.Client/HttpRepository/AdvisorReportRepository.cs @@ -0,0 +1,135 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Client.HttpInterfaces; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public class AdvisorReportRepository : IAdvisorReportRepository +{ + private readonly JsonSerializerOptions _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _api; + + public AdvisorReportRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _api = configuration.Value; + } + + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// + public async Task ReportExist(string workDate) + { + var result = await _client.GetFromJsonAsync( + $"{_api.CrmReports}/exist/{workDate}"); + return result.ReportClosed; + } + + /// + /// Get Reports for (SalesRep) + /// + /// + public async Task> GetReports() + { + var result = await _client.GetAsync($"{_api.CrmReports}"); + if (!result.IsSuccessStatusCode) + return new List(); + return await result.Content.ReadFromJsonAsync>(); + } + + /// + /// Get Report for given date (SalesRep) + /// + /// + /// + public async Task GetReport(string workDate) + { + var result = await _client.GetFromJsonAsync($"{_api.CrmReports}/{workDate}"); + return result ?? new ReportView(); + } + + /// + /// Initialize Report for given data (SalesRep) + /// + /// + /// + public async Task InitializeReportData(string workDate) + { + var initData = await _client + .GetFromJsonAsync($"{_api.CrmReports}/init/{workDate}"); + return initData ?? new ReportInitDto(); + } + + /// + /// Create Report for given data - using reportData + /// + /// + /// + /// + public async Task CreateReport(string workDate, ReportDto reportDto) + { + var response = await _client + .PostAsJsonAsync($"{_api.CrmReports}/{workDate}", reportDto, _options); + if (!response.IsSuccessStatusCode) + return new ApiResponseView + { + Code = (int) response.StatusCode, + Id = "", + Message = "Der er opstået en fejl.", + IsSuccess = false + }; + + var jsonDate = await response.Content.ReadAsStringAsync(); + if(string.IsNullOrWhiteSpace(jsonDate)) + return new ApiResponseView + { + Code = (int) response.StatusCode, + Id = "", + Message = "Response er tom", + IsSuccess = response.IsSuccessStatusCode + }; + + var result = JsonSerializer.Deserialize(jsonDate); + return new ApiResponseView + { + Code = result.Code, + Id = result.Id, + Message = result.Message, + IsSuccess = result.IsSuccess + }; + } +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs b/Wonky.Client/HttpRepository/AdvisorTaskItemRepository.cs similarity index 71% rename from Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs rename to Wonky.Client/HttpRepository/AdvisorTaskItemRepository.cs index c2c01e8b..09a5005b 100644 --- a/Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorTaskItemRepository.cs @@ -26,21 +26,21 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmTaskItemHttpRepository : ICrmTaskItemHttpRepository +public class AdvisorTaskItemRepository : IAdvisorTaskItemRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public CrmTaskItemHttpRepository(HttpClient client, - ILogger logger, + public AdvisorTaskItemRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -49,32 +49,60 @@ public class CrmTaskItemHttpRepository : ICrmTaskItemHttpRepository _apiConfig = configuration.Value; } - + /// + /// Get Task List (SalesRep) + /// + /// public async Task?> GetTaskList() { return await _client.GetFromJsonAsync>($"{_apiConfig.CrmTasks}", _options); } + /// + /// Get Task List for given workDate (SalesRep) + /// + /// + /// public async Task?> GetTaskList(string workDate) { return await _client.GetFromJsonAsync>($"{_apiConfig.CrmTasks}/date/{workDate}", _options); } + /// + /// Get Task Item by id (SalesRep) + /// + /// + /// public async Task GetTaskItem(string taskItemId) { return await _client.GetFromJsonAsync($"{_apiConfig.CrmTasks}/{taskItemId}", _options); } - + + /// + /// Create task using taskItem (SalesRep) + /// + /// + /// public async Task CreateTaskItem(TaskItemDto taskItem) { await _client.PostAsJsonAsync($"{_apiConfig.CrmTasks}", taskItem, _options); } - + + /// + /// Delete Task Item (SalesRep + /// + /// + /// public async Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem) { await _client.PutAsJsonAsync($"{_apiConfig.CrmTasks}/{taskItemId}", taskItem, _options); } - + + /// + /// Delete Task Item (SalesRep + /// + /// + /// public async Task DeleteTaskItem(string taskItemId) { await _client.DeleteAsync($"{_apiConfig.CrmTasks}/{taskItemId}"); diff --git a/Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs b/Wonky.Client/HttpRepository/AdvisorWorkplaceRepository.cs similarity index 68% rename from Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs rename to Wonky.Client/HttpRepository/AdvisorWorkplaceRepository.cs index ea91b497..ec67ba9a 100644 --- a/Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorWorkplaceRepository.cs @@ -24,21 +24,21 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository +public class AdvisorWorkplaceRepository : IAdvisorWorkplaceRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmWorkplaceHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, + public AdvisorWorkplaceRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) { _client = client; @@ -46,7 +46,12 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository _navigation = navigation; _api = configuration.Value; } - + + /// + /// Get Workplaces for given customer id + /// + /// + /// public async Task> GetWorkplaces(string companyId) { var result = await _client.GetFromJsonAsync>( @@ -54,6 +59,12 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository return result ?? new List(); } + /// + /// Get specific workplace using customer id and workplace id + /// + /// + /// + /// public async Task GetWorkplace(string companyId, string workplaceId) { var result = await _client.GetFromJsonAsync( @@ -61,18 +72,36 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository return result ?? new WorkplaceDto(); } + /// + /// Create new workplace given the customer id and workplace data + /// + /// + /// + /// public async Task CreateWorkplace(string companyId, WorkplaceDto workplace) { await _client.PostAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", workplace, _options); } + /// + /// Update workplace given the customer id and updated data + /// + /// + /// + /// public async Task UpdateWorkplace(string companyId, WorkplaceDto workplace) { await _client.PutAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplace.WorkplaceId}", workplace, _options); } + /// + /// Delete workplace given customer id and workplace id + /// + /// + /// + /// public async Task DeleteWorkplace(string companyId, string workplaceId) { await _client.DeleteAsync( diff --git a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs b/Wonky.Client/HttpRepository/CountryCatalogRepository.cs similarity index 65% rename from Wonky.Client/HttpRepository/CatalogHttpRepository.cs rename to Wonky.Client/HttpRepository/CountryCatalogRepository.cs index 3ad86041..f8f18e64 100644 --- a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CountryCatalogRepository.cs @@ -31,7 +31,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CatalogHttpRepository : ICatalogHttpRepository +public class CountryCatalogRepository : ICountryCatalogRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -39,38 +39,39 @@ public class CatalogHttpRepository : ICatalogHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; - private readonly ApiConfig _apiConfig; + private readonly ApiConfig _api; - public CatalogHttpRepository(HttpClient client, - ILogger logger, + public CountryCatalogRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; _logger = logger; _navigation = navigation; - _apiConfig = configuration.Value; + _api = configuration.Value; } /// /// Get a paged sales item list /// - /// + /// + /// /// - public async Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters) + public async Task> GetSalesItemsPaged(string countryCode, CatalogPager pager) { var queryString = new Dictionary { - ["pageNumber"] = pagingParameters.PageNumber.ToString(), - ["pageSize"] = pagingParameters.PageSize.ToString(), - ["orderBy"] = pagingParameters.OrderBy, - ["searchColumn"] = pagingParameters.SearchColumn, - ["searchTerm"] = pagingParameters.SearchTerm, - ["selectGroup"] = pagingParameters.SelectGroup == "0" ? "" : pagingParameters.SelectGroup, + ["pageNumber"] = pager.PageNumber.ToString(), + ["pageSize"] = pager.PageSize.ToString(), + ["orderBy"] = pager.OrderBy, + ["searchColumn"] = pager.SearchColumn, + ["searchTerm"] = pager.SearchTerm, + ["selectGroup"] = pager.SelectGroup == "0" ? "" : pager.SelectGroup }; var response = await _client - .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.Catalog}/page", queryString)); + .GetAsync(QueryHelpers.AddQueryString($"{_api.Catalog}/{countryCode}/page", queryString)); if (!response.IsSuccessStatusCode) { @@ -91,55 +92,52 @@ public class CatalogHttpRepository : ICatalogHttpRepository return pagingResponse; } + /// /// Get sales item by id /// + /// /// /// - public async Task GetSalesItemId(string salesItemId) + public async Task GetSalesItemId(string countryCode, string salesItemId) { var salesItem = await _client - .GetFromJsonAsync($"{_apiConfig.Catalog}/{salesItemId}"); + .GetFromJsonAsync($"{_api.Catalog}/{countryCode}/{salesItemId}"); return salesItem ?? new SalesItemView(); } /// - /// Get sales item by sku - /// - /// - /// - public async Task GetSalesItemSku(string sku) - { - var salesItem = await _client.GetFromJsonAsync($"{_apiConfig.Catalog}/sku/{sku}"); - return salesItem ?? new SalesItemView(); - } - - /// - /// Overload Get sales item by id and country code + /// Overload Get sales item by sku and country code /// /// /// /// - public async Task GetSalesItemSku(string sku, string countryCode) + public async Task GetSalesItemSku(string countryCode, string sku) { - var salesItem = await _client.GetFromJsonAsync($"{_apiConfig.Catalog}/{countryCode}/sku/{sku}"); + var salesItem = await _client.GetFromJsonAsync($"{_api.Catalog}/{countryCode}/sku/{sku}"); return salesItem ?? new SalesItemView(); } /// /// Get sales item by variant id /// + /// /// /// - public async Task GetSalesVariantId(string variantId) + public async Task GetSalesVariantId(string countryCode, string variantId) { var salesItem = await _client - .GetFromJsonAsync($"{_apiConfig.Catalog}/variant/{variantId}"); + .GetFromJsonAsync($"{_api.Catalog}/{countryCode}/variant/{variantId}"); return salesItem ?? new SalesItemView(); } - - public async Task> GetPriceList() + + /// + /// Complete catalog for print country + /// + /// + /// + public async Task> GetPriceList(string countryCode) { - return await _client.GetFromJsonAsync>($"{_apiConfig.Catalog}", _options); + return await _client.GetFromJsonAsync>($"{_api.Catalog}/{countryCode}", _options); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs b/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs deleted file mode 100644 index 71074793..00000000 --- a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using System.Net.Http.Json; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.Options; -using Wonky.Client.HttpInterfaces; -using Wonky.Entity.Configuration; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpRepository; - -public class CrmReportHttpRepository :ICrmReportHttpRepository -{ - private readonly JsonSerializerOptions _options = new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true - }; - - private readonly NavigationManager _navigation; - private ILogger _logger; - private readonly HttpClient _client; - private readonly ApiConfig _apiConfig; - - public CrmReportHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, IOptions configuration) - { - _client = client; - _logger = logger; - _navigation = navigation; - _apiConfig = configuration.Value; - } - - public async Task> GetReports() - { - return await _client.GetFromJsonAsync>($"{_apiConfig.CrmReports}"); - } - public async Task ReportExist(string workDate) - { - var result = await _client.GetFromJsonAsync( - $"{_apiConfig.CrmReports}/exist/{workDate}"); - return result.ReportClosed; - } - - public async Task GetReport(string workDate) - { - return await _client.GetFromJsonAsync($"{_apiConfig.CrmReports}/{workDate}"); - - } - public async Task InitializeReportData(string workDate) - { - var initData = await _client - .GetFromJsonAsync($"{_apiConfig.CrmReports}/init/{workDate}"); - return initData ?? new ReportInitDto(); - } - - public async Task PostReport(string workDate, ReportDto reportDto) - { - var response = await _client - .PostAsJsonAsync($"{_apiConfig.CrmReports}/{workDate}", reportDto, _options); - - var jsonDate = await response.Content.ReadAsStringAsync(); - var result = JsonSerializer.Deserialize(jsonDate); - return new ApiResponseView - { - Code = result.Code, - Id = result.Id, - Message = result.Message, - IsSuccess = result.IsSuccess - }; - } -} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/OfficeCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/OfficeCustomerHistoryRepository.cs new file mode 100644 index 00000000..5b3a9e54 --- /dev/null +++ b/Wonky.Client/HttpRepository/OfficeCustomerHistoryRepository.cs @@ -0,0 +1,145 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Pages; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepository +{ + private readonly JsonSerializerOptions _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _api; + + public CountryCustomerHistoryRepository( + HttpClient client, ILogger logger, + NavigationManager navigation, IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _api = configuration.Value; + } + + /// + /// Fetch Invoice LIst + /// + /// + /// + /// + public async Task FetchInvoiceList(string countryCode, string companyId) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices"); + + if (!response.IsSuccessStatusCode) return new InvoiceListView(); + + var content = await response.Content.ReadAsStringAsync(); + return response.IsSuccessStatusCode + ? JsonSerializer.Deserialize(content, _options) + : new InvoiceListView(); + } + + /// + /// Fetch given invoice for given customer + /// + /// + /// + /// + /// + public async Task FetchInvoice(string countryCode, string companyId, string invoiceId) + { + return await _client + .GetFromJsonAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices/{invoiceId}", _options); + } + + /// + /// Fetch inventory from given customer + /// + /// + /// + public async Task> FetchInventory(string countryCode, string companyId) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmInventoryExt}"); + if (!response.IsSuccessStatusCode) + return new List(); + var content = await response.Content.ReadAsStringAsync(); + return string.IsNullOrWhiteSpace(content) + ? new List() + : JsonSerializer.Deserialize>(content, _options); + } + + /// + /// Fetch History for given customer + /// + /// + /// + public async Task> FetchHistory(string countryCode, string companyId) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmProductExt}"); + + if (!response.IsSuccessStatusCode) return new List(); + + var content = await response.Content.ReadAsStringAsync(); + return string.IsNullOrWhiteSpace(content) + ? new List() + : JsonSerializer.Deserialize>(content, _options); + } + + /// + /// Fetch history for given customer and a given product + /// + /// + /// + /// + public async Task> FetchHistory(string countryCode, string companyId, string sku) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmProductExt}/{sku}"); + if (!response.IsSuccessStatusCode) + return new List(); + var content = await response.Content.ReadAsStringAsync(); + return string.IsNullOrWhiteSpace(content) + ? new List() + : JsonSerializer.Deserialize>(content, _options); + } + + /// + /// RPC call to initiate remote server sync for given customer + /// + /// + /// + /// + public async Task InvoiceErpToCrmRpc(string countryCode, string companyId, string syncDate) + { + var x = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}"); + if (!x.IsSuccessStatusCode) + return string.Empty; + var content = await x.Content.ReadAsStringAsync(); + return content.Replace("\"", ""); + } +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs b/Wonky.Client/HttpRepository/OfficeCustomerRepository.cs similarity index 56% rename from Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs rename to Wonky.Client/HttpRepository/OfficeCustomerRepository.cs index 61beb540..8cc6b9b8 100644 --- a/Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs +++ b/Wonky.Client/HttpRepository/OfficeCustomerRepository.cs @@ -34,50 +34,81 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository +public class CountryCustomerRepository : ICountryCustomerRepository { private readonly JsonSerializerOptions _options = new () { PropertyNameCaseInsensitive = true }; - private readonly NavigationManager _navigation; - private ILogger _logger; + private readonly NavigationManager _navigator; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public OfficeCustomerHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, + public CountryCustomerRepository(HttpClient client, + ILogger logger, + NavigationManager navigator, IOptions apiConfig) { _client = client; _logger = logger; - _navigation = navigation; + _navigator = navigator; _api = apiConfig.Value; } - + /// - /// Get paged list of customer entities by sales rep id + /// Get customers paged for given sales rep /// - /// - /// + /// + /// /// - public async Task> GetCompaniesPagedSalesRep(string salesRepId, CompanyPagingParams pagingParameters) + public async Task> GetCompaniesPaged(string countryCode, CustomerPaging paging) { var queryString = new Dictionary { - ["pageNumber"] = pagingParameters.PageNumber.ToString(), - ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = pagingParameters.SearchTerm, - ["searchColumn"] = pagingParameters.SearchColumn, - ["orderBy"] = pagingParameters.OrderBy, - ["isHidden"] = pagingParameters.IsHidden.ToString(), - ["hasFolded"] = pagingParameters.HasFolded.ToString(), - ["countryCode"] = pagingParameters.CountryCode + ["pageNumber"] = paging.PageNumber.ToString(), + ["pageSize"] = paging.PageSize.ToString(), + ["searchTerm"] = paging.SearchTerm, + ["searchColumn"] = paging.SearchColumn, + ["orderBy"] = paging.OrderBy, + ["isHidden"] = paging.IsHidden.ToString(), + ["hasFolded"] = paging.HasFolded.ToString(), }; - var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}/", queryString)); + var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/{countryCode}", queryString)); + 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) + }; + return pagingResponse; + } + + /// + /// Get customers paged for given sales rep + /// + /// + /// + /// + /// + public async Task> GetCompaniesPaged(string countryCode, string salesRepId, + CustomerPaging paging) + { + var queryString = new Dictionary + { + ["pageNumber"] = paging.PageNumber.ToString(), + ["pageSize"] = paging.PageSize.ToString(), + ["searchTerm"] = paging.SearchTerm, + ["searchColumn"] = paging.SearchColumn, + ["orderBy"] = paging.OrderBy, + ["isHidden"] = paging.IsHidden.ToString(), + ["hasFolded"] = paging.HasFolded.ToString(), + }; + + var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/{countryCode}/salesRep/{salesRepId}/", queryString)); var content = await response.Content.ReadAsStringAsync(); var pagingResponse = new PagingResponse { @@ -87,83 +118,31 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository return pagingResponse; } - - /// - /// Get paged list of customer companies by country code - /// - /// - /// - public async Task> GetCompaniesPaged(CompanyPagingParams pagingParameters) - { - var queryString = new Dictionary - { - ["pageNumber"] = pagingParameters.PageNumber.ToString(), - ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = pagingParameters.SearchTerm, - ["searchColumn"] = pagingParameters.SearchColumn, - ["orderBy"] = pagingParameters.OrderBy, - ["isHidden"] = pagingParameters.IsHidden.ToString(), - ["hasFolded"] = pagingParameters.HasFolded.ToString(), - ["countryCode"] = pagingParameters.CountryCode - }; - - var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}", queryString)); - 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) - }; - return pagingResponse; - } - + /// /// Get customer entity by id /// + /// /// /// - public async Task GetByCustomerId(string companyId) + public async Task GetByCustomerId(string countryCode, string companyId) { - var company = await _client.GetFromJsonAsync($"{_api.OfficeCustomers}/id/{companyId}"); + var company = await _client.GetFromJsonAsync($"{_api.OfficeCustomers}/{countryCode}/id/{companyId}"); return company ?? new CompanyDto(); } /// - /// Create company from model - /// - /// - /// company id - public async Task CreateCompany(CompanyDto model) - { - var response = await _client.PostAsJsonAsync($"{_api.OfficeCustomers}", model); - var content = await response.Content.ReadAsStringAsync(); - var result = JsonSerializer.Deserialize(content, _options); - return result.CompanyId; - } - - /// - /// Update company card + /// Update Company data /// + /// /// /// /// - public async Task UpdateCompany(string companyId, CompanyDto model) + public async Task UpdateCompany(string countryCode, string companyId, CompanyDto model) { - var response = await _client.PutAsJsonAsync($"{_api.OfficeCustomers}/{companyId}", model); + var response = await _client.PutAsJsonAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}", model); var content = await response.Content.ReadAsStringAsync(); Console.WriteLine(content); return response.IsSuccessStatusCode; } - - /// - /// Delete company - /// - /// - /// - public async Task DeleteCompany(string companyId) - { - var response = await _client.DeleteAsync($"{_api.OfficeCustomers}/{companyId}"); - return response.IsSuccessStatusCode; - } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs b/Wonky.Client/HttpRepository/OfficeReportRepository.cs similarity index 60% rename from Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs rename to Wonky.Client/HttpRepository/OfficeReportRepository.cs index 42319199..79e2192f 100644 --- a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs +++ b/Wonky.Client/HttpRepository/OfficeReportRepository.cs @@ -13,6 +13,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // + using System.Net.Http.Json; using System.Text.Json; using Microsoft.AspNetCore.Components; @@ -24,7 +25,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class OfficeReportHttpRepository : IOfficeReportHttpRepository +public class CountryReportRepository : ICountryReportRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -32,12 +33,12 @@ public class OfficeReportHttpRepository : IOfficeReportHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public OfficeReportHttpRepository(HttpClient client, - ILogger logger, + public CountryReportRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -45,15 +46,36 @@ public class OfficeReportHttpRepository : IOfficeReportHttpRepository _navigation = navigation; _apiConfig = configuration.Value; } - - public async Task> GetReports(string userId) + + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// + public async Task ReportExist(string salesRepId, string workDate) + { + var result = await _client.GetFromJsonAsync( + $"{_apiConfig.OfficeReports}/{salesRepId}/{workDate}/exist"); + return result.ReportClosed; + } + /// + /// Get Reports for given userId (Office) + /// + /// + /// + public async Task> GetCountryReports(string userId) { return await _client.GetFromJsonAsync>($"{_apiConfig.OfficeReports}/{userId}"); } - - public async Task GetReport(string userId, string workDate) + + /// + /// Get Report for given userId and workDate (Office) + /// + /// + /// + /// + public async Task GetCountryReport(string userId, string workDate) { return await _client.GetFromJsonAsync($"{_apiConfig.OfficeReports}/{userId}/{workDate}"); - - } + } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs b/Wonky.Client/HttpRepository/OrderProcessRepository.cs similarity index 66% rename from Wonky.Client/HttpRepository/WarehouseHttpRepository.cs rename to Wonky.Client/HttpRepository/OrderProcessRepository.cs index ec429f4e..edf9f3a0 100644 --- a/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs +++ b/Wonky.Client/HttpRepository/OrderProcessRepository.cs @@ -19,25 +19,26 @@ using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Options; using Wonky.Client.HttpInterfaces; using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class WarehouseHttpRepository : IWarehouseHttpRepository +public class OrderProcessRepository : IOrderProcessRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public WarehouseHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, + public OrderProcessRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) { _client = client; @@ -46,23 +47,46 @@ public class WarehouseHttpRepository : IWarehouseHttpRepository _api = configuration.Value; } + /// + /// Get warehouse order list by date + /// + /// + /// public async Task> GetWarehouseOrderListByDate(string date) { return await _client.GetFromJsonAsync>($"{_api.Warehouse}?date={date}", _options); } - + + /// + /// Get orders by status + /// + /// + /// + /// public async Task> GetWarehouseOrderListByStatus(string status, string express = "") { - return await _client.GetFromJsonAsync>($"{_api.Warehouse}?status={status}&express={express}", _options); + return await _client.GetFromJsonAsync>( + $"{_api.Warehouse}?status={status}&express={express}", _options); } + /// + /// Get order with orderId + /// + /// + /// public async Task GetWarehouseOrder(string orderId) { return await _client.GetFromJsonAsync($"{_api.Warehouse}/{orderId}", _options); } - public async Task UpdateWarehouseOrderStatus(WarehouseProcess process) + + /// + /// Update Order status setting new process status + /// + /// + /// + public async Task UpdateWarehouseOrderStatus(OrderProcessState processState) { - _logger.LogDebug("process => {}", JsonSerializer.Serialize(process, _options)); - await _client.PutAsJsonAsync($"{_api.Warehouse}/{process.OrderId}", process, _options); + _logger.LogDebug("process => {}", JsonSerializer.Serialize(processState, _options)); + await _client.PutAsJsonAsync($"{_api.Warehouse}/{processState.OrderId}", processState, _options); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/SendMailService.cs b/Wonky.Client/HttpRepository/SystemSendMailService.cs similarity index 77% rename from Wonky.Client/HttpRepository/SendMailService.cs rename to Wonky.Client/HttpRepository/SystemSendMailService.cs index 3281b434..bdbb0aa5 100644 --- a/Wonky.Client/HttpRepository/SendMailService.cs +++ b/Wonky.Client/HttpRepository/SystemSendMailService.cs @@ -10,19 +10,19 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class SendMailService : ISendMailService +public class SystemSendMailService : ISystemSendMailService { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public SendMailService(HttpClient client, ILogger logger, + public SystemSendMailService(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -30,14 +30,20 @@ public class SendMailService : ISendMailService _navigation = navigation; _api = configuration.Value; } - + + /// + /// Send Mail + /// + /// + /// + /// public async Task SendMail(string messageType, EmailMessage message) { var response = await _client.PostAsJsonAsync($"{_api.ServicesMail}/{messageType}", message, _options); if (!response.IsSuccessStatusCode) return new ApiResponseView { - Code = (int) response.StatusCode, + Code = (int)response.StatusCode, Message = $"{response.ReasonPhrase}: {await response.Content.ReadAsStringAsync()}", IsSuccess = false, Id = "" diff --git a/Wonky.Client/HttpRepository/UserHttpRepository.cs b/Wonky.Client/HttpRepository/SystemUserRepository.cs similarity index 65% rename from Wonky.Client/HttpRepository/UserHttpRepository.cs rename to Wonky.Client/HttpRepository/SystemUserRepository.cs index ab00e9dc..d2eadf3c 100644 --- a/Wonky.Client/HttpRepository/UserHttpRepository.cs +++ b/Wonky.Client/HttpRepository/SystemUserRepository.cs @@ -25,19 +25,19 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class UserHttpRepository : IUserHttpRepository +public class SystemUserRepository : ISystemUserRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public UserHttpRepository(HttpClient client, ILogger logger, + public SystemUserRepository(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -45,40 +45,78 @@ public class UserHttpRepository : IUserHttpRepository _navigation = navigation; _api = configuration.Value; } - + + /// + /// Get Advisors (Office) + /// + /// public async Task> GetAdvisors() { return await _client.GetFromJsonAsync>(_api.OfficeAdvisors); } - + + /// + /// Get Advisor Info for given userId + /// + /// + /// public async Task GetAdvisorInfo(string userId) { return await _client.GetFromJsonAsync($"{_api.OfficeAdvisors}/{userId}"); } + /// + /// Update Advisor using userId and updated data + /// + /// + /// + /// public async Task UpdateAdvisor(string userId, UserUpdateDto model) { await _client.PutAsJsonAsync($"{_api.OfficeAdvisors}/{userId}", model, _options); } + /// + /// Get Administrative Users + /// + /// public async Task> GetAdminUsers() { return await _client.GetFromJsonAsync>(_api.OfficeUsers); } + /// + /// Get Admin Info for giver userId + /// + /// + /// public async Task GetAdminUserInfo(string userId) { return await _client.GetFromJsonAsync($"{_api.OfficeUsers}/{userId}"); } - + + /// + /// Update Admin user using userId and updated data + /// + /// + /// + /// public async Task UpdateAdminUser(string userId, UserUpdateDto model) { await _client.PutAsJsonAsync($"{_api.OfficeUsers}/{userId}", model, _options); } + /// + /// Set new user password + /// + /// + /// + /// + /// public async Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd) { - var passwd = new Dictionary {{"newPassword", newPasswd}, {"confirmPassword", confirmPasswd}}; + var passwd = new Dictionary + { { "newPassword", newPasswd }, { "confirmPassword", confirmPasswd } }; await _client.PostAsJsonAsync($"{_api.OfficeUserPasswd}/{userId}", passwd, _options); } } \ No newline at end of file diff --git a/Wonky.Client/Models/Draft.cs b/Wonky.Client/Models/Draft.cs index d09b3dfa..42d14ea4 100644 --- a/Wonky.Client/Models/Draft.cs +++ b/Wonky.Client/Models/Draft.cs @@ -17,7 +17,9 @@ using Wonky.Entity.DTO; using Wonky.Entity.Views; namespace Wonky.Client.Models; - +/// +/// Draft Item model class +/// public class DraftItem { public int Quantity { get; set; } @@ -27,7 +29,9 @@ public class DraftItem public bool Sas { get; set; } public decimal LineTotal => (Price - Price * Discount / 100) * Quantity; } - +/// +/// Draft model class +/// public class Draft { public string DraftId { get; set; } = ""; diff --git a/Wonky.Client/Models/PStatus.cs b/Wonky.Client/Models/PStatus.cs new file mode 100644 index 00000000..efc39909 --- /dev/null +++ b/Wonky.Client/Models/PStatus.cs @@ -0,0 +1,12 @@ +namespace Wonky.Client.Models; + +public enum PStatus +{ + None, + Picked, + Packed, + Shipped, + All, + Express, + Accepted +} \ No newline at end of file diff --git a/Wonky.Client/Models/QCallbackArgs.cs b/Wonky.Client/Models/QCallbackArgs.cs new file mode 100644 index 00000000..7813233f --- /dev/null +++ b/Wonky.Client/Models/QCallbackArgs.cs @@ -0,0 +1,13 @@ +namespace Wonky.Client.Models; + +public class QCallbackArgs +{ + /// + /// ESalesNumber + /// + public string ESalesNumber { get; set; } = ""; + /// + /// QStatus + /// + public QStatus Status { get; set; } +} \ No newline at end of file diff --git a/Wonky.Client/Models/QuoteCallbackArgs.cs b/Wonky.Client/Models/QuoteCallbackArgs.cs deleted file mode 100644 index 44e2ab68..00000000 --- a/Wonky.Client/Models/QuoteCallbackArgs.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Wonky.Client.Models; - -public class QuoteCallbackArgs -{ - public string ESalesNumber { get; set; } = ""; - public QStatus Status { get; set; } -} \ No newline at end of file diff --git a/Wonky.Client/Models/SelectedSku.cs b/Wonky.Client/Models/SelectedSku.cs index 9f018483..acc19134 100644 --- a/Wonky.Client/Models/SelectedSku.cs +++ b/Wonky.Client/Models/SelectedSku.cs @@ -17,7 +17,16 @@ namespace Wonky.Client.Models; public class SelectedSku { + /// + /// ItemId + /// public string ItemId { get; set; } = ""; + /// + /// Quantity + /// public string Quantity { get; set; } = ""; + /// + /// Rate + /// public string Rate { get; set; } = ""; } \ No newline at end of file diff --git a/Wonky.Client/Models/VatAddress.cs b/Wonky.Client/Models/VatAddress.cs index 0d8c19b9..f5bf5049 100644 --- a/Wonky.Client/Models/VatAddress.cs +++ b/Wonky.Client/Models/VatAddress.cs @@ -20,7 +20,21 @@ namespace Wonky.Client.Models; public class VatAddress { - [Required(ErrorMessage = "Vejnavn skal angives")] public string StreetName { get; set; } = ""; - [Required(ErrorMessage = "Husnummer skal angives")] public string HouseNumber { get; set; } = ""; - [Required(ErrorMessage = "Postnr skal angives")] public string ZipCode { get; set; } = ""; + /// + /// Street Name + /// + [Required(ErrorMessage = "Vejnavn skal angives")] + public string StreetName { get; set; } = ""; + + /// + /// House Number + /// + [Required(ErrorMessage = "Husnummer skal angives")] + public string HouseNumber { get; set; } = ""; + + /// + /// Postal Code + /// + [Required(ErrorMessage = "Postnr skal angives")] + public string ZipCode { get; set; } = ""; } \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityListCustomerPage.razor b/Wonky.Client/Pages/ActivityListCustomerPage.razor deleted file mode 100644 index b103eb59..00000000 --- a/Wonky.Client/Pages/ActivityListCustomerPage.razor +++ /dev/null @@ -1,98 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Wonky.Client.Components -@using Microsoft.AspNetCore.Authorization -@page "/companies/{CompanyId}/activities" -@attribute [Authorize(Roles = "Advisor")] - -@if (!string.IsNullOrWhiteSpace(Company.Name)) -{ - - -
-
-
-
-

Dato

-
-
-

Demo

-
-
-

Salg

-
-
-

Note /Kontor

-
-
-

Note /Selv

-
-
-
- - @if (Activities.Any()) - { - @foreach (var activity in Activities) - { -
-
-
- @activity.OrderDate -
-
- @activity.Demo -
-
- @activity.Sales -
-
- @activity.OfficeNote -
-
- ikke fuldt implementeret -
-
-
- } - } - else - { -
-
-
- Ingen data -
-
-
- } -
-} -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/ActivityCreateCrmPage.razor b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor similarity index 70% rename from Wonky.Client/Pages/ActivityCreateCrmPage.razor rename to Wonky.Client/Pages/AdvisorActivityCreatePage.razor index 7c5d3665..2261bb63 100644 --- a/Wonky.Client/Pages/ActivityCreateCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor @@ -15,14 +15,16 @@ // *@ -@page "/companies/{CompanyId}/activities/new" @using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Advisor")] @using Wonky.Client.Components +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/customers/{CompanyId}/activities/new" + +Ny aktivitet - @Company.Name
- +
@@ -32,7 +34,7 @@

Ring til kontoret. Denne konto er spærret med kode '@Company.Blocked'

} -
+

@Activity.Name - @Activity.Account

@@ -40,16 +42,21 @@ @if (ReportClosed) { -
Der kan ikke oprettes besøg når der findes rapport for @SelectedDate.ToShortDateString()
+
+
+

Der kan ikke oprettes besøg når der findes rapport for @SelectedDate.ToShortDateString()

+
+
+ } else { -
- -
+
+ +
@@ -58,8 +65,8 @@ else
- -
+ +
@if (!string.IsNullOrEmpty(Activity.VatNumber) && !string.IsNullOrWhiteSpace(Activity.Address1) && Company.HasFolded == 0) @@ -92,66 +99,78 @@ else
}
-
-
- -
+ +
- -
+ +
-
-
- -
+ +
- -
+ +
-
-
- -
- - -
- - -
- - -
-
- -
- -
+ +
- -
+ +
-
+ + +
+ + +
+ +
+ + +
+ +
+ +
+ + +
+
+ +
+
+ +
+
+ + @* *@ +
+
+ +
+
+
- @* Order lines -----------------------------------------------------*@ + @* Draft lines in draft -----------------------------------------------------*@
@@ -202,7 +221,7 @@ else @@ -211,7 +230,7 @@ else
@($"{DraftProvider.Draft.Total:N2}") -
- @* draft line ----------------------------------------------------- *@ + @* Create Draft line ----------------------------------------------------- *@
@if (!string.IsNullOrWhiteSpace(SelectedItem.Name) && ShowItem) @@ -222,9 +241,9 @@ else Kladdelinje - Antal - Pris - Rabat + Antal + Pris + Rabat SAS Varenr. @@ -232,18 +251,18 @@ else - + - +
-
- + @@ -251,7 +270,7 @@ else @SelectedItem.Sku - + @@ -273,31 +292,31 @@ else aria-labelledby="deliveryHeader" data-bs-parent="#crmActivity">
- +
- +
- +
- +
- +
@@ -309,16 +328,31 @@ else
- +
} - - - - - \ No newline at end of file + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs similarity index 64% rename from Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs index 75cb6ed2..ec4393f7 100644 --- a/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs @@ -18,7 +18,6 @@ using System.Text.Json; using Blazored.LocalStorage; using Blazored.Toast.Services; using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpRepository; using Wonky.Client.Models; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; @@ -31,30 +30,31 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ActivityCreateCrmPage : IDisposable +public partial class AdvisorActivityCreatePage : IDisposable { - // Parameters - [CascadingParameter] DraftStateProvider DraftProvider { get; set; } - [Parameter] public string CompanyId { get; set; } // Services - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public UserProfileService Profiles { get; set; } - [Inject] public IToastService Toast { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository Catalog { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private UserProfileService Profiles { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private ICountryCatalogRepository CatalogRepo { get; set; } + [Inject] private IAdvisorCustomerRepository CompanyRepo { get; set; } + [Inject] private IAdvisorActivityRepository ActivityRepo { get; set; } + [Inject] private IAdvisorReportRepository ReportRepo { get; set; } + [Inject] private IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } + + [CascadingParameter] private DraftStateProvider DraftProvider { get; set; } = new(); + [Parameter] public string CompanyId { get; set; } + // variables - private readonly JsonSerializerOptions? _options = new() {PropertyNameCaseInsensitive = true}; + private readonly JsonSerializerOptions _options = new() {PropertyNameCaseInsensitive = true}; private SalesItemView SelectedItem { get; set; } = new(); private UserPref UserPrefs { get; set; } = new(); private ActivityDto Activity { get; set; } = new(); private CompanyDto Company = new(); - private EditContext ActivityContext { get; set; } + private EditContext? ActivityContext { get; set; } private bool PoFormInvalid { get; set; } = true; private bool ShowItem { get; set; } private string Quantity { get; set; } = "1"; @@ -62,25 +62,33 @@ public partial class ActivityCreateCrmPage : IDisposable private string Discount { get; set; } = "0"; private bool Sas { get; set; } private bool InvalidActivityType { get; set; } = true; - private bool InvalidStatusType { get; set; } = true; private bool InvalidActivity { get; set; } = true; - private bool InvalidCanvas { get; set; } = true; - private bool NoHistory { get; set; } = true; private bool ReportClosed { get; set; } private bool Working { get; set; } = true; - private UserInfoView ThisUserInfo { get; set; } = new(); + private UserInfoView SalesRep { get; set; } = new(); private DateTime SelectedDate { get; set; } private string OldPhone { get; set; } = ""; - private string PromptDateConfirm { get; set; } - // MODAL DIALOGS - private PriceListModal PriceListModal { get; set; } - private ProductHistoryModal HistoryModal { get; set; } - private ProductPriceHistoryModal PriceHistoryModal { get; set; } - private ConfirmWorkDateModal ConfirmWorkDateModal { get; set; } = new(); - private ConfirmProductCheckModal ConfirmProductCheckModal { get; set; } = new(); + private string PromptDateConfirm { get; set; } = ""; + + // OVERLAY PAGES + private PriceCatalogModalOverlay CatalogOverlay { get; set; } = new(); + private ProductHistoryModalOverlay ProductOverlay { get; set; } = new(); + private ProductPriceHistoryModal PriceOverlay { get; set; } = new(); + private ConfirmWorkDateModalOverlay WorkDateOverlay { get; set; } = new(); + private ConfirmProductCheckModalOverlay ProductCheckOverlay { get; set; } = new(); + private CustomerInvoiceListModalOverlay InvoiceListOverlay { get; set; } = new(); + private CustomerInventoryListModalOverlay InventoryListOverlay { get; set; } = new(); + private CustomerActivityListModalOverlay ActivityListOverlay { get; set; } = new(); + private List Inventory { get; set; } = new(); private List CheckList { get; set; } = new(); + private InvoiceListView CompanyInvoices { get; set; } = new(); + private List Activities { get; set; } = new(); + + private string ButtonText { get; set; } = "Gem besøg"; + private bool OrgWarning { get; set; } + /// /// Page initialization /// @@ -95,12 +103,13 @@ public partial class ActivityCreateCrmPage : IDisposable // User Preferences UserPrefs = await Profiles.GetPreferences(); // User Info - ThisUserInfo = await Storage.GetItemAsync("_xu"); + SalesRep = await Storage.GetItemAsync("_xu"); // Fetch Customer from http Company = await CompanyRepo.GetCompanyById(CompanyId); if (Company.HasFolded == 1) // Company has shutdown activities Activity.OrderMessage = "BEMÆRK: CVR nummer er ophørt."; + // variable to validate if customer needs phone number update OldPhone = Company.Phone; if (string.IsNullOrWhiteSpace(Company.Phone) @@ -115,9 +124,9 @@ public partial class ActivityCreateCrmPage : IDisposable Activity.ActivityStatusEnum = "noSale"; Activity.VisitTypeEnum = Company.Account is "" or "NY" ? "new" : "recall"; Activity.CompanyId = Company.CompanyId; - Activity.SalesRepId = ThisUserInfo.Id; - Activity.SalesRep = ThisUserInfo.Advisor; - Activity.CountryCode = ThisUserInfo.CountryCode; + Activity.SalesRepId = SalesRep.Id; + Activity.SalesRep = SalesRep.Advisor; + Activity.CountryCode = SalesRep.CountryCode; Activity.Account = Company.Account; Activity.VatNumber = Company.VatNumber; Activity.Email = Company.Email; @@ -142,7 +151,7 @@ public partial class ActivityCreateCrmPage : IDisposable if (!UserPrefs.DateConfirmed) { PromptDateConfirm = $"Aktiviteter oprettes med dato {SelectedDate.ToShortDateString()}. Er dette OK?"; - ConfirmWorkDateModal.Show(); + WorkDateOverlay.Show(); } // Lines may already have been added from the company inventory page if (DraftProvider.Draft.DraftType == "order") @@ -153,10 +162,86 @@ public partial class ActivityCreateCrmPage : IDisposable PoFormInvalid = false; } Working = false; - //StateHasChanged(); } - private async Task CallConfirmProductCheckModel() + private async Task ShowVisitOverlay() + { + Logger.LogDebug("ShowInventoryOverlay - wait for visits"); + + ActivityListOverlay.Show(); + + Activities = await ActivityRepo.GetCustomerActivities(CompanyId); + + await Task.Delay(500); + } + + private async Task ShowInventoryOverlay() + { + Logger.LogDebug("ShowInventoryOverlay - wait for inventory"); + + InventoryListOverlay.Show(); + + Inventory = await HistoryRepo.FetchInventory(CompanyId); + + await Task.Delay(500); + } + + private async Task OnInventoryCallback(DraftItem item) + { + Activity.ActivityStatusEnum = "order"; + DraftProvider.Draft.DraftType = "order"; + DraftProvider.Draft.Items.Add(item); + StateHasChanged(); + } + + private async Task ShowInvoiceOverlay() + { + Logger.LogDebug("ShowInvoiceOverlay - wait for invoices"); + + InvoiceListOverlay.Show(); + CompanyInvoices = await FetchCompanyInvoices(); + await Task.Delay(500); + } + + private async Task FetchCompanyInvoices() + { + // fetch from storage + var storage = await Storage.GetItemAsStringAsync($"{CompanyId}-invoices"); + await Task.Delay(500); + var iDate = await Storage.GetItemAsStringAsync($"{CompanyId}-iDate"); + + // if we have a list and iDate was today return the list + if (!string.IsNullOrWhiteSpace(storage) && (!string.IsNullOrWhiteSpace(iDate) && DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now)) + { + Logger.LogDebug("fetching invoices from storage"); + Logger.LogDebug("storage contains <= {}", storage); + return JsonSerializer.Deserialize(storage); + } + + Logger.LogDebug("pulling invoices from backend"); + // pull invoices + var companyInvoices = await HistoryRepo.FetchInvoiceList(CompanyId); + // send invoices to storage + await Storage.SetItemAsync($"{CompanyId}-invoices", companyInvoices); + await Storage.SetItemAsync($"{CompanyId}-iDate", $"{DateTime.Now:yyyy-MM-dd}"); + Logger.LogDebug(" --> return invoices from backend"); + Working = false; + Logger.LogDebug("backend contains <= {}", JsonSerializer.Serialize(companyInvoices)); + return companyInvoices; + } + + private void ShowOrgWarning() + { + if (OrgWarning) + return; + OrgWarning = true; + if (Company.CountryCode.ToLower() == "se" && VatUtils.SanitizeVatNumber(Activity.VatNumber).Length < 10 && Activity.ActivityStatusEnum == "order") + { + Toaster.ShowWarning("Org nummer er ufuldstændig. Skal opdateres før bestilling kan sendes. ", "ADVARSEL"); + } + } + + private async Task CallConfirmCheckOverlay() { // check if new account if (string.IsNullOrWhiteSpace(Company.Account) @@ -170,54 +255,60 @@ public partial class ActivityCreateCrmPage : IDisposable // check if product has been checked // fetch products from storage - var storage = await Storage.GetItemAsStringAsync($"{CompanyId}-products"); + var pStorage = await Storage.GetItemAsStringAsync($"{CompanyId}-products"); + Logger.LogDebug("pStorage => {}", pStorage); // fetch pDate from storage - var pDate = await Storage.GetItemAsStringAsync($"{CompanyId}-pDate"); + var pDate = await Storage.GetItemAsync($"{CompanyId}-pDate"); + if (string.IsNullOrWhiteSpace(pDate)) + pDate = $"{DateTime.Now.AddDays(-1):yyyy-MM-dd}"; + Logger.LogDebug("pDate => {}", pDate); + // check if product data is valid and updated today - if (string.IsNullOrWhiteSpace(storage) || DateTime.Parse(pDate.Replace("\"", "")) < DateTime.Now) + if (string.IsNullOrWhiteSpace(pStorage) || pDate.Replace("\"", "") != $"{DateTime.Now:yyyy-MM-dd}") { Working = true; - // pop a message - Toast.ShowError("Produkt gennemgang mangler. Vent mens produkt oversigt indlæses. Gå ikke væk fra siden!", "Produkt check ..."); + Toaster.ShowError("Produkt gennemgang mangler. Vent mens produkt oversigt indlæses. Gå ikke væk fra siden!", "Produkt check ..."); // product inventory has not been updated // send rpc call to sync ERP to CRM - Toast.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ..."); - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + Toaster.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ..."); + var ts = await HistoryRepo.InvoiceErpToCrmRpc(CompanyId, Company.HistorySync); while (string.IsNullOrWhiteSpace(ts)) - { - await Task.Delay(1000); - } + await Task.Delay(500); // save pDate await Storage.SetItemAsync($"{CompanyId}-pDate", ts); // request products from backend - Toast.ShowInfo("Vent mens produkt oversigt hentes", "CRM produkt liste"); + Toaster.ShowInfo("Vent mens produkt oversigt hentes", "CRM produkt liste"); + CheckList = await HistoryRepo.FetchInventory(CompanyId); - CheckList = CheckList.OrderBy(x => x.Description).ToList(); + if(CheckList.Any()) + CheckList = CheckList.OrderBy(x => x.Description).ToList(); + await Storage.SetItemAsync($"{CompanyId}-products", CheckList); Working = false; } else { // deserialize storage data - CheckList = JsonSerializer.Deserialize>(storage); + CheckList = JsonSerializer.Deserialize>(pStorage); if(CheckList.Any()) CheckList = CheckList.OrderBy(x => x.Description).ToList(); } // Show CheckList modal - ConfirmProductCheckModal.Show(); + ProductCheckOverlay.Show(); } + private async Task ConfirmProductCheckCallback() { + ProductCheckOverlay.Hide(); await CreateActivity(); foreach (var item in CheckList) { item.Check = false; } - await Storage.SetItemAsync($"{CompanyId}-products", CheckList); - ConfirmProductCheckModal.Hide(); + } /// @@ -226,7 +317,7 @@ public partial class ActivityCreateCrmPage : IDisposable private async Task WorkDateConfirmCallback() { await Profiles.SetDateConfirmed(true); - ConfirmWorkDateModal.Hide(); + WorkDateOverlay.Hide(); StateHasChanged(); } @@ -244,9 +335,9 @@ public partial class ActivityCreateCrmPage : IDisposable /// /// Show Price list modal /// - private void CallPriceListModal() + private void ShowPriceListOverlay() { - PriceListModal.Show(); + CatalogOverlay.Show(); } /// @@ -258,7 +349,7 @@ public partial class ActivityCreateCrmPage : IDisposable // get selected item if (string.IsNullOrWhiteSpace(sku.ItemId)) return; - SelectedItem = await Catalog.GetSalesItemId(sku.ItemId); + SelectedItem = await CatalogRepo.GetSalesItemId(SalesRep.CountryCode.ToLower(), sku.ItemId); ShowItem = true; Price = sku.Rate; Quantity = sku.Quantity; @@ -268,10 +359,10 @@ public partial class ActivityCreateCrmPage : IDisposable /// /// Show Price History modal /// - private void CallPriceHistoryModal() + private void ShowPriceHistoryOverlay() { if(ShowItem) - PriceHistoryModal.Show(); + PriceOverlay.Show(); } /// @@ -294,26 +385,35 @@ public partial class ActivityCreateCrmPage : IDisposable // avoid duplication if (Working) return; - // validate customer address1 - this is a required input + // validate customer address1 + // - this is a required input if (string.IsNullOrWhiteSpace(Activity.Address1)) { - Toast.ShowError("Kunde adresse er ufuldstændig."); + Toaster.ShowError("Kunde adresse er ufuldstændig."); return; } - // + // validate org number + // - this is a required input + // - must validate according to country rules. + if (!VatUtils.ValidateFormat(Company.CountryCode, Activity.VatNumber)) + { + Toaster.ShowError("Firma registreringsnummer er ikke korrekt."); + return; + } + // validate input according to status switch (Activity.ActivityStatusEnum) { // don't accept order with no lines case "order" when DraftProvider.Draft.Items.Count == 0: - Toast.ShowError("Ved bestilling skal der være en eller flere linjer i kladden."); + Toaster.ShowError("Ved bestilling skal der være en eller flere linjer i kladden."); return; // phone number is required if first time customer case "order" when Company.Account is "NY" or "" && string.IsNullOrWhiteSpace(Activity.Phone): - Toast.ShowError("Ved bestilling til ny kunde skal telefon nummer angives."); + Toaster.ShowError("Ved bestilling til ny kunde skal telefon nummer angives."); return; // verify email address is a valid address case "quote" when !Utils.IsValidEmail(Activity.Email): - Toast.ShowError("Ved tilbud skal en gyldig email adresse angives."); + Toaster.ShowError("Ved tilbud skal en gyldig email adresse angives."); return; } // raise working flag @@ -325,14 +425,15 @@ public partial class ActivityCreateCrmPage : IDisposable if (OldPhone != Activity.Phone) { Company.Phone = Activity.Phone; + Activity.OrderMessage = $"Telefonnr. opdateret.\n{Activity.OrderMessage}"; await CompanyRepo.UpdateErpData(Company.CompanyId, Company); } // begin assembling activity Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}"; Activity.OurRef = Activity.ActivityTypeEnum switch { - "phone" => $"T:{ThisUserInfo.FullName.Split(" ")[0]}", - "onSite" => $"B:{ThisUserInfo.FullName.Split(" ")[0]}", + "phone" => $"T:{SalesRep.FullName.Split(" ")[0]}", + "onSite" => $"B:{SalesRep.FullName.Split(" ")[0]}", _ => "" }; if (Activity.Express) @@ -367,16 +468,16 @@ public partial class ActivityCreateCrmPage : IDisposable // show result message if (result.IsSuccess) { - Toast.ShowSuccess($"{result.Message}", + Toaster.ShowSuccess($"{result.Message}", DraftProvider.Draft.Items.Count == 0 ? "Besøg er oprettet" : "Bestilling/Tilbud er oprettet"); await DeleteDraft(); - Navigator.NavigateTo($"/companies"); + Navigator.NavigateTo($"/advisor/customers"); return; } // lower working flag Working = false; // show error message - Toast.ShowError(result.Message, "ORDRE FEJL"); + Toaster.ShowError(result.Message, "ORDRE FEJL"); } /// @@ -444,10 +545,15 @@ public partial class ActivityCreateCrmPage : IDisposable { Logger.LogDebug("ActivityNewPage => ActivityStatusEnum == 'noSale' <= remove items"); DraftProvider.Draft.Items = new List(); - } - - + + ButtonText = Activity.ActivityStatusEnum.ToLower() switch + { + "nosale" => "Gem Besøg", + "order" => "Send Bestilling", + "quote" => "Send Tilbud" + }; + // InvalidCanvas = InvalidActivityType; InvalidActivity = InvalidActivityType || PoFormInvalid @@ -471,10 +577,20 @@ public partial class ActivityCreateCrmPage : IDisposable { if (string.IsNullOrEmpty(Activity.ActivityTypeEnum) && !ReportClosed) { - Toast.ShowWarning("Aktivitet type kan ikke være tom"); + Toaster.ShowWarning("Aktivitet type kan ikke være tom"); PoFormInvalid = true; return; } + + if (Activity.ActivityStatusEnum.ToLower() is "order" or "quote" + && Company.CountryCode.ToLower() == "se" + && VatUtils.SanitizeVatNumber(Activity.VatNumber).Length < 10) + { + ShowOrgWarning(); + PoFormInvalid = true; + return; + } + PoFormInvalid = false; ActivityContext.OnFieldChanged -= HandleFieldChanged; ActivityContext.OnValidationStateChanged -= ValidationChanged; diff --git a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor b/Wonky.Client/Pages/AdvisorActivityTodayListPage.razor similarity index 74% rename from Wonky.Client/Pages/ActivityListTodayCrmPage.razor rename to Wonky.Client/Pages/AdvisorActivityTodayListPage.razor index 68ee182a..f22b29a2 100644 --- a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorActivityTodayListPage.razor @@ -18,8 +18,8 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @attribute [Authorize(Roles = "Advisor")] -@page "/activity-today" - +@page "/advisor/activity-today" +Aktiviteter for @($"{SelectedDate:yyyy-MM-dd}")
@@ -30,17 +30,17 @@
@if (ReportExist) { - Rapport + Rapport } else { - Rapport + Rapport }
@if (ReportStatusView.ReportItems.Any()) { - + } @if (Working) { diff --git a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorActivityTodayListPage.razor.cs similarity index 73% rename from Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorActivityTodayListPage.razor.cs index ee65739b..729fc543 100644 --- a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorActivityTodayListPage.razor.cs @@ -25,15 +25,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ActivityListTodayCrmPage : IDisposable +public partial class AdvisorActivityTodayListPage : IDisposable { - [Inject] public UserProfileService UserProfileService { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } - [Inject] public IToastService Toaster { get; set; } + [Inject] private UserProfileService UserProfileService { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private IAdvisorActivityRepository AdvisorActivityRepo { get; set; } + [Inject] private IAdvisorReportRepository AdvisorReportRepo { get; set; } + [Inject] private IToastService Toaster { get; set; } private ReportStatusView? ReportStatusView { get; set; } = new(); private UserPref UserPref { get; set; } = new(); private DateTime SelectedDate { get; set; } @@ -46,7 +46,7 @@ public partial class ActivityListTodayCrmPage : IDisposable Interceptor.RegisterBeforeSendEvent(); UserPref = await UserProfileService.GetPreferences(); SelectedDate = string.IsNullOrWhiteSpace(UserPref.WorkDate) ? DateTime.Now : DateTime.Parse(UserPref.WorkDate); - ReportExist = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + ReportExist = await AdvisorReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); await GetActivities($"{SelectedDate:yyyy-MM-dd}"); Working = false; } @@ -57,8 +57,8 @@ public partial class ActivityListTodayCrmPage : IDisposable Toaster.ShowInfo("Vent nogle sekunder for data", "HENTER DATA"); SelectedDate = DateTime.Parse(workDate); ReportStatusView = new ReportStatusView(); - ReportExist = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); - ReportStatusView = await CrmActivityRepo.GetActivities($"{SelectedDate:yyyy-MM-dd}"); + ReportExist = await AdvisorReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + ReportStatusView = await AdvisorActivityRepo.GetActivities($"{SelectedDate:yyyy-MM-dd}"); Logger.LogDebug("Activities => {}", JsonSerializer.Serialize(ReportStatusView)); Working = false; Toaster.ClearAll(); diff --git a/Wonky.Client/Pages/ActivityViewCrmPage.razor b/Wonky.Client/Pages/AdvisorActivityViewPage.razor similarity index 94% rename from Wonky.Client/Pages/ActivityViewCrmPage.razor rename to Wonky.Client/Pages/AdvisorActivityViewPage.razor index 39a03caa..31a1d25e 100644 --- a/Wonky.Client/Pages/ActivityViewCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorActivityViewPage.razor @@ -18,10 +18,11 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components -@attribute [Authorize(Roles = "Admin,Office,Warehouse,Advisor")] -@page "/companies/{CompanyId}/orders/{OrderId}" -@page "/companies/{CompanyId}/quotes/{OrderId}" +@attribute [Authorize(Roles = "Admin,Advisor,Warehouse")] +@page "/advisor/customers/{CompanyId}/orders/{OrderId}" +@page "/advisor/customers/{CompanyId}/quotes/{OrderId}" +@ReportItem.Company.Name @ReportItem.OrderDate @* *@ @@ -129,7 +130,7 @@
@* Office Note *@ -@if (ReportItem.ProcessStatusEnum == "None" && !ReportItem.Express && AllowOfficeNoteUpdate()) +@if (ReportItem is { ProcessStatusEnum: "None",Express: false } && AllowOfficeNoteUpdate()) {
diff --git a/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorActivityViewPage.razor.cs similarity index 82% rename from Wonky.Client/Pages/ActivityViewCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorActivityViewPage.razor.cs index 32506389..63fa537b 100644 --- a/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorActivityViewPage.razor.cs @@ -29,15 +29,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ActivityViewCrmPage : IDisposable +public partial class AdvisorActivityViewPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string OrderId { get; set; } = ""; - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public IToastService Toaster { get; set; } - [Inject] public NavigationManager Navigator { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private IAdvisorActivityRepository AdvisorActivityRepo { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private NavigationManager Navigator { get; set; } private ReportItemView ReportItem { get; set; } = new(); private ActivityOfficeNote Note { get; set; } = new(); private EditContext NoteContext { get; set; } @@ -51,7 +51,7 @@ public partial class ActivityViewCrmPage : IDisposable Interceptor.RegisterBeforeSendEvent(); NoteContext = new EditContext(Note); NoteContext.OnFieldChanged += HandleFieldChanged; - ReportItem = await ActivityRepo.GetReportItem(OrderId); + ReportItem = await AdvisorActivityRepo.GetReportItem(OrderId); Note.ActivityId = ReportItem.ActivityId; Note.OfficeNote = ReportItem.OfficeNote; Logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(ReportItem)); @@ -68,9 +68,9 @@ public partial class ActivityViewCrmPage : IDisposable Working = true; Disabled = true; Logger.LogDebug("OfficeNote => \n {}", JsonSerializer.Serialize(Note)); - await ActivityRepo.UpdateOfficeNote(Note); + await AdvisorActivityRepo.UpdateOfficeNote(Note); Toaster.ShowInfo($"{ReportItem.ESalesNumber} - notat opdateret"); - Navigator.NavigateTo("/activity-today"); + Navigator.NavigateTo("/advisor/activity-today"); } private bool AllowOfficeNoteUpdate() diff --git a/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor new file mode 100644 index 00000000..080a68da --- /dev/null +++ b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor @@ -0,0 +1,44 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/customers/{CompanyId}/activities" + +Rådgiver Aktiviteter for @Company.Name + +@if (!string.IsNullOrWhiteSpace(Company.Name)) +{ +
+
+

@Company.Name

+
+ +
+ Besøg +
+
+ + +} +@if (Working) +{ + +} diff --git a/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor.cs similarity index 83% rename from Wonky.Client/Pages/ActivityListCustomerPage.razor.cs rename to Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor.cs index c255395a..7e9279d2 100644 --- a/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor.cs @@ -25,12 +25,12 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ActivityListCustomerPage : IDisposable +public partial class AdvisorCustomerActivityListPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] private HttpInterceptorService _interceptor { get; set; } + [Inject] private IAdvisorActivityRepository AdvisorActivityRepo { get; set; } + [Inject] private IAdvisorCustomerRepository CompanyRepo { get; set; } private List Activities { get; set; } = new(); private CompanyDto Company { get; set; } = new(); private bool Working { get; set; } = true; @@ -48,7 +48,7 @@ public partial class ActivityListCustomerPage : IDisposable private async Task GetActivities() { Working = true; - Activities = await CrmActivityRepo.GetCustomerActivities(CompanyId); + Activities = await AdvisorActivityRepo.GetCustomerActivities(CompanyId); if(Activities.Any()) Activities = Activities.OrderByDescending(x => x.OrderDate).ToList(); Working = false; diff --git a/Wonky.Client/Pages/CustomerCreateCrmPage.razor b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor similarity index 86% rename from Wonky.Client/Pages/CustomerCreateCrmPage.razor rename to Wonky.Client/Pages/AdvisorCustomerCreatePage.razor index fbf7f30c..baf37c9f 100644 --- a/Wonky.Client/Pages/CustomerCreateCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor @@ -15,12 +15,13 @@ // *@ -@page "/companies/new" +@page "/advisor/customers/new" @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @using System.Xml @attribute [Authorize(Roles = "Advisor")] +Rådgiver Opret Kunde

Opret kunde

@@ -30,7 +31,20 @@
@* vat lookup *@
- +
+ @switch (Company.CountryCode) + { + case "dk": + + break; + case "no": + Firma søgning + break; + case "se": + Firma søgning + break; + } +
@* entity name *@ @@ -69,7 +83,7 @@
@* entity vat number *@ - +
@@ -99,7 +113,7 @@

-
+
@@ -124,7 +138,7 @@
-
+
diff --git a/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs similarity index 91% rename from Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs index 06aa3abb..2de4916b 100644 --- a/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs @@ -37,15 +37,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages { - public partial class CustomerCreateCrmPage : IDisposable + public partial class AdvisorCustomerCreatePage : IDisposable { - [Inject] public IToastService Toaster { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public VatInfoLookupService VatService { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private IAdvisorCustomerRepository CompanyRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private VatInfoLookupService VatService { get; set; } private EditContext CompanyContext { get; set; } private CompanyDto Company { get; set; } = new(); private VirkRegInfo CompanyRegInfo { get; set; } = new(); @@ -136,7 +136,7 @@ namespace Wonky.Client.Pages /// private void SelectCompanyCallback(VirkRegInfo regInfo) { - Logger.LogDebug($"CrmCompanyView => SelectCompanyCallback => {JsonSerializer.Serialize(regInfo)}"); + Logger.LogDebug("CrmCompanyView => SelectCompanyCallback => {}", JsonSerializer.Serialize(regInfo)); // this can be removed in favor of the new data returned from updating the VatNumber RegState = regInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead"; @@ -177,7 +177,7 @@ namespace Wonky.Client.Pages if (!string.IsNullOrWhiteSpace(newId)) { Toaster.ShowSuccess($"'{Company.Name}' er oprettet i CRM."); - Navigator.NavigateTo($"/companies/{newId}"); + Navigator.NavigateTo($"/advisor/customers/{newId}"); } else { diff --git a/Wonky.Client/Pages/CustomerProductListCrmPage.razor b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor similarity index 64% rename from Wonky.Client/Pages/CustomerProductListCrmPage.razor rename to Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor index f4899d73..8bc6700e 100644 --- a/Wonky.Client/Pages/CustomerProductListCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor @@ -17,23 +17,26 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization -@page "/companies/{CompanyId}/h/i" +@page "/advisor/customers/{CompanyId}/h/i" @attribute [Authorize(Roles = "Advisor")] +Produkt oversigt for @Company.Name - + + + @if (Working) { - -} + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs new file mode 100644 index 00000000..5c969cc4 --- /dev/null +++ b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs @@ -0,0 +1,110 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Text.Json; +using Blazored.LocalStorage; +using Blazored.Toast.Services; +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Models; +using Wonky.Client.Shared; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class AdvisorCustomerInventoryListPage : IDisposable +{ + [Inject] private IAdvisorCustomerHistoryRepository CustomerHistory { get; set; } + [Inject] private IAdvisorCustomerRepository Customers { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private ICountryCatalogRepository Catalog { get; set; } + + [CascadingParameter] public DraftStateProvider DraftStateProvider { get; set; } = new(); + [Parameter] public string CompanyId { get; set; } = ""; + + + private readonly JsonSerializerOptions _options = new JsonSerializerOptions(JsonSerializerDefaults.Web); + private CompanyDto Company { get; set; } = new(); + private bool Working { get; set; } = true; + private SalesItemView SalesItem { get; set; } = new(); + private CustomerInventoryReorderModalOverlay CustomerInventoryReorderOverlay { get; set; } = new(); + private List Inventory { get; set; } = new(); + + + protected override async Task OnInitializedAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + Company = await Customers.GetCompanyById(CompanyId); + + // fetch product inventory + await FetchProductInventory(); + + Working = false; + } + + private async Task OnReorderCallback(string sku) + { + // fetch item from http repo + SalesItem = await Catalog.GetSalesItemSku(Company.CountryCode.ToLower(), sku); + CustomerInventoryReorderOverlay.Show(); + } + + private async Task OnSelectedItem(DraftItem draftItem) + { + // add item to order draft + DraftStateProvider.Draft.DraftType = "order"; + DraftStateProvider.Draft.Items.Add(draftItem); + // set item checked + await DraftStateProvider.SaveChangesAsync(); + } + + private async Task FetchProductInventory() + { + Inventory = new List(); + + var pStorage = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-products"); + var pDate = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-pDate"); + var local = !string.IsNullOrWhiteSpace(pStorage) && !string.IsNullOrWhiteSpace(pDate); + // if we have a list and pDate was today return the list + if (local && pDate.Replace("\"", "") == $"{DateTime.Now:yyyy-MM-dd}") + { + Inventory = JsonSerializer.Deserialize>(pStorage); + Logger.LogDebug("CustomerProductListCrmPage => Inventory <= {}", JsonSerializer.Serialize(Inventory, _options)); + } + Logger.LogDebug("pulling products from backend"); + // fetch product history + Inventory = await CustomerHistory.FetchInventory(CompanyId); + // default sort order by description + if (Inventory.Any()) + Inventory = Inventory.OrderBy(x => x.Description).ToList(); + // send products to storage + await Storage.SetItemAsync($"{Company.CompanyId}-products", Inventory); + await Storage.SetItemAsync($"{Company.CompanyId}-pDate", $"{DateTime.Now:yyyy-MM-dd}"); + Logger.LogDebug("Loaded products from backend"); + Logger.LogDebug("CustomerProductListCrmPage => Inventory <= {}", JsonSerializer.Serialize(Inventory, _options)); + } + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} diff --git a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor new file mode 100644 index 00000000..48aeb824 --- /dev/null +++ b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor @@ -0,0 +1,42 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization +@page "/advisor/customers/{CompanyId}/invoices" +@attribute [Authorize(Roles = "Advisor")] +Faktura Oversigt for @Company.Name +@if (!string.IsNullOrWhiteSpace(Company.Name)) +{ +
+
+

@Company.Name

+
+ +
+ Besøg +
+
+ + +} + +@if (Working) +{ + +} diff --git a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs new file mode 100644 index 00000000..0ecc83b7 --- /dev/null +++ b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs @@ -0,0 +1,101 @@ +using System.Globalization; +using System.Net.NetworkInformation; +using System.Text.Json; +using Blazored.LocalStorage; +using Blazored.Toast.Services; +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Shared; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class AdvisorCustomerInvoiceListPage : IDisposable +{ + [Parameter] public string CompanyId { get; set; } = ""; + [Inject] private IAdvisorCustomerRepository CompanyRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private ILogger Logger { get; set; } + private InvoiceListView CompanyInvoices { get; set; } = new(); + private CompanyDto Company { get; set; } = new(); + private CustomerInvoiceViewModalOverlay CustomerInvoiceView { get; set; } = new(); + private string InvoiceId { get; set; } = ""; + private bool Working { get; set; } + private bool AllSet { get; set; } + private string _companyId = ""; + + protected override void OnInitialized() + { + _companyId = CompanyId; + Working = true; + } + + protected override async Task OnInitializedAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + Company = await CompanyRepo.GetCompanyById(_companyId); + + // while (string.IsNullOrWhiteSpace(Company.HistorySync)) + // await Task.Delay(500); + // + // var iDate = await Storage.GetItemAsStringAsync($"{_companyId}-iDate"); + // if (string.IsNullOrWhiteSpace(iDate) || (iDate == Company.HistorySync && iDate != $"{DateTime.Now:yyyy-MM-dd}")) + // { + // // send rpc to sync invoices from ERP to CRM + // var ts = await HistoryRepo.ErpInvoiceToCrmRpc(_companyId, Company.HistorySync); + // // wait until we have the result + // while (string.IsNullOrWhiteSpace(ts)) + // await Task.Delay(500); + // + // await Storage.SetItemAsync($"{_companyId}-iDate", ts); + // } + CompanyInvoices = await FetchCompanyInvoices(); + AllSet = true; + } + + private void CallInvoiceModal(string invoiceId) + { + InvoiceId = invoiceId; + CustomerInvoiceView.Show(); + } + + private async Task FetchCompanyInvoices() + { + // fetch from storage + var storage = await Storage.GetItemAsStringAsync($"{_companyId}-invoices"); + var iDate = await Storage.GetItemAsStringAsync($"{_companyId}-iDate"); + + // if we have a list and iDate was today return the list + if (!string.IsNullOrWhiteSpace(storage) && (!string.IsNullOrWhiteSpace(iDate) && DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now)) + { + Logger.LogDebug("fetching invoices from storage"); + return JsonSerializer.Deserialize(storage); + } + Logger.LogDebug("pulling invoices from backend"); + // pull invoices + var companyInvoices = await HistoryRepo.FetchInvoiceList(_companyId); + if (companyInvoices.Invoices.Any()) + companyInvoices.Invoices = companyInvoices.Invoices + .OrderByDescending(x => x.DocumentDate) + .ToList(); + + // send invoices to storage + await Storage.SetItemAsync($"{_companyId}-invoices", companyInvoices); + await Storage.SetItemAsync($"{_companyId}-iDate", $"{DateTime.Now:yyyy-MM-dd}"); + Logger.LogDebug("return invoices from backend"); + Working = false; + return companyInvoices; + } + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} diff --git a/Wonky.Client/Pages/CustomerListCrmPage.razor b/Wonky.Client/Pages/AdvisorCustomerListPage.razor similarity index 70% rename from Wonky.Client/Pages/CustomerListCrmPage.razor rename to Wonky.Client/Pages/AdvisorCustomerListPage.razor index c9144a45..2b6b0e17 100644 --- a/Wonky.Client/Pages/CustomerListCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerListPage.razor @@ -15,42 +15,48 @@ // *@ -@page "/companies" @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization - +@page "/advisor/customers" @attribute [Authorize(Roles = "Advisor")] - +Kunde oversigt
- +
- +
- +
+ + + @*
+ *@
- + @if (Working) { diff --git a/Wonky.Client/Pages/CustomerListCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerListPage.razor.cs similarity index 67% rename from Wonky.Client/Pages/CustomerListCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorCustomerListPage.razor.cs index f99730a0..8b1cf069 100644 --- a/Wonky.Client/Pages/CustomerListCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerListPage.razor.cs @@ -28,13 +28,13 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages { - public partial class CustomerListCrmPage : IDisposable + public partial class AdvisorCustomerListPage : IDisposable { - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public NavigationManager Navigator { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } + [Inject] private IAdvisorCustomerRepository CompanyRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private NavigationManager Navigator { get; set; } private List Companies { get; set; } = new(); private UserPref Prefs { get; set; } = new(); private UserInfoView UserInfo { get; set; } = new(); @@ -42,7 +42,8 @@ namespace Wonky.Client.Pages private bool IncludeFolded { get; set; } private bool Working { get; set; } = true; private MetaData PageData { get; set; } = new(); - private CompanyPagingParams PageParams { get; set; } = new(); + private CustomerPaging Paging { get; set; } = new(); + private string ButtonFoldedText { get; set; } = "Vis Ophørte"; protected override void OnParametersSet() { @@ -56,65 +57,66 @@ namespace Wonky.Client.Pages // set preferences Prefs = await ProfileService.GetPreferences(); UserInfo = await Storage.GetItemAsync("_xu"); - PageParams.OrderBy = Prefs.CompanySort; - PageParams.SearchColumn = Prefs.CompanySearch; - PageParams.PageSize = Convert.ToInt32(Prefs.PageSize); - PageParams.HasFolded = IncludeFolded ? 1 : 0; - PageParams.CountryCode = UserInfo.CountryCode; - + Paging.OrderBy = Prefs.CompanySort; + Paging.SearchColumn = Prefs.CompanySearch; + Paging.PageSize = Convert.ToInt32(Prefs.PageSize); + Paging.HasFolded = IncludeFolded ? 1 : 0; + // load saved search SavedSearch = string.IsNullOrWhiteSpace(Prefs.CompanyFilterPhrase) ? "" : Prefs.CompanyFilterPhrase; - PageParams.SearchTerm = SavedSearch; + Paging.SearchTerm = SavedSearch; // get companies - await FetchCompanies(); + await FetchCustomers(); Working = false; } private async Task OnFoldedClick() { + Working = true; IncludeFolded = !IncludeFolded; + ButtonFoldedText = IncludeFolded ? "Vis Aktive" : "Vis Ophørte"; Companies = new List(); - PageParams.PageNumber = 1; - PageParams.HasFolded = IncludeFolded ? 1 : 0; - await FetchCompanies(); + Paging.PageNumber = 1; + Paging.HasFolded = IncludeFolded ? 1 : 0; + await FetchCustomers(); } private async Task SelectedPage(int page) { Companies = new List(); - PageParams.PageNumber = page; - await FetchCompanies(); + Paging.PageNumber = page; + await FetchCustomers(); } private async Task SetSearchCol(string searchColumn) { Companies = new List(); - PageParams.SearchColumn = searchColumn; - PageParams.PageNumber = 1; - await FetchCompanies(); + Paging.SearchColumn = searchColumn; + Paging.PageNumber = 1; + await FetchCustomers(); } private async Task SetPageSize(string pageSize) { Companies = new List(); - PageParams.PageSize = Convert.ToInt32(pageSize); - PageParams.PageNumber = 1; - await FetchCompanies(); + Paging.PageSize = Convert.ToInt32(pageSize); + Paging.PageNumber = 1; + await FetchCustomers(); } private async Task SetSearchPhrase(string searchTerm) { Companies = new List(); - PageParams.PageNumber = 1; - PageParams.SearchTerm = searchTerm; - await FetchCompanies(); + Paging.PageNumber = 1; + Paging.SearchTerm = searchTerm; + await FetchCustomers(); } private async Task SetSortCol(string orderBy) { Companies = new List(); - PageParams.OrderBy = orderBy; - await FetchCompanies(); + Paging.OrderBy = orderBy; + await FetchCustomers(); } /// @@ -125,15 +127,15 @@ namespace Wonky.Client.Pages { Companies = new List(); await CompanyRepo.DeleteCompany(companyId); - if (PageParams.PageNumber > 1 && Companies.Count == 1) - PageParams.PageNumber--; - await FetchCompanies(); + if (Paging.PageNumber > 1 && Companies.Count == 1) + Paging.PageNumber--; + await FetchCustomers(); } - private async Task FetchCompanies() + private async Task FetchCustomers() { Working = true; - var pageRes = await CompanyRepo.GetCompanies(PageParams); + var pageRes = await CompanyRepo.GetCompanies(Paging); Working = false; if (pageRes.Items.Any()) { diff --git a/Wonky.Client/Pages/CustomerViewCrmPage.razor b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor similarity index 86% rename from Wonky.Client/Pages/CustomerViewCrmPage.razor rename to Wonky.Client/Pages/AdvisorCustomerViewPage.razor index 6dc7870f..1e9c1f9f 100644 --- a/Wonky.Client/Pages/CustomerViewCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor @@ -19,7 +19,8 @@ @using Microsoft.AspNetCore.Components @using Wonky.Client.Components @attribute [Authorize(Roles = "Advisor")] -@page "/companies/{CompanyId}" +@page "/advisor/customers/{CompanyId}" +Kundekort for @Company.Name @if (!string.IsNullOrWhiteSpace(Company.Account)) { @@ -91,10 +92,10 @@
- +
- +
@* account *@ @@ -103,7 +104,7 @@
@* vat number*@ - +
@@ -115,11 +116,22 @@
@* vat lookup *@
- + @switch (CountryCode) + { + case "dk": + + break; + case "no": + Firma opslag + break; + case "se": + Firma opslag + break; + }
@* save vat number *@
- +
@@ -127,13 +139,13 @@ @* activity buttons *@
@* Save CRM data button *@
- +
@* crm context - contacts *@ -
+
diff --git a/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs similarity index 89% rename from Wonky.Client/Pages/CustomerViewCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs index 593bf8fc..6a8cdefe 100644 --- a/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs @@ -31,18 +31,18 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class CustomerViewCrmPage : IDisposable +public partial class AdvisorCustomerViewPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public IToastService Toaster { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } - [Inject] public ICrmContactHttpRepository ContactRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public VatInfoLookupService VatService { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private IAdvisorCustomerRepository CompanyRepo { get; set; } + [Inject] private IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } + [Inject] private IAdvisorContactRepository AdvisorContactRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private VatInfoLookupService VatService { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } private readonly JsonSerializerOptions _options = new () { PropertyNameCaseInsensitive = true }; private CompanyDto Company { get; set; } = new(); private EditContext ErpContext { get; set; } @@ -115,7 +115,7 @@ public partial class CustomerViewCrmPage : IDisposable // display urgency of next visit VisitState = Utils.GetVisitState($"{NextVisit:yyyy-MM-dd}"); // action link passed to activity button component - ActionLink = $"/companies/{CompanyId}/activities/new"; // used when drawing visit button + ActionLink = $"/advisor/customers/{CompanyId}/activities/new"; // used when drawing visit button // handle company out of business case if(Company.HasFolded == 1) { @@ -138,9 +138,20 @@ public partial class CustomerViewCrmPage : IDisposable CompanyVatAddress = PrepareVatAddress(Company); await FetchContacts(CompanyId); - + // remove loading image Working = false; + + await RequestErpUpdate(); + } + + private async Task RequestErpUpdate() + { + if(Working) + return; + Working = true; + await HistoryRepo.InvoiceErpToCrmRpc(CompanyId, Company.HistorySync); + Working = false; } /// @@ -150,7 +161,7 @@ public partial class CustomerViewCrmPage : IDisposable private async Task FetchContacts(string companyId) { // load contacts - Contacts = await ContactRepo.GetContacts(companyId); + Contacts = await AdvisorContactRepo.GetContacts(companyId); if(Contacts.Any() && Contacts.Count > 1) Contacts = Contacts.OrderBy(x => x.FirstName).ToList(); } @@ -216,14 +227,14 @@ public partial class CustomerViewCrmPage : IDisposable // new contact created Logger.LogDebug("create => {}", jsonContact); // send post request to backend - await ContactRepo.CreateContact(contact); + await AdvisorContactRepo.CreateContact(contact); } else { // contact modified Logger.LogDebug("update => {}", jsonContact); // send put request to backend - await ContactRepo.UpdateContact(contact); + await AdvisorContactRepo.UpdateContact(contact); } // reset selected contact SelectedContact = new ContactDto(); @@ -241,7 +252,7 @@ public partial class CustomerViewCrmPage : IDisposable Working = true; Logger.LogDebug("delete {}", contactId); // send delete request to backend - await ContactRepo.DeleteContact(CompanyId, contactId); + await AdvisorContactRepo.DeleteContact(CompanyId, contactId); // reset selected contact SelectedContact = new ContactDto(); // reload contacts from backend @@ -263,11 +274,13 @@ public partial class CustomerViewCrmPage : IDisposable Company.NextVisit = $"{NextVisit:yyyy-MM-dd}"; Company.IsHidden = 0; var result = await CompanyRepo.UpdateCrmData(CompanyId, Company); - if (!string.IsNullOrWhiteSpace(result.Name)) + if (!string.IsNullOrWhiteSpace(result.CompanyId)) { Company = result; + StateHasChanged(); } Working = false; + Toaster.ClearAll(); } /// @@ -281,11 +294,13 @@ public partial class CustomerViewCrmPage : IDisposable Working = true; Toaster.ShowInfo("Vent venligst ...", "OPDATERER STAM DATA"); var result = await CompanyRepo.UpdateErpData(CompanyId, Company); - if (!string.IsNullOrWhiteSpace(result.Name)) + if (!string.IsNullOrWhiteSpace(result.CompanyId)) { Company = result; + StateHasChanged(); } Working = false; + Toaster.ClearAll(); } /// @@ -305,11 +320,12 @@ public partial class CustomerViewCrmPage : IDisposable Working = true; Toaster.ShowInfo("Vent venligst ...", "OPDATERER MOMS NUMMER"); var result = await CompanyRepo.UpdateCompanyVat(CompanyId, Company.VatNumber); - if (!string.IsNullOrWhiteSpace(result.Name)) + if (!string.IsNullOrWhiteSpace(result.CompanyId)) { Company = result; StateHasChanged(); } + Toaster.ClearAll(); Working = false; } diff --git a/Wonky.Client/Pages/QuoteListCrmPage.razor b/Wonky.Client/Pages/AdvisorQuoteListPage.razor similarity index 61% rename from Wonky.Client/Pages/QuoteListCrmPage.razor rename to Wonky.Client/Pages/AdvisorQuoteListPage.razor index f9b5aed8..4c4a85f1 100644 --- a/Wonky.Client/Pages/QuoteListCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorQuoteListPage.razor @@ -1,7 +1,25 @@ -@page "/open-quotes" +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ @using Wonky.Client.Components @using Wonky.Client.Models - +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/agreements" +Aftaler og Tilbud - Oversigt

Aftaler og Tilbud

@@ -9,23 +27,23 @@
+ + + - + - - - - - - - - + + - + + + + - +
@* diff --git a/Wonky.Client/Pages/QuoteListCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs similarity index 65% rename from Wonky.Client/Pages/QuoteListCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs index 1af232fa..18d390ad 100644 --- a/Wonky.Client/Pages/QuoteListCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.IO.Enumeration; using System.Security.Policy; using System.Text.Json; using Blazored.LocalStorage; @@ -13,27 +14,29 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class QuoteListCrmPage : IDisposable +public partial class AdvisorQuoteListPage : IDisposable { - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public IToastService Toaster { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } + [Inject] private IAdvisorActivityRepository AdvisorActivityRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } private List Quotes { get; set; } = new(); private List _quotes { get; set; } = new(); - private bool Working { get; set; } = true; + private bool Working { get; set; } private QStatus QFilter { get; set; } = QStatus.NoteOpen; protected override async Task OnInitializedAsync() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - Quotes = await ActivityRepo.GetQuotes(); + Working = true; + Quotes = await AdvisorActivityRepo.GetQuotes(); await Storage.SetItemAsync("quotes", Quotes.OrderBy(x => x.Company.Name)); + Working = false; + // filter quotes - if any - default to QStatus.NoteOpen if (Quotes.Any()) await FilterQuotes(QFilter); - Working = false; } private async Task FilterQuotes(QStatus status) @@ -51,31 +54,33 @@ public partial class QuoteListCrmPage : IDisposable }; } - private async Task UpdateQuoteCallback(QuoteCallbackArgs args) + private async Task UpdateQuoteCallback(QCallbackArgs args) { + Working = true; + // find the quote to update var quote = Quotes.First(x => x.ESalesNumber == args.ESalesNumber); if (args.Status == QStatus.Win) quote.OrderDate = $"{DateTime.Now:yyyy-MM-dd}"; quote.QuoteStatusEnum = Utils.EnumToString(args.Status); - var response = await ActivityRepo.UpdateQuoteStatus(quote); + // send update request to backend + var response = await AdvisorActivityRepo.UpdateQuoteStatus(quote); Toaster.ShowInfo($"{response.Message}", $"HTTP STATUS {response.Code}"); - + // clear and reload quotes Quotes = new List(); await Storage.RemoveItemAsync("quotes"); - Quotes = await ActivityRepo.GetQuotes(); - while (!Quotes.Any()) - await Task.Delay(1000); - + Quotes = await AdvisorActivityRepo.GetQuotes(); + // store quotes in local storage await Storage.SetItemAsync("quotes", Quotes.OrderBy(x => x.Company.Name)); - - await FilterQuotes(QFilter); - + // filter quotes - if any - based on active filter + if(Quotes.Any()) + await FilterQuotes(QFilter); + Working = false; + // signal page state changed StateHasChanged(); } public void Dispose() { - Storage.RemoveItemAsync("quotes"); Interceptor.DisposeEvent(); } } diff --git a/Wonky.Client/Pages/AdvisorReportCreatePage.razor b/Wonky.Client/Pages/AdvisorReportCreatePage.razor new file mode 100644 index 00000000..071563a7 --- /dev/null +++ b/Wonky.Client/Pages/AdvisorReportCreatePage.razor @@ -0,0 +1,201 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components +@using Wonky.Entity.Views +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/reports/new" + +Opret Dagsrapport for @_workDate + +@* report header *@ +
+
+ +
+
+ +
+
+ +@* report form *@ + +@* Day info row *@ +
+ + + + + + + + + + + + + + @if (Report.DayTypeEnum.ToLower().Contains("leave")) + { + Report.Figures.KmMorning = 0; + + + } + else + { + Report.Figures.KmMorning = Prefs.KmMorning; + + + } + + + + +
Dag / PeriodeBegyndtAfsluttet
+ + + + + + + + + + + + + + +
+
+ +@* report details for everything but leave *@ +@if (!Report.DayTypeEnum.ToLower().Contains("leave")) +{ +
+ @* details input *@ + + + + + + + + + + + + + +
BeskrivelseMin medkørende supervisor
+ + + + + +
+
+ +
+ @* distance ledger input *@ + + + + + + + + + + + + + + + + + +
Km aftenKm morgenKm dagKm måned
+ + + + + + + +
+ + + + + + + + + + + + + +
Km privatKm privat måned
+ + + +
+
+ @if (Activities.Any()) + { +
+ +
+ } +} +
+ @* ledger summaries calculated *@ + +
+
+ + +@if (Working) +{ + +} diff --git a/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs similarity index 72% rename from Wonky.Client/Pages/ReportCreateCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs index 46beacd1..5e520614 100644 --- a/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs @@ -27,15 +27,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ReportCreateCrmPage : IDisposable +public partial class AdvisorReportCreatePage : IDisposable { - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public IToastService Toaster { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } + [Inject] private IAdvisorActivityRepository AdvisorActivityRepo { get; set; } + [Inject] private IAdvisorReportRepository AdvisorReportRepo { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private IToastService Toaster { get; set; } private EditContext ReportContext { get; set; } private ReportDto Report { get; set; } = new(); private List Activities { get; set; } = new(); @@ -43,7 +43,7 @@ public partial class ReportCreateCrmPage : IDisposable private UserPref Prefs { get; set; } = new(); private bool FormInvalid { get; set; } = true; private bool NoFigures { get; set; } = true; - private bool Working { get; set; } = true; + private bool Working { get; set; } private DateTime _workDate { get; set; } private TimeOnly _checkIn { get; set; } = new(12, 0); private TimeOnly _checkOut { get; set; } = new(12, 0); @@ -51,7 +51,10 @@ public partial class ReportCreateCrmPage : IDisposable private DateTime EndLeave { get; set; } = DateTime.Now; private ConfirmationModal ConfirmReportModal { get; set; } private string Prompt { get; set; } = ""; - + private string WorkDate { get; set; } = ""; + private int currKmMonth { get; set; } + private int currKmPrivate { get; set; } + /// /// OnInitialized /// @@ -64,13 +67,24 @@ public partial class ReportCreateCrmPage : IDisposable ReportContext.OnFieldChanged += HandleFieldChanged; ReportContext.OnValidationStateChanged += ValidationChanged; + ProfileService.OnChange += ProfileServiceOnOnChange; Prefs = await ProfileService.GetPreferences(); - _workDate = DateTime.Now; - if (!string.IsNullOrWhiteSpace(Prefs.WorkDate)) - _workDate = DateTime.Parse(Prefs.WorkDate); - - // if(await CrmReportRepo.ReportExist(Prefs.WorkDate)) - // Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); + Logger.LogDebug("{}", JsonSerializer.Serialize(Prefs)); + + WorkDate = Prefs.WorkDate; + if (string.IsNullOrWhiteSpace(WorkDate)) + { + _workDate = DateTime.Now; + WorkDate = $"{_workDate:yyyy-MM-dd}"; + await ProfileService.SetWorkDate(_workDate); + } + else + { + _workDate = DateTime.Parse(WorkDate); + } + + if(await AdvisorReportRepo.ReportExist(WorkDate)) + Navigator.NavigateTo($"/advisor/reports/view/{_workDate:yyyy-MM-dd}"); BeginLeave = _workDate; EndLeave = _workDate; @@ -81,13 +95,54 @@ public partial class ReportCreateCrmPage : IDisposable Report.Figures.KmMorning = 0; Report.Figures.KmEvening = 0; Report.Figures.Distance = 0; + Report.Figures.DistancePrivate = 0; Report.Figures.DistancePrivateMonth = 0; - - Working = false; - Logger.LogDebug("OnInitializedAsync => GetKeyFigures"); + await GetKeyFigures(); + Logger.LogDebug("OnInitializedAsync => GetKeyFigures <= {}", JsonSerializer.Serialize(Report)); } + private void ProfileServiceOnOnChange(UserPref userPref) + { + Prefs = userPref; + WorkDate = Prefs.WorkDate; + StateHasChanged(); + } + + private async Task GetKeyFigures() + { + if (Working) + return; + Working = true; + + Report.Figures = new ReportFiguresDto(); + InitialValues = new ReportFiguresDto(); + Activities = new List(); + + var data = await AdvisorReportRepo.InitializeReportData(WorkDate); + if(data.ReportClosed) + Navigator.NavigateTo($"/advisor/reports/view/{_workDate:yyyy-MM-dd}"); + + Report.Figures = data.ReportData; + InitialValues = data.ReportData; + Activities = data.ReportItems; + currKmMonth = data.ReportData.DistanceMonth; + currKmPrivate = data.ReportData.DistancePrivate; + if (Report.DayTypeEnum.ToLower().Contains("leave")) + { + // ensure no distances in calculation + Report.Figures.KmMorning = 0; + Report.Figures.KmEvening = 0; + Report.Figures.DistancePrivate = 0; + } + else + { + Report.Figures.KmMorning = Prefs.KmMorning; + } + + NoFigures = false; + Working = false; + } /// /// Field data change event /// @@ -97,11 +152,13 @@ public partial class ReportCreateCrmPage : IDisposable { // Console.WriteLine($"e FieldName => {e.FieldIdentifier.FieldName}"); FormInvalid = !ReportContext.Validate(); - if (Report.Figures.KmEvening - Report.Figures.KmMorning > 1000) + Report.Figures.Distance = Report.Figures.KmEvening - Report.Figures.KmMorning; + Report.Figures.DistanceMonth = Report.Figures.Distance + currKmMonth; + Report.Figures.DistancePrivateMonth = Report.Figures.DistancePrivate + currKmPrivate; + if (Report.Figures.Distance is > 1000 or < 0) { - Toaster.ShowError($"KM tal '{Report.Figures.KmEvening - Report.Figures.KmMorning}'. Er du sikker på at det er rigtigt?", "KM tal"); + Toaster.ShowError($"Kørte km for rapporten er '{Report.Figures.Distance}'. Er du sikker på at det er rigtigt?", "KM tal"); } - StateHasChanged(); } @@ -130,15 +187,16 @@ public partial class ReportCreateCrmPage : IDisposable return; Working = true; - var result = await CrmReportRepo.PostReport($"{_workDate:yyyy-MM-dd}", Report); - Toaster.ShowInfo($"{result.Message}", $"HTTP Status"); + var result = await AdvisorReportRepo.CreateReport(WorkDate, Report); + Logger.LogDebug("CreateReport.result => {}", JsonSerializer.Serialize(result)); // reset km and date confirmation await ProfileService.SetKmMorning(0); // reset date confirmed await ProfileService.SetDateConfirmed(false); - Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); + Navigator.NavigateTo($"/advisor/reports/view/{_workDate:yyyy-MM-dd}"); } + /// /// Submit report /// @@ -178,29 +236,26 @@ public partial class ReportCreateCrmPage : IDisposable // format report date time input Report.FromDateTime = checkIn.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture); Report.ToDateTime = checkOut.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture); - - // assign final distance numbers - if (Report.DayTypeEnum.ToLower().Contains("leave")) - { - Report.Figures.KmEvening = 0; - Report.Figures.KmMorning = 0; - } - // calculate distance - Report.Figures.Distance = Report.Figures.KmEvening - Report.Figures.KmMorning; - // add distance to distance month - Report.Figures.DistanceMonth += Report.Figures.Distance; - // add private distance to month - Report.Figures.DistancePrivateMonth += Report.Figures.DistancePrivate; - Logger.LogDebug("_workDate => {workDate}", $"{_workDate:yyyy-MM-dd}"); Logger.LogDebug("_report => {report}", JsonSerializer.Serialize(Report)); + if (Report.DayTypeEnum is "leave" or "sickLeave") + { + // reset distance calculation + Report.Figures.KmEvening = 0; + Report.Figures.KmMorning = 0; + Report.Figures.DistanceMonth = currKmMonth; + Report.Figures.DistancePrivateMonth = currKmPrivate; + } + // pop confirmation // create a prompt for popup confirmation var warning = Report.Figures.KmEvening - Report.Figures.KmMorning > 1000 ? - $"KM tal '{Report.Figures.KmEvening - Report.Figures.KmMorning}'. Er du sikker på at det er rigtigt?

" : ""; - Prompt = $"{warning}Gem rapport for {_workDate.ToLongDateString()}?"; + $"Kørte km for rapporten er '{Report.Figures.KmEvening - Report.Figures.KmMorning}'. Er du sikker på at det er rigtigt?
" : ""; + + Prompt = $"{warning}
Gem rapport for {_workDate.ToLongDateString()}?"; + ConfirmReportModal.Show(); } @@ -222,11 +277,14 @@ public partial class ReportCreateCrmPage : IDisposable /// private void SetWorkDateCallback(string workDate) { + WorkDate = workDate; _workDate = DateTime.Parse(workDate); + NoFigures = true; Report.Figures = new ReportFiguresDto(); InitialValues = new ReportFiguresDto(); Activities = new List(); + Report.Figures.KmEvening = 0; Report.Figures.KmMorning = 0; Report.Figures.Distance = 0; @@ -236,46 +294,16 @@ public partial class ReportCreateCrmPage : IDisposable Report.FromDateTime = $"{_workDate:yyyy-MM-dd'T'12:00}"; Report.ToDateTime = $"{_workDate:yyyy-MM-dd'T'12:00}"; } - - /// - /// Get key figures from backend - /// - private async Task GetKeyFigures() + + private void OnCancelCallback() { - if (Working) - return; - Working = true; - - Report.Figures = new ReportFiguresDto(); - InitialValues = new ReportFiguresDto(); - Activities = new List(); - - var data = await CrmReportRepo.InitializeReportData($"{_workDate:yyyy-MM-dd}"); - if(data.ReportClosed) - Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); - - Report.Figures = data.ReportData; - InitialValues = data.ReportData; - Activities = data.ReportItems; - - if (Report.DayTypeEnum.ToLower().Contains("leave")) - { - Report.Figures.KmMorning = 0; - Report.Figures.KmEvening = 0; - } - else - { - Report.Figures.KmMorning = Prefs.KmMorning; - } - - NoFigures = false; - Working = false; - } - + ConfirmReportModal.Hide(); + } public void Dispose() { Interceptor.DisposeEvent(); ReportContext.OnFieldChanged -= HandleFieldChanged; ReportContext.OnValidationStateChanged -= ValidationChanged; + ProfileService.OnChange -= ProfileServiceOnOnChange; } } \ No newline at end of file diff --git a/Wonky.Client/Pages/ReportListCrmPage.razor b/Wonky.Client/Pages/AdvisorReportListPage.razor similarity index 77% rename from Wonky.Client/Pages/ReportListCrmPage.razor rename to Wonky.Client/Pages/AdvisorReportListPage.razor index 208379c3..d91ff99b 100644 --- a/Wonky.Client/Pages/ReportListCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorReportListPage.razor @@ -16,13 +16,15 @@ *@ @using Wonky.Client.Components -@page "/sales-reports" - +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/reports" +Rapport Arkiv
-
+

Rapport Arkiv

- +
diff --git a/Wonky.Client/Pages/ReportListCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorReportListPage.razor.cs similarity index 69% rename from Wonky.Client/Pages/ReportListCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorReportListPage.razor.cs index 65c07b1e..ce407b70 100644 --- a/Wonky.Client/Pages/ReportListCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportListPage.razor.cs @@ -22,32 +22,34 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ReportListCrmPage : IDisposable +public partial class AdvisorReportListPage : IDisposable { - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] private IAdvisorReportRepository AdvisorReportRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private ILogger Logger { get; set; } private List ReportList { get; set; } = new(); - private bool Working { get; set; } = true; + private bool Working { get; set; } protected override async Task OnInitializedAsync() { - Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterEvent(); + + Working = true; - ReportList = await ReportRepo.GetReports(); - if (ReportList.Any()) - ReportList = ReportList.OrderByDescending(x => x.ReportDate).ToList(); - + var reports = await AdvisorReportRepo.GetReports(); + if (reports.Any()) + ReportList = reports.OrderByDescending(x => x.ReportDate).ToList(); + Working = false; } private void ShowThisReport(string reportDate) { Logger.LogDebug("CrmReportListPage => ShowThisReport <= {}", reportDate); - Navigator.NavigateTo($"/sales-reports/view/{reportDate}"); + Navigator.NavigateTo($"/advisor/reports/view/{reportDate}"); } public void Dispose() diff --git a/Wonky.Client/Pages/ReportViewCrmPage.razor b/Wonky.Client/Pages/AdvisorReportViewPage.razor similarity index 90% rename from Wonky.Client/Pages/ReportViewCrmPage.razor rename to Wonky.Client/Pages/AdvisorReportViewPage.razor index 76497ca7..3b50ff35 100644 --- a/Wonky.Client/Pages/ReportViewCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorReportViewPage.razor @@ -18,9 +18,9 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Models -@page "/sales-reports/view/{ReportDate}" -@attribute [Authorize(Roles = "Advisor,Admin,Supervisor")] - +@attribute [Authorize(Roles = "Advisor,Admin")] +@page "/advisor/reports/view/{ReportDate}" +@Report.ReportData.Name
@@ -36,7 +36,7 @@
-
+
@if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum)) { @Report.ReportData.Name @@ -51,7 +51,7 @@
- + } else diff --git a/Wonky.Client/Pages/ReportViewCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs similarity index 80% rename from Wonky.Client/Pages/ReportViewCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorReportViewPage.razor.cs index dde5d10e..34a1c68f 100644 --- a/Wonky.Client/Pages/ReportViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs @@ -23,15 +23,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ReportViewCrmPage : IDisposable +public partial class AdvisorReportViewPage : IDisposable { [Parameter] public string ReportDate { get; set; } - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private IAdvisorReportRepository AdvisorReportRepo { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } private UserPref Prefs { get; set; } = new(); private ReportView Report { get; set; } = new(); @@ -61,10 +61,10 @@ public partial class ReportViewCrmPage : IDisposable switch (target) { case PTarget.OrderPage: - Navigator.NavigateTo($"/print/orders/{UserInfo.CountryCode.ToLower()}/{UserInfo.Id}/{ReportDate}?returnUrl={ReturnUrl}"); + Navigator.NavigateTo($"/report/print/orders/{UserInfo.CountryCode.ToLower()}/{UserInfo.Id}/{ReportDate}?returnUrl={ReturnUrl}"); break; case PTarget.FrontPage: - Navigator.NavigateTo($"/print/report/{UserInfo.CountryCode.ToLower()}/{UserInfo.Id}/{ReportDate}?returnUrl={ReturnUrl}"); + Navigator.NavigateTo($"/report/print/summary/{UserInfo.CountryCode.ToLower()}/{UserInfo.Id}/{ReportDate}?returnUrl={ReturnUrl}"); break; case PTarget.None: break; @@ -85,7 +85,7 @@ public partial class ReportViewCrmPage : IDisposable } // ensure the browser address bar contains the correct link - Navigator.NavigateTo($"/sales-reports/view/{workDate}", false, true); + Navigator.NavigateTo($"/advisor/reports/view/{workDate}", false, true); // return if we are already at it if (Working) @@ -101,7 +101,7 @@ public partial class ReportViewCrmPage : IDisposable Working = true; // fetch report - Report = await ReportRepo.GetReport(workDate); + Report = await AdvisorReportRepo.GetReport(workDate); // extract activities Activities = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); diff --git a/Wonky.Client/Pages/TaskItemListCrmPage.razor b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor similarity index 90% rename from Wonky.Client/Pages/TaskItemListCrmPage.razor rename to Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor index 69ec18fa..56d129d5 100644 --- a/Wonky.Client/Pages/TaskItemListCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor @@ -18,8 +18,8 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Advisor")] -@page "/task-items" - +@page "/advisor/task-items" +Opgave Oversigt
@@ -30,7 +30,7 @@
diff --git a/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs similarity index 79% rename from Wonky.Client/Pages/TaskItemListCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs index 2af94738..d5829d4a 100644 --- a/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs @@ -25,14 +25,14 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class TaskItemListCrmPage : IDisposable +public partial class AdvisorTaskItemListCrmPage : IDisposable { - [Inject] public UserProfileService UserProfileService { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmTaskItemHttpRepository TaskItemRepo { get; set; } - [Inject] public IToastService Toaster { get; set; } + [Inject] private UserProfileService UserProfileService { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private IAdvisorTaskItemRepository AdvisorTaskRepo { get; set; } + [Inject] private IToastService Toaster { get; set; } private UserPref Prefs { get; set; } = new(); private string WorkDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; private bool ReportExist = false; @@ -55,7 +55,7 @@ public partial class TaskItemListCrmPage : IDisposable { Working = true; Toaster.ShowInfo("Vent nogle sekunder for data"); - TaskItems = await TaskItemRepo.GetTaskList(workDate); + TaskItems = await AdvisorTaskRepo.GetTaskList(workDate); Toaster.ClearAll(); Working = false; diff --git a/Wonky.Client/Pages/TaskItemViewCrmPage.razor b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor similarity index 98% rename from Wonky.Client/Pages/TaskItemViewCrmPage.razor rename to Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor index 2f26a641..e08ea6b4 100644 --- a/Wonky.Client/Pages/TaskItemViewCrmPage.razor +++ b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor @@ -18,8 +18,8 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @attribute [Authorize(Roles = "Advisor")] -@page "/tasks/{TaskItemId}" - +@page "/advisor/tasks/{TaskItemId}" +Opgave kort

Opgave

diff --git a/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs similarity index 86% rename from Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs rename to Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs index 6dd66623..567f4b75 100644 --- a/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs @@ -24,11 +24,11 @@ using Wonky.Entity.DTO; namespace Wonky.Client.Pages; -public partial class TaskItemViewCrmPage : IDisposable +public partial class AdvisorTaskItemViewCrmPage : IDisposable { [Parameter] public string TaskItemId { get; set; } - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmTaskItemHttpRepository CrmTaskItemRepo { get; set; } + [Inject] private HttpInterceptorService _interceptor { get; set; } + [Inject] private IAdvisorTaskItemRepository AdvisorTaskRepo { get; set; } private TaskItemDto _taskItem = new (); private EditContext _editContext { get; set; } private bool Working { get; set; } = true; @@ -39,7 +39,7 @@ public partial class TaskItemViewCrmPage : IDisposable _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _taskItem = await CrmTaskItemRepo.GetTaskItem(TaskItemId); + _taskItem = await AdvisorTaskRepo.GetTaskItem(TaskItemId); Console.WriteLine(JsonSerializer.Serialize(_taskItem)); Working = false; } diff --git a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor b/Wonky.Client/Pages/AdvisorWorkplaceDocumentListPage.razor similarity index 84% rename from Wonky.Client/Pages/WorkplaceDocumentListPage.razor rename to Wonky.Client/Pages/AdvisorWorkplaceDocumentListPage.razor index 37db7090..bdb7da82 100644 --- a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor +++ b/Wonky.Client/Pages/AdvisorWorkplaceDocumentListPage.razor @@ -17,9 +17,10 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components -@attribute [Authorize(Roles = "Admin,Warehouse,Office")] -@page "/companies/{CompanyId}/workplaces/{WorkplaceId}/documents" +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/customers/{CompanyId}/workplaces/{WorkplaceId}/documents" +Dokumenter for Arbejdssted

Dokumenter

@if (Working) diff --git a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs b/Wonky.Client/Pages/AdvisorWorkplaceDocumentListPage.razor.cs similarity index 85% rename from Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs rename to Wonky.Client/Pages/AdvisorWorkplaceDocumentListPage.razor.cs index 7083f2e9..6dacf017 100644 --- a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorWorkplaceDocumentListPage.razor.cs @@ -21,13 +21,13 @@ using Wonky.Client.HttpRepository; namespace Wonky.Client.Pages; -public partial class WorkplaceDocumentListPage +public partial class AdvisorWorkplaceDocumentListPage { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string WorkplaceId { get; set; } = ""; - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } + [Inject] private HttpInterceptorService _interceptor { get; set; } + [Inject] private IAdvisorWorkplaceRepository Workplaces { get; set; } private bool Working { get; set; } = true; } \ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceListPage.razor b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor similarity index 89% rename from Wonky.Client/Pages/WorkplaceListPage.razor rename to Wonky.Client/Pages/AdvisorWorkplaceListPage.razor index c31ee858..ee86f86e 100644 --- a/Wonky.Client/Pages/WorkplaceListPage.razor +++ b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor @@ -18,11 +18,11 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @attribute [Authorize(Roles = "Advisor")] -@page "/companies/{CompanyId}/workplaces" - +@page "/advisor/customers/{CompanyId}/workplaces" +@Company.Name arbejdssteder
-

@_company.Name

+

@Company.Name

diff --git a/Wonky.Client/Pages/WorkplaceListPage.razor.cs b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs similarity index 77% rename from Wonky.Client/Pages/WorkplaceListPage.razor.cs rename to Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs index 143fc09b..63a8afa9 100644 --- a/Wonky.Client/Pages/WorkplaceListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs @@ -24,28 +24,28 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class WorkplaceListPage : IDisposable +public partial class AdvisorWorkplaceListPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } - [Inject] public HttpInterceptorService _interceptor { get; set; } + [Inject] private IAdvisorWorkplaceRepository Workplaces { get; set; } + [Inject] private IAdvisorCustomerRepository _companyRepo { get; set; } + [Inject] private HttpInterceptorService _interceptor { get; set; } private List _workplaces { get; set; } = new(); - private CompanyDto _company { get; set; } = new(); + private CompanyDto Company { get; set; } = new(); private bool Working { get; set; } = true; protected override async Task OnParametersSetAsync() { _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _company = await _companyRepo.GetCompanyById(CompanyId); + Company = await _companyRepo.GetCompanyById(CompanyId); Working = false; } protected override async Task OnInitializedAsync() { Working = true; - _workplaces = await CrmWorkplaceRepo.GetWorkplaces(CompanyId); + _workplaces = await Workplaces.GetWorkplaces(CompanyId); Working = false; } diff --git a/Wonky.Client/Pages/WorkplaceViewPage.razor b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor similarity index 69% rename from Wonky.Client/Pages/WorkplaceViewPage.razor rename to Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor index d95453d3..307977ba 100644 --- a/Wonky.Client/Pages/WorkplaceViewPage.razor +++ b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor @@ -19,13 +19,13 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @attribute [Authorize(Roles = "Advisor")] -@page "/companies/{CompanyId}/workplaces/{WorkplaceId}" - +@page "/advisor/customers/{CompanyId}/workplaces/{WorkplaceId}" +@Workplace.CompanyName - @Workplace.Name
-

@_workplace.CompanyName

-

@_workplace.Name @(!string.IsNullOrWhiteSpace(_workplace.Description) ? $"- {_workplace.Description}" : "")

+

@Workplace.CompanyName

+

@Workplace.Name @(!string.IsNullOrWhiteSpace(Workplace.Description) ? $"- {Workplace.Description}" : "")

@@ -44,13 +44,13 @@ Navn - - + + Beskrivelse - - + + @@ -59,48 +59,48 @@ Produkter - - + + Masker - - + + Øjenskylleflaske - - + + Handsker - - + + Førstehjælp - - + + Sikkerhedsbriller - - + + Affald - - + + @@ -114,7 +114,7 @@
diff --git a/Wonky.Client/Pages/WorkplaceViewPage.razor.cs b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs similarity index 70% rename from Wonky.Client/Pages/WorkplaceViewPage.razor.cs rename to Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs index 479f2146..f40f8ce2 100644 --- a/Wonky.Client/Pages/WorkplaceViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs @@ -25,15 +25,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class WorkplaceViewPage : IDisposable +public partial class AdvisorWorkplaceViewPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string WorkplaceId { get; set; } = ""; - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public NavigationManager _navigator { get; set; } - private WorkplaceDto _workplace { get; set; } = new(); + [Inject] private IAdvisorWorkplaceRepository Workplaces { get; set; } + [Inject] private IAdvisorCustomerRepository _companyRepo { get; set; } + [Inject] private HttpInterceptorService _interceptor { get; set; } + [Inject] private NavigationManager _navigator { get; set; } + private WorkplaceDto Workplace { get; set; } = new(); private EditContext _editContext { get; set; } private bool Working { get; set; } = true; @@ -42,27 +42,27 @@ public partial class WorkplaceViewPage : IDisposable _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _workplace = await CrmWorkplaceRepo.GetWorkplace(CompanyId, WorkplaceId); + Workplace = await Workplaces.GetWorkplace(CompanyId, WorkplaceId); Working = false; } protected override void OnInitialized() { - _editContext = new EditContext(_workplace); + _editContext = new EditContext(Workplace); } private async Task SubmitUpdate() { Working = true; - await CrmWorkplaceRepo.UpdateWorkplace(CompanyId, _workplace); + await Workplaces.UpdateWorkplace(CompanyId, Workplace); Working = false; } private async Task DeleteWorkplace() { Working = true; - await CrmWorkplaceRepo.DeleteWorkplace(CompanyId, _workplace.WorkplaceId); - _navigator.NavigateTo($"/companies/{CompanyId}/workplaces"); + await Workplaces.DeleteWorkplace(CompanyId, Workplace.WorkplaceId); + _navigator.NavigateTo($"/advisor/customers/{CompanyId}/workplaces"); } public void Dispose() diff --git a/Wonky.Client/Pages/CatalogPage.razor b/Wonky.Client/Pages/CatalogCountryPage.razor similarity index 83% rename from Wonky.Client/Pages/CatalogPage.razor rename to Wonky.Client/Pages/CatalogCountryPage.razor index 6f941ed9..49bbfd1e 100644 --- a/Wonky.Client/Pages/CatalogPage.razor +++ b/Wonky.Client/Pages/CatalogCountryPage.razor @@ -15,11 +15,14 @@ // *@ -@page "/price-catalog" -@using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components -@attribute [Authorize(Roles = "Advisor,Admin,Office")] +@attribute [Authorize(Roles = "Admin,Advisor,Office,Supervisor,Warehouse")] +@page "/catalog" +@page "/catalog/{CountryCode}" + +Produkt Katalog @CountryName
@@ -42,11 +45,13 @@
- + + + @if (Working) { diff --git a/Wonky.Client/Pages/CatalogPage.razor.cs b/Wonky.Client/Pages/CatalogCountryPage.razor.cs similarity index 51% rename from Wonky.Client/Pages/CatalogPage.razor.cs rename to Wonky.Client/Pages/CatalogCountryPage.razor.cs index da655145..b8d085dc 100644 --- a/Wonky.Client/Pages/CatalogPage.razor.cs +++ b/Wonky.Client/Pages/CatalogCountryPage.razor.cs @@ -13,109 +13,122 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using System.Text.Json; using Blazored.LocalStorage; using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpRepository; using Microsoft.AspNetCore.Components; -using Wonky.Client.Components; +using Wonky.Client.Helpers; using Wonky.Client.HttpInterfaces; using Wonky.Client.Services; -using Wonky.Entity.DTO; using Wonky.Entity.Requests; using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class CatalogPage : IDisposable +public partial class CatalogCountryPage : IDisposable { - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository ItemRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public UserProfileService ProfileService { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private ICountryCatalogRepository Catalog { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + + [Parameter] public string CountryCode { get; set; } = ""; + private List Items { get; set; } = new(); private MetaData MetaInfo { get; set; } = new(); - private CatalogPagingParams PageParams = new(); - private UserPref Prefs = new(); + private CatalogPager Pager { get; set; } = new(); + private UserPref Prefs { get; set; } = new(); private UserInfoView UserInfo { get; set; } = new(); - private bool Working { get; set; } = true; - + private bool Working { get; set; } + private string CountryName { get; set; } = ""; + protected override async Task OnInitializedAsync() { Prefs = await ProfileService.GetPreferences(); UserInfo = await Storage.GetItemAsync("_xu"); - - PageParams.CountryCode = UserInfo.CountryCode; - - PageParams.OrderBy = Prefs.ItemSort; - PageParams.SearchColumn = Prefs.ItemSearch; - PageParams.PageSize = Convert.ToInt32(Prefs.PageSize); + + Pager.OrderBy = Prefs.ItemSort; + Pager.SearchColumn = Prefs.ItemSearch; + Pager.PageSize = Convert.ToInt32(Prefs.PageSize); + Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); + + if (string.IsNullOrWhiteSpace(CountryCode)) + { + while (string.IsNullOrWhiteSpace(UserInfo.CountryCode)) + await Task.Delay(500); + + CountryCode = UserInfo.CountryCode.ToLower(); + Navigator.NavigateTo($"/catalog/{CountryCode}", false, true); + } - await FetchSalesItems(); + CountryName = Utils.CountryName(CountryCode); + await GetCatalogPaged(); } private async Task SetSearchPhrase(string searchTerm) { Items = new List(); - PageParams.PageNumber = 1; - PageParams.SearchTerm = searchTerm; - await FetchSalesItems(); + Pager.PageNumber = 1; + Pager.SearchTerm = searchTerm; + await GetCatalogPaged(); } private async Task SetPageSize(string pageSize) { Items = new List(); - PageParams.PageSize = Convert.ToInt32(pageSize); - PageParams.PageNumber = 1; - await FetchSalesItems(); + Pager.PageSize = Convert.ToInt32(pageSize); + Pager.PageNumber = 1; + await GetCatalogPaged(); } private async Task SetSearchCol(string columnName) { Items = new List(); - PageParams.PageNumber = 1; - PageParams.SearchColumn = columnName; - await FetchSalesItems(); + Pager.PageNumber = 1; + Pager.SearchColumn = columnName; + await GetCatalogPaged(); } private async Task SetSortCol(string orderBy) { Items = new List(); - PageParams.OrderBy = orderBy; - await FetchSalesItems(); + Pager.OrderBy = orderBy; + await GetCatalogPaged(); } private async Task SetSelectedPage(int page) { Items = new List(); - PageParams.PageNumber = page; - await FetchSalesItems(); + Pager.PageNumber = page; + await GetCatalogPaged(); } private async Task SetGroupCol(string groupFilter) { Items = new List(); - PageParams.PageNumber = 1; - PageParams.SelectGroup = groupFilter; - await FetchSalesItems(); + Pager.PageNumber = 1; + Pager.SelectGroup = groupFilter; + await GetCatalogPaged(); } - - private async Task FetchSalesItems() + + private async Task GetCatalogPaged() { + if (string.IsNullOrWhiteSpace(CountryCode)) + return; + if (Working) + return; Working = true; - var pagingResponse = await ItemRepo.GetSalesItemsPaged(PageParams); + var page = await Catalog.GetSalesItemsPaged(CountryCode, Pager); + Items = page.Items!; + MetaInfo = page.MetaData!; Working = false; - Items = pagingResponse.Items!; - MetaInfo = pagingResponse.MetaData; - } - - + public void Dispose() => Interceptor.DisposeEvent(); } \ No newline at end of file diff --git a/Wonky.Client/Pages/PrintCatalogPage.razor b/Wonky.Client/Pages/CatalogCountryPrintPage.razor similarity index 78% rename from Wonky.Client/Pages/PrintCatalogPage.razor rename to Wonky.Client/Pages/CatalogCountryPrintPage.razor index ccced787..6c8cb462 100644 --- a/Wonky.Client/Pages/PrintCatalogPage.razor +++ b/Wonky.Client/Pages/CatalogCountryPrintPage.razor @@ -15,13 +15,15 @@ // *@ -@page "/print/catalog" @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Admin,Advisor,Office,Supervisor,Warehouse")] +@page "/catalog/{CountryCode}/print" -@attribute [Authorize(Roles = "Admin,Advisor,Office,Warehouse")] +Udskriv Katalog for @CountryName + + - @if (Working) { diff --git a/Wonky.Client/Pages/PrintCatalogPage.razor.cs b/Wonky.Client/Pages/CatalogCountryPrintPage.razor.cs similarity index 72% rename from Wonky.Client/Pages/PrintCatalogPage.razor.cs rename to Wonky.Client/Pages/CatalogCountryPrintPage.razor.cs index a7246b2b..82605594 100644 --- a/Wonky.Client/Pages/PrintCatalogPage.razor.cs +++ b/Wonky.Client/Pages/CatalogCountryPrintPage.razor.cs @@ -21,6 +21,7 @@ using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; using Microsoft.AspNetCore.Components; using Wonky.Client.Components; +using Wonky.Client.Helpers; using Wonky.Client.HttpInterfaces; using Wonky.Client.Services; using Wonky.Entity.DTO; @@ -29,22 +30,22 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class PrintCatalogPage : IDisposable +public partial class CatalogCountryPrintPage : IDisposable { - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository ItemRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private ICountryCatalogRepository Catalog { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Parameter] public string CountryCode { get; set; } = ""; private List Items { get; set; } = new(); - private UserInfoView UserInfo { get; set; } = new(); private bool Working { get; set; } = true; + private string CountryName { get; set; } = ""; - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - UserInfo = await Storage.GetItemAsync("_xu"); - - Items = await ItemRepo.GetPriceList(); + Items = await Catalog.GetPriceList(CountryCode); + CountryName = Utils.CountryName(CountryCode); Working = false; } diff --git a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor b/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor deleted file mode 100644 index 16a620c4..00000000 --- a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor +++ /dev/null @@ -1,23 +0,0 @@ -@page "/companies/{CompanyId}/invoices" -@using Wonky.Client.Components - -@if (!string.IsNullOrWhiteSpace(Company.Name)) -{ -
-
-

@Company.Name

-
- -
- Besøg -
-
- -} - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs deleted file mode 100644 index 4e8731ed..00000000 --- a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Globalization; -using System.Net.NetworkInformation; -using System.Text.Json; -using Blazored.LocalStorage; -using Blazored.Toast.Services; -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class CustomerInvoiceListCrmPage : IDisposable -{ - [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } - [Inject] public IToastService Toaster { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ILogger Logger { get; set; } - private InvoiceListView CompanyInvoices { get; set; } = new(); - private CompanyDto Company { get; set; } = new(); - private bool Working { get; set; } = true; - - protected override async Task OnInitializedAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - - Company = await CompanyRepo.GetCompanyById(CompanyId); - while (string.IsNullOrWhiteSpace(Company.HistorySync)) - { - await Task.Delay(1000); - } - - var iDate = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-iDate"); - if (string.IsNullOrWhiteSpace(iDate) || (iDate == Company.HistorySync && iDate != $"{DateTime.Now:yyyy-MM-dd}")) - { - // send rpc to sync invoices from ERP to CRM - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); - // wait until we have the result - while (string.IsNullOrWhiteSpace(ts)) - { - await Task.Delay(1000); - } - await Storage.SetItemAsync($"{Company.CompanyId}-iDate", ts); - } - - CompanyInvoices = await FetchCompanyInvoices(); - Working = false; - } - - private async Task FetchCompanyInvoices() - { - var storage = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-invoices"); - var iDate = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-iDate"); - // if we have a list and iDate was today return the list - if (!string.IsNullOrWhiteSpace(storage) && DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now) - { - Logger.LogDebug("return invoices from storage"); - return JsonSerializer.Deserialize(storage); - } - Logger.LogDebug("pulling invoices from backend"); - // pull invoices - var invoices = await HistoryRepo.FetchInvoiceList(CompanyId); - // send invoices to storage - await Storage.SetItemAsync($"{Company.CompanyId}-invoices", invoices); - Logger.LogDebug("return invoices from backend"); - return invoices; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} diff --git a/Wonky.Client/Pages/CustomerListOfficePage.razor b/Wonky.Client/Pages/CustomerListOfficePage.razor deleted file mode 100644 index b84981ef..00000000 --- a/Wonky.Client/Pages/CustomerListOfficePage.razor +++ /dev/null @@ -1,61 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Wonky.Client.Components -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin,Office,Warehouse")] -@page "/office/companies/{CountryCode}" - -
-
-
-
- -
-
- -
-
- -
-
- -
-
-
-
-
- - -
-
-
- -
- -
-
-
- - - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/CustomerListOfficePage.razor.cs b/Wonky.Client/Pages/CustomerListOfficePage.razor.cs deleted file mode 100644 index 60f5345c..00000000 --- a/Wonky.Client/Pages/CustomerListOfficePage.razor.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.Services; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.Pages; - -public partial class CustomerListOfficePage : IDisposable -{ - [Parameter] public string UserId { get; set; } = ""; - [Parameter] public string CountryCode { get; set; } = "dk"; - - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository CustomerRepo { get; set; } - [Inject] public UserProfileService UserProfileService { get; set; } - private List _companyList { get; set; } = new(); - private MetaData _metaData { get; set; } = new(); - private CompanyPagingParams _paging = new(); - private UserPref UserPref { get; set; } = new(); - private string _savedSearch { get; set; } = ""; - private bool _includeFolded { get; set; } - private bool Working { get; set; } = true; - - protected override async Task OnParametersSetAsync() - { - Interceptor.DisposeEvent(); - Interceptor.RegisterBeforeSendEvent(); - - // set preferences - UserPref = await UserProfileService.GetPreferences(); - - _paging.CountryCode = CountryCode; - - _paging.OrderBy = UserPref.CompanySort; - _paging.SearchColumn = UserPref.CompanySearch; - _paging.PageSize = Convert.ToInt32(UserPref.PageSize); - _paging.HasFolded = _includeFolded ? 1 : 0; - - // load saved search - _savedSearch = UserPref.CompanyFilterPhrase; - _paging.SearchTerm = _savedSearch; - - await FetchCompanies(); - Working = false; - } - - private async Task OnFoldedClick() - { - _includeFolded = !_includeFolded; - _companyList = new List(); - _paging.PageNumber = 1; - _paging.HasFolded = _includeFolded ? 1 : 0; - await FetchCompanies(); - } - - private async Task SelectedPage(int page) - { - _companyList = new List(); - _paging.PageNumber = page; - await FetchCompanies(); - } - - private async Task SetSearchCol(string searchColumn) - { - _companyList = new List(); - _paging.SearchColumn = searchColumn; - _paging.PageNumber = 1; - await FetchCompanies(); - } - private async Task SetPageSize(string pageSize) - { - _companyList = new List(); - _paging.PageSize = Convert.ToInt32(pageSize); - _paging.PageNumber = 1; - await FetchCompanies(); - } - - private async Task SetSearchPhrase(string searchTerm) - { - // if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.Length < 3) return; - - _companyList = new List(); - _paging.PageNumber = 1; - _paging.SearchTerm = searchTerm; - await FetchCompanies(); - if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.TrimEnd().Length > 2) - { - _savedSearch = searchTerm; - await UserProfileService.SetCompanyFilterPhrase(searchTerm.Trim()); - } - } - - private async Task SetSortCol(string orderBy) - { - _companyList = new List(); - _paging.OrderBy = orderBy; - await FetchCompanies(); - } - - private async Task FetchCompanies() - { - Working = true; - var pagingResponse = await CustomerRepo.GetCompaniesPagedSalesRep(UserId, _paging); - _companyList = pagingResponse.Items; - _metaData = pagingResponse.MetaData; - Working = false; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs deleted file mode 100644 index d0b20dd4..00000000 --- a/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using System.Globalization; -using System.Text.Json; -using Blazored.LocalStorage; -using Blazored.Toast.Services; -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class CustomerProductListCrmPage : IDisposable -{ - [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IToastService Toaster { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } - private JsonSerializerOptions _options = new JsonSerializerOptions(JsonSerializerDefaults.Web); - private CompanyDto Company { get; set; } = new(); - private List Inventory { get; set; } = new(); - private bool Working { get; set; } = true; - - protected override async Task OnInitializedAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - - Company = await CompanyRepo.GetCompanyById(CompanyId); - - while (string.IsNullOrWhiteSpace(Company.HistorySync)) - { - await Task.Delay(1000); - } - - var pDate = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-pDate"); - if (string.IsNullOrWhiteSpace(pDate) || (pDate == Company.HistorySync && pDate != $"{DateTime.Now:yyyy-MM-dd}")) - { - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); - while (string.IsNullOrWhiteSpace(ts)) - { - await Task.Delay(1000); - } - await Storage.SetItemAsync($"{Company.CompanyId}-pDate", ts); - } - // fetch product inventory - Inventory = await FetchProductInventory(); - Logger.LogDebug("CustomerProductListCrmPage => Inventory <= {}", JsonSerializer.Serialize(Inventory, _options)); - Working = false; - } - - private async Task> FetchProductInventory() - { - var storage = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-products"); - var pDate = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-pDate"); - // if we have a list and pDate was today return the list - if (!string.IsNullOrWhiteSpace(storage) || DateTime.Parse(pDate.Replace("\"", "")) >= DateTime.Now) - { - Logger.LogDebug("return products from storage"); - return JsonSerializer.Deserialize>(storage); - } - Logger.LogDebug("pulling products from backend"); - // fetch product history - var inventory = await HistoryRepo.FetchInventory(CompanyId); - // default sort order by description - inventory = inventory.Any() ? inventory.OrderBy(x => x.Description).ToList() : new List(); - // send products to storage - await Storage.SetItemAsync($"{Company.CompanyId}-products", inventory); - Logger.LogDebug("return products from backend"); - return inventory; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} diff --git a/Wonky.Client/Pages/ErrorPage401.razor b/Wonky.Client/Pages/ErrorPage401.razor index dfd9abb3..1a57ddf5 100644 --- a/Wonky.Client/Pages/ErrorPage401.razor +++ b/Wonky.Client/Pages/ErrorPage401.razor @@ -16,6 +16,7 @@ *@ @page "/401" +Fejl 401
diff --git a/Wonky.Client/Pages/ErrorPage404.razor b/Wonky.Client/Pages/ErrorPage404.razor index fec60876..eeb6b1e7 100644 --- a/Wonky.Client/Pages/ErrorPage404.razor +++ b/Wonky.Client/Pages/ErrorPage404.razor @@ -17,6 +17,7 @@ @page "/page404" @page "/404" +Fejl 404
diff --git a/Wonky.Client/Pages/ErrorPage404.razor.cs b/Wonky.Client/Pages/ErrorPage404.razor.cs index c22a2502..33f18895 100644 --- a/Wonky.Client/Pages/ErrorPage404.razor.cs +++ b/Wonky.Client/Pages/ErrorPage404.razor.cs @@ -19,9 +19,9 @@ namespace Wonky.Client.Pages; public partial class ErrorPage404 { - [Inject] public NavigationManager NavigationManager { get; set; } + [Inject] private NavigationManager NavigationManager { get; set; } - public void NavigateToHome() + private void NavigateToHome() { // preserving the uri for later navigation var currUri = NavigationManager.Uri; diff --git a/Wonky.Client/Pages/ErrorPage500.razor b/Wonky.Client/Pages/ErrorPage500.razor index 17a568d0..ac123d2f 100644 --- a/Wonky.Client/Pages/ErrorPage500.razor +++ b/Wonky.Client/Pages/ErrorPage500.razor @@ -17,6 +17,7 @@ @page "/error" @page "/500" +Fejl 500
diff --git a/Wonky.Client/Pages/ErrorReportPage.razor b/Wonky.Client/Pages/ErrorReportPage.razor index da38f683..a29acc6f 100644 --- a/Wonky.Client/Pages/ErrorReportPage.razor +++ b/Wonky.Client/Pages/ErrorReportPage.razor @@ -16,6 +16,7 @@ *@ @page "/report-error/{errorCode:int}/{errorDescription}" +Fejlrapport

@ErrorCode

@ErrorDescription

diff --git a/Wonky.Client/Pages/Index.razor b/Wonky.Client/Pages/Index.razor index 743e4de5..b24eddcf 100644 --- a/Wonky.Client/Pages/Index.razor +++ b/Wonky.Client/Pages/Index.razor @@ -15,25 +15,19 @@ // *@ +@using Wonky.Client.Components; +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Admin,Advisor,Office,Supervisor,Warehouse")] @page "/" @page "/index" @page "/home" -@using Wonky.Client.Components; -@using Microsoft.AspNetCore.Authorization - - -@attribute [Authorize(Roles = "Advisor,Admin,Supervisor,Office,Warehouse")] - +Innotec Danmark A/S - - - - - - + + @code{ diff --git a/Wonky.Client/Pages/InfoPage.razor b/Wonky.Client/Pages/InfoPage.razor index 5d78d83b..a6e68da8 100644 --- a/Wonky.Client/Pages/InfoPage.razor +++ b/Wonky.Client/Pages/InfoPage.razor @@ -20,8 +20,8 @@ @using Wonky.Entity.Configuration @using Microsoft.AspNetCore.Authorization @page "/info" - -@attribute [Authorize(Roles = "Advisor,Admin,Office,Warehouse")] +App Information +@attribute [Authorize(Roles = "Admin,Advisor,Office,Supervisor,Warehouse")]
@@ -31,38 +31,36 @@
-
-

Piktogrammer

- +

Piktogrammer

+
+
-
-
-
-

Testede browsere

-
    -
  • Safari (macOS, iOS)
  • -
  • Chrome (Linux, Windows, Android)
  • -
  • Edge (Linux, Windows, Android)
  • -
  • Firefox (Linux, Windows, Android)
  • -
  • Chromium (Linux)
  • -
  • Vivaldi (Linux)
  • -
+
+
-
-
-
-

Open Source

- +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
diff --git a/Wonky.Client/Pages/KrvItemViewAdminPage.razor b/Wonky.Client/Pages/KrvItemViewAdminPage.razor deleted file mode 100644 index 9603d279..00000000 --- a/Wonky.Client/Pages/KrvItemViewAdminPage.razor +++ /dev/null @@ -1,68 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@page "/sales-item/{salesItemId}" -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Advisor,Admin")] - - -
-
-

@_item.Name

-
-
- - - - - - - - - - - - - - - - - - - -
Navn@_item.Name
Varenr@_item.Sku
@_item.ProductGroup
Kort Navn@_item.ShortName
- - - - - - - - @foreach (var rate in _item.Rates) - { - - - - - } - -
Priser
@rate.Quantity@rate.Rate
-
- -
\ No newline at end of file diff --git a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs b/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs deleted file mode 100644 index 70819c02..00000000 --- a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using System; -using System.Threading.Tasks; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpRepository; -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterfaces; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class KrvItemViewAdminPage : IDisposable -{ - [Parameter] public string SalesItemId { get; set; } = ""; - private SalesItemView _item { get; set; } = new (); - [Inject] public ICatalogHttpRepository _itemRepo { get; set; } - [Inject] public HttpInterceptorService _interceptor { get; set; } - - - protected override async Task OnInitializedAsync() - { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); - _item = await _itemRepo.GetSalesVariantId(SalesItemId); - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - _interceptor!.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.css b/Wonky.Client/Pages/KrvItemViewAdminPage.razor.css deleted file mode 100644 index 50839936..00000000 --- a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.css +++ /dev/null @@ -1,10 +0,0 @@ -/* item image preview */ -.image-name { - margin-left: 10px; -} -.image-preview { - width: auto; - max-width: 200px; - height: 100px; - margin-top: 15px; -} \ No newline at end of file diff --git a/Wonky.Client/Pages/LandingPageAdminAdvisers.razor b/Wonky.Client/Pages/LandingPageAdminAdvisers.razor deleted file mode 100644 index 3c76a205..00000000 --- a/Wonky.Client/Pages/LandingPageAdminAdvisers.razor +++ /dev/null @@ -1,39 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin")] -@page "/office/users/advisors" - -
-
-
-

Lande

-
-
-
- -
-
- -@code { - -} \ No newline at end of file diff --git a/Wonky.Client/Pages/LandingPageAdminUsers.razor b/Wonky.Client/Pages/LandingPageAdminUsers.razor deleted file mode 100644 index b7aa8857..00000000 --- a/Wonky.Client/Pages/LandingPageAdminUsers.razor +++ /dev/null @@ -1,37 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin")] -@page "/office/users/office" - -
-
-
-

Administrative brugere

-
-
-
-
- Danmark -
-
-
- -@code { - -} \ No newline at end of file diff --git a/Wonky.Client/Pages/Login.razor b/Wonky.Client/Pages/Login.razor index 5be25076..f036bff5 100644 --- a/Wonky.Client/Pages/Login.razor +++ b/Wonky.Client/Pages/Login.razor @@ -17,7 +17,7 @@ @using Wonky.Client.Components @page "/login/{returnUrl?}" - +App Login
@if (ShowAuthError) { diff --git a/Wonky.Client/Pages/Login.razor.cs b/Wonky.Client/Pages/Login.razor.cs index 3b08dffd..3cc13839 100644 --- a/Wonky.Client/Pages/Login.razor.cs +++ b/Wonky.Client/Pages/Login.razor.cs @@ -22,9 +22,9 @@ namespace Wonky.Client.Pages; public partial class Login { - [Inject] public NavigationManager NavigationManager { get; set; } - [Inject] public IAuthenticationService AuthenticationService { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] private NavigationManager NavigationManager { get; set; } + [Inject] private IAuthenticationService AuthenticationService { get; set; } + [Inject] private ILogger Logger { get; set; } [Parameter] public string ReturnUrl { get; set; } private CredentialDto _credentialDto = new (); private bool ShowAuthError { get; set; } @@ -45,7 +45,7 @@ public partial class Login } else { - Logger.LogInformation($"returnUrl={ReturnUrl}"); + Logger.LogInformation("returnUrl={}", ReturnUrl); var returnUrl = string.IsNullOrWhiteSpace(ReturnUrl) ? "/" : ReturnUrl; NavigationManager.NavigateTo(returnUrl); } diff --git a/Wonky.Client/Pages/Logout.razor.cs b/Wonky.Client/Pages/Logout.razor.cs index a855c368..5a9fed52 100644 --- a/Wonky.Client/Pages/Logout.razor.cs +++ b/Wonky.Client/Pages/Logout.razor.cs @@ -22,9 +22,9 @@ namespace Wonky.Client.Pages; public partial class Logout { - [Inject] public IAuthenticationService AuthenticationService { get; set; } - [Inject] public NavigationManager NavigationManager { get; set; } - [Inject] public ILocalStorageService LocalStorage { get; set; } + [Inject] private IAuthenticationService AuthenticationService { get; set; } + [Inject] private NavigationManager NavigationManager { get; set; } + [Inject] private ILocalStorageService LocalStorage { get; set; } protected override async Task OnInitializedAsync() { diff --git a/Wonky.Client/Pages/OfficeCustomerCountryListPage.razor b/Wonky.Client/Pages/OfficeCustomerCountryListPage.razor new file mode 100644 index 00000000..703ef319 --- /dev/null +++ b/Wonky.Client/Pages/OfficeCustomerCountryListPage.razor @@ -0,0 +1,70 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] + +@page "/office/customers/{countryCode}" + +Kunde oversigt @CountryCode +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + @* +
+ + +
+ *@ +
+
+ +
+
+
+
+ Loading... +
+
+
+
+
+ + + +@if (Working) +{ + +} + diff --git a/Wonky.Client/Pages/OfficeCustomerCountryListPage.razor.cs b/Wonky.Client/Pages/OfficeCustomerCountryListPage.razor.cs new file mode 100644 index 00000000..1cc9acc2 --- /dev/null +++ b/Wonky.Client/Pages/OfficeCustomerCountryListPage.razor.cs @@ -0,0 +1,146 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Blazored.LocalStorage; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Services; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages +{ + public partial class OfficeCustomerCountryListPage : IDisposable + { + [Parameter] public string CountryCode { get; set; } = ""; + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } + [Inject] private ICountryCustomerRepository CustomerRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + private List Companies { get; set; } = new(); + private UserPref Prefs { get; set; } = new(); + private UserInfoView UserInfo { get; set; } = new(); + private string SavedSearch { get; set; } = ""; + private bool IncludeFolded { get; set; } + private bool Working { get; set; } = true; + private MetaData PageData { get; set; } = new(); + private CustomerPaging Paging { get; set; } = new(); + private string ButtonFoldedText { get; set; } = "Vis Ophørte"; + + protected override async Task OnParametersSetAsync() + { + Working = true; + + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + // set preferences + Prefs = await ProfileService.GetPreferences(); + UserInfo = await Storage.GetItemAsync("_xu"); + Paging.OrderBy = Prefs.CompanySort; + Paging.SearchColumn = Prefs.CompanySearch; + Paging.PageSize = Convert.ToInt32(Prefs.PageSize); + Paging.HasFolded = IncludeFolded ? 1 : 0; + + // load saved search + SavedSearch = string.IsNullOrWhiteSpace(Prefs.CompanyFilterPhrase) ? "" : Prefs.CompanyFilterPhrase; + Paging.SearchTerm = SavedSearch; + + // get companies + await FetchCustomers(); + } + + private async Task OnFoldedClick() + { + Working = true; + IncludeFolded = !IncludeFolded; + ButtonFoldedText = IncludeFolded ? "Vis Aktive" : "Vis Ophørte"; + Companies = new List(); + Paging.PageNumber = 1; + Paging.HasFolded = IncludeFolded ? 1 : 0; + await FetchCustomers(); + } + + private async Task SelectedPage(int page) + { + Working = true; + Companies = new List(); + Paging.PageNumber = page; + await FetchCustomers(); + } + + private async Task SetSearchCol(string searchColumn) + { + Working = true; + Companies = new List(); + Paging.SearchColumn = searchColumn; + Paging.PageNumber = 1; + await FetchCustomers(); + } + private async Task SetPageSize(string pageSize) + { + Working = true; + Companies = new List(); + Paging.PageSize = Convert.ToInt32(pageSize); + Paging.PageNumber = 1; + await FetchCustomers(); + } + + private async Task SetSearchPhrase(string searchTerm) + { + Working = true; + Companies = new List(); + Paging.PageNumber = 1; + Paging.SearchTerm = searchTerm; + await FetchCustomers(); + } + + private async Task SetSortCol(string orderBy) + { + Working = true; + Companies = new List(); + Paging.OrderBy = orderBy; + await FetchCustomers(); + } + + private async Task FetchCustomers() + { + Working = true; + var response = await CustomerRepo.GetCompaniesPaged(CountryCode, Paging); + Working = false; + if (response.Items.Any()) + { + Companies = response.Items; + PageData = response.MetaData; + } + else + { + Companies = new List(); + PageData = new MetaData(); + } + } + + public void Dispose() => Interceptor.DisposeEvent(); + } +} + + \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeCustomerCreatePhoneOrderPage.razor b/Wonky.Client/Pages/OfficeCustomerCreatePhoneOrderPage.razor new file mode 100644 index 00000000..481cc0d6 --- /dev/null +++ b/Wonky.Client/Pages/OfficeCustomerCreatePhoneOrderPage.razor @@ -0,0 +1,228 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] +@page "/office/customers/{CountryCode}/{CompanyId}/order" + +Telefon Ordre - @Customer.Name - @Customer.Account + +
+
+ +
+
+ +
+
+

@Customer.Name - @Customer.Account

+
+
+ + + + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+
+
+
+ + +
+
+ +
+ +
+ @* Order lines -----------------------------------------------------*@ +
+
+ + + + + + + + + + + + + + + + + + @if (DraftProvider.Draft.Items.Count > 0) + { + @foreach (var cartItem in DraftProvider.Draft.Items) + { + + + + + + + + + + } + } + + + + + + + +
+ Ordrekladde Global kladde (udløber efter @(DraftProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) + + +
NavnVarenrAntalEnhedspris%Linjesum
@cartItem.Item.Name@cartItem.Item.Sku@cartItem.Quantity@($"{cartItem.Price:N2}")@($"{cartItem.Discount:N2}")@($"{cartItem.LineTotal:N2}") + +
Total@($"{DraftProvider.Draft.Total:N2}") + +
+
+
+ @* draft line ----------------------------------------------------- *@ +
+
+ @if (!string.IsNullOrWhiteSpace(SelectedItem.Name) && ShowItem) + { + + + + + + + + + + + + + + + + + + + + + + +
Kladdelinje
AntalPrisRabatVarenr.
+ + +
+ + +
+
+ + @SelectedItem.Sku + +
+ } +
+
+ @* end draft line ------------------------------------------------- *@ +
+
+ @* Delivery address *@ +
+

+ +

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+
+ + \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeCustomerCreatePhoneOrderPage.razor.cs b/Wonky.Client/Pages/OfficeCustomerCreatePhoneOrderPage.razor.cs new file mode 100644 index 00000000..d729f0ef --- /dev/null +++ b/Wonky.Client/Pages/OfficeCustomerCreatePhoneOrderPage.razor.cs @@ -0,0 +1,214 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Text.Json; +using Wonky.Client.HttpInterceptors; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Models; +using Wonky.Client.Services; +using Wonky.Client.Shared; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class OfficeCustomerCreatePhoneOrderPage : IDisposable +{ + [Inject] private ILogger Logger { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private ICountryCustomerRepository CustomerRepo { get; set; } + [Inject] private ICountryCustomerHistoryRepository InventoryRepo { get; set; } + [Inject] private ICountryReportRepository ReportRepo { get; set; } + [Inject] private ISystemUserRepository UserRepo { get; set; } + [Inject] private ICountryCatalogRepository Catalog { get; set; } + // parameters + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public string CountryCode { get; set; } = ""; + [CascadingParameter] public DraftStateProvider DraftProvider { get; set; } + + // private variables + private readonly JsonSerializerOptions _options = new() {PropertyNameCaseInsensitive = true}; + // class objects + private CompanyDto Customer { get; set; } = new(); + private List CustomerInventory { get; set; } = new(); + private SalesItemView SelectedItem { get; set; } = new(); + private ActivityDto Activity { get; set; } = new(); + private WebUserInfoView SalesRep { get; set; } = new(); + // edit context + private EditContext ActivityContext { get; set; } + // variables + private DateTime SelectedDate { get; set; } + private bool ShowItem { get; set; } + private string Quantity { get; set; } = "1"; + private string Price { get; set; } = "0"; + private string Discount { get; set; } = "0"; + private bool ReportClosed { get; set; } + private bool PoFormInvalid { get; set; } = true; + private bool Working { get; set; } + private PriceCatalogModalOverlay CatalogOverlay { get; set; } = new(); + + + protected override async Task OnInitializedAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + // setup edit context + ActivityContext = new EditContext(Activity); + ActivityContext.OnFieldChanged += HandleFieldChanged; + ActivityContext.OnValidationStateChanged += ValidationChanged; + + // fetch customer + Customer = await CustomerRepo.GetByCustomerId(CountryCode, CompanyId); + Logger.LogDebug("Customer => {}", JsonSerializer.Serialize(Customer)); + // + // var today = $"{DateTime.Now:yyyy-MM-dd}"; + // + // // initiate a sync to ensure up-to-date product history + // if (Customer.HistorySync != today) + // Customer.HistorySync = await InventoryRepo.InvoiceErpToCrmRpc(CountryCode, CompanyId, Customer.HistorySync); + // + // // fetch customer inventory + // CustomerInventory = await InventoryRepo.FetchInventory(CountryCode, CompanyId); + // Logger.LogDebug("Inventory => {}", JsonSerializer.Serialize(CustomerInventory)); + // + // // get sales rep info + // SalesRep = await UserRepo.GetAdvisorInfo(Customer.SalesRepId); + // Logger.LogDebug("SalesRep => {}", JsonSerializer.Serialize(SalesRep)); + // + // // set activity salesRep and countryCode + // Activity.SalesRep = SalesRep.Advisor; + // Activity.CountryCode = SalesRep.CountryCode; + // + // // add customer info into activity properties + // Activity.Account = Customer.Account; + // Activity.VatNumber = Customer.VatNumber; + // Activity.Email = Customer.Email; + // Activity.Phone = Customer.Phone; + // Activity.Mobile = Customer.Mobile; + // Activity.Name = Customer.Name; + // Activity.Address1 = Customer.Address1; + // Activity.Address2 = Customer.Address2; + // Activity.ZipCode = Customer.ZipCode; + // Activity.City = Customer.City; + // Activity.DlvName = Customer.Name; + // Activity.DlvAddress1 = Customer.Address1; + // Activity.DlvAddress2 = Customer.Address2; + // Activity.DlvZipCode = Customer.ZipCode; + // Activity.DlvCity = Customer.City; + // Activity.BcId = Customer.BcId; + // Activity.CompanyId = Customer.CompanyId; + // Activity.SalesRepId = Customer.SalesRepId; + // + // // setting up activity properties + // Activity.ActivityStatusEnum = "noSale"; + // Activity.VisitTypeEnum = "recall"; + // Activity.ActivityTypeEnum = "phone"; + // Activity.ActivityStatusEnum = "order"; + // + // // Initialize date variable + // SelectedDate = DateTime.Now; + } + + private void CallPriceListModal() + { + CatalogOverlay.Show(); + } + + private async Task PriceListCallback(SelectedSku sku) + { + // get selected item + if (string.IsNullOrWhiteSpace(sku.ItemId)) + return; + SelectedItem = await Catalog.GetSalesItemId(CountryCode, sku.ItemId); + ShowItem = true; + Price = sku.Rate; + Quantity = sku.Quantity; + StateHasChanged(); + } + + private void CallPriceHistoryModal() + { + + } + + private void DeleteDraft() + { + + } + + private void AddItem(SalesItemView item) + { + + } + private void RemoveItem(DraftItem item) + { + + } + + private void CreateActivity() + { + + } + + /// + /// Work Date component callback + /// + /// + private async Task WorkDateComponentCallback(string workDate) + { + ReportClosed = await ReportRepo.ReportExist(Customer.SalesRepId, workDate); + SelectedDate = DateTime.Parse(workDate); + Activity.ActivityDate = workDate; + } + + /// + /// Edit Context handle field change + /// + /// + /// + private void HandleFieldChanged(object sender, FieldChangedEventArgs e) + { + PoFormInvalid = !ActivityContext.Validate(); + StateHasChanged(); + } + + /// + /// Edit Context handle validation change + /// + /// + /// + private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) + { + PoFormInvalid = false; + ActivityContext.OnFieldChanged -= HandleFieldChanged; + ActivityContext.OnValidationStateChanged -= ValidationChanged; + ActivityContext = new EditContext(Activity); + ActivityContext.OnFieldChanged += HandleFieldChanged; + ActivityContext.OnValidationStateChanged += ValidationChanged; + } + + /// + /// Implement Dispose from IDisposable + /// + public void Dispose() + { + Interceptor.DisposeEvent(); + ActivityContext.OnFieldChanged -= HandleFieldChanged; + ActivityContext.OnValidationStateChanged -= ValidationChanged; + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/OrderViewOfficePage.razor b/Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor similarity index 78% rename from Wonky.Client/Pages/OrderViewOfficePage.razor rename to Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor index ee590b0b..abb27222 100644 --- a/Wonky.Client/Pages/OrderViewOfficePage.razor +++ b/Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor @@ -17,36 +17,38 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components -@attribute [Authorize(Roles = "Admin,Office,Warehouse,Advisor")] +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] @page "/office/customers/{CompanyId}/orders/{OrderId}" - +@_reportItem.ESalesNumber - @_reportItem.Company.Name - @foreach (var line in _order.Lines) + @foreach (var line in Order.Lines) { @@ -93,10 +93,10 @@ }
- @if (_reportItem.Express) - { -
- +
+
+
+
- @if (_reportItem.ProcessStatusEnum == "None") + @if (_reportItem.Express) { - - -
-
-
- -
-
- -
+ @* +
+ +
+ *@ + @if (_reportItem.ProcessStatusEnum == "None") + { + + +
+
-
- - + + + } } - } +
+

@_reportItem.Company.Name

@if (_reportItem.Express) @@ -158,4 +160,4 @@ @if (Working) { -} +} \ No newline at end of file diff --git a/Wonky.Client/Pages/OrderViewOfficePage.razor.cs b/Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor.cs similarity index 83% rename from Wonky.Client/Pages/OrderViewOfficePage.razor.cs rename to Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor.cs index d22868ed..07d9324b 100644 --- a/Wonky.Client/Pages/OrderViewOfficePage.razor.cs +++ b/Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor.cs @@ -30,17 +30,17 @@ using Wonky.Client.Services; namespace Wonky.Client.Pages; -public partial class OrderViewOfficePage : IDisposable +public partial class OfficeCustomerOrderViewPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string OrderId { get; set; } = ""; - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } - [Inject] public ISendMailService MailService { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public IUserHttpRepository UserRepo { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public IToastService Toast { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private IAdvisorActivityRepository AdvisorActivityRepo { get; set; } + [Inject] private ISystemSendMailService MailService { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private ISystemUserRepository SystemUserRepo { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private IToastService Toast { get; set; } private ReportItemView _reportItem { get; set; } = new(); private bool _isNotified { get; set; } private bool Working { get; set; } = true; @@ -55,7 +55,7 @@ public partial class OrderViewOfficePage : IDisposable Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); // fetch order from backend - _reportItem = await ActivityRepo.GetReportItem(OrderId); + _reportItem = await AdvisorActivityRepo.GetReportItem(OrderId); Logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(_reportItem, _options)); Working = false; } @@ -71,12 +71,12 @@ public partial class OrderViewOfficePage : IDisposable Working = true; Logger.LogDebug("GetExpressState => {}", JsonSerializer.Serialize(_reportItem, _options)); // send request to backend - var responseView = await ActivityRepo.GetExpressState(_reportItem.ActivityId); + var responseView = await AdvisorActivityRepo.GetExpressState(_reportItem.ActivityId); Logger.LogDebug("SetExpressState => responseView <= {} ", JsonSerializer.Serialize(responseView)); // get user info from storage var user = await Storage.GetItemAsync("_xu"); // fetch sales rep from response - var salesRep = await UserRepo.GetAdvisorInfo(responseView.Id); + var salesRep = await SystemUserRepo.GetAdvisorInfo(responseView.Id); Logger.LogDebug("SetExpressState => salesRep => {}", JsonSerializer.Serialize(salesRep)); // create email notification body var body = new StringBuilder(); @@ -109,6 +109,7 @@ public partial class OrderViewOfficePage : IDisposable Logger.LogDebug("SetExpressState Notification => \n {}", JsonSerializer.Serialize(msg)); // send a system generated email var sendMail = await MailService.SendMail("System", msg); + // result notification if (sendMail.IsSuccess) { @@ -122,6 +123,7 @@ public partial class OrderViewOfficePage : IDisposable .ShowWarning( $"Notifikation til {salesRep.FirstName} kunne ikke sendes. {sendMail.Message}", "ADVARSEL"); } + Logger.LogDebug("SendMail Result => \n {}", JsonSerializer.Serialize(sendMail)); // disable further notifications _isNotified = true; Working = false; diff --git a/Wonky.Client/Pages/OrderViewOfficePage.razor.css b/Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor.css similarity index 50% rename from Wonky.Client/Pages/OrderViewOfficePage.razor.css rename to Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor.css index 6396fa53..fed02a26 100644 --- a/Wonky.Client/Pages/OrderViewOfficePage.razor.css +++ b/Wonky.Client/Pages/OfficeCustomerOrderViewPage.razor.css @@ -1,6 +1,6 @@ #watermark { - position: fixed; - z-index: 999; + position: absolute; + z-index: -999; top: 10px; right: 0; } \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeLandingPage.razor b/Wonky.Client/Pages/OfficeLandingPage.razor new file mode 100644 index 00000000..8115bb09 --- /dev/null +++ b/Wonky.Client/Pages/OfficeLandingPage.razor @@ -0,0 +1,86 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] +@page "/office/country" +Kunde oversigt @CountryCode +
+
+
+
Danmark
+ +
+
+ +
+ +
+ +
+
+
Sverige
+ +
+
+ +
\ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeLandingPage.razor.cs b/Wonky.Client/Pages/OfficeLandingPage.razor.cs new file mode 100644 index 00000000..4e2ca41c --- /dev/null +++ b/Wonky.Client/Pages/OfficeLandingPage.razor.cs @@ -0,0 +1,10 @@ +using Blazored.LocalStorage; +using Microsoft.AspNetCore.Components; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class OfficeLandingPage +{ + [Parameter] public string CountryCode { get; set; } = ""; +} \ No newline at end of file diff --git a/Wonky.Client/Pages/UserListSalesRepPage.razor b/Wonky.Client/Pages/OfficeUserAdvisorCustomerListPage.razor similarity index 69% rename from Wonky.Client/Pages/UserListSalesRepPage.razor rename to Wonky.Client/Pages/OfficeUserAdvisorCustomerListPage.razor index ef18369c..3fa5f28e 100644 --- a/Wonky.Client/Pages/UserListSalesRepPage.razor +++ b/Wonky.Client/Pages/OfficeUserAdvisorCustomerListPage.razor @@ -17,20 +17,22 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin,Office,Warehouse")] -@page "/office/users/advisors/{CountryCode}/{UserId}/companies" +@attribute [Authorize(Roles = "Admin,Office")] +@page "/office/users/advisors/{CountryCode}/{UserId}/customers" + +Kundeliste for @SalesRep.FirstName @SalesRep.LastName
- +
- +
- +
@@ -39,21 +41,21 @@
- +
- +
- + @if (Working) { diff --git a/Wonky.Client/Pages/UserListSalesRepPage.razor.cs b/Wonky.Client/Pages/OfficeUserAdvisorCustomerListPage.razor.cs similarity index 57% rename from Wonky.Client/Pages/UserListSalesRepPage.razor.cs rename to Wonky.Client/Pages/OfficeUserAdvisorCustomerListPage.razor.cs index 4b0fed7a..bca81efe 100644 --- a/Wonky.Client/Pages/UserListSalesRepPage.razor.cs +++ b/Wonky.Client/Pages/OfficeUserAdvisorCustomerListPage.razor.cs @@ -19,42 +19,44 @@ using Wonky.Client.HttpInterfaces; using Wonky.Client.Services; using Wonky.Entity.DTO; using Wonky.Entity.Requests; +using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class UserListSalesRepPage : IDisposable +public partial class OfficeUserAdvisorCustomerListPage : IDisposable { [Parameter] public string UserId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = "dk"; - - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository CustomerRepo { get; set; } - [Inject] public UserProfileService UserProfileService { get; set; } - private List _companyList { get; set; } = new(); - private MetaData _metaData { get; set; } = new(); - private CompanyPagingParams _paging = new(); + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private ICountryCustomerRepository CustomerRepo { get; set; } + [Inject] private UserProfileService UserProfileService { get; set; } + [Inject] private ISystemUserRepository UserRepo { get; set; } + private List CompanyList { get; set; } = new(); + private MetaData ResponseMeta { get; set; } = new(); + private CustomerPaging Paging = new(); private UserPref UserPref { get; set; } = new(); - private string _savedSearch { get; set; } = ""; - private bool _includeFolded { get; set; } + private string SavedSearch { get; set; } = ""; + private bool IncludeFolded { get; set; } private bool Working { get; set; } = true; + private WebUserInfoView SalesRep { get; set; } = new(); protected override async Task OnParametersSetAsync() { Interceptor.DisposeEvent(); Interceptor.RegisterBeforeSendEvent(); + SalesRep = await UserRepo.GetAdvisorInfo(UserId); + // set preferences UserPref = await UserProfileService.GetPreferences(); - _paging.CountryCode = CountryCode; - _paging.OrderBy = UserPref.CompanySort; - _paging.SearchColumn = UserPref.CompanySearch; - _paging.PageSize = Convert.ToInt32(UserPref.PageSize); - _paging.HasFolded = _includeFolded ? 1 : 0; + Paging.OrderBy = UserPref.CompanySort; + Paging.SearchColumn = UserPref.CompanySearch; + Paging.PageSize = Convert.ToInt32(UserPref.PageSize); + Paging.HasFolded = IncludeFolded ? 1 : 0; // load saved search - _savedSearch = UserPref.CompanyFilterPhrase; - _paging.SearchTerm = _savedSearch; + SavedSearch = UserPref.CompanyFilterPhrase; + Paging.SearchTerm = SavedSearch; await FetchCompanies(); Working = false; @@ -62,33 +64,33 @@ public partial class UserListSalesRepPage : IDisposable private async Task OnFoldedClick() { - _includeFolded = !_includeFolded; - _companyList = new List(); - _paging.PageNumber = 1; - _paging.HasFolded = _includeFolded ? 1 : 0; + IncludeFolded = !IncludeFolded; + CompanyList = new List(); + Paging.PageNumber = 1; + Paging.HasFolded = IncludeFolded ? 1 : 0; await FetchCompanies(); } private async Task SelectedPage(int page) { - _companyList = new List(); - _paging.PageNumber = page; + CompanyList = new List(); + Paging.PageNumber = page; await FetchCompanies(); } private async Task SetSearchCol(string searchColumn) { - _companyList = new List(); - _paging.SearchColumn = searchColumn; - _paging.PageNumber = 1; + CompanyList = new List(); + Paging.SearchColumn = searchColumn; + Paging.PageNumber = 1; await FetchCompanies(); } private async Task SetPageSize(string pageSize) { - _companyList = new List(); - _paging.PageSize = Convert.ToInt32(pageSize); - _paging.PageNumber = 1; + CompanyList = new List(); + Paging.PageSize = Convert.ToInt32(pageSize); + Paging.PageNumber = 1; await FetchCompanies(); } @@ -96,30 +98,30 @@ public partial class UserListSalesRepPage : IDisposable { // if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.Length < 3) return; - _companyList = new List(); - _paging.PageNumber = 1; - _paging.SearchTerm = searchTerm; + CompanyList = new List(); + Paging.PageNumber = 1; + Paging.SearchTerm = searchTerm; await FetchCompanies(); if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.TrimEnd().Length > 2) { - _savedSearch = searchTerm; + SavedSearch = searchTerm; await UserProfileService.SetCompanyFilterPhrase(searchTerm.Trim()); } } private async Task SetSortCol(string orderBy) { - _companyList = new List(); - _paging.OrderBy = orderBy; + CompanyList = new List(); + Paging.OrderBy = orderBy; await FetchCompanies(); } private async Task FetchCompanies() { Working = true; - var pagingResponse = await CustomerRepo.GetCompaniesPagedSalesRep(UserId, _paging); - _companyList = pagingResponse.Items; - _metaData = pagingResponse.MetaData; + var pagingResponse = await CustomerRepo.GetCompaniesPaged(CountryCode, UserId, Paging); + CompanyList = pagingResponse.Items; + ResponseMeta = pagingResponse.MetaData; Working = false; } diff --git a/Wonky.Client/Pages/UserListOfficePage.razor b/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor similarity index 90% rename from Wonky.Client/Pages/UserListOfficePage.razor rename to Wonky.Client/Pages/OfficeUserAdvisorListPage.razor index 2c97f745..eb5dcc36 100644 --- a/Wonky.Client/Pages/UserListOfficePage.razor +++ b/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor @@ -20,12 +20,14 @@ @attribute [Authorize(Roles = "Admin,Office")] @page "/office/users/advisors/{CountryCode}" +Sælger Oversigt @CountryName +

Sælgere

- +
diff --git a/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor.cs b/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor.cs new file mode 100644 index 00000000..53bb4e7e --- /dev/null +++ b/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Client.Helpers; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpInterfaces; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class OfficeUserAdvisorListPage :IDisposable +{ + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private ISystemUserRepository SystemUserRepo { get; set; } + [Parameter] public string CountryCode { get; set; } = ""; + private List SalesReps { get; set; } = new(); + private bool Working { get; set; } = true; + private string CountryName { get; set; } = ""; + + protected override async Task OnInitializedAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + CountryName = Utils.CountryName(CountryCode); + var AdvisorList = await SystemUserRepo.GetAdvisors(); + SalesReps = AdvisorList + .Where(x => x.CountryCode.ToLower() == CountryCode && Convert.ToInt32(x.SalesRep) < 100) + .ToList(); + Working = false; + } + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/ReportListOfficePage.razor b/Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor similarity index 80% rename from Wonky.Client/Pages/ReportListOfficePage.razor rename to Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor index 17b8a5c5..92939bfd 100644 --- a/Wonky.Client/Pages/ReportListOfficePage.razor +++ b/Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor @@ -17,14 +17,15 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin")] +@attribute [Authorize(Roles = "Admin,Office")] @page "/office/users/advisors/{CountryCode}/{UserId}/reports" +Rapport Arkiv @UserInfo.FirstName @UserInfo.LastName

Rapport Arkiv - @UserInfo.FirstName @UserInfo.LastName

- +
diff --git a/Wonky.Client/Pages/ReportListOfficePage.razor.cs b/Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor.cs similarity index 71% rename from Wonky.Client/Pages/ReportListOfficePage.razor.cs rename to Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor.cs index d2e990a9..5e41ba3c 100644 --- a/Wonky.Client/Pages/ReportListOfficePage.razor.cs +++ b/Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor.cs @@ -23,32 +23,46 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ReportListOfficePage : IDisposable +public partial class OfficeUserAdvisorReportListPage : IDisposable { [Parameter] public string UserId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = ""; - [Inject] public IOfficeReportHttpRepository ReportRepo { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IUserHttpRepository UserRepo { get; set; } - [Inject] public NavigationManager Navigator { get; set; } + [Inject] private ICountryReportRepository ReportRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private ISystemUserRepository SystemUserRepo { get; set; } + [Inject] private NavigationManager Navigator { get; set; } private List ActivityReports { get; set; } = new(); private bool Working { get; set; } = true; private WebUserInfoView UserInfo { get; set; } = new(); + /// + /// override OnParametersSeAsync + /// protected override async Task OnParametersSetAsync() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - UserInfo = await UserRepo.GetAdvisorInfo(UserId); + UserInfo = await SystemUserRepo.GetAdvisorInfo(UserId); + while (string.IsNullOrWhiteSpace(UserInfo.UserId)) + { + await Task.Delay(500); + } - var reports = await ReportRepo.GetReports(UserId); + var reports = await ReportRepo.GetCountryReports(UserId); if (reports.Any()) ActivityReports = reports.OrderByDescending(x => x.ReportDate).ToList(); - - Working = false; } + protected override void OnInitialized() + { + Working = false; + } + + /// + /// Callback to shoe the report + /// + /// private void ShowThisReport(string reportDate) { var uri = new Uri(Navigator.Uri); diff --git a/Wonky.Client/Pages/ReportViewOfficePage.razor b/Wonky.Client/Pages/OfficeUserAdvisorReportViewPage.razor similarity index 88% rename from Wonky.Client/Pages/ReportViewOfficePage.razor rename to Wonky.Client/Pages/OfficeUserAdvisorReportViewPage.razor index bc7311bb..3eb8c142 100644 --- a/Wonky.Client/Pages/ReportViewOfficePage.razor +++ b/Wonky.Client/Pages/OfficeUserAdvisorReportViewPage.razor @@ -18,8 +18,8 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Models +@attribute [Authorize(Roles = "Admin,Office")] @page "/office/users/advisors/{CountryCode}/{UserId}/reports/{ReportDate}" -@attribute [Authorize(Roles = "Admin")]
@@ -32,7 +32,7 @@
- +
@@ -41,7 +41,7 @@ { @Report.ReportData.Name
-
+

@Report.ReportData.Name

@@ -53,7 +53,7 @@
- + } else diff --git a/Wonky.Client/Pages/ReportViewOfficePage.razor.cs b/Wonky.Client/Pages/OfficeUserAdvisorReportViewPage.razor.cs similarity index 62% rename from Wonky.Client/Pages/ReportViewOfficePage.razor.cs rename to Wonky.Client/Pages/OfficeUserAdvisorReportViewPage.razor.cs index abb21d03..77c815ec 100644 --- a/Wonky.Client/Pages/ReportViewOfficePage.razor.cs +++ b/Wonky.Client/Pages/OfficeUserAdvisorReportViewPage.razor.cs @@ -14,98 +14,71 @@ // using Blazored.LocalStorage; +using Blazored.Toast.Services; using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using Wonky.Client.Helpers; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; using Wonky.Client.Models; using Wonky.Client.Services; +using Wonky.Client.Shared; +using Wonky.Entity.DTO; using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ReportViewOfficePage : IDisposable +public partial class OfficeUserAdvisorReportViewPage : IDisposable { - /// - /// Country code from url parameter - /// - [Parameter] - public string CountryCode { get; set; } = ""; - - /// - /// User entity Id from url parameter - /// - [Parameter] - public string UserId { get; set; } = ""; - - /// - /// Report Date - /// - [Parameter] - public string ReportDate { get; set; } = ""; - /// - /// Injected interceptor service - /// - [Inject] - public HttpInterceptorService Interceptor { get; set; } - - /// - /// Injected administrative report http repo - /// - [Inject] - public IOfficeReportHttpRepository ReportRepo { get; set; } - - /// - /// Navigation Manager - /// - [Inject] - public NavigationManager Navigator { get; set; } - - /// - /// Logger service - /// - [Inject] - public ILogger Logger { get; set; } - - /// - /// Storage service - /// - [Inject] - public ILocalStorageService Storage { get; set; } - - /// - /// Preference service - /// - [Inject] - public UserProfileService ProfileService { get; set; } - + [Parameter] public string CountryCode { get; set; } = ""; + [Parameter] public string UserId { get; set; } = ""; + [Parameter] public string ReportDate { get; set; } = ""; + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private ICountryReportRepository ReportRepo { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private UserProfileService ProfileService { get; set; } + [Inject] private IJSRuntime JSRuntime { get; set; } + [Inject] private IToastService Toaster { get; set; } + [Inject] private IOrderProcessRepository ProcessRepo { get; set; } + private IJSObjectReference JsModule { get; set; } private ReportView Report { get; set; } = new(); private List Activities { get; set; } = new(); private bool Working { get; set; } = true; private UserPref Prefs = new(); private string ReturnUrl = ""; private string PrintUrl = ""; - + protected override async Task OnParametersSetAsync() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - + ProfileService.OnChange += ProfileServiceOnOnChange; await ProfileService.SetWorkDate(DateTime.Parse(ReportDate)); - + await FetchUserReport(ReportDate); } + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + JsModule = await JSRuntime + .InvokeAsync("import", "/scripts/print-invoke.js"); + } + } private void Print(PTarget target) { ReturnUrl = new Uri(Navigator.Uri).AbsolutePath; switch (target) { case PTarget.OrderPage: - Navigator.NavigateTo($"/print/orders/{CountryCode}/{UserId}/{ReportDate}?returnUrl={ReturnUrl}"); + Navigator.NavigateTo($"/report/print/orders/{CountryCode}/{UserId}/{ReportDate}?returnUrl={ReturnUrl}"); break; case PTarget.FrontPage: - Navigator.NavigateTo($"/print/report/{CountryCode}/{UserId}/{ReportDate}?returnUrl={ReturnUrl}"); + Navigator.NavigateTo($"/report/print/summary/{CountryCode}/{UserId}/{ReportDate}?returnUrl={ReturnUrl}"); break; case PTarget.None: break; @@ -115,7 +88,26 @@ public partial class ReportViewOfficePage : IDisposable throw new ArgumentOutOfRangeException(nameof(target), target, null); } } - + + private async Task Print() + { + var current = 0; + var orders = Report.ReportItems + .Where(x => x is { StatusTypeEnum: "Order", ProcessStatusEnum: "None" } ); + var count = orders.Count(); + foreach (var item in orders) + { + Toaster.ShowInfo($"Behandler {current++} af {count} ordrer. Vent venligst"); + await ProcessRepo.UpdateWarehouseOrderStatus(new OrderProcessState + { + OrderId = item.ActivityId, + ProcessStatusEnum = Utils.EnumToString(PStatus.Accepted) + }); + } + Toaster.ClearAll(); + await JsModule.InvokeVoidAsync("printInvoke"); + } + /// /// Work date component event handler /// @@ -129,35 +121,35 @@ public partial class ReportViewOfficePage : IDisposable } ReportDate = workDate; - + // ensure the browser address bar contains the correct link Navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{workDate}", false, true); - + // return if we are already at it if (Working) { return; } - + // reset variables Report = new ReportView(); Activities = new List(); - + // set busy signal Working = true; - + // fetch report - Report = await ReportRepo.GetReport(UserId, workDate); - + Report = await ReportRepo.GetCountryReport(UserId, workDate); + // extract activities Activities = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); - + // store locally if (!string.IsNullOrWhiteSpace(Report.ReportData.ReportDate)) { await Storage.SetItemAsync($"{UserId}-{workDate}", Report); } - + // remove busy signal Working = false; } @@ -168,7 +160,7 @@ public partial class ReportViewOfficePage : IDisposable Prefs = userPref; Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange => Prefs.WorkDate <= {}", Prefs.WorkDate); ReportDate = Prefs.WorkDate; - + StateHasChanged(); } diff --git a/Wonky.Client/Pages/UserViewOfficePage.razor b/Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor similarity index 93% rename from Wonky.Client/Pages/UserViewOfficePage.razor rename to Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor index 39432332..0afeab52 100644 --- a/Wonky.Client/Pages/UserViewOfficePage.razor +++ b/Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor @@ -15,17 +15,17 @@ // *@ -@page "/office/users/advisors/{CountryCode}/{UserId}/view" @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @attribute [Authorize(Roles = "Admin")] +@page "/office/users/advisors/{CountryCode}/{UserId}/view"

Bruger info

- @if (_userInfo != null) + @if (!string.IsNullOrWhiteSpace(UserInfo.UserId)) { @@ -70,7 +70,7 @@ Sælgernr.
- @_userInfo.Advisor + @UserInfo.Advisor Landekode @@ -107,6 +107,11 @@

NULSTIL ADGANGSKODE

+
+

Password politik

+

Mindst 10 tegn bestående af store og små bogstaver samt tal.

+

Du kan teste pasword og danne stærke password på pw.nix.dk

+
diff --git a/Wonky.Client/Pages/UserViewOfficePage.razor.cs b/Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor.cs similarity index 70% rename from Wonky.Client/Pages/UserViewOfficePage.razor.cs rename to Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor.cs index 98f0e509..f178d85c 100644 --- a/Wonky.Client/Pages/UserViewOfficePage.razor.cs +++ b/Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor.cs @@ -26,19 +26,19 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class UserViewOfficePage : IDisposable +public partial class OfficeUserAdvisorViewEditPage : IDisposable { [Parameter] public string UserId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = ""; - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public IUserHttpRepository UserRepo { get; set; } - [Inject] public ILogger _logger { get; set; } - [Inject] public NavigationManager _navigator { get; set; } - [Inject] public IToastService _toast { get; set; } - private WebUserInfoView _userInfo { get; set; } = new(); + [Inject] private HttpInterceptorService _interceptor { get; set; } + [Inject] private ISystemUserRepository SystemUserRepo { get; set; } + [Inject] private ILogger _logger { get; set; } + [Inject] private NavigationManager _navigator { get; set; } + [Inject] private IToastService _toast { get; set; } + private WebUserInfoView UserInfo { get; set; } = new(); private EditContext _editContext { get; set; } private UserUpdateDto _updateInfo { get; set; } = new(); - private AdminResetPasswordDto _passwords { get; set; } = new(); + private ResetPasswordDto _passwords { get; set; } = new(); private EditContext _passwdContext { get; set; } private bool _pwInvalid { get; set; } = true; private bool Working { get; set; } = true; @@ -56,14 +56,14 @@ public partial class UserViewOfficePage : IDisposable _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _userInfo = await UserRepo.GetAdvisorInfo(UserId); + UserInfo = await SystemUserRepo.GetAdvisorInfo(UserId); - _updateInfo.Email = _userInfo.Email; - _updateInfo.CountryCode = _userInfo.CountryCode; - _updateInfo.FirstName = _userInfo.FirstName; - _updateInfo.LastName = _userInfo.LastName; - _updateInfo.PhoneNumber = _userInfo.PhoneNumber; - _updateInfo.LockoutEnabled = _userInfo.LockoutEnabled; + _updateInfo.Email = UserInfo.Email; + _updateInfo.CountryCode = UserInfo.CountryCode; + _updateInfo.FirstName = UserInfo.FirstName; + _updateInfo.LastName = UserInfo.LastName; + _updateInfo.PhoneNumber = UserInfo.PhoneNumber; + _updateInfo.LockoutEnabled = UserInfo.LockoutEnabled; _passwdContext.OnFieldChanged += PwHandleFieldChanged; _passwdContext.OnValidationStateChanged += PwValidationChanged; @@ -75,8 +75,10 @@ public partial class UserViewOfficePage : IDisposable { Working = true; _toast.ShowInfo("Sender data til server ..."); - await UserRepo.UpdateAdvisor(UserId, _updateInfo); + await SystemUserRepo.UpdateAdvisor(UserId, _updateInfo); Working = false; + _toast.ShowInfo("Sælger er opdateret ..."); + // _navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}"); } private void PwHandleFieldChanged(object sender, FieldChangedEventArgs e) @@ -103,11 +105,13 @@ public partial class UserViewOfficePage : IDisposable if (Working) return; Working = true; - await UserRepo.ResetUserPassword(UserId, _passwords.NewPassword, _passwords.ConfirmPassword); - _toast.ShowInfo("Password er nulstillet."); + _toast.ShowInfo("Nulstiller adgangskode."); + await SystemUserRepo.ResetUserPassword(UserId, _passwords.NewPassword, _passwords.ConfirmPassword); _passwords.NewPassword = ""; _passwords.ConfirmPassword = ""; Working = false; + _toast.ShowInfo("Adgangskode er nulstillet."); + // _navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}"); } public void Dispose() { diff --git a/Wonky.Client/Pages/OrderCreateOfficePage.razor b/Wonky.Client/Pages/OrderCreateOfficePage.razor deleted file mode 100644 index 30036b66..00000000 --- a/Wonky.Client/Pages/OrderCreateOfficePage.razor +++ /dev/null @@ -1,198 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Microsoft.AspNetCore.Authorization -@using Wonky.Client.Components -@attribute [Authorize(Roles = "Admin,Office,Warehouse")] -@page "/office/customers/{CompanyId}/orders/new" - - - -
- -
- -
- -
- -
- -
- -
- -
-
- -
- - -
- - -
- - -
-
- -
- -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - @if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0) - { - @foreach (var cartItem in DraftStateProvider.Draft.Items) - { - - - - - - - - - - } - } - - - - - - - - -
- Ordrekladde Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) - - -
NavnVarenrAntalEnhedsprisLinjesumSAS
@cartItem.Item.Name@cartItem.Item.Sku@cartItem.Quantity@cartItem.Price@cartItem.LineTotal - - - -
Total@DraftStateProvider.Draft.Total - -
-
-
-
-
- @* draft line *@ - @if (_selectedItem != null && ShowItem) - { - - - - - - - - - - - - - - - - - - - - - - - - -
Kladdelinje
AntalPrisRabatSASVarenr.
- - - - - - - - @_selectedItem.Sku - -
- } -
-
- -
-
-
- -
-
- -
-
- -
-
-
-
- -
-
- -
-
-
- - -
- - - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs b/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs deleted file mode 100644 index cf85067e..00000000 --- a/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using System.Globalization; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; -using Wonky.Client.Models; -using Wonky.Client.Shared; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class OrderCreateOfficePage : IDisposable -{ - [CascadingParameter] DraftStateProvider DraftStateProvider { get; set; } - [Parameter] public string CompanyId { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository OfficeCustomerRepo { get; set; } - [Inject] public IUserHttpRepository UserRepo { get; set; } - [Inject] public ICatalogHttpRepository CatalogRepo { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ILogger Logger { get; set; } - - private ActivityDto _activity { get; set; } = new(); - private EditContext _editContext { get; set; } - private PriceListModal _priceList { get; set; } = new(); - private CompanyDto _company { get; set; } = new(); - private WebUserInfoView _userInfo { get; set; } = new(); - private SalesItemView _selectedItem { get; set; } = new(); - private string Rate { get; set; } = "0"; - private string Quantity { get; set; } = "1"; - private string Price { get; set; } = "0"; - private string Discount { get; set; } = "0"; - private bool ShowItem { get; set; } - private bool Sas { get; set; } - private bool FormInvalid { get; set; } = true; - private bool HideButton { get; set; } - private bool Working { get; set; } = true; - - protected override async Task OnParametersSetAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - _company = await OfficeCustomerRepo.GetByCustomerId(CompanyId); - } - - protected override async Task OnInitializedAsync() - { - - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - - _userInfo = await UserRepo.GetAdvisorInfo(_company.SalesRepId); - - _activity.ActivityDate = $"{DateTime.Now:yyyy-MM-dd}" ; - - // variable to validate if customer needs phone number update - // _phone = _company.Phone; - if (string.IsNullOrWhiteSpace(_company.Phone) - && !string.IsNullOrWhiteSpace(_company.Account) - && _company.Account != "NY" && _company.Account.Length > 7) - { - _company.Phone = _company.Account[..8]; - } - - _activity.ActivityStatusEnum = "order"; - _activity.ActivityTypeEnum = "phone"; - - // set up identification - _activity.CompanyId = _company.CompanyId; - _activity.BcId = _company.BcId; - _activity.SalesRepId = _company.SalesRepId; - _activity.SalesRep = _company.SalesRep; - _activity.Account = _company.Account; - _activity.VatNumber = _company.VatNumber; - _activity.Email = _company.Email; - _activity.Phone = _company.Phone; - _activity.Mobile = _company.Mobile; - - _activity.Name = _company.Name; - _activity.Address1 = _company.Address1; - _activity.Address2 = _company.Address2; - _activity.ZipCode = _company.ZipCode; - _activity.City = _company.City; - - _activity.DlvName = _company.Name; - _activity.DlvAddress1 = _company.Address1; - _activity.DlvAddress2 = _company.Address2; - _activity.DlvZipCode = _company.ZipCode; - _activity.DlvCity = _company.City; - - Working = false; - - } - private void CallPriceListModal() - { - _priceList.Show(); - } - - private async Task SelectSku(SelectedSku sku) - { - ShowItem = true; - _selectedItem = await CatalogRepo.GetSalesVariantId(sku.ItemId); - Price = sku.Rate; - Quantity = sku.Quantity; - } - - private async Task DeleteDraft() - { - await DraftStateProvider.DeleteDraftAsync(); - } - - private async Task CreateOrder() - { - Working = true; - await CrmActivityRepo.CreateActivity(_activity); - Working = false; - } - private async Task AddItem(SalesItemView salesItem) - { - ShowItem = false; - // create a new cart item - var item = new DraftItem - { - Item = salesItem, - Quantity = Convert.ToInt32(Quantity), - Price = Convert.ToDecimal(Price, CultureInfo.InvariantCulture), - Discount = Convert.ToDecimal(Discount, CultureInfo.InvariantCulture), - Sas = Sas - }; - // reset internals to initial state - Sas = false; - Quantity = "1"; - Price = "0"; - Discount = "0"; - // add it to the cart - DraftStateProvider.Draft.Items.Add(item); - // save the item using the CartStateProvider's save method - await DraftStateProvider.SaveChangesAsync(); - } - private async Task RemoveItem(DraftItem item) - { - // remove item - DraftStateProvider.Draft.Items.Remove(item); - // save the remaining draft - await DraftStateProvider.SaveChangesAsync(); - } - - private void HandleFieldChanged(object sender, FieldChangedEventArgs e) - { - if (DraftStateProvider.Draft.Items.Count == 0) - { - FormInvalid = true; - return; - } - - FormInvalid = !_editContext.Validate(); - StateHasChanged(); - } - private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) - { - FormInvalid = false; - - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/PreferencesPage.razor b/Wonky.Client/Pages/PreferencesPage.razor index 48011910..928f22d8 100644 --- a/Wonky.Client/Pages/PreferencesPage.razor +++ b/Wonky.Client/Pages/PreferencesPage.razor @@ -22,35 +22,35 @@
- +
- +
- +
- +
- +
diff --git a/Wonky.Client/Pages/ReportCreateCrmPage.razor b/Wonky.Client/Pages/ReportCreateCrmPage.razor deleted file mode 100644 index 28706842..00000000 --- a/Wonky.Client/Pages/ReportCreateCrmPage.razor +++ /dev/null @@ -1,305 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Microsoft.AspNetCore.Authorization -@using Wonky.Client.Components -@attribute [Authorize(Roles = "Advisor")] -@page "/sales-reports/new" - -@* report header *@ -
-
- -
-
- -
-
- -@* report form *@ - -@* Day info row *@ -
- - - - - - - - - - - - - - @if (Report.DayTypeEnum.ToLower().Contains("leave")) - { - - - Report.Figures.KmMorning = 0; - } - else - { - Report.Figures.KmMorning = Prefs.KmMorning; - - - } - - - - -
Dag / PeriodeBegyndtAfsluttet
- - - - - - - - - - - - - - -
-
- -@* report details for everything but leave *@ -@if (!Report.DayTypeEnum.ToLower().Contains("leave")) -{ -
- @* details input *@ - - - - - - - - - - - - - -
TekstSupervisor
- - - - - -
-
- -
- @* distance ledger input *@ - - - - - - - - - - - - - - - -
Km aftenKm morgenKm privat
- - - - - -
-
- @if (Activities.Any()) - { -
- @* Report activities *@ - - - - - - - - - - - - - - - - - - @foreach (var activity in Activities) - { - - - - - - - - - - - - - - } - - - - - - - -
KundeBynavnDemoSalgNotesasBeløb - - - - - - - -
@activity.Company.Name@activity.Company.City@activity.Demo@activity.Sales@activity.OfficeNote@($"{activity.SasAmount:N2}")@(activity.StatusTypeEnum.Contains("Quote") ? $"{0:N2}" : $"{activity.OrderAmount:N2}") - @if (activity.OurRef.Contains("T:")) - { - - } - - @if (activity.Express) - { - - } - - @if (activity.StatusTypeEnum == "Quote") - { - - } - - -
Total@Activities.Where(x => x.StatusTypeEnum != "Quote").Sum(x => x.OrderAmount)
-
- } -} -
- @* ledger summaries calculated *@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dagens Demo @(Report.Figures.NewDemoCount + Report.Figures.RecallDemoCount)Dagens ResultatMåneds Resultat
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@Report.Figures.NewVisitCount@Report.Figures.NewDemoCount@Report.Figures.NewSaleCount@Report.Figures.NewTurnover@Report.Figures.NewVisitCountMonth@Report.Figures.NewDemoCountMonth@Report.Figures.NewSaleCountMonth@Report.Figures.NewTurnoverMonth
R@Report.Figures.RecallVisitCount@Report.Figures.RecallDemoCount@Report.Figures.RecallSaleCount@Report.Figures.RecallTurnover@Report.Figures.RecallVisitCountMonth@Report.Figures.RecallDemoCountMonth@Report.Figures.RecallSaleCountMonth@Report.Figures.RecallTurnoverMonth
SAS@Report.Figures.SasCount@Report.Figures.SasTurnover@Report.Figures.SasCountMonth@Report.Figures.SasTurnoverMonth
TOTAL@Report.Figures.TotalVisitCount@Report.Figures.TotalDemoCount@Report.Figures.TotalSaleCount@Report.Figures.TotalTurnover@Report.Figures.TotalVisitCountMonth@Report.Figures.TotalDemoCountMonth@Report.Figures.TotalSaleCountMonth@Report.Figures.TotalTurnoverMonth
-
-
- - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/PrintOrderPage.razor b/Wonky.Client/Pages/ReportPrintOrderPage.razor similarity index 72% rename from Wonky.Client/Pages/PrintOrderPage.razor rename to Wonky.Client/Pages/ReportPrintOrderPage.razor index b8503e6b..384751d5 100644 --- a/Wonky.Client/Pages/PrintOrderPage.razor +++ b/Wonky.Client/Pages/ReportPrintOrderPage.razor @@ -17,15 +17,21 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization -@page "/print/orders/{CountryCode}/{UserId}/{ReportDate}" -@attribute [Authorize(Roles = "Admin,Advisor")] +@attribute [Authorize(Roles = "Admin,Office,Advisor")] +@page "/report/print/orders/{CountryCode}/{UserId}/{ReportDate}"
- + + + + + + +
@@ -33,7 +39,7 @@ { foreach (var item in Items.Where(item => item.StatusTypeEnum.ToLower() == "order" && item.ProcessStatusEnum.ToLower() == "none")) { - + } } else @@ -43,4 +49,4 @@ else

Der er ingen ordrer til udskrivning

-} +} \ No newline at end of file diff --git a/Wonky.Client/Pages/PrintOrderPage.razor.cs b/Wonky.Client/Pages/ReportPrintOrderPage.razor.cs similarity index 65% rename from Wonky.Client/Pages/PrintOrderPage.razor.cs rename to Wonky.Client/Pages/ReportPrintOrderPage.razor.cs index f42ceb12..aadd874d 100644 --- a/Wonky.Client/Pages/PrintOrderPage.razor.cs +++ b/Wonky.Client/Pages/ReportPrintOrderPage.razor.cs @@ -14,26 +14,34 @@ // using Blazored.LocalStorage; +using Blazored.Toast.Services; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using Wonky.Client.Helpers; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Models; +using Wonky.Client.Shared; +using Wonky.Entity.DTO; using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class PrintOrderPage +public partial class ReportPrintOrderPage { [Parameter] public string CountryCode { get; set; } = ""; [Parameter] public string UserId { get; set; } = ""; [Parameter] public string ReportDate { get; set; } = ""; - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public NavigationManager Navigator { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private IOrderProcessRepository ProcessRepo { get; set; } [Inject] private IJSRuntime JSRuntime { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] private ILogger Logger { get; set; } + [Inject] private IToastService Toaster { get; set; } private ReportView Report { get; set; } = new(); private List Items { get; set; } = new(); private IJSObjectReference JsModule { get; set; } private string ReturnUrl { get; set; } = ""; + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) @@ -52,11 +60,30 @@ public partial class PrintOrderPage Report = await Storage.GetItemAsync($"{UserId}-{ReportDate}"); Items = Report.ReportItems; } + + private async Task OfficePrint() + { + var current = 0; + var orders = Report.ReportItems + .Where(x => x is { StatusTypeEnum: "Order", ProcessStatusEnum: "None" } ); + var count = orders.Count(); + foreach (var item in orders) + { + Toaster.ShowInfo($"Behandler {current++} af {count} ordrer. Vent venligst"); + await ProcessRepo.UpdateWarehouseOrderStatus(new OrderProcessState + { + OrderId = item.ActivityId, + ProcessStatusEnum = Utils.EnumToString(PStatus.Accepted) + }); + } + Toaster.ClearAll(); + await JsModule.InvokeVoidAsync("printInvoke"); + Navigator.NavigateTo(ReturnUrl); + } private async Task Print() { await JsModule.InvokeVoidAsync("printInvoke"); - Navigator.NavigateTo(ReturnUrl); } diff --git a/Wonky.Client/Pages/PrintFrontPage.razor b/Wonky.Client/Pages/ReportPrintSummaryPage.razor similarity index 79% rename from Wonky.Client/Pages/PrintFrontPage.razor rename to Wonky.Client/Pages/ReportPrintSummaryPage.razor index 49b98e5b..ef738bb0 100644 --- a/Wonky.Client/Pages/PrintFrontPage.razor +++ b/Wonky.Client/Pages/ReportPrintSummaryPage.razor @@ -17,8 +17,8 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization -@page "/print/report/{CountryCode}/{UserId}/{ReportDate}" -@attribute [Authorize(Roles = "Admin,Advisor")] +@attribute [Authorize(Roles = "Admin,Office,Advisor")] +@page "/report/print/summary/{CountryCode}/{UserId}/{ReportDate}"
@@ -29,11 +29,13 @@
-
+
@Report.ReportData.Name
-
-

@Report.ReportData.Name

+
+
+

@Report.ReportData.Name

+
@@ -44,6 +46,6 @@
- +
\ No newline at end of file diff --git a/Wonky.Client/Pages/PrintFrontPage.razor.cs b/Wonky.Client/Pages/ReportPrintSummaryPage.razor.cs similarity index 90% rename from Wonky.Client/Pages/PrintFrontPage.razor.cs rename to Wonky.Client/Pages/ReportPrintSummaryPage.razor.cs index 11ccbd1a..f1646300 100644 --- a/Wonky.Client/Pages/PrintFrontPage.razor.cs +++ b/Wonky.Client/Pages/ReportPrintSummaryPage.razor.cs @@ -22,15 +22,15 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class PrintFrontPage +public partial class ReportPrintSummaryPage { [Parameter] public string CountryCode { get; set; } = ""; [Parameter] public string UserId { get; set; } = ""; [Parameter] public string ReportDate { get; set; } = ""; - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public NavigationManager Navigator { get; set; } + [Inject] private ILocalStorageService Storage { get; set; } + [Inject] private NavigationManager Navigator { get; set; } [Inject] private IJSRuntime JSRuntime { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] private ILogger Logger { get; set; } private ReportView Report { get; set; } = new(); private IJSObjectReference JsModule { get; set; } private string ReturnUrl { get; set; } = ""; diff --git a/Wonky.Client/Pages/UserListOfficePage.razor.cs b/Wonky.Client/Pages/UserListOfficePage.razor.cs deleted file mode 100644 index bb3a0880..00000000 --- a/Wonky.Client/Pages/UserListOfficePage.razor.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class UserListOfficePage : IDisposable -{ - [Parameter] public string CountryCode { get; set; } = ""; - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public IUserHttpRepository UserRepo { get; set; } - private List _salesReps { get; set; } = new(); - private bool Working { get; set; } = true; - - - protected override async Task OnInitializedAsync() - { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); - var AdvisorList = await UserRepo.GetAdvisors(); - _salesReps = AdvisorList - .Where(x => x.CountryCode.ToLower() == CountryCode && Convert.ToInt32(x.SalesRep) < 100) - .ToList(); - Working = false; - } - - public void Dispose() - { - _interceptor.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/OrderListWarehousePage.razor b/Wonky.Client/Pages/WarehouseOrderListPage.razor similarity index 58% rename from Wonky.Client/Pages/OrderListWarehousePage.razor rename to Wonky.Client/Pages/WarehouseOrderListPage.razor index 6a8b8961..515e3c67 100644 --- a/Wonky.Client/Pages/OrderListWarehousePage.razor +++ b/Wonky.Client/Pages/WarehouseOrderListPage.razor @@ -17,13 +17,20 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin,Warehouse,Office")] +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] @page "/warehouse/orders/{Status}" - - -@code{ - - [Parameter] public string Status { get; set; } = "none"; - -} +
+
+

Forsendelser

+
+
+
+
+ Loading... +
+
+
+
+ \ No newline at end of file diff --git a/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs b/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs new file mode 100644 index 00000000..5fe729c9 --- /dev/null +++ b/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs @@ -0,0 +1,109 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Client.Helpers; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Models; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class WarehouseOrderListPage : IDisposable +{ + [Parameter] public string Status { get; set; } = "none"; + + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private IOrderProcessRepository OrderProcessRepo { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + private List OrderList { get; set; } + private bool Working { get; set; } = true; + private string Header { get; set; } = "Ubehandlet"; + private bool ReadyToShip { get; set; } + protected override async Task OnParametersSetAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + OrderList = await FetchOrders(Status); + } + + private async Task GetStatusCallback(PStatus status) + { + Working = true; + OrderList = new List(); + switch (status) + { + case PStatus.None or PStatus.Accepted: + Header = "Ubehandlede ordrer"; + ReadyToShip = false; + break; + case PStatus.Picked: + Header = "Plukkede ordrer"; + ReadyToShip = false; + break; + case PStatus.Packed: + Header = "Pakkede ordrer"; + ReadyToShip = true; + break; + case PStatus.Shipped: + break; + case PStatus.All: + break; + case PStatus.Express: + break; + default: + throw new ArgumentOutOfRangeException(nameof(status), status, null); + } + Status = Utils.EnumToString(status).ToLower(); + OrderList = await FetchOrders(Status); + Working = false; + } + + /// + /// QPak - quick mark an order as shipped + /// + /// + private async Task QPakCallback(string orderId) + { + Working = true; + var order = OrderList.First(x => x.OrderId == orderId); + order.ProcessStatusEnum = "packed"; + var process = new OrderProcessState + { + OrderId = order.OrderId, + ProcessStatusEnum = "packed" + }; + await OrderProcessRepo.UpdateWarehouseOrderStatus(process); + OrderList.Remove(order); + Working = false; + } + /// + /// Set status shipped where status is packed + /// + private async Task SetShippedCallback() + { + Working = true; + foreach (var order in OrderList.Where(order => order.ProcessStatusEnum.ToLower() == "packed")) + { + order.ProcessStatusEnum = "shipped"; + var process = new OrderProcessState + { + OrderId = order.OrderId, + ProcessStatusEnum = "shipped" + }; + await OrderProcessRepo.UpdateWarehouseOrderStatus(process); + } + Working = false; + } + + private async Task> FetchOrders(string status) + { + Working = true; + var orderList = await OrderProcessRepo.GetWarehouseOrderListByStatus(status.ToLower()); + if(orderList.Any(x => x.Express)) + orderList = orderList.OrderByDescending(x => x.Express).ToList(); + Working = false; + return orderList; + } + + public void Dispose() => Interceptor.DisposeEvent(); +} \ No newline at end of file diff --git a/Wonky.Client/Pages/OrderViewWarehousePage.razor b/Wonky.Client/Pages/WarehouseOrderViewPage.razor similarity index 77% rename from Wonky.Client/Pages/OrderViewWarehousePage.razor rename to Wonky.Client/Pages/WarehouseOrderViewPage.razor index 135c3642..cb95d92f 100644 --- a/Wonky.Client/Pages/OrderViewWarehousePage.razor +++ b/Wonky.Client/Pages/WarehouseOrderViewPage.razor @@ -17,53 +17,53 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components -@attribute [Authorize(Roles = "Admin,Warehouse,Office")] +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] @page "/warehouse/orders/process/{OrderId}" -@if (!string.IsNullOrWhiteSpace(_order.OrderDate)) +@if (!string.IsNullOrWhiteSpace(Order.OrderDate)) { - + - + - + - + - + - + - + - + - + - +
- @if (_order.Express) + @if (Order.Express) {

HASTE ORDRE

} -

@_order.Company.Name

+

@Order.Company.Name

Konto@_order.Company.Account@Order.Company.Account Telefon@_order.Company.Phone@Order.Company.Phone
Kunde@_order.Company.Name@Order.Company.Name Lev.Navn@_order.DlvName@Order.DlvName
Adresse@_order.Company.Address1@Order.Company.Address1 Lev.Adresse@_order.DlvAddress1@Order.DlvAddress1
Adresse@_order.Company.Address2@Order.Company.Address2 Lev.Adresse@_order.DlvAddress2@Order.DlvAddress2
Postnr By@_order.Company.ZipCode @_order.Company.City@Order.Company.ZipCode @Order.Company.City Lev.Postnr By@_order.DlvZipCity@Order.DlvZipCity
@@ -77,7 +77,7 @@
@line.Location
- @if (!string.IsNullOrWhiteSpace(_order.OfficeNote)) + @if (!string.IsNullOrWhiteSpace(Order.OfficeNote)) {
-

@_order.OfficeNote

+

@Order.OfficeNote

}
@@ -106,15 +106,15 @@
- @if (_order.ProcessStatusEnum.ToLower() == "none") + @if (Order.ProcessStatusEnum.ToLower() is "none" or "accepted") { } - @if (_order.ProcessStatusEnum.ToLower() == "picked") + @if (Order.ProcessStatusEnum.ToLower() == "picked") { } - @if (_order.ProcessStatusEnum.ToLower() == "packed") + @if (Order.ProcessStatusEnum.ToLower() == "packed") { } diff --git a/Wonky.Client/Pages/OrderViewWarehousePage.razor.cs b/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs similarity index 52% rename from Wonky.Client/Pages/OrderViewWarehousePage.razor.cs rename to Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs index d30fa144..d562feb2 100644 --- a/Wonky.Client/Pages/OrderViewWarehousePage.razor.cs +++ b/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs @@ -21,70 +21,79 @@ using Microsoft.AspNetCore.Components; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; using Wonky.Client.HttpRepository; +using Wonky.Entity.DTO; using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class OrderViewWarehousePage : IDisposable +public partial class WarehouseOrderViewPage : IDisposable { [Parameter] public string OrderId { get; set; } = ""; - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public IWarehouseHttpRepository _warehouseRepo { get; set; } - [Inject] public NavigationManager _navigator { get; set; } - [Inject] public IToastService _toast { get; set; } - [Inject] public ILogger _logger { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private IOrderProcessRepository OrderProcessRepo { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + [Inject] private IToastService Toast { get; set; } + [Inject] private ILogger Logger { get; set; } - private WarehouseOrderView _order { get; set; } = new(); - private bool Working { get; set; } + private WarehouseOrderView Order { get; set; } = new(); + private bool Working { get; set; } = true; protected override async Task OnParametersSetAsync() { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); if (!string.IsNullOrWhiteSpace(OrderId)) - _order = await _warehouseRepo.GetWarehouseOrder(OrderId); + Order = await OrderProcessRepo.GetWarehouseOrder(OrderId); - _logger.LogDebug("Warehouse OrderView =>\n{}", JsonSerializer.Serialize(_order)); + Logger.LogDebug("Warehouse OrderView =>\n{}", JsonSerializer.Serialize(Order)); + Working = false; } private async Task SetProcessStatusPicked() { + if (Working) + return; + Working = true; - var process = new WarehouseProcess + var process = new OrderProcessState { - OrderId = _order.OrderId, + OrderId = Order.OrderId, ProcessStatusEnum = "picked" }; - await _warehouseRepo.UpdateWarehouseOrderStatus(process); - _navigator.NavigateTo("/warehouse/orders/none"); + await OrderProcessRepo.UpdateWarehouseOrderStatus(process); + Navigator.NavigateTo("/warehouse/orders/none"); } private async Task SetProcessStatusPacked() { + if (Working) + return; Working = true; - var process = new WarehouseProcess + var process = new OrderProcessState { - OrderId = _order.OrderId, + OrderId = Order.OrderId, ProcessStatusEnum = "packed" }; - await _warehouseRepo.UpdateWarehouseOrderStatus(process); - _navigator.NavigateTo("/warehouse/orders/picked"); + await OrderProcessRepo.UpdateWarehouseOrderStatus(process); + Navigator.NavigateTo("/warehouse/orders/picked"); } private async Task SetProcessStatusShipped() { + if (Working) + return; Working = true; - var process = new WarehouseProcess + var process = new OrderProcessState { - OrderId = _order.OrderId, + OrderId = Order.OrderId, ProcessStatusEnum = "shipped" }; - await _warehouseRepo.UpdateWarehouseOrderStatus(process); - _navigator.NavigateTo("/warehouse/orders/none"); + await OrderProcessRepo.UpdateWarehouseOrderStatus(process); + Navigator.NavigateTo("/warehouse/orders/none"); } public void Dispose() { - _interceptor.DisposeEvent(); + Interceptor.DisposeEvent(); } } \ No newline at end of file diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index 013ed6af..453bc5dc 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -36,9 +36,9 @@ builder.RootComponents.Add("head::after"); builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); builder.Services.AddScoped(sp => - sp.GetService().CreateClient("backend")); + sp.GetService().CreateClient("inno-api")); -builder.Services.AddHttpClient("backend", (sp, cl) => +builder.Services.AddHttpClient("inno-api", (sp, cl) => { var apiConfig = sp.GetRequiredService>(); cl.BaseAddress = new Uri(apiConfig.Value.BaseUrl); @@ -54,23 +54,23 @@ builder.Services.Configure(builder.Configuration.GetSection("ApiConfi // app info object builder.Services.Configure(builder.Configuration.GetSection("AppInfo")); // crm repositories -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); // administrative repositories -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); // warehouse repository -builder.Services.AddScoped(); -// catalog repository -builder.Services.AddScoped(); +builder.Services.AddScoped(); // mail service -builder.Services.AddScoped(); +builder.Services.AddScoped(); // interceptor builder.Services.AddScoped(); // storage diff --git a/Wonky.Client/Services/AuthenticationService.cs b/Wonky.Client/Services/AuthenticationService.cs index 7856b45b..3c85b4ad 100644 --- a/Wonky.Client/Services/AuthenticationService.cs +++ b/Wonky.Client/Services/AuthenticationService.cs @@ -120,7 +120,9 @@ namespace Wonky.Client.Services { ((AuthStateProvider)_authStateProvider).NotifyUserLogout(); _client.DefaultRequestHeaders.Authorization = null; + var backupPreferences = _localStorage.GetItemAsync("preferences"); await _localStorage.ClearAsync(); + await _localStorage.SetItemAsync("preferences", backupPreferences); } public async Task UserInfo(bool write = false) diff --git a/Wonky.Client/Services/UserProfileService.cs b/Wonky.Client/Services/UserProfileService.cs index 58a9ee32..74618eb5 100644 --- a/Wonky.Client/Services/UserProfileService.cs +++ b/Wonky.Client/Services/UserProfileService.cs @@ -18,11 +18,11 @@ namespace Wonky.Client.Services; public record UserPref { - public string? CompanyFilterPhrase { get; set; } = ""; - public string? CompanySearch { get; set; } = "name"; - public string? CompanySort { get; set; } = "name"; - public string? ItemSearch { get; set; } = "name"; - public string? ItemSort { get; set; } = "name"; + public string CompanyFilterPhrase { get; set; } = ""; + public string CompanySearch { get; set; } = "name"; + public string CompanySort { get; set; } = "name"; + public string ItemSearch { get; set; } = "name"; + public string ItemSort { get; set; } = "name"; public string PageSize { get; set; } = "10"; public string WorkDate { get; set; } = ""; public int KmMorning { get; set; } @@ -32,6 +32,7 @@ public record UserPref public class UserProfileService { private readonly ILocalStorageService _localStorageService; + private const string KeyName = "preferences"; public event Action? OnChange; public UserProfileService(ILocalStorageService localStorageService) { @@ -46,7 +47,7 @@ public class UserProfileService { DateConfirmed = confirmed }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -58,7 +59,7 @@ public class UserProfileService { KmMorning = kmMorning }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -70,7 +71,7 @@ public class UserProfileService { CompanyFilterPhrase = filterPhrase }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -82,7 +83,7 @@ public class UserProfileService { WorkDate = $"{workDate:yyyy-MM-dd}" }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -91,7 +92,7 @@ public class UserProfileService var preferences = await GetPreferences(); var newPreferences = preferences with { CompanySearch = companySearch }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -100,7 +101,7 @@ public class UserProfileService var preferences = await GetPreferences(); var newPreferences = preferences with { CompanySort = companySort }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -109,7 +110,7 @@ public class UserProfileService var preferences = await GetPreferences(); var newPreferences = preferences with { ItemSearch = itemSearch }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -118,7 +119,7 @@ public class UserProfileService var preferences = await GetPreferences(); var newPreferences = preferences with { ItemSort = itemSort }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } @@ -127,13 +128,12 @@ public class UserProfileService var preferences = await GetPreferences(); var newPreferences = preferences with { PageSize = pageSize }; - await _localStorageService.SetItemAsync("preferences", newPreferences); + await _localStorageService.SetItemAsync(KeyName, newPreferences); OnChange?.Invoke(newPreferences); } public async Task GetPreferences() { - return await _localStorageService.GetItemAsync("preferences").ConfigureAwait(true) - ?? new UserPref(); + return await _localStorageService.GetItemAsync(KeyName) ?? new UserPref(); } } \ No newline at end of file diff --git a/Wonky.Client/Shared/ConfirmProductCheckModal.razor b/Wonky.Client/Shared/ConfirmProductCheckModalOverlay.razor similarity index 96% rename from Wonky.Client/Shared/ConfirmProductCheckModal.razor rename to Wonky.Client/Shared/ConfirmProductCheckModalOverlay.razor index 6aa75cee..34432c14 100644 --- a/Wonky.Client/Shared/ConfirmProductCheckModal.razor +++ b/Wonky.Client/Shared/ConfirmProductCheckModalOverlay.razor @@ -16,7 +16,7 @@ *@ @using Wonky.Client.Components