diff --git a/Wonky.Client/Components/QuoteListComponent.razor b/Wonky.Client/Components/QuoteListComponent.razor index fb3dc02e..7482b194 100644 --- a/Wonky.Client/Components/QuoteListComponent.razor +++ b/Wonky.Client/Components/QuoteListComponent.razor @@ -53,7 +53,7 @@
break; case "Note": diff --git a/Wonky.Client/Enums/QuoteStatus.cs b/Wonky.Client/Enums/QuoteStatus.cs index 468bd104..221c4951 100644 --- a/Wonky.Client/Enums/QuoteStatus.cs +++ b/Wonky.Client/Enums/QuoteStatus.cs @@ -21,8 +21,20 @@ public enum QuoteStatus None, Order, Lose, - Archive, Note, + Archive, + Trash, All, NoteOpen } + +// public enum QuoteStatus +// { +// None, +// Order, +// Lose, +// Archive, +// Note, +// All, +// NoteOpen +// } diff --git a/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs b/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs index 0d8dd909..92a29888 100644 --- a/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs @@ -62,7 +62,6 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository { return new List(); } - return JsonSerializer.Deserialize>(content, _options) ?? new List(); } @@ -73,7 +72,7 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository /// public async Task UpdateQuoteStatus(ReportItemView activity) { - var resp = new ApiResponseView + var responseView = new ApiResponseView { Code = 404, IsSuccess = false, @@ -85,11 +84,10 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository var content = await response.Content.ReadAsStringAsync(); if (string.IsNullOrWhiteSpace(content)) { - return resp; + return responseView; } - _logger.LogDebug("UpdateQuote Response Content <= {}", content); - return JsonSerializer.Deserialize(content, _options) ?? resp; + return JsonSerializer.Deserialize(content, _options) ?? responseView; } /// @@ -124,12 +122,10 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository { var response = await _client .GetAsync($"{_api.CrmActivities}/date/{activityDate}"); - if (!response.IsSuccessStatusCode) - return new ReportStatusView(); var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new ReportStatusView() - : JsonSerializer.Deserialize(content, _options); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + return new ReportStatusView(); + return JsonSerializer.Deserialize(content, _options) ?? new ReportStatusView(); } /// @@ -153,11 +149,9 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository { var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}"); var content = await response.Content.ReadAsStringAsync(); - if (!response.IsSuccessStatusCode) + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) return new List(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + return JsonSerializer.Deserialize>(content, _options) ?? new List(); } /// diff --git a/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs index 84f2c6ae..367b8130 100644 --- a/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs @@ -60,7 +60,7 @@ public class AdvisorCustomerHistoryRepository : IAdvisorCustomerHistoryRepositor public async Task GetInvoiceListHeader(string companyId) { - var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/invoices"); + var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/invoices/head"); var content = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) { diff --git a/Wonky.Client/Local.Services/CabinetDrawerService.cs b/Wonky.Client/Local.Services/CabinetDrawerService.cs index c9dac0b8..e29a4dca 100644 --- a/Wonky.Client/Local.Services/CabinetDrawerService.cs +++ b/Wonky.Client/Local.Services/CabinetDrawerService.cs @@ -36,12 +36,12 @@ public class CabinetDrawerService : ICabinetDrawerService } - public async Task GetActivityDrawerAsync(string companyId, bool force = false) + public async Task GetActivityDrawerAsync(string companyId, bool forceBackend = false) { var drawer = await _asyncStorageService .GetItemAsync($"{companyId}.{ActivityDrawer.Label}"); - if (drawer == null) force = true; - if (!force) return drawer ?? new ActivityDrawer(); + if (drawer == null) forceBackend = true; + if (!forceBackend) return drawer ?? new ActivityDrawer(); var result = await _activityRepo.GetCustomerActivities(companyId); drawer = new ActivityDrawer { @@ -53,13 +53,13 @@ public class CabinetDrawerService : ICabinetDrawerService } - public async Task GetCatalogDrawerAsync(string countryCode, bool force = false) + public async Task GetCatalogDrawerAsync(string countryCode, bool forceBackend = false) { var drawer = await _asyncStorageService .GetItemAsync($"{countryCode}.{CatalogDrawer.Label}"); - if (drawer == null) force = true; - if (!force) return drawer ?? new CatalogDrawer(); + if (drawer == null) forceBackend = true; + if (!forceBackend) return drawer ?? new CatalogDrawer(); var result = await _priceCatalogRepo.GetPriceList(countryCode); drawer = new CatalogDrawer { @@ -71,13 +71,13 @@ public class CabinetDrawerService : ICabinetDrawerService } - public async Task GetInfoDrawerAsync(string companyId, bool force = false) + public async Task GetInfoDrawerAsync(string companyId, bool forceBackend = false) { var drawer = await _asyncStorageService .GetItemAsync($"{companyId}.{InfoDrawer.Label}"); - if (drawer == null) force = true; - if (!force) return drawer ?? new InfoDrawer(); + if (drawer == null) forceBackend = true; + if (!forceBackend) return drawer ?? new InfoDrawer(); var result = await _customerRepo.GetCompanyById(companyId); drawer = new InfoDrawer { @@ -85,17 +85,17 @@ public class CabinetDrawerService : ICabinetDrawerService Content = result }; await StoreInfoDrawerAsync(companyId, drawer); - return drawer ?? new InfoDrawer(); + return drawer; } - public async Task GetInventoryDrawerAsync(string companyId, bool force = false) + public async Task GetInventoryDrawerAsync(string companyId, bool forceBackend = false) { var drawer = await _asyncStorageService .GetItemAsync($"{companyId}.{InventoryDrawer.Label}"); - if (drawer == null) force = true; - if (!force) return drawer ?? new InventoryDrawer(); + if (drawer == null) forceBackend = true; + if (!forceBackend) return drawer ?? new InventoryDrawer(); var result = await _historyRepo.GetInventory(companyId); drawer = new InventoryDrawer { @@ -107,12 +107,12 @@ public class CabinetDrawerService : ICabinetDrawerService } - public async Task GetInvoiceDrawerAsync(string companyId, bool force = false) + public async Task GetInvoiceDrawerAsync(string companyId, bool forceBackend = false) { var drawer = await _asyncStorageService .GetItemAsync($"{companyId}.{InvoiceDrawer.Label}"); - if (drawer == null) force = true; - if (!force) return drawer ?? new InvoiceDrawer(); + if (drawer == null) forceBackend = true; + if (!forceBackend) return drawer ?? new InvoiceDrawer(); var result = await _historyRepo.GetInvoiceList(companyId); drawer = new InvoiceDrawer { @@ -120,17 +120,17 @@ public class CabinetDrawerService : ICabinetDrawerService Content = result }; await StoreInvoiceDrawerAsync(companyId, drawer); - return drawer ?? new InvoiceDrawer(); + return drawer; } - public async Task GetStatisticDrawerAsync(string companyId, bool force = false) + public async Task GetStatisticDrawerAsync(string companyId, bool forceBackend = false) { var drawer = await _asyncStorageService .GetItemAsync($"{companyId}.{StatisticDrawer.Label}"); - if (drawer == null) force = true; - if (!force) return drawer ?? new StatisticDrawer(); + if (drawer == null) forceBackend = true; + if (!forceBackend) return drawer ?? new StatisticDrawer(); var result = await _historyRepo.GetProductInvoiceLines(companyId); var content = result.Select(x => new InventoryItem { @@ -153,7 +153,7 @@ public class CabinetDrawerService : ICabinetDrawerService public async Task StoreActivityDrawerAsync(string companyId, ActivityDrawer drawer) { - if (drawer.Content.Any()) + if (drawer.Content.Count != 0) { drawer.Content = drawer.Content.OrderByDescending(x => x.OrderDate).ToList(); } @@ -176,7 +176,7 @@ public class CabinetDrawerService : ICabinetDrawerService public async Task StoreInventoryDrawerAsync(string companyId, InventoryDrawer drawer) { - if (drawer.Content.Any()) + if (drawer.Content.Count != 0) { drawer.Content = drawer.Content.OrderByDescending(x => x.LastInvoiceDate).ToList(); } @@ -187,7 +187,7 @@ public class CabinetDrawerService : ICabinetDrawerService public async Task StoreInvoiceDrawerAsync(string companyId, InvoiceDrawer drawer) { - if (drawer.Content.Any()) + if (drawer.Content.Count != 0) { drawer.Content = drawer.Content.OrderByDescending(x => x.DocumentDate).ToList(); } @@ -198,7 +198,7 @@ public class CabinetDrawerService : ICabinetDrawerService public async Task StoreStatisticDrawerAsync(string companyId, StatisticDrawer drawer) { - if (drawer.Content.Any()) + if (drawer.Content.Count != 0) { drawer.Content = drawer.Content.OrderByDescending(x => x.DeliveryDate).ToList(); } diff --git a/Wonky.Client/Local.Services/ICabinetDrawerService.cs b/Wonky.Client/Local.Services/ICabinetDrawerService.cs index a3934bee..62b4fc78 100644 --- a/Wonky.Client/Local.Services/ICabinetDrawerService.cs +++ b/Wonky.Client/Local.Services/ICabinetDrawerService.cs @@ -6,12 +6,12 @@ namespace Wonky.Client.Local.Services; public interface ICabinetDrawerService { - Task GetActivityDrawerAsync(string companyId, bool force = false); - Task GetCatalogDrawerAsync(string countryCode, bool force = false); - Task GetInfoDrawerAsync(string companyId, bool force = false); - Task GetInventoryDrawerAsync(string companyId, bool force = false); - Task GetInvoiceDrawerAsync(string companyId, bool force = false); - Task GetStatisticDrawerAsync(string companyId, bool force = false); + Task GetActivityDrawerAsync(string companyId, bool forceBackend = false); + Task GetCatalogDrawerAsync(string countryCode, bool forceBackend = false); + Task GetInfoDrawerAsync(string companyId, bool forceBackend = false); + Task GetInventoryDrawerAsync(string companyId, bool forceBackend = false); + Task GetInvoiceDrawerAsync(string companyId, bool forceBackend = false); + Task GetStatisticDrawerAsync(string companyId, bool forceBackend = false); Task StoreActivityDrawerAsync(string companyId, ActivityDrawer drawer); Task StoreCatalogDrawerAsync(string countryCode, CatalogDrawer drawer); diff --git a/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs index f2a0da16..c90f346c 100644 --- a/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerCreatePage.razor.cs @@ -64,7 +64,7 @@ public partial class AdvisorCustomerCreatePage : IDisposable CompanyContext.OnValidationStateChanged += ValidationChanged; UserInfo = await UserInfoService.GetUserInfo(); - Dk = UserInfo.CountryCode.ToLower() == "dk"; + Dk = UserInfo.CountryCode.Equals("dk", StringComparison.CurrentCultureIgnoreCase); Company.SalesRepId = UserInfo.UserId; Company.CountryCode = UserInfo.CountryCode.ToLower(); @@ -95,7 +95,7 @@ public partial class AdvisorCustomerCreatePage : IDisposable Logger.LogDebug("CrmCompanyView => SelectCompanyCallback => {}", JsonSerializer.Serialize(regInfo)); // this can be removed in favor of the new data returned from updating the VatNumber - RegState = regInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead"; + RegState = regInfo.States[0].State.Equals("normal", StringComparison.CurrentCultureIgnoreCase) ? "the-good" : "the-dead"; if (regInfo.SyncAll) { Company.Name = regInfo.Name; diff --git a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs index d87ccc8d..55245cdb 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs @@ -55,7 +55,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable // ########################################################################### [Parameter] public string CompanyId { get; set; } = ""; - + // ########################################################################### private EditContext _erpFormContext; private DateTime _lastVisit; @@ -67,7 +67,9 @@ public partial class AdvisorCustomerViewEditPage : IDisposable private VatLookupDkModal _vatLookupPopup = new(); private List _contacts = new(); private string VatState { get; set; } = "the-ugly"; + private bool _validVat; + // private bool _hasFolded; // private string _currentVat = ""; private string _countryCode = "dk"; @@ -82,7 +84,9 @@ public partial class AdvisorCustomerViewEditPage : IDisposable private string _activitiesLink = ""; private string _invoiceLink = ""; private string _newActivityLink = ""; + private int _enableLink = 1; + // private ActivityDrawer _activityDrawer = new(); // private InventoryDrawer _inventoryDrawer = new(); // private InvoiceDrawer _invoiceDrawer = new(); @@ -92,7 +96,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable private CompanyDto _company = new(); // private string _companyId = ""; - + protected override async Task OnInitializedAsync() { /* @@ -128,15 +132,15 @@ public partial class AdvisorCustomerViewEditPage : IDisposable { Navigator.NavigateTo($"/advisor/customers/{CompanyId}/activities/new"); } + /* * fetch user info from local storage */ _userInfo = await UserInfoService.GetUserInfo(); _countryCode = _userInfo.CountryCode.ToLower(); _countryIsDk = _countryCode == "dk"; - _infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId); - _infoDrawer.Content = _company; - await DrawerService.StoreInfoDrawerAsync(CompanyId, _infoDrawer); + _infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, forceBackend: true); + /* * internal _enableActivity flag */ @@ -149,86 +153,91 @@ public partial class AdvisorCustomerViewEditPage : IDisposable { _enableActivity = 1; } + /* * only execute if the InfoDrawer.Company is not KANVAS */ - Logger.LogDebug("_company => {}", JsonSerializer.Serialize(_company)); - /* - * toggle view button text - */ - _toggleButtonText = _company.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning"; - // _currentVat = _company.VatNumber; - _company.CountryCode = _userInfo.CountryCode.ToLower(); - /* - * visit interval init - */ - if (_company.Interval == 0) - { - _company.Interval = 8; - } - /* - * visit date init - */ - _lastVisit = DateTime.Parse(_company.LastVisit); - _nextVisit = DateTime.Parse(_company.NextVisit); - /* - * if no previous visit is registered - force last visit date to 2020 - */ - if (_lastVisit.Year < 2020) - { - _lastVisit = DateTime.Parse("2020-01-01"); - } - /* - * set next visit according to last visit and interval - */ - if (!_company.ValidDateSpan()) - { - _nextVisit = _lastVisit.AddDays(_company.Interval * 7); - } - /* - * display urgency of next visit - */ - _visitStateCss = Mapper.MapVisitState($"{_nextVisit:yyyy-MM-dd}"); - /* - * handle InfoDrawer.Company out of business case - */ - if (_company.HasFolded == 1) - { - /* - * this is only used if user has selected to show closed companies - */ - // _hasFolded = true; - VatState = "the-dead"; - _visitStateCss = "the-dead"; - } - else - { - /* - * vat validation flags - */ - _company.ValidVat = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? 1 : 0; - _validVat = _company.ValidVat == 1; // true/false flag set if InfoDrawer.Company has a valid vatNumber - VatState = _company.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class - } + Logger.LogDebug("_company => {}", JsonSerializer.Serialize(_company)); + /* + * toggle view button text + */ + _toggleButtonText = _company.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning"; + // _currentVat = _company.VatNumber; + _company.CountryCode = _userInfo.CountryCode.ToLower(); + /* + * visit interval init + */ + if (_company.Interval == 0) + { + _company.Interval = 8; + } - if (_countryIsDk) - { - _companyVatAddress = PrepareVatAddress(_company); - } - // await GetContacts(CompanyId); + /* + * visit date init + */ + _lastVisit = DateTime.Parse(_company.LastVisit); + _nextVisit = DateTime.Parse(_company.NextVisit); + /* + * if no previous visit is registered - force last visit date to 2020 + */ + if (_lastVisit.Year < 2020) + { + _lastVisit = DateTime.Parse("2020-01-01"); + } + + /* + * set next visit according to last visit and interval + */ + if (!_company.ValidDateSpan()) + { + _nextVisit = _lastVisit.AddDays(_company.Interval * 7); + } + + /* + * display urgency of next visit + */ + _visitStateCss = Mapper.MapVisitState($"{_nextVisit:yyyy-MM-dd}"); + /* + * handle InfoDrawer.Company out of business case + */ + if (_company.HasFolded == 1) + { + /* + * this is only used if user has selected to show closed companies + */ + // _hasFolded = true; + VatState = "the-dead"; + _visitStateCss = "the-dead"; + } + else + { + /* + * vat validation flags + */ + _company.ValidVat = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? 1 : 0; + _validVat = _company.ValidVat == 1; // true/false flag set if InfoDrawer.Company has a valid vatNumber + VatState = _company.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class + } + + if (_countryIsDk) + { + _companyVatAddress = PrepareVatAddress(_company); + } + + // await GetContacts(CompanyId); /* * remove loading image */ _working = false; } - + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await GetContacts(CompanyId); - _ = await DrawerService.GetActivityDrawerAsync(CompanyId, force:true); + await DrawerService.GetActivityDrawerAsync(CompanyId, forceBackend: true); if (!_company.Account.StartsWith("NY")) { await ReloadHistory(); @@ -236,45 +245,50 @@ public partial class AdvisorCustomerViewEditPage : IDisposable } } - - private async Task ReloadHistory(bool force = false) + + private async Task ReloadHistory(bool forceBackend = false) { - if (force) + if (forceBackend) { - Toaster.ShowInfo("Afventer svar fra tjenester ..."); + Toaster.ShowInfo("Afventer svar fra tjenester ..."); } + _enableLink = 0; _enableActivity = 0; - var newSync = await CustomerHistoryRepo.RequestErpSync(CompanyId, _company.HistorySync, force); + var newSync = await CustomerHistoryRepo.RequestErpSync(CompanyId, _company.HistorySync, forceBackend); + await Task.Delay(500); + if (!string.IsNullOrWhiteSpace(newSync)) { + Toaster.ShowSuccess($"{forceBackend} {newSync} ERP hitorik synkroniseret til CRM."); _company.HistorySync = newSync; if (!_company.Account.StartsWith("NY")) { - _ = await DrawerService.GetInvoiceDrawerAsync(CompanyId, force); - _ = await DrawerService.GetInventoryDrawerAsync(CompanyId, force); - _ = await DrawerService.GetStatisticDrawerAsync(CompanyId, force); + await DrawerService.GetInvoiceDrawerAsync(CompanyId, forceBackend); + await DrawerService.GetInventoryDrawerAsync(CompanyId, forceBackend); + await DrawerService.GetStatisticDrawerAsync(CompanyId, forceBackend); } - _ = await DrawerService.GetActivityDrawerAsync(CompanyId, force); + await DrawerService.GetActivityDrawerAsync(CompanyId, forceBackend); } + _enableLink = 1; _enableActivity = _company.ValidVat; StateHasChanged(); - if (force) + if (forceBackend) { - Toaster.ShowSuccess("Alle tjenester har svaret."); + Toaster.ShowSuccess("Alle tjenester har svaret."); } } - - + + private void ToggleErpEdit() { _erpEditDisabled = !_erpEditDisabled; } - + private void ToggleVatEdit() { _vatEditDisabled = !_vatEditDisabled; @@ -294,7 +308,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable await AdvisorCustomerRepo.UpdateCrmData(CompanyId, _company); } - + /* * Request contacts for company */ @@ -319,7 +333,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _vatLookupPopup.Show(); } - + /* * Callback from vat lookup overlay with registration infomration */ @@ -340,6 +354,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _company.ZipCode = regInfo.ZipCode; _company.City = regInfo.City; } + _company.VatNumber = regInfo.VatNumber; } @@ -386,6 +401,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable */ await ContactRepo.PutContact(contact); } + /* * reset default contact */ @@ -400,7 +416,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable /* * Delete contact callback - */ + */ private async Task DeleteContactCallback(string contactId) { if (_working) @@ -408,7 +424,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _working = true; /* * send delete request to backend - */ + */ await ContactRepo.DeleteContact(CompanyId, contactId); /* * reset default contact @@ -421,7 +437,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _working = false; } - + /* * Execute post requset - updating CRM data (non ERP related) */ @@ -440,6 +456,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, true); _company = _infoDrawer.Content; } + StateHasChanged(); _working = false; Toaster.ShowSuccess("Dine CRM data er opdateret."); @@ -462,6 +479,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, true); _company = _infoDrawer.Content; } + StateHasChanged(); _working = false; Toaster.ShowSuccess(_company.Account.StartsWith("NY") @@ -484,12 +502,13 @@ public partial class AdvisorCustomerViewEditPage : IDisposable return; /* * VAT format validation - */ + */ if (!VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber)) { Toaster.ShowError($"Moms Nummer ugyldigt"); return; } + _working = true; _vatEditDisabled = true; Toaster.ShowInfo("Vent venligst ..."); @@ -499,6 +518,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _infoDrawer = await DrawerService.GetInfoDrawerAsync(CompanyId, true); _company = _infoDrawer.Content; } + StateHasChanged(); _working = false; // if (_company.HasFolded == 1) @@ -508,7 +528,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable Toaster.ShowSuccess("Moms Nr. er opdateret."); } - + /* * Prepare vat address * used to lookup danish company @@ -529,6 +549,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable HouseNumber = company.Address1.Split(' ')[1].Split('-')[0] }; } + /* * process address2 */ @@ -542,13 +563,14 @@ public partial class AdvisorCustomerViewEditPage : IDisposable HouseNumber = company.Address2.Split(' ')[1].Split('-')[0] }; } + /* * return empty model */ return new VatAddress(); } - - + + /* * Force enable activioty - even if company has turned keys and shut down */ @@ -563,7 +585,6 @@ public partial class AdvisorCustomerViewEditPage : IDisposable */ private void HandleFieldChanged(object? sender, FieldChangedEventArgs? e) { - _nextVisit = _lastVisit.AddDays(_company.Interval * 7); /* * avoid nesting if by assuming _validVat is false @@ -571,7 +592,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable _validVat = false; /* * set _validVat true if validation succeed - */ + */ if (VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber)) { _validVat = true; diff --git a/Wonky.Client/Pages/AdvisorQuoteListPage.razor b/Wonky.Client/Pages/AdvisorQuoteListPage.razor index 0f6a5051..ad6b32b2 100644 --- a/Wonky.Client/Pages/AdvisorQuoteListPage.razor +++ b/Wonky.Client/Pages/AdvisorQuoteListPage.razor @@ -26,33 +26,31 @@
- - - - - - - - - - - - - - - - - - + @* all quotes (list) *@ + + + @* lost quotes (trash) *@ + + + @* archived quotes (archive) *@ + + + @* open/undecided quotes (question) *@ + + + @* quotes tagged as notes (tag) *@ + + + @* quotes - either tagged or open (activity) *@ + +
- - @* -
- - -
- *@
diff --git a/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs b/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs index d8436681..d6198d4f 100644 --- a/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs @@ -48,7 +48,7 @@ public partial class AdvisorQuoteListPage : IDisposable await Storage.SetItemAsync("quotes", QuoteList.OrderBy(x => x.Company.Name)); Working = false; // filter quotes - if any - default to QStatus.NoteOpen - if (QuoteList.Any()) + if (QuoteList.Count != 0) await FilterQuotes(QuoteFilter); } @@ -62,6 +62,7 @@ public partial class AdvisorQuoteListPage : IDisposable QuoteStatus.Lose => QuoteList.Where(x => x.QuoteStatusEnum is "Lose").ToList(), QuoteStatus.Archive => QuoteList.Where(x => x.QuoteStatusEnum is "Archive").ToList(), QuoteStatus.Note => QuoteList.Where(x => x.QuoteStatusEnum is "Note").ToList(), + QuoteStatus.Trash => QuoteList.Where(x => x.QuoteStatusEnum is "Trash").ToList(), QuoteStatus.NoteOpen => QuoteList.Where(x => x.QuoteStatusEnum is "Note" or "None").ToList(), _ => QuoteList.ToList() }; @@ -75,19 +76,24 @@ public partial class AdvisorQuoteListPage : IDisposable if (args.Status == QuoteStatus.Order) quote.OrderDate = $"{DateTime.Now:yyyy-MM-dd}"; quote.QuoteStatusEnum = Utils.EnumToString(args.Status); + // send update request to backend var response = await AdvisorActivityRepo.UpdateQuoteStatus(quote); Toaster.ShowInfo($"{response.Message}"); + // clear and reload quotes QuoteList = new List(); await Storage.RemoveItemAsync("quotes"); QuoteList = await AdvisorActivityRepo.GetQuotes(); + // store quotes in local storage await Storage.SetItemAsync("quotes", QuoteList.OrderBy(x => x.Company.Name)); + // filter quotes - if any - based on active filter if(QuoteList.Count != 0) await FilterQuotes(QuoteFilter); Working = false; + // signal page state changed StateHasChanged(); }