From bd09308a76a0eb63d64d6771fb0590cc2b72153b Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 13 Dec 2022 07:57:29 +0100 Subject: [PATCH 01/11] WIP: quotes - refactor express call to use get instead of put --- .../ICrmActivityHttpRepository.cs | 8 +++- .../CrmActivityHttpRepository.cs | 44 +++++++++++-------- ...CrmCompanyQuotes.razor => CrmQuotes.razor} | 2 +- Wonky.Client/Pages/InfoPage.razor | 17 ++++--- Wonky.Client/Pages/OfficeOrderViewPage.razor | 6 ++- .../Pages/OfficeOrderViewPage.razor.cs | 34 +++++++------- Wonky.Client/wwwroot/appsettings.json | 4 +- 7 files changed, 63 insertions(+), 52 deletions(-) rename Wonky.Client/Pages/{CrmCompanyQuotes.razor => CrmQuotes.razor} (87%) diff --git a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs index a3807d2d..ee0534ae 100644 --- a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs @@ -20,6 +20,12 @@ namespace Wonky.Client.HttpInterfaces; public interface ICrmActivityHttpRepository { + /// + /// Get a list of open quotes + /// + /// List of Activities with ActivityStatus == Quote + Task> GetQuotes(); + /// /// Convert quote to sale /// @@ -67,7 +73,7 @@ public interface ICrmActivityHttpRepository /// /// /// ApiResponseView - Task SetProcessStateExpress(string activityId); + Task GetExpressState(string activityId); /// /// Update office note for activity diff --git a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs b/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs index 5d835af1..4fd61e62 100644 --- a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs @@ -46,6 +46,16 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository _api = configuration.Value; } + /// + /// Get a list of quotes + /// + /// List of activities with Quote status + public async Task> GetQuotes() + { + var result = await _client.GetFromJsonAsync>($"{_api.CrmActivities}/quotes", _options); + return result ?? new List(); + } + /// /// Convert quote to sale /// @@ -55,7 +65,7 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository { var response = await _client.PutAsJsonAsync( $"{_api.CrmActivities}/{activity.SalesHeadId}/accept", activity, _options); - + var content = await response.Content.ReadAsStringAsync(); var result = JsonSerializer.Deserialize(content); return result!; @@ -89,8 +99,8 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository if (!response.IsSuccessStatusCode) return new ReportStatusView(); var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new ReportStatusView() + return string.IsNullOrWhiteSpace(content) + ? new ReportStatusView() : JsonSerializer.Deserialize(content, _options); } @@ -115,12 +125,11 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository { var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}"); var content = await response.Content.ReadAsStringAsync(); - if(!response.IsSuccessStatusCode) + if (!response.IsSuccessStatusCode) return new List(); return string.IsNullOrWhiteSpace(content) ? new List() - : JsonSerializer.Deserialize>(content, _options); - + : JsonSerializer.Deserialize>(content, _options); } /// @@ -135,24 +144,21 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository return salesItem ?? new ReportItemView(); } + /// /// Set backend process state to express /// /// /// ApiResponseView - public async Task SetProcessStateExpress(string activityId) + public async Task GetExpressState(string activityId) { - var response = await _client.PutAsync( - $"{_api.CrmActivities}/express/{activityId}?status=Express", null); - var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new ApiResponseView - { - Code = (int)response.StatusCode, - Id = activityId, - Message = "Resoursen returnerede fejl", - IsSuccess = false - } - : JsonSerializer.Deserialize(content); + var response = await _client.GetFromJsonAsync($"{_api.CrmActivities}/express/{activityId}?status=Express", _options); + return response ?? new ApiResponseView + { + Code = 404, + IsSuccess = false, + Message = "Uventet svare fra server", + Id = "" + }; } /// diff --git a/Wonky.Client/Pages/CrmCompanyQuotes.razor b/Wonky.Client/Pages/CrmQuotes.razor similarity index 87% rename from Wonky.Client/Pages/CrmCompanyQuotes.razor rename to Wonky.Client/Pages/CrmQuotes.razor index c102c516..e6e5efb6 100644 --- a/Wonky.Client/Pages/CrmCompanyQuotes.razor +++ b/Wonky.Client/Pages/CrmQuotes.razor @@ -1,4 +1,4 @@ -@page "/companies/{CompanyId}/quotes" +@page "/open-quotes" @using Wonky.Client.HttpInterfaces

Åbne tilbud

diff --git a/Wonky.Client/Pages/InfoPage.razor b/Wonky.Client/Pages/InfoPage.razor index 562c99e1..5d78d83b 100644 --- a/Wonky.Client/Pages/InfoPage.razor +++ b/Wonky.Client/Pages/InfoPage.razor @@ -26,14 +26,14 @@
Wonky Logo -
+

Piktogrammer

- +
diff --git a/Wonky.Client/Pages/OfficeOrderViewPage.razor b/Wonky.Client/Pages/OfficeOrderViewPage.razor index 415dc641..ee590b0b 100644 --- a/Wonky.Client/Pages/OfficeOrderViewPage.razor +++ b/Wonky.Client/Pages/OfficeOrderViewPage.razor @@ -35,9 +35,11 @@
-
+
- +
+
+
diff --git a/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs b/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs index 7adee03f..bd9029b7 100644 --- a/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs +++ b/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs @@ -45,7 +45,7 @@ public partial class OfficeOrderViewPage : IDisposable private bool _isNotified { get; set; } private bool Working { get; set; } = true; - private readonly JsonSerializerOptions? _options = new JsonSerializerOptions + private readonly JsonSerializerOptions _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; @@ -54,6 +54,7 @@ public partial class OfficeOrderViewPage : IDisposable { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); + // fetch order from backend _reportItem = await ActivityRepo.GetReportItem(OrderId); Logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(_reportItem, _options)); Working = false; @@ -64,25 +65,20 @@ public partial class OfficeOrderViewPage : IDisposable ///
private async Task SetExpressState() { + // disable doubled actions if (Working) return; Working = true; - Logger.LogDebug("SetExpressState => \n {}", JsonSerializer.Serialize(_reportItem, _options)); - var responseView = await ActivityRepo.SetProcessStateExpress(_reportItem.ActivityId); - Logger.LogDebug("SetExpressState => \n {}", responseView.Message ); - - if (!responseView.IsSuccess) - { - Toast.ShowError(responseView.Message); - Working = false; - return; - } - + Logger.LogDebug("GetExpressState => {}", JsonSerializer.Serialize(_reportItem, _options)); + // send request to backend + var responseView = await ActivityRepo.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); - - Logger.LogDebug("SetExpressState => salesRep => \n {}", JsonSerializer.Serialize(salesRep)); - + Logger.LogDebug("SetExpressState => salesRep => {}", JsonSerializer.Serialize(salesRep)); + // create email notification body var body = new StringBuilder(); body.AppendLine($"Kvittering for modtagelse af hasteordre {_reportItem.ESalesNumber}"); body.AppendLine($"Konto : {_reportItem.Company.Account}"); @@ -93,7 +89,7 @@ public partial class OfficeOrderViewPage : IDisposable body.AppendLine("Med venlig hilsen"); body.AppendLine($"{user.FullName}"); body.AppendLine($"{user.PhoneNumber}"); - + // create a list of mail addresses var sendTo = new List { new() @@ -102,7 +98,7 @@ public partial class OfficeOrderViewPage : IDisposable Name = $"{salesRep.FirstName} {salesRep.LastName}" } }; - + // create an email var msg = new EmailMessage { Body = body.ToString(), @@ -111,7 +107,9 @@ public partial class OfficeOrderViewPage : IDisposable IsBodyHtml = false }; 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) { Toast @@ -124,7 +122,7 @@ public partial class OfficeOrderViewPage : IDisposable .ShowWarning( $"Notifikation til {salesRep.FirstName} kunne ikke sendes. {sendMail.Message}", "ADVARSEL"); } - + // disable further notifications _isNotified = true; Working = false; } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index d20dd595..2fa6d186 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.83.3", + "version": "0.84.1", "rc": true, "sandBox": false, "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://zeta.innotec.dk", + "baseUrl": "https://eta.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", From be93ab06f8fee4684ca79b836a6b2f42b359ea4a Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 13 Dec 2022 11:29:34 +0100 Subject: [PATCH 02/11] new attempt to prevent doubled history --- .../ProductInventoryTableComponent.razor | 2 +- .../Pages/CrmCompanyInventoryPage.razor.cs | 12 +++++++++--- .../Pages/CrmCompanyInvoiceListPage.razor.cs | 16 +++++++++++----- Wonky.Client/wwwroot/appsettings.json | 4 ++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Wonky.Client/Components/ProductInventoryTableComponent.razor b/Wonky.Client/Components/ProductInventoryTableComponent.razor index 9dc3b1a0..1d346cd9 100644 --- a/Wonky.Client/Components/ProductInventoryTableComponent.razor +++ b/Wonky.Client/Components/ProductInventoryTableComponent.razor @@ -53,7 +53,7 @@ @product.Quantity - Se Historik + Genbestil } diff --git a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs index 57cbb3f3..b016b5e5 100644 --- a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs +++ b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs @@ -43,9 +43,15 @@ public partial class CrmCompanyInventoryPage : IDisposable Interceptor.RegisterBeforeSendEvent(); Company = await CompanyRepo.GetCompanyById(CompanyId); - - var _ = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); - + while (string.IsNullOrWhiteSpace(Company.HistorySync)) + { + await Task.Delay(1000); + } + var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + while (string.IsNullOrWhiteSpace(ts)) + { + await Task.Delay(1000); + } await FetchInventory(); Working = false; } diff --git a/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs b/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs index 876fc041..c570f0f4 100644 --- a/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs +++ b/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs @@ -24,13 +24,19 @@ public partial class CrmCompanyInvoiceListPage : IDisposable { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - + Company = await CompanyRepo.GetCompanyById(CompanyId); - - var _ = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); - - History = await HistoryRepo.FetchInvoiceList(CompanyId); + while (string.IsNullOrWhiteSpace(Company.HistorySync)) + { + await Task.Delay(1000); + } + var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + while (string.IsNullOrWhiteSpace(ts)) + { + await Task.Delay(1000); + } + History = await HistoryRepo.FetchInvoiceList(CompanyId); Working = false; } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 2fa6d186..ee1ff149 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.84.3", "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", From c5f648b7997de79e13211bbf5f90561adb076fe6 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 13 Dec 2022 17:34:43 +0100 Subject: [PATCH 03/11] 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", From b5cf59069fd187e5a3df72342149fea840cd7c3b Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 14 Dec 2022 16:44:15 +0100 Subject: [PATCH 04/11] WIP: added action buttons to quote list --- Wonky.Client/Pages/CrmActivityViewPage.razor | 2 +- Wonky.Client/Pages/CrmQuotes.razor | 17 +- Wonky.Client/Pages/CrmQuotes.razor.cs | 11 +- Wonky.Client/wwwroot/appsettings.json | 2 +- Wonky.Entity/Views/ReportItemView.cs | 154 +++++++++++-------- 5 files changed, 114 insertions(+), 72 deletions(-) diff --git a/Wonky.Client/Pages/CrmActivityViewPage.razor b/Wonky.Client/Pages/CrmActivityViewPage.razor index 6f755767..39a03caa 100644 --- a/Wonky.Client/Pages/CrmActivityViewPage.razor +++ b/Wonky.Client/Pages/CrmActivityViewPage.razor @@ -32,7 +32,7 @@

@ReportItem.Company.Name

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

TILBUD @ReportItem.ESalesNumber

+

TILBUD @ReportItem.ESalesNumber

} @if (ReportItem.VisitTypeEnum.ToLower() == "phone" || ReportItem.OurRef.Contains("T:")) { diff --git a/Wonky.Client/Pages/CrmQuotes.razor b/Wonky.Client/Pages/CrmQuotes.razor index b64a5e33..2db46fb8 100644 --- a/Wonky.Client/Pages/CrmQuotes.razor +++ b/Wonky.Client/Pages/CrmQuotes.razor @@ -5,7 +5,7 @@

Åbne tilbud

-
+
@@ -27,10 +27,10 @@ { foreach (var quote in Quotes) { - -
+
+
@quote.Company.Name @@ -41,9 +41,10 @@
@($"{quote.OrderAmount:N2}")
-
- -
+
+
+
+
@if (!string.IsNullOrWhiteSpace(quote.OfficeNote)) {
Note
@@ -52,7 +53,7 @@
}
- +
} } else diff --git a/Wonky.Client/Pages/CrmQuotes.razor.cs b/Wonky.Client/Pages/CrmQuotes.razor.cs index 9b4b820e..3255c9aa 100644 --- a/Wonky.Client/Pages/CrmQuotes.razor.cs +++ b/Wonky.Client/Pages/CrmQuotes.razor.cs @@ -11,7 +11,7 @@ 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; + private bool Working { get; set; } = true; protected override async Task OnInitializedAsync() { @@ -23,6 +23,15 @@ public partial class CrmQuotes : IDisposable Working = false; } + private void SetQuote(int status) + { + // todo - implement update quote from status + // status matches QuoteStatusEnum + // 0 - None + // 1 - Win + // 2 - Lose + // 3 - Draw + } public void Dispose() { Interceptor.DisposeEvent(); diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 40a62cf9..1dbf92ab 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.85.2", + "version": "0.85.4", "rc": true, "sandBox": false, "image": "grumpy-coder.png" diff --git a/Wonky.Entity/Views/ReportItemView.cs b/Wonky.Entity/Views/ReportItemView.cs index 1e6a2b37..6d7853a9 100644 --- a/Wonky.Entity/Views/ReportItemView.cs +++ b/Wonky.Entity/Views/ReportItemView.cs @@ -21,96 +21,128 @@ public class ReportItemView /// Customer company info ///
public ReportItemCustomer Company { get; set; } = new(); + /// /// Lines /// public List Lines { get; set; } = new(); - /// - /// entity id for sales rep - /// - public string SalesRepId { get; set; } = ""; + /// /// Activity entity id /// public string ActivityId { get; set; } = ""; - /// - /// Entity CreateTimestamp as string - /// - public string CreateTimestamp { get; set; } = ""; + /// /// Closed sale /// public bool Closed { get; set; } + /// - /// ProcessStatus as string + /// Entity CreateTimestamp as string /// - public string ProcessStatusEnum { get; set; } = ""; + public string CreateTimestamp { get; set; } = ""; + /// - /// express flag + /// CRM Note /// - public bool Express { get; set; } - /// - /// ESales number - /// - public string ESalesNumber { get; set; } = ""; - /// - /// Order amount - /// - public decimal OrderAmount { get; set; } - /// - /// Order safe seal amount - /// - public decimal SasAmount { get; set; } - /// - /// Order date - /// - public string OrderDate { get; set; } = ""; - /// - /// Office note - /// - public string OfficeNote { get; set; } = ""; + public string CrmNote { get; set; } = ""; + /// /// Product demo /// public string Demo { get; set; } = ""; - /// - /// Product sale resume - /// - public string Sales { get; set; } = ""; - /// - /// Our reference - /// - public string OurRef { get; set; } = ""; - /// - /// Customer reference - /// - public string YourRef { get; set; } = ""; - /// - /// Customer reference number - /// - public string ReferenceNumber { get; set; } = ""; - /// - /// Visit type enum as string - /// - public string VisitTypeEnum { get; set; } = ""; - /// - /// Status type enum as string - /// - public string StatusTypeEnum { get; set; } = ""; - /// - /// Customer deliver name - /// - public string DlvName { get; set; } = ""; + /// /// Customer delivery address line 1 /// public string DlvAddress1 { get; set; } = ""; + /// /// Customer delivery address line 2 /// public string DlvAddress2 { get; set; } = ""; + + /// + /// Customer deliver name + /// + public string DlvName { get; set; } = ""; + /// /// Customer delivery post code and city name /// - public string DlvZipCity { get; set; } = ""; + public string DlvZipCity { get; set; } = ""; + /// + /// ESales number + /// + public string ESalesNumber { get; set; } = ""; + + /// + /// express flag + /// + public bool Express { get; set; } + + /// + /// Office note + /// + public string OfficeNote { get; set; } = ""; + + /// + /// Order amount + /// + public decimal OrderAmount { get; set; } + + /// + /// Order date + /// + public string OrderDate { get; set; } = ""; + + /// + /// Our reference + /// + public string OurRef { get; set; } = ""; + + /// + /// ProcessStatus as string + /// + public string ProcessStatusEnum { get; set; } = ""; + + /// + /// QuoteStatus as string + /// + public string QuoteStatusEnum { get; set; } = ""; + + /// + /// Customer reference number + /// + public string ReferenceNumber { get; set; } = ""; + + /// + /// Product sale resume + /// + public string Sales { get; set; } = ""; + + /// + /// entity id for sales rep + /// + public string SalesRepId { get; set; } = ""; + + /// + /// Order safe seal amount + /// + public decimal SasAmount { get; set; } + + /// + /// Status type enum as string + /// + public string StatusTypeEnum { get; set; } = ""; + + /// + /// Visit type enum as string + /// + public string VisitTypeEnum { get; set; } = ""; + + /// + /// Customer reference + /// + public string YourRef { get; set; } = ""; } \ No newline at end of file From 2888273e808057d78973f352f74acb92d3ebb409 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 14 Dec 2022 16:45:49 +0100 Subject: [PATCH 05/11] ensure no duplicates --- Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs | 10 +++++++++- Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs index 57cbb3f3..eff44a39 100644 --- a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs +++ b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs @@ -44,7 +44,15 @@ public partial class CrmCompanyInventoryPage : IDisposable Company = await CompanyRepo.GetCompanyById(CompanyId); - var _ = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + while (string.IsNullOrWhiteSpace(Company.HistorySync)) + { + await Task.Delay(1000); + } + var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + while (string.IsNullOrWhiteSpace(ts)) + { + await Task.Delay(1000); + } await FetchInventory(); Working = false; diff --git a/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs b/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs index 876fc041..50407f27 100644 --- a/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs +++ b/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs @@ -27,7 +27,15 @@ public partial class CrmCompanyInvoiceListPage : IDisposable Company = await CompanyRepo.GetCompanyById(CompanyId); - var _ = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + while (string.IsNullOrWhiteSpace(Company.HistorySync)) + { + await Task.Delay(1000); + } + var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + while (string.IsNullOrWhiteSpace(ts)) + { + await Task.Delay(1000); + } History = await HistoryRepo.FetchInvoiceList(CompanyId); From 7afd67378ccd12f2ef8140d281352f0fce812058 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 14 Dec 2022 17:55:53 +0100 Subject: [PATCH 06/11] remove var declare --- Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs | 2 +- Wonky.Client/wwwroot/appsettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs b/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs index 36056ffa..35a77f8c 100644 --- a/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs +++ b/Wonky.Client/Pages/CrmCompanyInvoiceListPage.razor.cs @@ -43,7 +43,7 @@ public partial class CrmCompanyInvoiceListPage : IDisposable { await Task.Delay(1000); } - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); while (string.IsNullOrWhiteSpace(ts)) { await Task.Delay(1000); diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 75b1b9d3..4e5408a5 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.85.4", + "version": "0.85.5", "rc": true, "sandBox": false, "image": "grumpy-coder.png" From 41ce3362999becba7ffcd5216416b2e0b0bb5cb3 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Thu, 15 Dec 2022 17:05:09 +0100 Subject: [PATCH 07/11] WIP: quote listing and status update --- .../Components/QuoteListComponent.razor | 99 +++++++++++++++++++ Wonky.Client/Helpers/Utils.cs | 8 +- .../ICrmActivityHttpRepository.cs | 2 +- .../CrmActivityHttpRepository.cs | 16 +-- Wonky.Client/Models/QStatus.cs | 11 +++ Wonky.Client/Models/QuoteCallbackArgs.cs | 7 ++ Wonky.Client/Pages/CrmActivityNewPage.razor | 14 +-- .../Pages/CrmActivityNewPage.razor.cs | 48 +++++---- Wonky.Client/Pages/CrmQuotes.razor | 69 ------------- Wonky.Client/Pages/CrmQuotes.razor.cs | 39 -------- Wonky.Client/Pages/CrmQuotesListPage.razor | 44 +++++++++ Wonky.Client/Pages/CrmQuotesListPage.razor.cs | 81 +++++++++++++++ Wonky.Client/wwwroot/appsettings.json | 4 +- 13 files changed, 297 insertions(+), 145 deletions(-) create mode 100644 Wonky.Client/Components/QuoteListComponent.razor create mode 100644 Wonky.Client/Models/QStatus.cs create mode 100644 Wonky.Client/Models/QuoteCallbackArgs.cs delete mode 100644 Wonky.Client/Pages/CrmQuotes.razor delete mode 100644 Wonky.Client/Pages/CrmQuotes.razor.cs create mode 100644 Wonky.Client/Pages/CrmQuotesListPage.razor create mode 100644 Wonky.Client/Pages/CrmQuotesListPage.razor.cs diff --git a/Wonky.Client/Components/QuoteListComponent.razor b/Wonky.Client/Components/QuoteListComponent.razor new file mode 100644 index 00000000..ae26ba59 --- /dev/null +++ b/Wonky.Client/Components/QuoteListComponent.razor @@ -0,0 +1,99 @@ +@using Wonky.Entity.Views +@using Wonky.Client.Models + +
+
+
+
+ Reference +
+
+ Kunde +
+
+ Dato +
+
+ Status +
+
+
+
+ @if (Quotes.Any()) + { + foreach (var quote in Quotes) + { +
+
+ +
+ @quote.Company.Name +
+ + @quote.OrderDate + +
+ @switch (quote.QuoteStatusEnum) + { + case "None": + + break; + case "Win": + Ordre + break; + case "Lose": + + break; + case "Note": + + break; + case "Archive": + + break; + default: + + break; + } +
+
+ + + + +
+ @if (!string.IsNullOrWhiteSpace(quote.OfficeNote)) + { +
+
+ @quote.OfficeNote +
+ } +
+
+ } + } + else + { +
Ingen data
+ } +
+ +@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/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index 57b4db2d..ebce0ac1 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -35,7 +35,13 @@ public static class Utils catch { return false; } - } + } + + public static string EnumToString(Enum value) + { + return value.ToString(); + } + public static int GetHashFromNow() { return DateTime.Now.ToFileTimeUtc().GetHashCode(); diff --git a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs index 7abb669c..dbab34d8 100644 --- a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs @@ -31,7 +31,7 @@ public interface ICrmActivityHttpRepository /// /// /// - Task AcceptQuote(ReportItemView activity); + Task UpdateQuoteStatus(ReportItemView activity); /// /// Get activities by date diff --git a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs b/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs index d9c088fe..2e1d877b 100644 --- a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CrmActivityHttpRepository.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; using System.Net.Http.Json; using System.Text.Json; using Microsoft.AspNetCore.Components; @@ -60,14 +61,13 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository /// /// /// - public async Task AcceptQuote(ReportItemView activity) + public async Task UpdateQuoteStatus(ReportItemView activity) { - var response = await _client.PutAsJsonAsync( - $"{_api.CrmActivities}/{activity.ActivityId}/accept", activity, _options); - + var response = await _client.PutAsJsonAsync( + $"{_api.CrmActivities}/quote/{activity.ActivityId}", activity, _options); var content = await response.Content.ReadAsStringAsync(); - var result = JsonSerializer.Deserialize(content); - return result!; + _logger.LogDebug("UpdateQuote Response Content <= {}", content); + return JsonSerializer.Deserialize(content, _options); } /// @@ -150,7 +150,9 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository /// ApiResponseView public async Task GetExpressState(string activityId) { - var response = await _client.GetFromJsonAsync($"{_api.CrmActivities}/express/{activityId}?status=Express", _options); + var response = + await _client.GetFromJsonAsync($"{_api.CrmActivities}/express/{activityId}?status=Express", + _options); return response ?? new ApiResponseView { Code = 404, diff --git a/Wonky.Client/Models/QStatus.cs b/Wonky.Client/Models/QStatus.cs new file mode 100644 index 00000000..130994ce --- /dev/null +++ b/Wonky.Client/Models/QStatus.cs @@ -0,0 +1,11 @@ +namespace Wonky.Client.Models; + +public enum QStatus +{ + None, + Win, + Lose, + Archive, + Note, + All +} \ No newline at end of file diff --git a/Wonky.Client/Models/QuoteCallbackArgs.cs b/Wonky.Client/Models/QuoteCallbackArgs.cs new file mode 100644 index 00000000..44e2ab68 --- /dev/null +++ b/Wonky.Client/Models/QuoteCallbackArgs.cs @@ -0,0 +1,7 @@ +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/Pages/CrmActivityNewPage.razor b/Wonky.Client/Pages/CrmActivityNewPage.razor index abd5f453..ea304e21 100644 --- a/Wonky.Client/Pages/CrmActivityNewPage.razor +++ b/Wonky.Client/Pages/CrmActivityNewPage.razor @@ -64,7 +64,7 @@ else @if (!string.IsNullOrEmpty(Activity.VatNumber) && !string.IsNullOrWhiteSpace(Activity.Address1) && Company.HasFolded == 0) { - @if (DraftStateProvider.Draft.DraftType == "order") + @if (DraftProvider.Draft.DraftType == "order") { } @@ -73,7 +73,7 @@ else } - @if(DraftStateProvider.Draft.DraftType == "offer") + @if(DraftProvider.Draft.DraftType == "offer") { } @@ -158,10 +158,10 @@ else - Ordrekladde Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) + Ordrekladde Global kladde (udløber efter @(DraftProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) - + @@ -176,9 +176,9 @@ else - @if (DraftStateProvider.Draft.Items.Count > 0) + @if (DraftProvider.Draft.Items.Count > 0) { - @foreach (var cartItem in DraftStateProvider.Draft.Items) + @foreach (var cartItem in DraftProvider.Draft.Items) { @cartItem.Item.Name @@ -199,7 +199,7 @@ else Total - @($"{DraftStateProvider.Draft.Total:N2}") + @($"{DraftProvider.Draft.Total:N2}") private async Task DeleteDraft() { - await DraftStateProvider.DeleteDraftAsync(); + await DraftProvider.DeleteDraftAsync(); Activity.ActivityStatusEnum = "noSale"; } @@ -342,11 +342,11 @@ public partial class CrmActivityNewPage : IDisposable Price = "0"; Discount = "0"; // add it to the cart - DraftStateProvider.Draft.Items.Add(item); + DraftProvider.Draft.Items.Add(item); if(Activity.ActivityStatusEnum != "quote") Activity.ActivityStatusEnum = "order"; // save the item using the CartStateProvider's save method - await DraftStateProvider.SaveChangesAsync(); + await DraftProvider.SaveChangesAsync(); } /// @@ -356,10 +356,10 @@ public partial class CrmActivityNewPage : IDisposable private async Task RemoveItem(DraftItem item) { // remove item - DraftStateProvider.Draft.Items.Remove(item); + DraftProvider.Draft.Items.Remove(item); // save the remaining draft - await DraftStateProvider.SaveChangesAsync(); - if (!DraftStateProvider.Draft.Items.Any()) + await DraftProvider.SaveChangesAsync(); + if (!DraftProvider.Draft.Items.Any()) Activity.ActivityStatusEnum = "noSale"; } @@ -370,11 +370,20 @@ public partial class CrmActivityNewPage : IDisposable /// private void HandleFieldChanged(object sender, FieldChangedEventArgs e) { - DraftStateProvider.Draft.DraftType = Activity.ActivityStatusEnum; + Logger.LogDebug("ActivityNewPage => HandleFieldChanged => ActivityStatusEnum <= '{}'", Activity.ActivityStatusEnum); + DraftProvider.Draft.DraftType = Activity.ActivityStatusEnum; + if (Activity.ActivityStatusEnum == "noSale") + { + Logger.LogDebug("ActivityNewPage => ActivityStatusEnum == 'noSale' <= remove items"); + DraftProvider.Draft.Items = new List(); + + } + + // InvalidCanvas = InvalidActivityType; InvalidActivity = InvalidActivityType || PoFormInvalid - || DraftStateProvider.Draft.Items.Count == 0 + || DraftProvider.Draft.Items.Count == 0 || (Activity.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(Activity.Email)); if (Activity.YourRef.Length > 35 || Activity.ReferenceNumber.Length > 20 || InvalidActivity) { @@ -395,6 +404,7 @@ public partial class CrmActivityNewPage : IDisposable if (string.IsNullOrEmpty(Activity.ActivityTypeEnum) && !ReportClosed) { Toast.ShowWarning("Aktivitet type kan ikke være tom"); + PoFormInvalid = true; return; } PoFormInvalid = false; diff --git a/Wonky.Client/Pages/CrmQuotes.razor b/Wonky.Client/Pages/CrmQuotes.razor deleted file mode 100644 index 2db46fb8..00000000 --- a/Wonky.Client/Pages/CrmQuotes.razor +++ /dev/null @@ -1,69 +0,0 @@ -@page "/open-quotes" -@using Wonky.Client.Components -
-
-

Åbne tilbud

-
-
-
-
-
-
- Reference -
-
- Kunde -
-
- Dato -
-
- Tilbudssum -
-
-
-
- @if (Quotes.Any()) - { - foreach (var quote in Quotes) - { -
-
- -
- @quote.Company.Name -
- - @quote.OrderDate - -
- @($"{quote.OrderAmount:N2}") -
-
-
-
-
- @if (!string.IsNullOrWhiteSpace(quote.OfficeNote)) - { -
Note
-
- @quote.OfficeNote -
- } -
-
- } - } - else - { -
Ingen data
- } -
- - -@if (Working) -{ - -} \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmQuotes.razor.cs b/Wonky.Client/Pages/CrmQuotes.razor.cs deleted file mode 100644 index 3255c9aa..00000000 --- a/Wonky.Client/Pages/CrmQuotes.razor.cs +++ /dev/null @@ -1,39 +0,0 @@ -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 { get; set; } = 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; - } - - private void SetQuote(int status) - { - // todo - implement update quote from status - // status matches QuoteStatusEnum - // 0 - None - // 1 - Win - // 2 - Lose - // 3 - Draw - } - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmQuotesListPage.razor b/Wonky.Client/Pages/CrmQuotesListPage.razor new file mode 100644 index 00000000..1812509c --- /dev/null +++ b/Wonky.Client/Pages/CrmQuotesListPage.razor @@ -0,0 +1,44 @@ +@page "/open-quotes" +@using Wonky.Client.Components +@using Wonky.Client.Models + +
+
+

Tilbud

+
+
+
+ + + + + + + + + + + + + + + + +
+ + @* +
+ + +
+ *@ +
+
+ + + +@if (Working) +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmQuotesListPage.razor.cs b/Wonky.Client/Pages/CrmQuotesListPage.razor.cs new file mode 100644 index 00000000..01d3535f --- /dev/null +++ b/Wonky.Client/Pages/CrmQuotesListPage.razor.cs @@ -0,0 +1,81 @@ +using System.Diagnostics.CodeAnalysis; +using System.Security.Policy; +using System.Text.Json; +using Blazored.LocalStorage; +using Blazored.Toast.Services; +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 CrmQuotesListPage : 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; } + private List Quotes { get; set; } = new(); + private List _quotes { get; set; } = new(); + private bool Working { get; set; } = true; + private QStatus QFilter { get; set; } = QStatus.None; + + protected override async Task OnInitializedAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + Quotes = await ActivityRepo.GetQuotes(); + await Storage.SetItemAsync("quotes", Quotes); + if (Quotes.Any()) + _quotes = Quotes.Where(x => x.QuoteStatusEnum is "Note" or "None").ToList(); + Working = false; + } + + private async Task FilterQuotes(QStatus status) + { + QFilter = status; + Quotes = await Storage.GetItemAsync>("quotes"); + _quotes = QFilter switch + { + QStatus.None => Quotes.Where(x => x.QuoteStatusEnum is "None").ToList(), + QStatus.Win => Quotes.Where(x => x.QuoteStatusEnum is "Win").ToList(), + QStatus.Lose => Quotes.Where(x => x.QuoteStatusEnum is "Lose").ToList(), + QStatus.Archive => Quotes.Where(x => x.QuoteStatusEnum is "Archive").ToList(), + QStatus.Note => Quotes.Where(x => x.QuoteStatusEnum is "Note").ToList(), + _ => Quotes.ToList() + }; + } + + private async Task UpdateQuoteCallback(QuoteCallbackArgs args) + { + 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); + Toaster.ShowInfo($"{response.Message}", $"HTTP STATUS {response.Code}"); + + Quotes = new List(); + await Storage.RemoveItemAsync("quotes"); + Quotes = await ActivityRepo.GetQuotes(); + while (!Quotes.Any()) + await Task.Delay(1000); + + await Storage.SetItemAsync("quotes", Quotes); + + await FilterQuotes(QFilter); + + StateHasChanged(); + } + + public void Dispose() + { + Storage.RemoveItemAsync("quotes"); + Interceptor.DisposeEvent(); + } +} \ No newline at end of file diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 4e5408a5..be7a4d33 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.85.5", + "version": "0.85.7", "rc": true, "sandBox": false, "image": "grumpy-coder.png" @@ -34,7 +34,7 @@ }, "Logging": { "LogLevel": { - "Default": "Debug", + "Default": "Information", "System": "Information", "Microsoft": "Information" }, From 536984b816fb8b5236a27b2f6d00a8275ca81af7 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Fri, 16 Dec 2022 07:25:20 +0100 Subject: [PATCH 08/11] documentation --- .../Components/WorkDateComponent.razor.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Wonky.Client/Components/WorkDateComponent.razor.cs b/Wonky.Client/Components/WorkDateComponent.razor.cs index ad1dbedc..29dc12f9 100644 --- a/Wonky.Client/Components/WorkDateComponent.razor.cs +++ b/Wonky.Client/Components/WorkDateComponent.razor.cs @@ -27,20 +27,30 @@ public partial class WorkDateComponent : IDisposable /// /// User preference service /// - [Inject] public UserPrefService Prefs { get; set; } + [Inject] + public UserPrefService Prefs { get; set; } + /// /// OnChanged callback function /// - [Parameter] public EventCallback OnChangedCallback { get; set; } + [Parameter] + public EventCallback OnChangedCallback { get; set; } + + /// + /// work date context holding the edit value + /// private EditContext WorkDateContext { get; set; } + /// /// Selected data /// private DateTime SelectedDate { get; set; } + /// /// user preferences /// private UserPref _prefs = new(); + /// /// Component Initialization /// @@ -49,10 +59,11 @@ public partial class WorkDateComponent : IDisposable WorkDateContext = new EditContext(SelectedDate); Prefs.OnChange += ProfileServiceOnOnChange; _prefs = await Prefs.GetPreferences(); - SelectedDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) + SelectedDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) ? DateTime.Now : DateTime.Parse(_prefs.WorkDate); } + /// /// OnDateChanged function call to invoke the event callback /// @@ -63,6 +74,7 @@ public partial class WorkDateComponent : IDisposable await Prefs.SetWorkDate(val); await OnChangedCallback.InvokeAsync($"{val:yyyy-MM-dd}"); } + /// /// ProfileService /// @@ -72,6 +84,7 @@ public partial class WorkDateComponent : IDisposable _prefs = newUserPref; StateHasChanged(); } + /// /// Component dispose /// From 379552533a08aca80c6bbd2ee5c329ef45e2d421 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 20 Dec 2022 05:34:55 +0100 Subject: [PATCH 09/11] quote list cosmetics - better date parser in component --- .../Components/QuoteListComponent.razor | 46 +++++++++++-------- .../Components/WorkDateComponent.razor.cs | 9 ++-- Wonky.Client/Pages/CrmQuotesListPage.razor.cs | 9 ++-- Wonky.Client/Shared/NavMenu.razor | 2 +- Wonky.Client/Wonky.Client.csproj | 8 ++-- Wonky.Client/wwwroot/appsettings.json | 4 +- 6 files changed, 43 insertions(+), 35 deletions(-) diff --git a/Wonky.Client/Components/QuoteListComponent.razor b/Wonky.Client/Components/QuoteListComponent.razor index ae26ba59..c4c75cf4 100644 --- a/Wonky.Client/Components/QuoteListComponent.razor +++ b/Wonky.Client/Components/QuoteListComponent.razor @@ -4,19 +4,21 @@
-
- Reference -
Kunde
Dato
-
+
+ Skift status +
+
Status
-
+
+ Reference +
@if (Quotes.Any()) @@ -25,27 +27,26 @@ {
-
@quote.Company.Name
@quote.OrderDate -
+
+ + + + +
+
@switch (quote.QuoteStatusEnum) { case "None": break; - case "Win": - Ordre - break; case "Lose": - + break; case "Note": @@ -58,19 +59,24 @@ break; }
-
- - - - + @if (!string.IsNullOrWhiteSpace(quote.OfficeNote)) { -
+
Note
@quote.OfficeNote
} + @if (!string.IsNullOrWhiteSpace(quote.CrmNote)) + { +
CRM note
+
+ @quote.CrmNote +
+ }
} diff --git a/Wonky.Client/Components/WorkDateComponent.razor.cs b/Wonky.Client/Components/WorkDateComponent.razor.cs index 29dc12f9..d52a70c3 100644 --- a/Wonky.Client/Components/WorkDateComponent.razor.cs +++ b/Wonky.Client/Components/WorkDateComponent.razor.cs @@ -70,9 +70,12 @@ public partial class WorkDateComponent : IDisposable /// private async Task OnDateChanged(ChangeEventArgs e) { - var val = DateTime.Parse(e.Value.ToString()); - await Prefs.SetWorkDate(val); - await OnChangedCallback.InvokeAsync($"{val:yyyy-MM-dd}"); + var x = DateTime.TryParse(e.Value.ToString(), out var val); + if (x) + { + await Prefs.SetWorkDate(val); + await OnChangedCallback.InvokeAsync($"{val:yyyy-MM-dd}"); + } } /// diff --git a/Wonky.Client/Pages/CrmQuotesListPage.razor.cs b/Wonky.Client/Pages/CrmQuotesListPage.razor.cs index 01d3535f..808ac9d2 100644 --- a/Wonky.Client/Pages/CrmQuotesListPage.razor.cs +++ b/Wonky.Client/Pages/CrmQuotesListPage.razor.cs @@ -23,16 +23,16 @@ public partial class CrmQuotesListPage : IDisposable private List Quotes { get; set; } = new(); private List _quotes { get; set; } = new(); private bool Working { get; set; } = true; - private QStatus QFilter { get; set; } = QStatus.None; + private QStatus QFilter { get; set; } = QStatus.All; protected override async Task OnInitializedAsync() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); Quotes = await ActivityRepo.GetQuotes(); - await Storage.SetItemAsync("quotes", Quotes); + await Storage.SetItemAsync("quotes", Quotes.OrderBy(x => x.Company.Name)); if (Quotes.Any()) - _quotes = Quotes.Where(x => x.QuoteStatusEnum is "Note" or "None").ToList(); + await FilterQuotes(QFilter); Working = false; } @@ -43,7 +43,6 @@ public partial class CrmQuotesListPage : IDisposable _quotes = QFilter switch { QStatus.None => Quotes.Where(x => x.QuoteStatusEnum is "None").ToList(), - QStatus.Win => Quotes.Where(x => x.QuoteStatusEnum is "Win").ToList(), QStatus.Lose => Quotes.Where(x => x.QuoteStatusEnum is "Lose").ToList(), QStatus.Archive => Quotes.Where(x => x.QuoteStatusEnum is "Archive").ToList(), QStatus.Note => Quotes.Where(x => x.QuoteStatusEnum is "Note").ToList(), @@ -66,7 +65,7 @@ public partial class CrmQuotesListPage : IDisposable while (!Quotes.Any()) await Task.Delay(1000); - await Storage.SetItemAsync("quotes", Quotes); + await Storage.SetItemAsync("quotes", Quotes.OrderBy(x => x.Company.Name)); await FilterQuotes(QFilter); diff --git a/Wonky.Client/Shared/NavMenu.razor b/Wonky.Client/Shared/NavMenu.razor index 28c92e87..a7461b5f 100644 --- a/Wonky.Client/Shared/NavMenu.razor +++ b/Wonky.Client/Shared/NavMenu.razor @@ -97,7 +97,7 @@