diff --git a/Wonky.Client/Components/UserTableComponent.razor b/Wonky.Client/Components/UserTableComponent.razor new file mode 100644 index 00000000..dc3833e0 --- /dev/null +++ b/Wonky.Client/Components/UserTableComponent.razor @@ -0,0 +1,57 @@ +@* +// 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()) +{ +
+
+
+
+ Navn +
+
+ Land +
+
+ Email +
+
+ Telefonnr. +
+
+
+ @foreach (var user in UserList) + { + +
+
+ @user.FullName +
+
+ @user.CountryCode +
+
+ @user.Email +
+
+ @user.PhoneNUmber +
+
+
+ } +
+} \ No newline at end of file diff --git a/Wonky.Client/Components/UserTableComponent.razor.cs b/Wonky.Client/Components/UserTableComponent.razor.cs new file mode 100644 index 00000000..fe5e8dd4 --- /dev/null +++ b/Wonky.Client/Components/UserTableComponent.razor.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.Components; + +public partial class UserTableComponent +{ + [Parameter] public List UserList { get; set; } +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/IUserHttpRepository.cs b/Wonky.Client/HttpRepository/IUserHttpRepository.cs new file mode 100644 index 00000000..1fc3f994 --- /dev/null +++ b/Wonky.Client/HttpRepository/IUserHttpRepository.cs @@ -0,0 +1,8 @@ +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpRepository; + +public interface IUserHttpRepository +{ + Task?> GetSalesReps(); +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/UserHttpRepository.cs b/Wonky.Client/HttpRepository/UserHttpRepository.cs new file mode 100644 index 00000000..e1566c29 --- /dev/null +++ b/Wonky.Client/HttpRepository/UserHttpRepository.cs @@ -0,0 +1,40 @@ +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpRepository; + +public class UserHttpRepository : IUserHttpRepository +{ + private readonly JsonSerializerOptions? _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _api; + + public UserHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, + IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _api = configuration.Value; + } + + public async Task?> GetSalesReps() + { + var response = await _client.GetAsync(_api.AdminSalesRepUri); + var content = await response.Content.ReadAsStringAsync(); + return !response.IsSuccessStatusCode + ? new List() + : JsonSerializer.Deserialize>(content, _options); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/AdminUserList.razor b/Wonky.Client/Pages/AdminUserList.razor new file mode 100644 index 00000000..b20da46a --- /dev/null +++ b/Wonky.Client/Pages/AdminUserList.razor @@ -0,0 +1,10 @@ +@using Wonky.Client.Components +@page "/admin/users" +
+
+

Sælgere

+
+
+ +
+
\ No newline at end of file diff --git a/Wonky.Client/Pages/AdminUserList.razor.cs b/Wonky.Client/Pages/AdminUserList.razor.cs new file mode 100644 index 00000000..c1329ade --- /dev/null +++ b/Wonky.Client/Pages/AdminUserList.razor.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Wonky.Entity.DTO; + +namespace Wonky.Client.Pages; + +public partial class AdminUserList +{ + [Inject] private HttpInterceptorService _interceptor { get; set; } + [Inject] private IUserHttpRepository _userRepo { get; set; } + private List? _salesReps { get; set; } = new(); + + protected override async Task OnInitializedAsync() + { + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); + + _salesReps = await _userRepo.GetSalesReps(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index 0f79cee9..f8190127 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -54,6 +54,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddBlazoredLocalStorage(); diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 9e01f97f..4325823b 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -18,12 +18,12 @@ }, "appInfo": { "name": "Wonky Client", - "version": "0.8.37", + "version": "0.8.38", "isBeta": true, "image": "grumpy-coder.png" }, "apiConfig": { - "innoBaseUrl": "https://staging.innotec.dk", + "innoBaseUrl": "https://dev.innotec.dk", "glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=", "glsId": "", "virkUrl": "api/v2/services/virk", @@ -38,6 +38,7 @@ "companyUri": "api/v2/crm/companies", "inventoryUri": "history/inventory", "productUri": "history/products", - "syncUri": "history/sync" + "syncUri": "history/sync", + "adminSalesRepUri": "api/v2/admin/users/salesreps" } } \ No newline at end of file diff --git a/Wonky.Entity/Configuration/ApiConfig.cs b/Wonky.Entity/Configuration/ApiConfig.cs index 43a7199e..271415e6 100644 --- a/Wonky.Entity/Configuration/ApiConfig.cs +++ b/Wonky.Entity/Configuration/ApiConfig.cs @@ -34,12 +34,13 @@ public class ApiConfig public string InventoryUri { get; set; } = ""; public string ProductUri { get; set; } = ""; public string SyncUri { get; set; } = ""; + public string AdminSalesRepUri { get; set; } = ""; + + - - // public string KrvVariantsUri { get; set; } = ""; // public string KrvProductsUri { get; set; } = ""; // public string ImageUploadUri { get; set; } = ""; // public string UserRegistrationUri { get; set; } = ""; - + } \ No newline at end of file diff --git a/Wonky.Entity/DTO/AdminUserListView.cs b/Wonky.Entity/DTO/AdminUserListView.cs new file mode 100644 index 00000000..ddbfbd23 --- /dev/null +++ b/Wonky.Entity/DTO/AdminUserListView.cs @@ -0,0 +1,10 @@ +namespace Wonky.Entity.DTO; + +public class AdminUserListView +{ + public string UserId { get; set; } = ""; + public string FullName { get; set; } = ""; + public string Email { get; set; } = ""; + public string CountryCode { get; set; } = ""; + public string PhoneNUmber { get; set; } = ""; +} \ No newline at end of file