FEAT: show hide customers in list

This commit is contained in:
Frede Hundewadt 2023-02-23 13:25:05 +01:00
parent e740f32fd7
commit 1a0255a14a
7 changed files with 266 additions and 231 deletions

View file

@ -1,4 +1,3 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
@ -30,7 +29,7 @@ namespace Wonky.Client.HttpRepository;
public class AdvisorCustomerRepository : IAdvisorCustomerRepository
{
private readonly JsonSerializerOptions _options = new ()
private readonly JsonSerializerOptions _options = new()
{
PropertyNameCaseInsensitive = true
};
@ -42,7 +41,7 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
public AdvisorCustomerRepository(HttpClient client,
ILogger<AdvisorCustomerRepository> logger,
NavigationManager navigation,
NavigationManager navigation,
IOptions<ApiConfig> apiConfig)
{
_client = client;
@ -50,7 +49,7 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
_navigation = navigation;
_conf = apiConfig.Value;
}
/// <summary>
/// Get a list of CRM customers (SalesRep)
/// </summary>
@ -78,15 +77,18 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
MetaData = new MetaData()
};
}
var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<CompanyDto>
{
Items = JsonSerializer.Deserialize<List<CompanyDto>>(content, _options),
MetaData = JsonSerializer.Deserialize<MetaData>(response.Headers.GetValues("X-Pagination").First(), _options)
MetaData = JsonSerializer.Deserialize<MetaData>(response.Headers.GetValues("X-Pagination").First(),
_options)
};
return pagingResponse;
}
/// <summary>
/// Get CRM customer by Id (SalesRep)
/// </summary>
@ -109,7 +111,7 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
var result = JsonSerializer.Deserialize<CompanyDto>(content, _options);
return result.CompanyId;
}
/// <summary>
/// Delete the CRM customer (SalesRep)
/// </summary>
@ -163,10 +165,10 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
Phone = model.Phone,
ZipCode = model.ZipCode
};
var response = await _client.PutAsJsonAsync($"{_conf.CrmCustomers}/{companyId}/erpData", updateModel, _options);
var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<CompanyDto>(content);
return JsonSerializer.Deserialize<CompanyDto>(content);
}
/// <summary>
@ -182,9 +184,16 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
{ "VatNumber", vatNumber }
};
var response = await _client.PutAsJsonAsync($"{_conf.CrmCustomers}/{companyId}/vat", model, _options);
if (!response.IsSuccessStatusCode)
return new CompanyDto();
var content = await response.Content.ReadAsStringAsync();
return response.IsSuccessStatusCode
? JsonSerializer.Deserialize<CompanyDto>(content)
: new CompanyDto{Name = "ERROR", VatNumber = vatNumber, CrmNotes = $"FEJL: {content}"};
return JsonSerializer.Deserialize<CompanyDto>(content)
?? new CompanyDto { Name = "ERROR", VatNumber = vatNumber, CrmNotes = $"FEJL: {content}" };
}
// public async Task<bool> ToggleVisibility(string companyId, bool hide)
// {
// var response = await _client.PostAsync($"{_conf.CrmCustomers}/{companyId}/toggle?hide={hide}", null);
// return response.IsSuccessStatusCode;
// }
}

View file

@ -76,4 +76,6 @@ public interface IAdvisorCustomerRepository
/// <param name="vatNumber"></param>
/// <returns>A CRM Company entity</returns>
Task<CompanyDto> UpdateCompanyVat(string companyId, string vatNumber);
// Task<bool> ToggleVisibility(string companyId, bool hide);
}

View file

@ -34,13 +34,17 @@
<div class="col-sm-2">
<PageSizeComponent OnChanged="SetPageSize" />
</div>
<div class="col-sm-2">
<button type button class="btn btn-warning @(@IncludeFolded ? "active" : "")"
data-bs-toggle="button" aria-pressed="@IncludeFolded" @onclick="OnFoldedClick">
<div class="col-sm-3">
<button type button class="btn btn-warning @(ShowFolded ? "active" : "")"
data-bs-toggle="button" aria-pressed="@ShowFolded" @onclick="OnFoldedClick">
@ButtonFoldedText
</button>
<button type button class="btn btn-warning @(@ShowHidden ? "active" : "")"
data-bs-toggle="button" aria-pressed="@ShowHidden" @onclick="OnHiddenClick">
@ButtonHiddenText
</button>
</div>
<div class="col-sm-8">
<div class="col-sm-7">
<PaginationComponent MetaData="PageData" Spread="2" SelectedPage="SelectedPage"/>
</div>
<div class="col-sm-2 text-end">

View file

@ -39,12 +39,13 @@ namespace Wonky.Client.Pages
private UserProfile Profiles { get; set; } = new();
private UserManagerEditView XUserInfo { get; set; } = new();
private string SavedSearch { get; set; } = "";
private bool IncludeFolded { get; set; }
private bool Working { get; set; } = true;
private MetaData PageData { get; set; } = new();
private CustomerPaging Paging { get; set; } = new();
private string ButtonFoldedText { get; set; } = "Vis Ophørte";
private bool ShowFolded { get; set; }
private string ButtonHiddenText { get; set; } = "Vis Skjulte";
private bool ShowHidden { get; set; }
protected override void OnParametersSet()
{
Interceptor.RegisterEvent();
@ -60,7 +61,7 @@ namespace Wonky.Client.Pages
Paging.OrderBy = Profiles.CompanySort;
Paging.SearchColumn = Profiles.CompanySearch;
Paging.PageSize = Convert.ToInt32(Profiles.PageSize);
Paging.HasFolded = IncludeFolded ? 1 : 0;
Paging.HasFolded = ShowFolded ? 1 : 0;
// load saved search
SavedSearch = string.IsNullOrWhiteSpace(Profiles.CompanyFilterPhrase) ? "" : Profiles.CompanyFilterPhrase;
@ -74,14 +75,25 @@ namespace Wonky.Client.Pages
private async Task OnFoldedClick()
{
Working = true;
IncludeFolded = !IncludeFolded;
ButtonFoldedText = IncludeFolded ? "Vis Aktive" : "Vis Ophørte";
ShowFolded = !ShowFolded;
ButtonFoldedText = ShowFolded ? "Vis Aktive" : "Vis Ophørte";
CompanyList = new List<CompanyDto>();
Paging.PageNumber = 1;
Paging.HasFolded = IncludeFolded ? 1 : 0;
Paging.HasFolded = ShowFolded ? 1 : 0;
await FetchCustomers();
}
private async Task OnHiddenClick()
{
Working = true;
ShowHidden = !ShowHidden;
ButtonHiddenText = ShowHidden ? "Vis Normale" : "Vis skjulte";
CompanyList = new List<CompanyDto>();
Paging.PageNumber = 1;
Paging.IsHidden = ShowHidden ? 1 : 0;
await FetchCustomers();
}
private async Task SelectedPage(int page)
{
CompanyList = new List<CompanyDto>();

View file

@ -31,223 +31,224 @@
</div>
}
<div class="row pt-2 mb-2 rounded rounded-2 bg-dark text-white">
<h3>@Company.Name</h3>
<h3>@Company.Name @(string.IsNullOrWhiteSpace(Company.Account) ? "" : "- ")@Company.Account</h3>
</div>
// erp context
<EditForm EditContext="ErpContext">
<DataAnnotationsValidator/>
<div class="row g-3">
@* Company Name *@
<label for="name" class="col-sm-1 col-form-label-sm">Navn</label>
<div class="col-sm-5">
<InputText id="name" class="form-control" @bind-Value="Company.Name"/>
<ValidationMessage For="@(() => Company.Name)"></ValidationMessage>
</div>
@* Company Attention *@
<label for="attention" class="col-sm-1 col-form-label-sm">Att.</label>
<div class="col-sm-5">
<InputText id="attention" class="form-control" @bind-Value="Company.Attention"/>
<ValidationMessage For="@(() => Company.Attention)"></ValidationMessage>
</div>
@* Address 1 *@
<label for="address1" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5">
<InputText id="address1" class="form-control" @bind-Value="Company.Address1"/>
<ValidationMessage For="@(() => Company.Address1)"></ValidationMessage>
</div>
@* Address 2 *@
<label for="address2" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5">
<InputText id="address2" class="form-control" @bind-Value="Company.Address2"/>
<ValidationMessage For="@(() => Company.Address2)"></ValidationMessage>
</div>
@* Post Code *@
<label for="zipCode" class="col-sm-1 col-form-label-sm">PostNr</label>
<div class="col-sm-2">
<InputText id="zipCode" class="form-control" @bind-Value="Company.ZipCode"/>
<ValidationMessage For="@(() => Company.ZipCode)"></ValidationMessage>
</div>
@* City Name *@
<label for="city" class="col-sm-1 col-form-label-sm">Bynavn</label>
<div class="col-sm-8">
<InputText id="city" class="form-control" @bind-Value="Company.City"/>
<ValidationMessage For="@(() => Company.City)"></ValidationMessage>
</div>
@* Phone *@
<label for="phone" class="col-sm-1 col-form-label-sm">Telefon</label>
<div class="col-sm-5">
<InputText id="phone" class="form-control" @bind-Value="Company.Phone"/>
<ValidationMessage For="@(() => Company.Phone)"></ValidationMessage>
</div>
@* Mobile *@
<label for="mobile" class="col-sm-1 col-form-label-sm">Mobil</label>
<div class="col-sm-5">
<InputText id="mobile" class="form-control" @bind-Value="Company.Mobile"/>
<ValidationMessage For="@(() => Company.Mobile)"></ValidationMessage>
</div>
@* Email *@
<label for="email" class="col-sm-1 col-form-label-sm">Epost</label>
<div class="col-sm-7">
<InputText id="email" class="form-control" @bind-Value="Company.Email"/>
<ValidationMessage For="@(() => Company.Email)"></ValidationMessage>
</div>
<div class="col-sm-2 d-grid mx-auto">
<button type="button" class="btn btn-primary d-block" disabled="@(Company.HasFolded == 0 || Company.Name == "ERROR")" onclick="@ForceActivity">Aktiver besøg</button>
</div>
<div class="col-sm-2 d-grid mx-auto">
<button type="button" class="btn btn-primary d-block" onclick="@UpdateErpData" disabled="@(Working || Company.Name == "ERROR")"><i class="bi-cloud-arrow-up"></i> STAM data </button>
</div>
@* account *@
<label for="account" class="col-sm-1 col-form-label-sm">Konto</label>
<div class="col-sm-2">
<input id="account" type="text" class="form-control" readonly value="@Company.Account"/>
</div>
@* vat number*@
<label for="vatNumber" class="col-sm-1 col-form-label-sm">Cvr/Org nr.</label>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-text">
<DisplayStateComponent StateClass="@VatState"/>
</span>
<InputText id="vatNumber" class="form-control" @bind-Value="Company.VatNumber"/>
<ValidationMessage For="@(() => Company.VatNumber)"></ValidationMessage>
</div>
</div>
@* vat lookup *@
<div class="col-sm-2 d-grid mx-auto">
@switch (CountryCode)
{
case "dk":
<button type="button" class="btn btn-info" @onclick="OpenVatLookupModal"><i class="bi-search"></i> Firma opslag</button>
break;
case "no":
<a class="btn btn-info" href="https://brreg.no/" target="_blank"><i class="bi-search"></i> Firma opslag</a>
break;
case "se":
<a class="btn btn-info" href="https://www.allabolag.se/what/@Company.Name" target="_blank"><i class="bi-search"></i> Firma opslag</a>
break;
}
</div>
@* save vat number *@
<div class="col-sm-2 d-grid mx-auto">
<button type="button" class="btn btn-primary d-block" @onclick="UpdateVatNumber"><i class="bi-cloud-arrow-up"></i> Moms/Org Nr.</button>
<DataAnnotationsValidator/>
<div class="row g-3">
@* Company Name *@
<label for="name" class="col-sm-1 col-form-label-sm">Navn</label>
<div class="col-sm-5">
<InputText id="name" class="form-control" @bind-Value="Company.Name"/>
<ValidationMessage For="@(() => Company.Name)"></ValidationMessage>
</div>
@* Company Attention *@
<label for="attention" class="col-sm-1 col-form-label-sm">Att.</label>
<div class="col-sm-5">
<InputText id="attention" class="form-control" @bind-Value="Company.Attention"/>
<ValidationMessage For="@(() => Company.Attention)"></ValidationMessage>
</div>
@* Address 1 *@
<label for="address1" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5">
<InputText id="address1" class="form-control" @bind-Value="Company.Address1"/>
<ValidationMessage For="@(() => Company.Address1)"></ValidationMessage>
</div>
@* Address 2 *@
<label for="address2" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5">
<InputText id="address2" class="form-control" @bind-Value="Company.Address2"/>
<ValidationMessage For="@(() => Company.Address2)"></ValidationMessage>
</div>
@* Post Code *@
<label for="zipCode" class="col-sm-1 col-form-label-sm">PostNr</label>
<div class="col-sm-2">
<InputText id="zipCode" class="form-control" @bind-Value="Company.ZipCode"/>
<ValidationMessage For="@(() => Company.ZipCode)"></ValidationMessage>
</div>
@* City Name *@
<label for="city" class="col-sm-1 col-form-label-sm">Bynavn</label>
<div class="col-sm-8">
<InputText id="city" class="form-control" @bind-Value="Company.City"/>
<ValidationMessage For="@(() => Company.City)"></ValidationMessage>
</div>
@* Phone *@
<label for="phone" class="col-sm-1 col-form-label-sm">Telefon</label>
<div class="col-sm-3">
<InputText id="phone" class="form-control" @bind-Value="Company.Phone"/>
<ValidationMessage For="@(() => Company.Phone)"></ValidationMessage>
</div>
@* Mobile *@
<label for="mobile" class="col-sm-1 col-form-label-sm">Mobil</label>
<div class="col-sm-3">
<InputText id="mobile" class="form-control" @bind-Value="Company.Mobile"/>
<ValidationMessage For="@(() => Company.Mobile)"></ValidationMessage>
</div>
<div class="col-sm-4 d-grid mx-auto">
<button type="button" class="btn btn-danger" @onclick="ToggleVisibility">@ToggleButtonText</button>
</div>
@* Email *@
<label for="email" class="col-sm-1 col-form-label-sm">Epost</label>
<div class="col-sm-5">
<InputText id="email" class="form-control" @bind-Value="Company.Email"/>
<ValidationMessage For="@(() => Company.Email)"></ValidationMessage>
</div>
<div class="col-sm-3 d-grid mx-auto">
<button type="button" class="btn btn-primary d-block" disabled="@(Company.HasFolded == 0 || Company.Name == "ERROR")" onclick="@ForceActivity">Aktiver besøg</button>
</div>
<div class="col-sm-3 d-grid mx-auto">
<button type="button" class="btn btn-danger d-block" onclick="@UpdateErpData" disabled="@(Working || Company.Name == "ERROR")"><i class="bi-cloud-arrow-up"></i> STAM data </button>
</div>
</div>
<hr class="mb-3"/>
<div class="row">
@* vat number*@
<label for="vatNumber" class="col-sm-2 col-form-label-sm">CVR/Org nr.</label>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-text">
<DisplayStateComponent StateClass="@VatState"/>
</span>
<InputText id="vatNumber" class="form-control" @bind-Value="Company.VatNumber"/>
<ValidationMessage For="@(() => Company.VatNumber)"></ValidationMessage>
</div>
</div>
<hr class="mb-3"/>
@* activity buttons *@
<div class="row mt-3 mb-3">
<div class="col-sm-3">
<a class="btn btn-danger d-block" href="/advisor/customers/@Company.CompanyId/invoices">Faktura</a>
</div>
<div class="col-sm-3">
<a class="btn btn-warning d-block" href="/advisor/customers/@Company.CompanyId/activities">Tidl. Besøg</a>
</div>
<div class="col-sm-3">
<a class="btn btn-success d-block" href="/advisor/customers/@Company.CompanyId/h/i">Produkter</a>
</div>
<div class="col-sm-3">
<ActivityButton ActionLink="@ActionLink"
ButtonText="Nyt Besøg"
ButtonType="primary"
Enabled="@EnableActivity">
</ActivityButton>
</div>
@* vat lookup *@
<div class="col-sm-3 d-grid mx-auto">
@switch (CountryCode)
{
case "dk":
<button type="button" class="btn btn-info" @onclick="OpenVatLookupModal"><i class="bi-search"></i> CVR</button>
break;
case "no":
<a class="btn btn-info" href="https://brreg.no/" target="_blank"><i class="bi-search"></i> brreg.no</a>
break;
case "se":
<a class="btn btn-info" href="https://www.allabolag.se/what/@Company.Name" target="_blank"><i class="bi-search"></i> allabolag.se</a>
break;
}
</div>
<hr class="mb-3"/>
@* crm context - OBS note *@
<div class="row mb-2">
<label for="note" class="col-sm-1 col-form-label-sm">OBS</label>
<div class="col-sm-9">
@if (string.IsNullOrWhiteSpace(Company.Note))
{
<InputText name="note" id="note" class="form-control" @bind-Value="Company.Note"/>
}
else
{
<InputText name="note" id="note" class="form-control bg-warning text-black" @bind-Value="Company.Note"/>
}
<ValidationMessage For="@(() => Company.Note)"></ValidationMessage>
</div>
@* Save CRM data button *@
<div class="col-sm-2 d-grid mx-auto">
<button type="button" class="btn btn-primary" disabled="@(Company.Name == "ERROR")" @onclick="UpdateCrmData"><i class="bi-cloud-arrow-up"></i> CRM data</button>
</div>
@* save vat number *@
<div class="col-sm-3 d-grid mx-auto">
<button type="button" class="btn btn-warning d-block" @onclick="UpdateVatNumber"><i class="bi-cloud-arrow-up"></i> Moms/Org Nr.</button>
</div>
@* crm context - contacts *@
<div class="row mb-4">
<label for="contacts" class="col-sm-1 col-form-label-sm">Kontakt</label>
<div id="contacts" class="col-sm-11">
<div class="list-group">
<div class="list-group-item list-group-item-action bg-dark text-white" @onclick="() => OpenContactPopup(DefaultContact)">
<div class="row">
<div class="col-sm-4">Stilling</div>
<div class="col-sm-4">Navn</div>
<div class="col-sm-3">Direkte</div>
<div class="col-sm-1 text-end">
<i class="bi-plus-circle"></i>
</div>
</div>
<hr class="mb-3"/>
@* activity buttons *@
<div class="row mt-3 mb-3">
<div class="col-sm-3">
<a class="btn btn-danger d-block" href="/advisor/customers/@Company.CompanyId/invoices">Faktura</a>
</div>
<div class="col-sm-3">
<a class="btn btn-warning d-block" href="/advisor/customers/@Company.CompanyId/activities">Tidl. Besøg</a>
</div>
<div class="col-sm-3">
<a class="btn btn-success d-block" href="/advisor/customers/@Company.CompanyId/h/i">Produkter</a>
</div>
<div class="col-sm-3">
<ActivityButton ActionLink="@ActionLink"
ButtonText="Nyt Besøg"
ButtonType="primary"
Enabled="@EnableActivity">
</ActivityButton>
</div>
</div>
<hr class="mb-3"/>
@* crm context - OBS note *@
<div class="row mb-2">
<label for="note" class="col-sm-1 col-form-label-sm">OBS</label>
<div class="col-sm-8">
@if (string.IsNullOrWhiteSpace(Company.Note))
{
<InputText name="note" id="note" class="form-control" @bind-Value="Company.Note"/>
}
else
{
<InputText name="note" id="note" class="form-control bg-warning text-black" @bind-Value="Company.Note"/>
}
<ValidationMessage For="@(() => Company.Note)"></ValidationMessage>
</div>
@* Save CRM data button *@
<div class="col-sm-3 d-grid mx-auto">
<button type="button" class="btn btn-warning" disabled="@(Company.Name == "ERROR")" @onclick="UpdateCrmData"><i class="bi-cloud-arrow-up"></i> CRM data</button>
</div>
</div>
@* crm context - contacts *@
<div class="row mb-4">
<label for="contacts" class="col-sm-1 col-form-label-sm">Kontakt</label>
<div id="contacts" class="col-sm-11">
<div class="list-group">
<div class="list-group-item list-group-item-action bg-dark text-white" @onclick="() => OpenContactPopup(DefaultContact)">
<div class="row">
<div class="col-sm-4">Stilling</div>
<div class="col-sm-4">Navn</div>
<div class="col-sm-3">Direkte</div>
<div class="col-sm-1 text-end">
<i class="bi-plus-circle"></i>
</div>
</div>
@if (Contacts.Any())
</div>
@if (Contacts.Any())
{
@foreach (var contact in Contacts)
{
@foreach (var contact in Contacts)
{
<div class="list-group-item list-group-item-action" @onclick="() => OpenContactPopup(contact)">
<div class="row g-2">
<div class="col-sm-4">@contact.JobTitle</div>
<div class="col-sm-4">@contact.FirstName @contact.LastName</div>
<div class="col-sm-3">
@contact.PhoneDirect
</div>
<div class="col-sm-1 text-end">
<i class="bi-pencil"></i>
</div>
<div class="list-group-item list-group-item-action" @onclick="() => OpenContactPopup(contact)">
<div class="row g-2">
<div class="col-sm-4">@contact.JobTitle</div>
<div class="col-sm-4">@contact.FirstName @contact.LastName</div>
<div class="col-sm-3">
@contact.PhoneDirect
</div>
<div class="col-sm-1 text-end">
<i class="bi-pencil"></i>
</div>
</div>
}
</div>
}
</div>
}
</div>
</div>
@* crm context - dates and interval *@
<div class="row mb-2">
<label for="nextVisit" class="col-sm-1 col-form-label-sm">Næste besøg</label>
<div class="col-sm-3">
<div class="input-group">
<span class="input-group-text">
<DisplayStateComponent StateClass="@VisitState"/>
</span>
<InputDate id="nextVisit" class="form-control" @bind-Value="@(NextVisit)"/>
</div>
</div>
<label for="lastVisit" class="col-sm-1 col-form-label-sm">Sidse besøg</label>
<div class="col-sm-3">
<InputDate id="lastVisit" class="form-control" @bind-Value="@LastVisit"/>
</div>
<label for="interval" class="col-sm-2 col-form-label-sm">Uge Interval</label>
<div class="col-sm-2">
<InputNumber id="interval" class="form-control" @bind-Value="Company.Interval"/>
<ValidationMessage For="@(() => Company.Interval)"></ValidationMessage>
</div>
@* crm context - dates and interval *@
<div class="row mb-2">
<label for="nextVisit" class="col-sm-1 col-form-label-sm">Næste besøg</label>
<div class="col-sm-3">
<div class="input-group">
<span class="input-group-text">
<DisplayStateComponent StateClass="@VisitState"/>
</span>
<InputDate id="nextVisit" class="form-control" @bind-Value="@(NextVisit)"/>
</div>
</div>
<div class="row mb-2">
<label for="crmNotes" class="col-sm-1 col-form-label-sm">Noter</label>
<div class="col-sm-11">
<InputTextArea id="crmNotes" class="form-control" @bind-Value="Company.CrmNotes"/>
</div>
<label for="lastVisit" class="col-sm-1 col-form-label-sm">Sidse besøg</label>
<div class="col-sm-3">
<InputDate id="lastVisit" class="form-control" @bind-Value="@LastVisit"/>
</div>
<label for="interval" class="col-sm-2 col-form-label-sm">Uge Interval</label>
<div class="col-sm-2">
<InputNumber id="interval" class="form-control" @bind-Value="Company.Interval"/>
<ValidationMessage For="@(() => Company.Interval)"></ValidationMessage>
</div>
</div>
<div class="row mb-2">
<label for="crmNotes" class="col-sm-1 col-form-label-sm">Noter</label>
<div class="col-sm-11">
<InputTextArea id="crmNotes" class="form-control" @bind-Value="Company.CrmNotes"/>
</div>
</div>
</EditForm>
}
@if (Working)
{
<WorkingThreeDots />
<WorkingThreeDots/>
}
<VatLookupDkModal VatAddress="CompanyVatAddress" EntityName="@Company.Name" VatNumber="@Company.VatNumber"
@ref="VatLookupPopup" OnSelectedCompany="SelectedCompanyCallback" />
<ContactModal ParamContact="@SelectedContact" CompanyName="@Company.Name"
@ref="ContactPopup" OnSaveClicked="WriteContactCallback" OnDeleteClicked="DeleteContactCallback"/>
<VatLookupDkModal VatAddress="CompanyVatAddress" EntityName="@Company.Name" VatNumber="@Company.VatNumber"
@ref="VatLookupPopup" OnSelectedCompany="SelectedCompanyCallback"/>
<ContactModal ParamContact="@SelectedContact" CompanyName="@Company.Name"
@ref="ContactPopup" OnSaveClicked="WriteContactCallback" OnDeleteClicked="DeleteContactCallback"/>

View file

@ -39,7 +39,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
[Inject] public IToastService Toaster { get; set; }
[Inject] public ILogger<AdvisorCustomerViewEditPage> Logger { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; }
[Inject] public IAdvisorCustomerRepository CustomerRepo { get; set; }
[Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; }
[Inject] public IAdvisorContactRepository AdvisorContactRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
@ -68,7 +68,8 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private ContactDto SelectedContact { get; set; } = new();
private ContactDto DefaultContact { get; set; } = new();
private ContactModal ContactPopup { get; set; } = new();
private UserManagerEditView XUserInfo { get; set; } = new();
private UserManagerEditView UserInfo { get; set; } = new();
private string ToggleButtonText { get; set; } = "";
protected override async Task OnInitializedAsync()
{
@ -86,19 +87,18 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
ErpContext.OnValidationStateChanged += ValidationChanged;
// fetch user info from local storage
XUserInfo = await UserInfoService.GetUserInfo();
CountryCode = XUserInfo.CountryCode.ToLower();
UserInfo = await UserInfoService.GetUserInfo();
CountryCode = UserInfo.CountryCode.ToLower();
CountryIsDk = CountryCode == "dk";
Logger.LogDebug("companyId => {}", CompanyId);
Company = await CompanyRepo.GetCompanyById(CompanyId);
Company = await CustomerRepo.GetCompanyById(CompanyId);
Logger.LogDebug("company => {}", JsonSerializer.Serialize(Company));
ToggleButtonText = Company.IsHidden == 0 ? "Skjul kunde" : "Vis kunde";
CurrentVat = Company.VatNumber;
Company.CountryCode = XUserInfo.CountryCode.ToLower();
Company.CountryCode = UserInfo.CountryCode.ToLower();
// internal flag
EnableActivity = Company.ValidVat;
// override if canvas which has account property as empty string or "NY"
@ -110,7 +110,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
// visit date init
LastVisit = DateTime.Parse(Company.LastVisit);
NextVisit = DateTime.Parse(Company.NextVisit);
// if not previous visit is registered - force last visit date to 2020
// 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
@ -149,6 +149,13 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
await RequestErpUpdate();
}
private async Task ToggleVisibility()
{
Company.IsHidden = Company.IsHidden == 0 ? 1 : 0;
ToggleButtonText = Company.IsHidden == 0 ? "Skjul kunde" : "Vis kunde";
Logger.LogDebug("ToggleVisibility => Company.IsHidden == {}", Company.IsHidden);
await CustomerRepo.UpdateCrmData(CompanyId, Company);
}
private async Task RequestErpUpdate()
{
if(Working)
@ -277,7 +284,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Company.LastVisit = $"{LastVisit:yyyy-MM-dd}";
Company.NextVisit = $"{NextVisit:yyyy-MM-dd}";
Company.IsHidden = 0;
var result = await CompanyRepo.UpdateCrmData(CompanyId, Company);
var result = await CustomerRepo.UpdateCrmData(CompanyId, Company);
if (!string.IsNullOrWhiteSpace(result.CompanyId))
{
Company = result;
@ -297,7 +304,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
return;
Working = true;
Toaster.ShowInfo("Vent venligst ...", "OPDATERER STAM DATA");
var result = await CompanyRepo.UpdateErpData(CompanyId, Company);
var result = await CustomerRepo.UpdateErpData(CompanyId, Company);
if (!string.IsNullOrWhiteSpace(result.CompanyId))
{
Company = result;
@ -323,7 +330,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
return;
Working = true;
Toaster.ShowInfo("Vent venligst ...", "OPDATERER MOMS NUMMER");
var result = await CompanyRepo.UpdateCompanyVat(CompanyId, Company.VatNumber);
var result = await CustomerRepo.UpdateCompanyVat(CompanyId, Company.VatNumber);
if (!string.IsNullOrWhiteSpace(result.CompanyId))
{
Company = result;

View file

@ -1,7 +1,7 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "0.117.0",
"version": "0.117.1",
"rc": true,
"sandBox": false,
"image": "grumpy-coder.png"