From c5f648b7997de79e13211bbf5f90561adb076fe6 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 13 Dec 2022 17:34:43 +0100 Subject: [PATCH] WIP: listing quotes - display on click --- .../ICrmActivityHttpRepository.cs | 4 +- .../CrmActivityHttpRepository.cs | 9 +-- Wonky.Client/Pages/CrmActivityViewPage.razor | 3 +- Wonky.Client/Pages/CrmCompanyViewPage.razor | 4 +- Wonky.Client/Pages/CrmQuotes.razor | 73 ++++++++++++++++--- Wonky.Client/Pages/CrmQuotes.razor.cs | 30 ++++++++ Wonky.Client/Shared/NavMenu.razor | 36 ++++----- Wonky.Client/wwwroot/appsettings.json | 4 +- 8 files changed, 124 insertions(+), 39 deletions(-) create mode 100644 Wonky.Client/Pages/CrmQuotes.razor.cs diff --git a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs index ee0534ae..7abb669c 100644 --- a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs @@ -24,14 +24,14 @@ public interface ICrmActivityHttpRepository /// Get a list of open quotes /// /// List of Activities with ActivityStatus == Quote - Task> GetQuotes(); + Task> GetQuotes(); /// /// Convert quote to sale /// /// /// - Task AcceptQuote(ActivityDto activity); + Task AcceptQuote(ReportItemView activity); /// /// Get activities by date diff --git a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs b/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs index 4fd61e62..d9c088fe 100644 --- a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs @@ -50,10 +50,9 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository /// Get a list of quotes /// /// List of activities with Quote status - public async Task> GetQuotes() + public async Task> GetQuotes() { - var result = await _client.GetFromJsonAsync>($"{_api.CrmActivities}/quotes", _options); - return result ?? new List(); + return await _client.GetFromJsonAsync>($"{_api.CrmActivities}/quotes", _options); } /// @@ -61,10 +60,10 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository /// /// /// - public async Task AcceptQuote(ActivityDto activity) + public async Task AcceptQuote(ReportItemView activity) { var response = await _client.PutAsJsonAsync( - $"{_api.CrmActivities}/{activity.SalesHeadId}/accept", activity, _options); + $"{_api.CrmActivities}/{activity.ActivityId}/accept", activity, _options); var content = await response.Content.ReadAsStringAsync(); var result = JsonSerializer.Deserialize(content); diff --git a/Wonky.Client/Pages/CrmActivityViewPage.razor b/Wonky.Client/Pages/CrmActivityViewPage.razor index 4fb0394e..6f755767 100644 --- a/Wonky.Client/Pages/CrmActivityViewPage.razor +++ b/Wonky.Client/Pages/CrmActivityViewPage.razor @@ -20,6 +20,7 @@ @attribute [Authorize(Roles = "Admin,Office,Warehouse,Advisor")] @page "/companies/{CompanyId}/orders/{OrderId}" +@page "/companies/{CompanyId}/quotes/{OrderId}" @* *@ @@ -31,7 +32,7 @@

@ReportItem.Company.Name

@if (ReportItem.StatusTypeEnum.ToLower() is "quote") { -

TILBUD

+

TILBUD @ReportItem.ESalesNumber

} @if (ReportItem.VisitTypeEnum.ToLower() == "phone" || ReportItem.OurRef.Contains("T:")) { diff --git a/Wonky.Client/Pages/CrmCompanyViewPage.razor b/Wonky.Client/Pages/CrmCompanyViewPage.razor index b404cfa7..1c4714bf 100644 --- a/Wonky.Client/Pages/CrmCompanyViewPage.razor +++ b/Wonky.Client/Pages/CrmCompanyViewPage.razor @@ -129,11 +129,13 @@ + @* + *@
Produkter diff --git a/Wonky.Client/Pages/CrmQuotes.razor b/Wonky.Client/Pages/CrmQuotes.razor index e6e5efb6..b64a5e33 100644 --- a/Wonky.Client/Pages/CrmQuotes.razor +++ b/Wonky.Client/Pages/CrmQuotes.razor @@ -1,15 +1,68 @@ @page "/open-quotes" -@using Wonky.Client.HttpInterfaces -
-

Åbne tilbud

+@using Wonky.Client.Components +
+
+

Åbne tilbud

+
+
+
+
+
+
+ Reference +
+
+ Kunde +
+
+ Dato +
+
+ Tilbudssum +
+
+
+
+ @if (Quotes.Any()) + { + foreach (var quote in Quotes) + { + +
+
+ @quote.ESalesNumber +
+
+ @quote.Company.Name +
+ + @quote.OrderDate + +
+ @($"{quote.OrderAmount:N2}") +
+
+ +
+ @if (!string.IsNullOrWhiteSpace(quote.OfficeNote)) + { +
Note
+
+ @quote.OfficeNote +
+ } +
+
+ } + } + else + { +
Ingen data
+ }
-@code { - [Inject] ICrmHistoryHttpRepository HistoryRepo { get; set; } - - protected override Task OnParametersSetAsync() - { - return base.OnParametersSetAsync(); - } +@if (Working) +{ + } \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmQuotes.razor.cs b/Wonky.Client/Pages/CrmQuotes.razor.cs new file mode 100644 index 00000000..9b4b820e --- /dev/null +++ b/Wonky.Client/Pages/CrmQuotes.razor.cs @@ -0,0 +1,30 @@ +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 CrmQuotes : IDisposable +{ + [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + private List Quotes { get; set; } = new(); + private bool Working = true; + + protected override async Task OnInitializedAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + Quotes = await ActivityRepo.GetQuotes(); + if (Quotes.Any()) + Quotes = Quotes.OrderBy(x => x.CreateTimestamp).ToList(); + Working = false; + } + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Shared/NavMenu.razor b/Wonky.Client/Shared/NavMenu.razor index 5bb26b99..28c92e87 100644 --- a/Wonky.Client/Shared/NavMenu.razor +++ b/Wonky.Client/Shared/NavMenu.razor @@ -33,12 +33,12 @@ @@ -47,12 +47,12 @@ @@ -60,17 +60,12 @@ - @@ -78,7 +73,7 @@ @@ -87,33 +82,38 @@ + diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 2fa6d186..40a62cf9 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.84.1", + "version": "0.85.2", "rc": true, "sandBox": false, "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://eta.innotec.dk", + "baseUrl": "https://zeta.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory",