diff --git a/Wonky.Client/Components/HistoryTableComponent.razor b/Wonky.Client/Components/HistoryTableComponent.razor new file mode 100644 index 00000000..c6d0d53b --- /dev/null +++ b/Wonky.Client/Components/HistoryTableComponent.razor @@ -0,0 +1,52 @@ +@if (History.Any()) +{ + + + + + + + + + + + + + @foreach (var line in History) + { + + + + + + + + + } + +
+ Dato + + Antal + + Vare + + Varenummer + + Rabat + + Pris +
+ @line.DeliverDate + + @line.Quantity + + @line.Name + + @line.Sku + + @(line.Discount)% + + @line.Price +
+} \ No newline at end of file diff --git a/Wonky.Client/Components/HistoryTableComponent.razor.cs b/Wonky.Client/Components/HistoryTableComponent.razor.cs new file mode 100644 index 00000000..cdcc8dc0 --- /dev/null +++ b/Wonky.Client/Components/HistoryTableComponent.razor.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Entity.DTO; + +namespace Wonky.Client.Components; + +public partial class HistoryTableComponent +{ + [Parameter] public List History { get; set; } +} \ No newline at end of file diff --git a/Wonky.Client/Components/InventoryTableComponent.razor b/Wonky.Client/Components/InventoryTableComponent.razor new file mode 100644 index 00000000..84efb096 --- /dev/null +++ b/Wonky.Client/Components/InventoryTableComponent.razor @@ -0,0 +1,34 @@ +@if (Products.Any()) +{ + + + + + + + + + + @foreach (var product in Products) + { + + + + + + } + +
+ Product + + Varenummer + + Antal +
+ @product.Name + + @product.Sku + + @product.Quantity +
+} \ No newline at end of file diff --git a/Wonky.Client/Components/InventoryTableComponent.razor.cs b/Wonky.Client/Components/InventoryTableComponent.razor.cs new file mode 100644 index 00000000..44358aec --- /dev/null +++ b/Wonky.Client/Components/InventoryTableComponent.razor.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Entity.DTO; + +namespace Wonky.Client.Components; + +public partial class InventoryTableComponent +{ + [Parameter] public List Products { get; set; } +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/HistoryHttpRepository.cs b/Wonky.Client/HttpRepository/HistoryHttpRepository.cs new file mode 100644 index 00000000..f5de2e80 --- /dev/null +++ b/Wonky.Client/HttpRepository/HistoryHttpRepository.cs @@ -0,0 +1,72 @@ +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Client.Pages; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public class HistoryHttpRepository : IHistoryHttpRepository +{ + private readonly JsonSerializerOptions _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _apiConfig; + + public HistoryHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _apiConfig = configuration.Value; + } + + + // public async Task> GetTaskList() + // { + // return await _client.GetFromJsonAsync>($"{_apiConfig.TaskItemEndpoint}"); + // } + // + // public async Task CreateTaskItem(TaskItemView taskItem) + // { + // await _client.PostAsJsonAsync($"{_apiConfig.TaskItemEndpoint}", taskItem); + // } + // + // public async Task GetTaskItem(string taskItemId) + // { + // return await _client.GetFromJsonAsync($"{_apiConfig.TaskItemEndpoint}/{taskItemId}"); + // } + public async Task> GetProductInventory(string companyId) + { + return await _client.GetFromJsonAsync>( + $"{_apiConfig.CompanyEndpoint}/{companyId}/{_apiConfig.HistoryEndpoint}/products"); + } + + public async Task> GetProductHistory(string companyId) + { + return await _client.GetFromJsonAsync>( + $"{_apiConfig.CompanyEndpoint}/{companyId}/{_apiConfig.HistoryEndpoint}/products"); + + } + + public async Task> GetProductHistory(string companyId, string sku) + { + return await _client.GetFromJsonAsync>( + $"{_apiConfig.CompanyEndpoint}/{companyId}/{_apiConfig.HistoryEndpoint}/products"); + } + + public async Task UpdateProductHistory(string companyId, string syncDate) + { + return await _client.GetStringAsync($"{_apiConfig.CompanyEndpoint}/{companyId}/{syncDate}"); + } +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/IHistoryHttpRepository.cs b/Wonky.Client/HttpRepository/IHistoryHttpRepository.cs new file mode 100644 index 00000000..2fc95118 --- /dev/null +++ b/Wonky.Client/HttpRepository/IHistoryHttpRepository.cs @@ -0,0 +1,12 @@ +using Wonky.Client.Pages; +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpRepository; + +public interface IHistoryHttpRepository +{ + Task> GetProductInventory(string companyId); + Task> GetProductHistory(string companyId); + Task> GetProductHistory(string companyId, string sku); + Task UpdateProductHistory(string companyId, string syncDate); +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CompanyView.razor b/Wonky.Client/Pages/CompanyView.razor index 6da4f579..389c7bca 100644 --- a/Wonky.Client/Pages/CompanyView.razor +++ b/Wonky.Client/Pages/CompanyView.razor @@ -200,6 +200,12 @@ + +
diff --git a/Wonky.Client/Pages/ProductInventory.razor b/Wonky.Client/Pages/ProductInventory.razor new file mode 100644 index 00000000..bf7f9d20 --- /dev/null +++ b/Wonky.Client/Pages/ProductInventory.razor @@ -0,0 +1 @@ +@page "/companies/{CompanyId}/products" diff --git a/Wonky.Client/Pages/ProductInventory.razor.cs b/Wonky.Client/Pages/ProductInventory.razor.cs new file mode 100644 index 00000000..c41b3073 --- /dev/null +++ b/Wonky.Client/Pages/ProductInventory.razor.cs @@ -0,0 +1,6 @@ +namespace Wonky.Client.Pages; + +public partial class ProductInventory +{ + +} \ No newline at end of file diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 49dba989..7345da22 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -36,7 +36,6 @@ "activityEndpoint": "api/v2/crm/salesReps/sales", "reportEndpoint": "api/v2/crm/salesReps/reports", "taskItemEndpoint": "api/v2/crm/salesRps/tasks", - "productHistoryEndpoint": "products", - "accountHistoryEndpoint": "account" + "historyEndpoint": "products" } } \ No newline at end of file diff --git a/Wonky.Entity/Configuration/ApiConfig.cs b/Wonky.Entity/Configuration/ApiConfig.cs index e3058745..4dbdfe1c 100644 --- a/Wonky.Entity/Configuration/ApiConfig.cs +++ b/Wonky.Entity/Configuration/ApiConfig.cs @@ -33,6 +33,5 @@ public class ApiConfig public string ActivityEndpoint { get; set; } = ""; public string ReportEndpoint { get; set; } = ""; public string TaskItemEndpoint { get; set; } = ""; - public string ProductHistoryEndpoint { get; set; } = ""; - public string AccountHistoryEndpoint { get; set; } = ""; + public string HistoryEndpoint { get; set; } = ""; } \ No newline at end of file diff --git a/Wonky.Entity/DTO/ProductHistoryView.cs b/Wonky.Entity/DTO/ProductHistoryView.cs new file mode 100644 index 00000000..4a1619ca --- /dev/null +++ b/Wonky.Entity/DTO/ProductHistoryView.cs @@ -0,0 +1,11 @@ +namespace Wonky.Entity.DTO; + +public class ProductHistoryView +{ + public string DeliverDate { get; set; } = ""; + public string Name { get; set; } = ""; + public string Sku { get; set; } = ""; + public int Quantity { get; set; } + public decimal Price { get; set; } + public decimal Discount { get; set; } +} \ No newline at end of file diff --git a/Wonky.Entity/DTO/ProductInventoryView.cs b/Wonky.Entity/DTO/ProductInventoryView.cs new file mode 100644 index 00000000..63d41ee4 --- /dev/null +++ b/Wonky.Entity/DTO/ProductInventoryView.cs @@ -0,0 +1,8 @@ +namespace Wonky.Entity.DTO; + +public class ProductInventoryView +{ + public string Name { get; set; } = ""; + public string Sku { get; set; } = ""; + public int Quantity { get; set; } +} \ No newline at end of file