- @Company.Name (@Company.Account)
+ @_infoDrawer.Content.Name (@_infoDrawer.Content.Account)
- @if (UserInfo.CountryCode is "DK")
+ @if (_userInfo.CountryCode is "DK")
{
Arbejdssted
}
- @*
*@
+
Tilbage
@@ -50,78 +50,78 @@
@* Company Name *@
-
-
+
+
@* Company Attention *@
-
-
+
+
@* Address 1 *@
-
-
+
+
@* Address 2 *@
-
-
+
+
@* Post Code *@
-
-
+
+
@* City Name *@
-
-
+
+
@* Email *@
-
-
+
+
@* Phone *@
-
-
+
+
@* Mobile *@
-
-
+
+
@* Email *@
-
-
+
+
@if (!Kanvas)
{
@* entity segment *@
- @if (UserInfo.CountryCode.ToLower() == "dk")
+ @if (_userInfo.CountryCode.ToLower() == "dk")
{
+ @bind-Value="@_infoDrawer.Content.Segment" disabled="@(ErpEditDisabled)">
-
+
@@ -145,7 +145,7 @@
@* Save erp data *@
-
+
@* vat number*@
@@ -155,8 +155,8 @@
-
-
+
+
@* Enable edit/save vatnumber *@
@@ -174,7 +174,7 @@
- @if (string.IsNullOrWhiteSpace(Company.Note))
+ @if (string.IsNullOrWhiteSpace(_infoDrawer.Content.Note))
{
-
+
}
else
{
-
+
}
-
+
@* Save CRM data button *@
-
+
@* crm context - contacts *@
@@ -300,14 +300,14 @@
- @if (UserInfo.CountryCode is "DK")
+ @if (_userInfo.CountryCode is "DK")
{
Kemi Dokumentation
}
@@ -331,10 +331,8 @@
}
-
-
-
-
\ No newline at end of file
diff --git a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs
index a37a8026..51f7fcbb 100644
--- a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs
+++ b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs
@@ -14,7 +14,6 @@
//
using System.Text.Json;
-using System.Text.RegularExpressions;
using Blazored.LocalStorage;
using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components;
@@ -40,25 +39,32 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
[Inject] public IToastService Toaster { get; set; }
[Inject] public ILogger
Logger { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
+ [Inject] public ICrmActivityRepository ActivityRepo { get; set; }
[Inject] public ICrmCustomerRepository CustomerRepo { get; set; }
[Inject] public ICrmCustomerHistoryRepository HistoryRepo { get; set; }
- [Inject] public ICrmContactRepository CrmContactRepo { get; set; }
+ [Inject] public ICrmContactRepository ContactRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public VatInfoLookupService VatService { get; set; }
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public IUserInfoService UserInfoService { get; set; }
[Inject] public IOptions? AppInfo { get; set; }
-
+ [Inject] public IDrawerCabinetService CabinetService { get; set; }
+
// ###########################################################################
[Parameter] public string CompanyId { get; set; } = "";
// ###########################################################################
- private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true };
- private CompanyDto Company { get; set; } = new();
private EditContext ErpContext { get; set; }
private DateTime LastVisit { get; set; }
private DateTime NextVisit { get; set; }
private VatAddress CompanyVatAddress { get; set; } = new();
+ private ContactDto SelectedContact { get; set; } = new();
+ private ContactDto DefaultContact { get; set; } = new();
+ private ContactViewEditModal ContactViewPopup { get; set; } = new();
+ private VatLookupDkModal VatLookupPopup { get; set; } = new();
+ private List Contacts { get; set; } = new();
+ private UserManagerEditView _userInfo = new();
+ private InfoDrawer _infoDrawer = new();
private string VatState { get; set; } = "the-ugly";
private bool ValidVat { get; set; }
private bool HasFolded { get; set; }
@@ -70,119 +76,168 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private bool CountryIsDk { get; set; } = true;
private bool ErpEditDisabled { get; set; } = true;
private bool VatEditDisabled { get; set; } = true;
- private List Contacts { get; set; } = new();
- private UserManagerEditView UserInfo { get; set; } = new();
private string ToggleButtonText { get; set; } = "";
private bool Kanvas { get; set; }
- private ContactDto SelectedContact { get; set; } = new();
- private ContactDto DefaultContact { get; set; } = new();
- private ContactViewEditModal ContactViewPopup { get; set; } = new();
- private VatLookupDkModal VatLookupPopup { get; set; } = new();
- private string RemoveHistoryWarning { get; set; } = "";
- private ConfirmActionModal ConfirmActionHistory { get; set; }
private string InventoryLink { get; set; } = "";
private string ActivityLink { get; set; } = "";
private string InvoiceLink { get; set; } = "";
private string NewActivityLink { get; set; } = "";
private int EnableLink { get; set; } = 1;
-
+ private ActivityDrawer _activityDrawer = new();
+ private InventoryDrawer _inventoryDrawer = new();
+ private InvoiceDrawer _invoiceDrawer = new();
+ private StatisticDrawer _statisticDrawer = new();
+ private string _companyId = "";
protected override async Task OnInitializedAsync()
{
- // setup interceptor
+ /*
+ * setup interceptor
+ */
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
-
- // initialize default contact
+ /*
+ * default contact
+ */
DefaultContact = new ContactDto { CompanyId = CompanyId, ContactId = "", FirstName = "" };
-
- // navigation button links
+ /*
+ * navigation button links
+ */
InventoryLink = $"/advisor/customers/{CompanyId}/history/inventory";
ActivityLink = $"/advisor/customers/{CompanyId}/activities";
InvoiceLink = $"/advisor/customers/{CompanyId}/invoices";
NewActivityLink = $"/advisor/customers/{CompanyId}/activities/new";
-
- // setup form context
- ErpContext = new EditContext(Company);
-
- // assign event handlers to context
+ /*
+ * setup form context
+ */
+ ErpContext = new EditContext(_infoDrawer.Content);
+ /*
+ * assign event handlers to context
+ */
ErpContext.OnFieldChanged += HandleFieldChanged;
ErpContext.OnValidationStateChanged += ValidationChanged!;
-
- // fetch user info from local storage
- UserInfo = await UserInfoService.GetUserInfo();
- CountryCode = UserInfo.CountryCode.ToLower();
+ /*
+ * fetch user info from local storage
+ */
+ _userInfo = await UserInfoService.GetUserInfo();
+ CountryCode = _userInfo.CountryCode.ToLower();
CountryIsDk = CountryCode == "dk";
-
- Logger.LogDebug("companyId => {}", CompanyId);
-
- Company = await CustomerRepo.GetCompanyById(CompanyId);
-
- // internal flag
- EnableActivity = Company.ValidVat;
- // override if canvas which has account property as empty string or "NY"
- if (Company.Account.StartsWith("NY") || Company.Account.StartsWith("KANVAS") || string.IsNullOrWhiteSpace(Company.Account))
+ /*
+ * get InfoDrawer.Company from drawer
+ */
+ _infoDrawer = await CabinetService.GetInfoDrawerAsync(CompanyId);
+ _infoDrawer.Content = _infoDrawer.Content;
+ /*
+ * internal EnableActivity flag
+ */
+ EnableActivity = _infoDrawer.Content.ValidVat;
+ /*
+ * if KANVAS or NY override EnableActivity
+ */
+ if (_infoDrawer.Content.Account.StartsWith("NY") || _infoDrawer.Content.Account.StartsWith("KANVAS") || string.IsNullOrWhiteSpace(_infoDrawer.Content.Account))
EnableActivity = 1;
-
- if (Company.Account.StartsWith("KANVAS"))
+ if (_infoDrawer.Content.Account.StartsWith("KANVAS"))
Kanvas = true;
-
- // only execute if the company a 'real' customer
+ /*
+ * only execute if the InfoDrawer.Company is not KANVAS
+ */
if (!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
+ Logger.LogDebug("InfoDrawer.Company => {}", JsonSerializer.Serialize(_infoDrawer.Content));
+ /*
+ * toggle view button text
+ */
+ ToggleButtonText = _infoDrawer.Content.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning";
+ CurrentVat = _infoDrawer.Content.VatNumber;
+ _infoDrawer.Content.CountryCode = _userInfo.CountryCode.ToLower();
+ /*
+ * visit interval init
+ */
+ if (_infoDrawer.Content.Interval == 0)
+ _infoDrawer.Content.Interval = 8;
+ /*
+ * visit date init
+ */
+ LastVisit = DateTime.Parse(_infoDrawer.Content.LastVisit);
+ NextVisit = DateTime.Parse(_infoDrawer.Content.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
+ /*
+ * set next visit according to last visit and interval
+ */
+ if (!_infoDrawer.Content.ValidDateSpan())
+ NextVisit = LastVisit.AddDays(_infoDrawer.Content.Interval * 7);
+ /*
+ * display urgency of next visit
+ */
VisitState = Utils.GetVisitState($"{NextVisit:yyyy-MM-dd}");
- // handle company out of business case
- if (Company.HasFolded == 1)
+ /*
+ * handle InfoDrawer.Company out of business case
+ */
+ if (_infoDrawer.Content.HasFolded == 1)
{
- // this is only used if user has selected to show closed companies
+ /*
+ * this is only used if user has selected to show closed companies
+ */
HasFolded = true;
VatState = "the-dead";
VisitState = "the-dead";
}
else
{
- // valid vat enum
- Company.ValidVat = VatUtils.ValidateFormat(Company.CountryCode, Company.VatNumber) ? 1 : 0;
- // valid vat flag
- ValidVat = Company.ValidVat == 1; // true/false flag set if company has a valid vatNumber
- // vat state css class
- VatState = Company.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class
+ /*
+ * vat validation flags
+ */
+ _infoDrawer.Content.ValidVat = VatUtils.ValidateFormat(_infoDrawer.Content.CountryCode, _infoDrawer.Content.VatNumber) ? 1 : 0;
+ ValidVat = _infoDrawer.Content.ValidVat == 1; // true/false flag set if InfoDrawer.Company has a valid vatNumber
+ VatState = _infoDrawer.Content.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class
}
-
- // create search address from address
+ /*
+ * create search address from address
+ */
if (CountryIsDk)
{
- CompanyVatAddress = PrepareVatAddress(Company);
+ CompanyVatAddress = PrepareVatAddress(_infoDrawer.Content);
}
-
- await FetchContacts(CompanyId);
-
- Working = false;
-
- await RequestErpUpdate();
+ await GetContacts(CompanyId);
}
-
- // remove loading image
+ /*
+ * remove loading image
+ */
Working = false;
}
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ if (string.IsNullOrWhiteSpace(_companyId))
+ {
+ _companyId = CompanyId;
+ await CabinetService.GetInvoiceDrawerAsync(CompanyId, true);
+ await CabinetService.GetInventoryDrawerAsync(CompanyId, true);
+ await CabinetService.GetActivityDrawerAsync(CompanyId, true);
+ await CabinetService.GetStatisticDrawerAsync(CompanyId, true);
+ }
+ }
+
+ private async Task ReloadHistory()
+ {
+ Toaster.ShowWarning("Arbejder på sagen ...");
+ var newSync = await HistoryRepo.RequestErpSync(CompanyId, _infoDrawer.Content.HistorySync, false);
+ if (!string.IsNullOrWhiteSpace(newSync))
+ {
+ _infoDrawer.Content.HistorySync = newSync;
+ _infoDrawer.Content = _infoDrawer.Content;
+ await CabinetService.StoreInfoDrawerAsync(CompanyId, _infoDrawer);
+ }
+ await CabinetService.GetInvoiceDrawerAsync(CompanyId, true);
+ await CabinetService.GetInventoryDrawerAsync(CompanyId, true);
+ await CabinetService.GetActivityDrawerAsync(CompanyId, true);
+ await CabinetService.GetStatisticDrawerAsync(CompanyId, true);
+
+ Toaster.ShowSuccess("Data er snart klar ....");
+ }
private void ToggleErpEdit()
{
@@ -196,60 +251,30 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
}
- private void ConfirmReloadHistory()
- {
- // $"Bekræft at du sletter
{Workplace.Name} fra {Workplace.CompanyName}?
AL INFORMATION slettes og handlingen er uigenkaldelig.";
- RemoveHistoryWarning = $"Denne process kan tage lang tid.
Bekræft at al historik gendannes for
{Company.Account} {Company.Name}";
- ConfirmActionHistory.Show();
- }
-
-
- private async Task ReloadHistory()
- {
- if (Working)
- return;
- Toaster.ShowWarning("Vent venligst ....");
- Working = true;
- EnableLink = 0;
- EnableActivity = 0;
- var result = await HistoryRepo.GetRecycledInvoiceList(CompanyId, Company.HistorySync, true);
- await Task.Delay(1000);
- Working = false;
- if (!string.IsNullOrWhiteSpace(result))
- {
- Toaster.ShowInfo("Historik gendannelse er færdig");
- EnableLink = 1;
- EnableActivity = 1;
- }
- }
-
-
private async Task ToggleVisibility()
{
- Company.IsHidden = Company.IsHidden == 0 ? 1 : 0;
- // toggle view button text
- ToggleButtonText = Company.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning";
- Logger.LogDebug("ToggleVisibility => Company.IsHidden == {}", Company.IsHidden);
- await CustomerRepo.UpdateCrmData(CompanyId, Company);
+ /*
+ * toggle view button text
+ */
+ _infoDrawer.Content.IsHidden = _infoDrawer.Content.IsHidden == 0 ? 1 : 0;
+ ToggleButtonText = _infoDrawer.Content.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning";
+ /*
+ * send update reqeust
+ */
+ await CustomerRepo.UpdateCrmData(CompanyId, _infoDrawer.Content);
}
- private async Task RequestErpUpdate()
+ private async Task GetContacts(string companyId)
{
- if (Working)
- return;
- Working = true;
- Company.HistorySync = await HistoryRepo.GetRecycledInvoiceList(CompanyId, Company.HistorySync, false);
- Working = false;
- }
-
-
- private async Task FetchContacts(string companyId)
- {
- // load contacts
- Contacts = await CrmContactRepo.GetContacts(companyId);
+ /*
+ * load contacts
+ */
+ Contacts = await ContactRepo.GetContacts(companyId);
if (Contacts.Any() && Contacts.Count > 1)
+ {
Contacts = Contacts.OrderBy(x => x.FirstName).ToList();
+ }
}
@@ -261,83 +286,95 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private void SelectedCompanyCallback(VirkRegInfo regInfo)
{
- Logger.LogDebug("CrmCompanyView => SelectCompanyCallback => {}", JsonSerializer.Serialize(regInfo));
- // this can be removed in favor of the new data returned from updating the VatNumber
ValidVat = regInfo.States[0].State.ToLower() == "normal";
- Company.HasFolded = ValidVat ? 1 : 0;
+ _infoDrawer.Content.HasFolded = ValidVat ? 1 : 0;
EnableActivity = ValidVat ? 1 : 0;
VatState = regInfo.States[0].State.ToLower() == "normal" ? "the-good" : "the-dead";
- // set new properties
+ /*
+ * set new properties if flagged
+ */
if (regInfo.SyncAll)
{
- Company.Name = regInfo.Name;
- Company.Address1 = regInfo.Address;
- Company.Address2 = regInfo.CoName;
- Company.ZipCode = regInfo.ZipCode;
- Company.City = regInfo.City;
+ _infoDrawer.Content.Name = regInfo.Name;
+ _infoDrawer.Content.Address1 = regInfo.Address;
+ _infoDrawer.Content.Address2 = regInfo.CoName;
+ _infoDrawer.Content.ZipCode = regInfo.ZipCode;
+ _infoDrawer.Content.City = regInfo.City;
}
-
- Company.VatNumber = regInfo.VatNumber;
+ _infoDrawer.Content.VatNumber = regInfo.VatNumber;
}
private void OpenContactPopup(ContactDto contact)
{
- // write contact to debug log
- Logger.LogDebug("CompanyView => OpenContactPopup => contact => {}", JsonSerializer.Serialize(contact));
-
- // object to pass on to the popup
+ /*
+ * pass contact to popup
+ */
SelectedContact = contact;
-
- Logger.LogDebug("CompanyView => OpenContactPopup => SelectedContact => {}", JsonSerializer.Serialize(SelectedContact));
-
- // show the popup
+ /*
+ * show the popup
+ */
ContactViewPopup.Show();
}
-
+ ///
+ /// Create request to update contact information
+ ///
+ ///
private async Task WriteContactCallback(ContactDto contact)
{
+ if (Working)
+ return;
Working = true;
- // write contact to debug log
- var jsonContact = JsonSerializer.Serialize(contact);
- Logger.LogDebug("CompanyView => SaveContactCallback <= {}", jsonContact);
+ /*
+ * if ContactId is empty it is a new contact
+ */
if (string.IsNullOrWhiteSpace(contact.ContactId))
{
- // new contact created
- Logger.LogDebug("create => {}", jsonContact);
- // send post request to backend
- await CrmContactRepo.CreateContact(contact);
+ /*
+ * contact created - send post request to backend
+ */
+ await ContactRepo.PostContact(contact);
}
else
{
- // contact modified
- Logger.LogDebug("update => {}", jsonContact);
- // send put request to backend
- await CrmContactRepo.UpdateContact(contact);
+ /*
+ * contact modified - send put request
+ */
+ await ContactRepo.PutContact(contact);
}
-
- // reset selected contact
+ /*
+ * reset default contact
+ */
SelectedContact = new ContactDto();
- // reload contacts from backend
- await FetchContacts(CompanyId);
+ /*
+ * reload contacts from backend
+ */
+ await GetContacts(CompanyId);
Working = false;
}
///
- /// Delete contact callback
+ /// Delete contact information
///
///
private async Task DeleteContactCallback(string contactId)
{
+ if (Working)
+ return;
Working = true;
- Logger.LogDebug("delete {}", contactId);
- // send delete request to backend
- await CrmContactRepo.DeleteContact(CompanyId, contactId);
- // reset selected contact
+ /*
+ * send delete request to backend
+ */
+ await ContactRepo.DeleteContact(CompanyId, contactId);
+ /*
+ * reset default contact
+ */
SelectedContact = new ContactDto();
- // reload contacts from backend
- await FetchContacts(CompanyId);
+ /*
+ * reload contacts from backend
+ */
+ await GetContacts(CompanyId);
Working = false;
}
@@ -345,22 +382,21 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
/// Update CRM data
///
/// true/false
- private async Task UpdateCrmData()
+ private async Task PostCrmData()
{
if (Working)
return;
Working = true;
Toaster.ShowInfo("Vent venligst ...");
- Company.LastVisit = $"{LastVisit:yyyy-MM-dd}";
- Company.NextVisit = $"{NextVisit:yyyy-MM-dd}";
- Company.IsHidden = 0;
- var result = await CustomerRepo.UpdateCrmData(CompanyId, Company);
- if (!string.IsNullOrWhiteSpace(result.CompanyId))
+ _infoDrawer.Content.LastVisit = $"{LastVisit:yyyy-MM-dd}";
+ _infoDrawer.Content.NextVisit = $"{NextVisit:yyyy-MM-dd}";
+ _infoDrawer.Content.IsHidden = 0;
+ var company = await CustomerRepo.UpdateCrmData(CompanyId, _infoDrawer.Content);
+ if (!string.IsNullOrWhiteSpace(company.CompanyId))
{
- Company = result;
+ await UpdateInfoDrawer(company);
StateHasChanged();
}
-
Working = false;
Toaster.ClearAll();
}
@@ -376,13 +412,12 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
ErpEditDisabled = true;
Working = true;
Toaster.ShowInfo("Vent venligst ...");
- var result = await CustomerRepo.UpdateErpData(CompanyId, Company);
- if (!string.IsNullOrWhiteSpace(result.CompanyId))
+ var company = await CustomerRepo.UpdateErpData(CompanyId, _infoDrawer.Content);
+ if (!string.IsNullOrWhiteSpace(company.CompanyId))
{
- Company = result;
+ await UpdateInfoDrawer(company);
StateHasChanged();
}
-
Working = false;
Toaster.ClearAll();
}
@@ -393,8 +428,10 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
/// true/false
private async Task UpdateVatNumber()
{
- // VAT format validation
- if (!VatUtils.ValidateFormat(Company.CountryCode, Company.VatNumber))
+ /*
+ * VAT format validation
+ */
+ if (!VatUtils.ValidateFormat(_infoDrawer.Content.CountryCode, _infoDrawer.Content.VatNumber))
{
Toaster.ShowError($"Moms Nummer ugyldigt");
return;
@@ -402,29 +439,30 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
if (Working)
return;
- VatEditDisabled = true;
Working = true;
+ VatEditDisabled = true;
Toaster.ShowInfo("Vent venligst ...");
- var result = await CustomerRepo.UpdateCompanyVat(CompanyId, Company.VatNumber);
- if (!string.IsNullOrWhiteSpace(result.CompanyId))
+ var company = await CustomerRepo.UpdateCompanyVat(CompanyId, _infoDrawer.Content.VatNumber);
+ if (!string.IsNullOrWhiteSpace(company.CompanyId))
{
- Company = result;
+ await UpdateInfoDrawer(company);
StateHasChanged();
}
-
Toaster.ClearAll();
Working = false;
}
-
+
///
- /// Prepare vat address from company model
+ /// Prepare vat address from InfoDrawer.Company model
///
///
///
private static VatAddress PrepareVatAddress(CompanyDto company)
{
var digits = "1234567890".ToCharArray();
- // process address1
+ /*
+ * process address1
+ */
var pos1 = company.Address1.IndexOfAny(digits);
if (pos1 > 0)
{
@@ -432,11 +470,12 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
{
ZipCode = company.ZipCode.Trim(),
StreetName = company.Address1[..pos1].Trim(),
- HouseNumber = Regex.Replace(company.Address1[pos1..], "[^0-9]", "").Trim()
+ HouseNumber = company.Address1.Split('-')[0]
};
}
-
- // process address2
+ /*
+ * process address2
+ */
var pos2 = company.Address2.IndexOfAny(digits);
if (pos2 > 0)
{
@@ -444,17 +483,22 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
{
ZipCode = company.ZipCode.Trim(),
StreetName = company.Address2[..pos2].Trim(),
- HouseNumber = Regex.Replace(company.Address2[pos2..], "[^0-9]", "").Trim()
+ HouseNumber = company.Address2.Split('-')[0]
};
}
-
- // return empty model
+ /*
+ * return empty model
+ */
return new VatAddress();
}
- ///
- /// Change activity enabled state
- ///
+
+ private async Task UpdateInfoDrawer(CompanyDto company)
+ {
+ _infoDrawer.Content = company;
+ await CabinetService.StoreInfoDrawerAsync(CompanyId, _infoDrawer);
+ }
+
private void ForceActivity()
{
EnableActivity = EnableActivity == 0 ? 1 : 0;
@@ -468,11 +512,15 @@ 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
+ NextVisit = LastVisit.AddDays(_infoDrawer.Content.Interval * 7);
+ /*
+ * avoid nesting if by assuming ValidVat is false
+ */
ValidVat = false;
- // set ValidVat true if validation succeed
- if (VatUtils.ValidateFormat(Company.CountryCode, Company.VatNumber))
+ /*
+ * set ValidVat true if validation succeed
+ */
+ if (VatUtils.ValidateFormat(_infoDrawer.Content.CountryCode, _infoDrawer.Content.VatNumber))
{
ValidVat = true;
EnableActivity = 1;
@@ -491,7 +539,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
ErpContext.OnFieldChanged -= HandleFieldChanged;
ErpContext.OnValidationStateChanged -= ValidationChanged!;
- ErpContext = new EditContext(Company);
+ ErpContext = new EditContext(_infoDrawer.Content);
ErpContext.OnFieldChanged += HandleFieldChanged;
ErpContext.OnValidationStateChanged += ValidationChanged!;
diff --git a/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor b/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor
index 733f42f2..58460b3e 100644
--- a/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor
+++ b/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor
@@ -24,7 +24,7 @@
Support Dokumentation
Tilbage
@@ -38,7 +38,7 @@
@* placeholder *@
-
+
Loading...
@@ -60,7 +60,7 @@
-
+
@@ -81,13 +81,15 @@
-
+
\ No newline at end of file
diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs
index 29a65187..a276b8e0 100644
--- a/Wonky.Client/Program.cs
+++ b/Wonky.Client/Program.cs
@@ -28,7 +28,6 @@ using Wonky.Client.HttpRepository;
using Wonky.Client.Local.Services;
using Wonky.Client.Shared;
using Wonky.Entity.Configuration;
-using Wonky.Entity.DTO;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add
("#app");
@@ -88,8 +87,6 @@ builder.Services.AddScoped();
builder.Services.AddScoped();
// interceptor
builder.Services.AddScoped();
-// storage
-builder.Services.AddBlazoredLocalStorage();
// authorization
builder.Services.AddAuthorizationCore();
// authentication state provider
@@ -102,7 +99,10 @@ builder.Services.AddScoped();
builder.Services.AddScoped();
// activity draft service
builder.Services.AddScoped();
-
+// cabinet service
+builder.Services.AddScoped();
+// storage
+builder.Services.AddBlazoredLocalStorage();
// ---------------------------------------
diff --git a/Wonky.Client/Shared/AuthStateProvider.cs b/Wonky.Client/Shared/AuthStateProvider.cs
index 59c1ae01..2ec822ab 100644
--- a/Wonky.Client/Shared/AuthStateProvider.cs
+++ b/Wonky.Client/Shared/AuthStateProvider.cs
@@ -31,7 +31,8 @@ public class AuthStateProvider : AuthenticationStateProvider
private readonly IUserInfoService _infoService;
private readonly ILogger _logger;
-
+ private bool DebugMe { get; set; } = false;
+
public AuthStateProvider(HttpClient client, IUserInfoService infoService, ILogger logger)
{
_client = client;
@@ -44,25 +45,29 @@ public class AuthStateProvider : AuthenticationStateProvider
public override async Task GetAuthenticationStateAsync()
{
var token = await _infoService.GetAccessToken();
- _logger.LogDebug("accessToken {}", token);
+
+ if (DebugMe) _logger.LogDebug("accessToken {}", token);
+
if (string.IsNullOrEmpty(token))
{
return _anonymous;
}
var userInfo = await _infoService.GetUserInfo();
- _logger.LogDebug("userInfo {}", JsonSerializer.Serialize(userInfo));
+
+ if (DebugMe) _logger.LogDebug("userInfo {}", JsonSerializer.Serialize(userInfo));
if (userInfo == null || string.IsNullOrWhiteSpace(userInfo.FirstName))
{
NotifyUserLogout();
return _anonymous;
}
- _logger.LogDebug("userInfo.FirstName {}", userInfo.FirstName);
+ if (DebugMe) _logger.LogDebug("userInfo.FirstName {}", userInfo.FirstName);
+
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token);
var exp = await _infoService.GetExpiration();
- _logger.LogDebug("expiration {}", exp);
+ if (DebugMe) _logger.LogDebug("expiration {}", exp);
var claims = new List
{
@@ -95,7 +100,9 @@ public class AuthStateProvider : AuthenticationStateProvider
}
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token);
+
var userInfo = await _infoService.GetUserInfo();
+
if (string.IsNullOrWhiteSpace(userInfo.UserId))
{
NotifyUserLogout();
diff --git a/Wonky.Client/Shared/ConfirmWorkDateModal.razor b/Wonky.Client/Shared/ConfirmWorkDateOverlay.razor
similarity index 100%
rename from Wonky.Client/Shared/ConfirmWorkDateModal.razor
rename to Wonky.Client/Shared/ConfirmWorkDateOverlay.razor
diff --git a/Wonky.Client/Shared/ConfirmWorkDateModal.razor.cs b/Wonky.Client/Shared/ConfirmWorkDateOverlay.razor.cs
similarity index 96%
rename from Wonky.Client/Shared/ConfirmWorkDateModal.razor.cs
rename to Wonky.Client/Shared/ConfirmWorkDateOverlay.razor.cs
index b92e08b5..a7fe1373 100644
--- a/Wonky.Client/Shared/ConfirmWorkDateModal.razor.cs
+++ b/Wonky.Client/Shared/ConfirmWorkDateOverlay.razor.cs
@@ -18,7 +18,7 @@ using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Shared;
-public partial class ConfirmWorkDateModal
+public partial class ConfirmWorkDateOverlay
{
private string _modalDisplay = "";
private bool _showBackdrop;
diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json
index cae1441b..54322b63 100644
--- a/Wonky.Client/wwwroot/appsettings.json
+++ b/Wonky.Client/wwwroot/appsettings.json
@@ -1,15 +1,15 @@
{
"appInfo": {
"name": "Wonky Online",
- "version": "158.0",
+ "version": "161.0",
"rc": true,
"sandBox": false,
"image": "grumpy-coder.png"
},
"Logging": {
"LogLevel": {
- "Default": "Debug",
- "System": "Debug",
+ "Default": "Information",
+ "System": "Information",
"Microsoft": "Information"
},
"Debug": {
@@ -19,7 +19,7 @@
}
},
"apiConfig": {
- "baseUrl": "https://dev.innotec.dk",
+ "baseUrl": "https://zeta.innotec.dk",
"catalog": "api/v2/catalog/country",
"crmCustomers": "api/v2/crm/companies",
"crmInventoryExt": "history/inventory",