+
@product.Quantity
diff --git a/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs b/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs
index 67f31bba..3b94ee3e 100644
--- a/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs
+++ b/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs
@@ -13,9 +13,11 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
+using System.Security.Policy;
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components;
using Wonky.Client.Enums;
+using Wonky.Client.Helpers;
using Wonky.Client.Models;
using Wonky.Entity.Views;
#pragma warning disable CS8618
@@ -27,57 +29,48 @@ public partial class CustomerProductCheckListComponent
[Parameter] public string CompanyId { get; set; } = "";
[Inject] public ILocalStorageService Storage { get; set; }
// private variables
- private bool Descending { get; set; }
-
+ private bool Descending { get; set; } = true;
+ private string SearchTerm { get; set; } = "";
+ private List
FilteredList { get; set; } = new();
+
protected override void OnParametersSet()
{
- if(Inventory.Any())
- Inventory = Inventory.OrderBy(x => x.Description).ToList();
+ Inventory = Utils.SortInventory(Inventory, ProductSort.LastInvoiceDate, Descending);
+ FilterItems(SearchTerm);
}
+
+ private void SetSortOrder()
+ {
+ Descending = !Descending;
+ FilteredList = Utils.SortInventory(FilteredList, ProductSort.LastInvoiceDate, Descending);
+ }
+
+
+ private void OnSearchChanged(string searchTerm)
+ {
+ FilterItems(searchTerm);
+ }
+
+
+ private void FilterItems(string filter)
+ {
+ SearchTerm = filter;
+ FilteredList = string.IsNullOrWhiteSpace(filter)
+ ? Inventory
+ : Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList();
+ }
+
+
private void SortProducts(ProductSort column)
{
- Descending = !Descending;
- switch (column)
- {
- case ProductSort.Desc:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Description).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Description).ToList();
- break;
- case ProductSort.Sku:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Sku).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Sku).ToList();
- break;
- case ProductSort.Qty:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Quantity).ToList();
- break;
- case ProductSort.None:
- break;
- case ProductSort.Abbr:
- break;
- default:
- Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList();
- break;
- }
+ FilteredList = Utils.SortInventory(Inventory, column, Descending);
}
- private async Task ProductCheck(string sku)
+
+ private void ProductCheck(string sku)
{
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/InfoColorPackageComponent.razor b/Wonky.Client/Components/InfoColorPackageComponent.razor
deleted file mode 100644
index 9c19239d..00000000
--- a/Wonky.Client/Components/InfoColorPackageComponent.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 Wonky.Client.Components
-
-Pakning / Forsendelse
-
-
-
- Symbol
- Betydning
-
-
-
-
-
-
-
-
-
- Ubehandlet
-
-
-
-
-
-
-
- Varer er plukket
-
-
-
-
-
-
-
- Varer er pakket
-
-
-
-
-
-
-
- Varer er afsendt
-
-
-
\ No newline at end of file
diff --git a/Wonky.Client/Components/InfoProcessStateComponent.razor b/Wonky.Client/Components/InfoProcessStateComponent.razor
index 8c64b4ef..fb9072ac 100644
--- a/Wonky.Client/Components/InfoProcessStateComponent.razor
+++ b/Wonky.Client/Components/InfoProcessStateComponent.razor
@@ -36,6 +36,7 @@
Udskrevet
+ @*
Plukket
@@ -48,5 +49,6 @@
Leveret
+ *@
diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor
index e0f62991..fb8e692b 100644
--- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor
+++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor
@@ -70,7 +70,7 @@
-
+
}
else
{
diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs
index a01f8562..b6e2aa57 100644
--- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs
+++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs
@@ -48,7 +48,7 @@ public partial class OfficeCountryCustomerListComponent
// overlays
private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new();
private OfficeCustomerActivityListOverlay ActivityListOverlay { get; set; } = new();
- private OfficeCustomerProductListOverlay ProductListOverlay { get; set; } = new();
+ private OfficeCustomerInventoryListOverlay InventoryListOverlay { get; set; } = new();
// ******************************************************
// variables
@@ -108,7 +108,7 @@ public partial class OfficeCountryCustomerListComponent
SelectedCompany.HistorySync = newSyncDate;
}
ProductList = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId);
- ProductListOverlay.Show();
+ InventoryListOverlay.Show();
}
private void ShowOrder(string companyId)
diff --git a/Wonky.Client/Components/OfficeInventoryListComponent.razor b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor
similarity index 52%
rename from Wonky.Client/Components/OfficeInventoryListComponent.razor
rename to Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor
index b2190ce3..bf2361f1 100644
--- a/Wonky.Client/Components/OfficeInventoryListComponent.razor
+++ b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor
@@ -24,11 +24,32 @@
-
SortProducts(ProductSort.Desc))"> Navn
-
SortProducts(ProductSort.Sku))"> Varenr
-
SortProducts(ProductSort.Qty))"> Antal
-
-
+ @*
SortProducts(ProductSort.Description))"> Navn
*@
+ @*
SortProducts(ProductSort.Sku))"> Varenr
*@
+
+
+
+
@foreach (var product in Inventory)
diff --git a/Wonky.Client/Components/OfficeInventoryListComponent.razor.cs b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs
similarity index 56%
rename from Wonky.Client/Components/OfficeInventoryListComponent.razor.cs
rename to Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs
index ec610356..ccb46de0 100644
--- a/Wonky.Client/Components/OfficeInventoryListComponent.razor.cs
+++ b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs
@@ -15,72 +15,70 @@
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components;
+using Microsoft.VisualBasic.CompilerServices;
using Wonky.Client.Enums;
using Wonky.Client.Models;
using Wonky.Entity.Views;
+using Utils = Wonky.Client.Helpers.Utils;
namespace Wonky.Client.Components;
#pragma warning disable CS8618
-public partial class OfficeInventoryListComponent
+public partial class OfficeCustomerInventoryListComponent
{
// *************************************************************
// Injections
[Inject] public ILocalStorageService Storage { get; set; }
+
// *************************************************************
// Parameters
[Parameter] public List
Inventory { get; set; } = new();
[Parameter] public string CompanyId { get; set; } = "";
[Parameter] public EventCallback OnReorderSelected { get; set; }
+
// *************************************************************
// private variables
- private bool Descending { get; set; }
-
+ private bool Descending { get; set; } = true;
+ private string SearchTerm { get; set; } = "";
+ private List FilteredList { get; set; } = new();
+ private ProductSort SortColumn { get; set; } = ProductSort.LastInvoiceDate;
+
+
protected override void OnParametersSet()
{
- if(Inventory.Any())
- Inventory = Inventory.OrderBy(x => x.Description).ToList();
+ Inventory = Utils.SortInventory(Inventory, SortColumn, Descending);
+ FilterItems(SearchTerm);
}
+
+
+ private void SetSortOrder()
+ {
+ Descending = !Descending;
+ FilteredList = Utils.SortInventory(FilteredList, SortColumn, Descending);
+ }
+
+
+ private void OnSearchChanged(string searchTerm)
+ {
+ FilterItems(searchTerm);
+ }
+
+
+ private void FilterItems(string filter)
+ {
+ SearchTerm = filter;
+ FilteredList = string.IsNullOrWhiteSpace(filter)
+ ? Inventory
+ : Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList();
+ }
+
private void SortProducts(ProductSort column)
{
- Descending = !Descending;
- switch (column)
- {
- case ProductSort.Desc:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Description).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Description).ToList();
- break;
- case ProductSort.Sku:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Sku).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Sku).ToList();
- break;
- case ProductSort.Qty:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Quantity).ToList();
- break;
- case ProductSort.None:
- break;
- case ProductSort.Abbr:
- break;
- default:
- Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList();
- break;
- }
+ FilteredList = Utils.SortInventory(FilteredList, column, Descending);
}
+
private async Task CallShowReorderModal(string sku)
{
// await ProductCheck(sku);
diff --git a/Wonky.Client/Components/InfoWarehouseComponent.razor b/Wonky.Client/Components/SearchPhraseComponent.razor
similarity index 68%
rename from Wonky.Client/Components/InfoWarehouseComponent.razor
rename to Wonky.Client/Components/SearchPhraseComponent.razor
index e9e0afc2..c241cd74 100644
--- a/Wonky.Client/Components/InfoWarehouseComponent.razor
+++ b/Wonky.Client/Components/SearchPhraseComponent.razor
@@ -13,20 +13,9 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*@
-Lager
-
-
-
- Symbol
- Betydning
-
-
-
-
-
-
-
- Pakning / Forsendelse
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/Wonky.Client/Components/InfoColorPackageComponent.razor.css b/Wonky.Client/Components/SearchPhraseComponent.razor.cs
similarity index 56%
rename from Wonky.Client/Components/InfoColorPackageComponent.razor.css
rename to Wonky.Client/Components/SearchPhraseComponent.razor.cs
index 211a9cbf..1d679bf9 100644
--- a/Wonky.Client/Components/InfoColorPackageComponent.razor.css
+++ b/Wonky.Client/Components/SearchPhraseComponent.razor.cs
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 FCS Frede's Computer Services.
+// 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
@@ -11,10 +11,27 @@
//
// 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]
-*/
-.pictogram {
- max-width: 30px;
-}
-.color-code {
- max-width: 30px;
+//
+
+using System.Timers;
+using Microsoft.AspNetCore.Components;
+using Timer = System.Timers.Timer;
+
+namespace Wonky.Client.Components;
+
+public partial class SearchPhraseComponent
+{
+ private string SearchTerm { get; set; } = "";
+ [Parameter] public EventCallback OnChanged { get; set; }
+
+ private void ClearSearch()
+ {
+ SearchTerm = "";
+ OnChanged.InvokeAsync("");
+ }
+
+ private void OnSearchChanged()
+ {
+ OnChanged.InvokeAsync(SearchTerm);
+ }
}
\ No newline at end of file
diff --git a/Wonky.Client/Components/WarehouseListComponent.razor b/Wonky.Client/Components/WarehouseListComponent.razor
deleted file mode 100644
index a11816dc..00000000
--- a/Wonky.Client/Components/WarehouseListComponent.razor
+++ /dev/null
@@ -1,102 +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.Models
-@using Wonky.Client.Enums
-
-@if (OrderList != null)
-{
-
-
-
-
- @Header
- @Orders.Count
- ordrer i listen
-
-
-
- @if (ReadyToShip && Orders.Any())
- {
- Sæt alle afsendt
- }
-
-
-
-
-
-
-
Modtager
-
-
-
Post By
-
-
-
Dato
-
-
-
Status
-
-
-
- @foreach (var order in Orders)
- {
-
-
-
- @order.Company.Name
-
-
- @order.Company.ZipCode @order.Company.City
-
-
- @order.OrderDate
-
-
- @if (order.Express)
- {
-
- }
- @switch (order.ProcessStatusEnum.ToLower())
- {
- case "none":
-
QuickPak(order.OrderId))">QuickPak
-
Pluk varer
- break;
- case "picked":
-
Pak varer
- break;
- case "packed":
-
Afhent varer
- break;
- }
-
-
-
- }
-
-}
\ No newline at end of file
diff --git a/Wonky.Client/Components/WarehouseListComponent.razor.cs b/Wonky.Client/Components/WarehouseListComponent.razor.cs
deleted file mode 100644
index 128baf16..00000000
--- a/Wonky.Client/Components/WarehouseListComponent.razor.cs
+++ /dev/null
@@ -1,56 +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.Enums;
-using Wonky.Client.Models;
-using Wonky.Entity.Views;
-
-namespace Wonky.Client.Components;
-
-public partial class WarehouseListComponent
-{
- [Parameter] public string Header { get; set; } = "";
- [Parameter] public List OrderList { get; set; } = new();
- [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 Orders { get; set; } = new();
-
- protected override async Task OnParametersSetAsync()
- {
- while (OrderList == null)
- await Task.Delay(500);
-
- Orders = OrderList;
- }
-
- private async Task SetShipStatus()
- {
- await OnSetShipped.InvokeAsync();
- }
-
- private async Task GetWithStatus(ProcessStatus status)
- {
- 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/Enums/ProductSort.cs b/Wonky.Client/Enums/ProductSort.cs
index 3fd7dba0..a2959dc0 100644
--- a/Wonky.Client/Enums/ProductSort.cs
+++ b/Wonky.Client/Enums/ProductSort.cs
@@ -18,9 +18,7 @@ namespace Wonky.Client.Enums;
public enum ProductSort
{
- None,
- Desc,
+ Description,
Sku,
- Qty,
- Abbr
+ LastInvoiceDate
}
\ No newline at end of file
diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs
index c6037ddc..3bf5528c 100644
--- a/Wonky.Client/Helpers/Utils.cs
+++ b/Wonky.Client/Helpers/Utils.cs
@@ -27,11 +27,37 @@ namespace Wonky.Client.Helpers;
///
public static class Utils
{
+ public static List SortInventory(IEnumerable inventory,
+ ProductSort column, bool descending)
+ {
+ return column switch
+ {
+ ProductSort.Description => descending
+ ? inventory.OrderByDescending(x => x.Description).ToList()
+ : inventory.OrderBy(x => x.Description).ToList(),
+ ProductSort.Sku => descending
+ ? inventory.OrderByDescending(x => x.Sku).ToList()
+ : inventory.OrderBy(x => x.Sku).ToList(),
+ ProductSort.LastInvoiceDate => descending
+ ? inventory.OrderByDescending(x => x.LastInvoiceDate).ToList()
+ : inventory.OrderBy(x => x.LastInvoiceDate).ToList(),
+ _ => inventory.OrderByDescending(x => x.LastInvoiceDate).ToList()
+ };
+ }
+
+
public static List GenerateVariantListDto(IEnumerable items)
{
- return items.Select(item => new ProductVariant { VariantId = item.VariantId, S5A = item.S5A, S9A = item.S9A }).ToList();
+ return items.Select(item => new ProductVariant
+ {
+ VariantId = item.VariantId,
+ S5A = item.S5A,
+ S9A = item.S9A
+ })
+ .ToList();
}
-
+
+
public static List GenerateRevListView(IEnumerable products)
{
var result = new List();
@@ -64,17 +90,19 @@ public static class Utils
break;
}
}
+
result.Add(newDoc);
}
}
+
return result.OrderBy(x => x.VariantName).ToList();
}
-
-
+
+
public static List GenerateDocListView(IEnumerable products)
{
var result = new List();
-
+
var docProducts = products.OrderBy(x => x.TradingName).ToList();
foreach (var product in docProducts)
@@ -104,45 +132,47 @@ public static class Utils
break;
}
}
+
result.Add(newDoc);
}
}
+
return result.OrderBy(x => x.VariantName).ToList();
}
-
-
+
+
public static List ParseRecipientsFromString(string recipients)
{
var addresses = recipients
.Replace(" ", ",")
- .Replace(",,",",")
+ .Replace(",,", ",")
.Split(",");
- return (from address
- in addresses
- where IsValidEmail(address)
+ return (from address
+ in addresses
+ where IsValidEmail(address)
select new EmailContact
{
Name = address, Email = address
}).ToList();
}
-
+
public static List MapSaveAssignedRoles(RoleAssignment model)
{
return new List()
{
- new (){ Name = "Admin", Assigned = model.Admin},
- new (){ Name = "Advisor", Assigned = model.Advisor},
- new (){ Name = "EDoc", Assigned = model.EDoc},
- new (){ Name = "EShop", Assigned = model.EShop},
- new (){ Name = "Management", Assigned = model.Management},
- new (){ Name = "Office", Assigned = model.Office},
- new (){ Name = "Supervisor", Assigned = model.Supervisor},
- new (){ Name = "Warehouse", Assigned = model.Warehouse}
+ new() { Name = "Admin", Assigned = model.Admin },
+ new() { Name = "Advisor", Assigned = model.Advisor },
+ new() { Name = "EDoc", Assigned = model.EDoc },
+ new() { Name = "EShop", Assigned = model.EShop },
+ new() { Name = "Management", Assigned = model.Management },
+ new() { Name = "Office", Assigned = model.Office },
+ new() { Name = "Supervisor", Assigned = model.Supervisor },
+ new() { Name = "Warehouse", Assigned = model.Warehouse }
};
}
-
+
public static RoleAssignment MapEditAssignedRoles(UserManagerEditView model)
{
@@ -177,9 +207,10 @@ public static class Utils
break;
}
}
+
return x;
}
-
+
public static string StringToDigits(string digitString)
{
@@ -195,7 +226,7 @@ public static class Utils
return check.All(c => c is >= '0' and <= '9');
}
-
+
public static bool Validate(ValidateType validateType, string toValidate)
{
return validateType switch
@@ -231,7 +262,7 @@ public static class Utils
{
validConditions++;
}
-
+
return validConditions == 3;
}
diff --git a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs
index cc341ee6..3f2ac15c 100644
--- a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs
+++ b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs
@@ -69,7 +69,8 @@ public class HttpInterceptorService
var absolutePath = e.Request.RequestUri.AbsolutePath;
if (!absolutePath.Contains("token"))
{
- // call TryRefreshToken
+ // we are using the tryRefreshToken
+ // the service returns the current access token or a new token using refreshToken
var token = await _refreshTokenService.TryRefreshToken();
if (!string.IsNullOrEmpty(token))
{
diff --git a/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs
index cd4d6711..c6348a7d 100644
--- a/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs
+++ b/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs
@@ -34,6 +34,7 @@ public class CrmCustomerHistoryRepository : ICrmCustomerHistoryRepository
private readonly HttpClient _client;
private readonly ApiConfig _api;
+
public CrmCustomerHistoryRepository(
HttpClient client, ILogger logger,
NavigationManager navigation, IOptions configuration)
@@ -44,92 +45,80 @@ public class CrmCustomerHistoryRepository : ICrmCustomerHistoryRepository
_api = configuration.Value;
}
- ///
- /// Fetch Invoice LIst
- ///
- ///
- ///
+
public async Task FetchInvoiceList(string companyId)
{
var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/invoices");
var content = await response.Content.ReadAsStringAsync();
- return response.IsSuccessStatusCode
- ? JsonSerializer.Deserialize(content, _options)
- : new InvoiceListView();
+ if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
+ {
+ return new InvoiceListView();
+ }
+ return JsonSerializer.Deserialize(content, _options) ?? new InvoiceListView();
}
- ///
- /// Fetch given invoice for given customer
- ///
- ///
- ///
- ///
+
public async Task FetchInvoice(string companyId, string invoiceId)
{
- return await _client
+ var content = await _client
.GetFromJsonAsync($"{_api.CrmCustomers}/{companyId}/invoices/{invoiceId}", _options);
+ return content ?? new InvoiceView();
}
- ///
- /// Fetch inventory from given customer
- ///
- ///
- ///
+
public async Task> FetchInventory(string companyId)
{
var response = await _client.GetAsync($"{_api.CrmCustomers}/{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);
+ if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
+ return new List();
+ return JsonSerializer.Deserialize>(content, _options) ?? new List();
}
- ///
- /// Fetch History for given customer
- ///
- ///
- ///
- public async Task> FetchHistory(string companyId)
+
+ public async Task> GetProductInvoiceLines(string companyId)
{
var response = await _client.GetAsync($"{_api.CrmCustomers}/{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);
+ if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
+ {
+ return new List();
+ }
+ return JsonSerializer.Deserialize>(content, _options) ?? new List();
}
- ///
- /// Fetch history for given customer and a given product
- ///
- ///
- ///
- ///
- public async Task> FetchHistory(string companyId, string sku)
+
+ public async Task> GetProductInvoiceLines(string companyId, int months)
+ {
+ var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}/statistic?months={months}");
+ var content = await response.Content.ReadAsStringAsync();
+ if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
+ {
+ return new List();
+ }
+ return JsonSerializer.Deserialize>(content, _options) ?? new List();
+ }
+
+
+ public async Task> GetProductInvoiceLines(string companyId, string sku)
{
var response = await _client.GetAsync($"{_api.CrmCustomers}/{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);
+ if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
+ {
+ return new List();
+ }
+ return JsonSerializer.Deserialize>(content, _options) ?? new List();
}
- ///
- /// RPC call to initiate remote server sync for given customer
- ///
- ///
- ///
- ///
+
public async Task InvoiceErpToCrmRpc(string companyId, string syncDate)
{
var x = await _client.GetAsync($"{_api.SyncRpc}/companies/{companyId}/invoices/{syncDate}");
if (!x.IsSuccessStatusCode)
+ {
return string.Empty;
+ }
return await x.Content.ReadAsStringAsync();
}
}
\ No newline at end of file
diff --git a/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs
index e3323d02..8bfb2ef1 100644
--- a/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs
+++ b/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs
@@ -49,15 +49,23 @@ public interface ICrmCustomerHistoryRepository
///
///
///
- Task> FetchHistory(string companyId);
+ Task> GetProductInvoiceLines(string companyId);
+ ///
+ /// Fetch history for customer for the past months. A hard limit on 24 months is enforced by the backed
+ ///
+ ///
+ ///
+ ///
+ Task> GetProductInvoiceLines(string companyId, int months);
+
///
/// Fetch history for given customer and a given product
///
///
///
///
- Task> FetchHistory(string companyId, string sku);
+ Task> GetProductInvoiceLines(string companyId, string sku);
///
/// RPC call to initiate remote server sync for given customer
diff --git a/Wonky.Client/Local.Services/AuthenticationService.cs b/Wonky.Client/Local.Services/AuthenticationService.cs
index c9d2a05e..5ed028be 100644
--- a/Wonky.Client/Local.Services/AuthenticationService.cs
+++ b/Wonky.Client/Local.Services/AuthenticationService.cs
@@ -150,11 +150,22 @@ public class AuthenticationService : IAuthenticationService
((AuthStateProvider)_authStateProvider).NotifyUserLogout();
}
+
+ public async Task AccessToken()
+ {
+ return await _infoService.GetAccessToken();
+ }
+
+
public async Task UserInfo(bool write = false)
{
+ // use http to fetch userInfo for authenticated user
var response = await _client.GetAsync(_apiConfig.Value.UserInfoAuth).ConfigureAwait(true);
-
var content = await response.Content.ReadAsStringAsync();
+ if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
+ {
+ return new UserManagerEditView();
+ }
var userInfo = JsonSerializer.Deserialize(content, _options) ?? new UserManagerEditView();
if (write)
{
diff --git a/Wonky.Client/Local.Services/IAuthenticationService.cs b/Wonky.Client/Local.Services/IAuthenticationService.cs
index a8a7233e..be7e66b5 100644
--- a/Wonky.Client/Local.Services/IAuthenticationService.cs
+++ b/Wonky.Client/Local.Services/IAuthenticationService.cs
@@ -23,6 +23,7 @@ public interface IAuthenticationService
{
Task Login(CredentialDto credentials);
Task Logout();
+ Task AccessToken();
Task RefreshToken();
Task UserInfo(bool write = false);
}
\ No newline at end of file
diff --git a/Wonky.Client/Local.Services/RefreshTokenService.cs b/Wonky.Client/Local.Services/RefreshTokenService.cs
index 43a440b2..868c6f93 100644
--- a/Wonky.Client/Local.Services/RefreshTokenService.cs
+++ b/Wonky.Client/Local.Services/RefreshTokenService.cs
@@ -39,14 +39,13 @@ public class RefreshTokenService
var user = authState.User;
var expClaim = user.FindFirst(c => c.Type.Contains("exp"))?.Value;
-
- //var expTime = DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64(expClaim));
+
var expTime = DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64(expClaim));
var diff = expTime - DateTime.UtcNow;
- return diff.TotalMinutes <= 2
- ? await _authService.RefreshToken() //.ConfigureAwait(true)
- : string.Empty;
+ return diff.TotalMinutes <= 10
+ ? await _authService.RefreshToken()
+ : await _authService.AccessToken();
}
}
\ No newline at end of file
diff --git a/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs b/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs
index 2bf29d5d..8a721859 100644
--- a/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs
+++ b/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs
@@ -47,7 +47,7 @@ public partial class CustomerInventoryReorderOverlay
if (string.IsNullOrWhiteSpace(SalesItem.Sku))
return;
- History = await HistoryRepo.FetchHistory(CompanyId, SalesItem.Sku);
+ History = await HistoryRepo.GetProductInvoiceLines(CompanyId, SalesItem.Sku);
if (!History.Any())
await Task.Delay(1000);
SelectedItem.Item = SalesItem;
diff --git a/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs b/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs
index 87b4a322..177e911a 100644
--- a/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs
+++ b/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs
@@ -24,10 +24,15 @@ namespace Wonky.Client.OverlayCustomer;
public partial class CustomerInvoiceViewOverlay : IDisposable
{
- [Parameter] public string CompanyId { get; set; } = "";
- [Parameter] public string InvoiceId { get; set; } = "";
+ // ##############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICrmCustomerHistoryRepository HistoryRepo { get; set; }
+
+ // ##############################################################
+ [Parameter] public string CompanyId { get; set; } = "";
+ [Parameter] public string InvoiceId { get; set; } = "";
+
+ // ##############################################################
private string _modalDisplay = "";
private bool _showBackdrop;
private InvoiceView Invoice { get; set; } = new();
diff --git a/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs b/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs
index fefd0de9..c02ab6b1 100644
--- a/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs
+++ b/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs
@@ -31,22 +31,13 @@ public partial class ProductSelectionOverlay
private List FilteredList { get; set; } = new();
private string SearchTerm { get; set; } = "";
+
protected override void OnInitialized()
{
FilterItems(SearchTerm);
}
-
- private void ClearSearch()
- {
- SearchTerm = "";
- FilterItems(SearchTerm);
- }
-
- private void OnSearchChanged()
- {
- FilterItems(SearchTerm);
- }
-
+
+
private async Task SelectItem(DocView item)
{
item.Added = !item.Added;
@@ -54,6 +45,19 @@ public partial class ProductSelectionOverlay
}
+ private void ClearSearch()
+ {
+ SearchTerm = "";
+ FilterItems(SearchTerm);
+ }
+
+
+ private void OnSearchChanged()
+ {
+ FilterItems(SearchTerm);
+ }
+
+
private void FilterItems(string filter)
{
SearchTerm = filter;
diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs
index 387a3e95..78d7058a 100644
--- a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs
@@ -22,9 +22,11 @@ namespace Wonky.Client.OverlayOffice;
public partial class OfficeCustomerActivityListOverlay
{
+ // ##############################################################
[Parameter] public CompanyDto Company { get; set; } = new();
[Parameter] public List ActivityList { get; set; } = new();
+ // ##############################################################
private string _modalDisplay = "";
private bool _showBackdrop;
diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs
index 9a92eda1..70b7c4f7 100644
--- a/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs
@@ -21,7 +21,10 @@ namespace Wonky.Client.OverlayOffice;
public partial class OfficeCustomerActivityViewOverlay
{
+ // ##############################################################
[Parameter] public ReportItemView Activity { get; set; } = new();
+
+ // ##############################################################
private string _modalDisplay = "";
private bool _showBackdrop;
diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor
similarity index 61%
rename from Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor
rename to Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor
index 93dcb757..1bb8e7c8 100644
--- a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor
@@ -30,11 +30,36 @@
-
SortProducts(ProductSort.Desc))"> Navn
+ @*
+
SortProducts(ProductSort.Description))"> Navn
SortProducts(ProductSort.Sku))"> Varenr
-
SortProducts(ProductSort.Qty))"> Antal
-
-
+ *@
+
+
+
+
@foreach (var product in Inventory)
diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs
similarity index 60%
rename from Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs
rename to Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs
index 4017113e..78b7fa6e 100644
--- a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs
@@ -16,6 +16,7 @@
using Microsoft.AspNetCore.Components;
using Wonky.Client.Enums;
+using Wonky.Client.Helpers;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Client.Models;
@@ -26,81 +27,75 @@ using Wonky.Entity.Views;
namespace Wonky.Client.OverlayOffice;
-public partial class OfficeCustomerProductListOverlay : IDisposable
+public partial class OfficeCustomerInventoryListOverlay : IDisposable
{
+ // ##############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryCatalogRepository CatalogRepo { get; set; }
- [Inject] public ILogger
Logger { get; set; }
+ [Inject] public ILogger Logger { get; set; }
+ // ##############################################################
+ [Parameter] public CompanyDto Company { get; set; } = new();
+ [Parameter] public List Inventory { get; set; } = new();
+
+ // ##############################################################
private string _modalDisplay = "";
private bool _showBackdrop;
private DraftItem DraftItem { get; set; } = new();
private SalesItemView SalesItem { get; set; } = new();
private OfficeCustomerInventoryReorderOverlay ReorderOverlay { get; set; } = new();
- private bool Descending { get; set; }
+ private bool Descending { get; set; } = true;
+ private string SearchTerm { get; set; } = "";
+ private List FilteredList { get; set; } = new();
+ private ProductSort SortColumn { get; set; } = ProductSort.LastInvoiceDate;
+
- [Parameter] public CompanyDto Company { get; set; } = new();
- [Parameter] public List Inventory { get; set; } = new();
-
- protected override void OnParametersSet()
- {
- if(Inventory.Any())
- Inventory = Inventory.OrderBy(x => x.Description).ToList();
- }
protected override void OnInitialized()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
+ Inventory = Utils.SortInventory(Inventory, SortColumn, Descending);
+ FilterItems(SearchTerm);
StateHasChanged();
}
+
+ private void OnSearchChanged(string searchTerm)
+ {
+ FilterItems(searchTerm);
+ }
+
+
+ private void SortProducts(ProductSort column)
+ {
+ Descending = !Descending;
+ FilteredList = Utils.SortInventory(FilteredList, column, Descending);
+ }
+
+
+ private void SetSortOrder()
+ {
+ Descending = !Descending;
+ FilteredList = Utils.SortInventory(FilteredList, SortColumn, Descending);
+ }
+
+
+ private void FilterItems(string filter)
+ {
+ SearchTerm = filter;
+ FilteredList = string.IsNullOrWhiteSpace(filter)
+ ? Inventory
+ : Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList();
+ }
+
+
private async Task ShowSkuReorder(string sku)
{
SalesItem = await CatalogRepo.GetSalesItemSku(Company.CountryCode.ToLower(), sku);
ReorderOverlay.Show();
}
-
- private void SortProducts(ProductSort column)
- {
- Descending = !Descending;
- switch (column)
- {
- case ProductSort.Desc:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Description).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Description).ToList();
- break;
- case ProductSort.Sku:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Sku).ToList();
- break;
- }
- Inventory = Inventory.OrderBy(x => x.Sku).ToList();
- break;
- case ProductSort.Qty:
- if (Descending)
- {
- Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList();
- break;
- }
-
- Inventory = Inventory.OrderBy(x => x.Quantity).ToList();
- break;
- case ProductSort.None:
- break;
- case ProductSort.Abbr:
- break;
- default:
- Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList();
- break;
- }
- }
public void Show()
{
_modalDisplay = "block;";
@@ -108,6 +103,7 @@ public partial class OfficeCustomerProductListOverlay : IDisposable
StateHasChanged();
}
+
private void Hide()
{
_modalDisplay = "none;";
@@ -115,9 +111,9 @@ public partial class OfficeCustomerProductListOverlay : IDisposable
StateHasChanged();
}
+
public void Dispose()
{
Interceptor.DisposeEvent();
}
-
}
\ No newline at end of file
diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs
index ac88d156..95bf9900 100644
--- a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs
@@ -26,10 +26,15 @@ namespace Wonky.Client.OverlayOffice;
public partial class OfficeCustomerInventoryReorderOverlay
{
+ // ##############################################################
[Parameter] public CompanyDto Company { get; set; }
[Parameter] public SalesItemView SalesItem { get; set; } = new();
[Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; }
+
+ // ##############################################################
[Parameter] public EventCallback OrderItemCallback { get; set; }
+
+ // ##############################################################
private List History { get; set; } = new();
private DraftItem SelectedItem { get; set; } = new();
private string ProductName { get; set; } = "";
diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs
index cd6e92c6..4fd4e14a 100644
--- a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs
@@ -24,12 +24,16 @@ namespace Wonky.Client.OverlayOffice;
public partial class OfficeCustomerInvoiceViewOverlay : IDisposable
{
+ // ##############################################################
[Parameter] public string CompanyId { get; set; } = "";
[Parameter] public string InvoiceId { get; set; } = "";
[Parameter] public string CountryCode { get; set; } = "";
+
+ // ##############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; }
+ // ##############################################################
private string _modalDisplay = "";
private bool _showBackdrop;
private InvoiceView Invoice { get; set; } = new();
diff --git a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor
similarity index 83%
rename from Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor
rename to Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor
index 06bde79e..8f80795f 100644
--- a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor
@@ -23,7 +23,7 @@
-
+
\ No newline at end of file
diff --git a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor.cs
similarity index 85%
rename from Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor.cs
rename to Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor.cs
index a6f0c2fc..0a12c58a 100644
--- a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor.cs
+++ b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor.cs
@@ -24,23 +24,26 @@ using Wonky.Entity.Views;
namespace Wonky.Client.OverlayOffice;
-public partial class OfficeOrderInventoryListOverlay : IDisposable
+public partial class OfficeCustomerOrderInventoryListOverlay : IDisposable
{
+ // ##############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryCatalogRepository CatalogRepo { get; set; }
- [Inject] public ILogger