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. // Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -30,7 +29,7 @@ namespace Wonky.Client.HttpRepository;
public class AdvisorCustomerRepository : IAdvisorCustomerRepository public class AdvisorCustomerRepository : IAdvisorCustomerRepository
{ {
private readonly JsonSerializerOptions _options = new () private readonly JsonSerializerOptions _options = new()
{ {
PropertyNameCaseInsensitive = true PropertyNameCaseInsensitive = true
}; };
@ -42,7 +41,7 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
public AdvisorCustomerRepository(HttpClient client, public AdvisorCustomerRepository(HttpClient client,
ILogger<AdvisorCustomerRepository> logger, ILogger<AdvisorCustomerRepository> logger,
NavigationManager navigation, NavigationManager navigation,
IOptions<ApiConfig> apiConfig) IOptions<ApiConfig> apiConfig)
{ {
_client = client; _client = client;
@ -50,7 +49,7 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
_navigation = navigation; _navigation = navigation;
_conf = apiConfig.Value; _conf = apiConfig.Value;
} }
/// <summary> /// <summary>
/// Get a list of CRM customers (SalesRep) /// Get a list of CRM customers (SalesRep)
/// </summary> /// </summary>
@ -78,15 +77,18 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
MetaData = new MetaData() MetaData = new MetaData()
}; };
} }
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<CompanyDto> var pagingResponse = new PagingResponse<CompanyDto>
{ {
Items = JsonSerializer.Deserialize<List<CompanyDto>>(content, _options), 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; return pagingResponse;
} }
/// <summary> /// <summary>
/// Get CRM customer by Id (SalesRep) /// Get CRM customer by Id (SalesRep)
/// </summary> /// </summary>
@ -109,7 +111,7 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
var result = JsonSerializer.Deserialize<CompanyDto>(content, _options); var result = JsonSerializer.Deserialize<CompanyDto>(content, _options);
return result.CompanyId; return result.CompanyId;
} }
/// <summary> /// <summary>
/// Delete the CRM customer (SalesRep) /// Delete the CRM customer (SalesRep)
/// </summary> /// </summary>
@ -163,10 +165,10 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
Phone = model.Phone, Phone = model.Phone,
ZipCode = model.ZipCode ZipCode = model.ZipCode
}; };
var response = await _client.PutAsJsonAsync($"{_conf.CrmCustomers}/{companyId}/erpData", updateModel, _options); var response = await _client.PutAsJsonAsync($"{_conf.CrmCustomers}/{companyId}/erpData", updateModel, _options);
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<CompanyDto>(content); return JsonSerializer.Deserialize<CompanyDto>(content);
} }
/// <summary> /// <summary>
@ -182,9 +184,16 @@ public class AdvisorCustomerRepository : IAdvisorCustomerRepository
{ "VatNumber", vatNumber } { "VatNumber", vatNumber }
}; };
var response = await _client.PutAsJsonAsync($"{_conf.CrmCustomers}/{companyId}/vat", model, _options); var response = await _client.PutAsJsonAsync($"{_conf.CrmCustomers}/{companyId}/vat", model, _options);
if (!response.IsSuccessStatusCode)
return new CompanyDto();
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
return response.IsSuccessStatusCode return JsonSerializer.Deserialize<CompanyDto>(content)
? JsonSerializer.Deserialize<CompanyDto>(content) ?? new CompanyDto { Name = "ERROR", VatNumber = vatNumber, CrmNotes = $"FEJL: {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> /// <param name="vatNumber"></param>
/// <returns>A CRM Company entity</returns> /// <returns>A CRM Company entity</returns>
Task<CompanyDto> UpdateCompanyVat(string companyId, string vatNumber); 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"> <div class="col-sm-2">
<PageSizeComponent OnChanged="SetPageSize" /> <PageSizeComponent OnChanged="SetPageSize" />
</div> </div>
<div class="col-sm-2"> <div class="col-sm-3">
<button type button class="btn btn-warning @(@IncludeFolded ? "active" : "")" <button type button class="btn btn-warning @(ShowFolded ? "active" : "")"
data-bs-toggle="button" aria-pressed="@IncludeFolded" @onclick="OnFoldedClick"> data-bs-toggle="button" aria-pressed="@ShowFolded" @onclick="OnFoldedClick">
@ButtonFoldedText @ButtonFoldedText
</button> </button>
<button type button class="btn btn-warning @(@ShowHidden ? "active" : "")"
data-bs-toggle="button" aria-pressed="@ShowHidden" @onclick="OnHiddenClick">
@ButtonHiddenText
</button>
</div> </div>
<div class="col-sm-8"> <div class="col-sm-7">
<PaginationComponent MetaData="PageData" Spread="2" SelectedPage="SelectedPage"/> <PaginationComponent MetaData="PageData" Spread="2" SelectedPage="SelectedPage"/>
</div> </div>
<div class="col-sm-2 text-end"> <div class="col-sm-2 text-end">

View file

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

View file

@ -31,223 +31,224 @@
</div> </div>
} }
<div class="row pt-2 mb-2 rounded rounded-2 bg-dark text-white"> <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> </div>
// erp context // erp context
<EditForm EditContext="ErpContext"> <EditForm EditContext="ErpContext">
<DataAnnotationsValidator/> <DataAnnotationsValidator/>
<div class="row g-3"> <div class="row g-3">
@* Company Name *@ @* Company Name *@
<label for="name" class="col-sm-1 col-form-label-sm">Navn</label> <label for="name" class="col-sm-1 col-form-label-sm">Navn</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="name" class="form-control" @bind-Value="Company.Name"/> <InputText id="name" class="form-control" @bind-Value="Company.Name"/>
<ValidationMessage For="@(() => Company.Name)"></ValidationMessage> <ValidationMessage For="@(() => Company.Name)"></ValidationMessage>
</div> </div>
@* Company Attention *@ @* Company Attention *@
<label for="attention" class="col-sm-1 col-form-label-sm">Att.</label> <label for="attention" class="col-sm-1 col-form-label-sm">Att.</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="attention" class="form-control" @bind-Value="Company.Attention"/> <InputText id="attention" class="form-control" @bind-Value="Company.Attention"/>
<ValidationMessage For="@(() => Company.Attention)"></ValidationMessage> <ValidationMessage For="@(() => Company.Attention)"></ValidationMessage>
</div> </div>
@* Address 1 *@ @* Address 1 *@
<label for="address1" class="col-sm-1 col-form-label-sm">Adresse</label> <label for="address1" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="address1" class="form-control" @bind-Value="Company.Address1"/> <InputText id="address1" class="form-control" @bind-Value="Company.Address1"/>
<ValidationMessage For="@(() => Company.Address1)"></ValidationMessage> <ValidationMessage For="@(() => Company.Address1)"></ValidationMessage>
</div> </div>
@* Address 2 *@ @* Address 2 *@
<label for="address2" class="col-sm-1 col-form-label-sm">Adresse</label> <label for="address2" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="address2" class="form-control" @bind-Value="Company.Address2"/> <InputText id="address2" class="form-control" @bind-Value="Company.Address2"/>
<ValidationMessage For="@(() => Company.Address2)"></ValidationMessage> <ValidationMessage For="@(() => Company.Address2)"></ValidationMessage>
</div> </div>
@* Post Code *@ @* Post Code *@
<label for="zipCode" class="col-sm-1 col-form-label-sm">PostNr</label> <label for="zipCode" class="col-sm-1 col-form-label-sm">PostNr</label>
<div class="col-sm-2"> <div class="col-sm-2">
<InputText id="zipCode" class="form-control" @bind-Value="Company.ZipCode"/> <InputText id="zipCode" class="form-control" @bind-Value="Company.ZipCode"/>
<ValidationMessage For="@(() => Company.ZipCode)"></ValidationMessage> <ValidationMessage For="@(() => Company.ZipCode)"></ValidationMessage>
</div> </div>
@* City Name *@ @* City Name *@
<label for="city" class="col-sm-1 col-form-label-sm">Bynavn</label> <label for="city" class="col-sm-1 col-form-label-sm">Bynavn</label>
<div class="col-sm-8"> <div class="col-sm-8">
<InputText id="city" class="form-control" @bind-Value="Company.City"/> <InputText id="city" class="form-control" @bind-Value="Company.City"/>
<ValidationMessage For="@(() => Company.City)"></ValidationMessage> <ValidationMessage For="@(() => Company.City)"></ValidationMessage>
</div> </div>
@* Phone *@ @* Phone *@
<label for="phone" class="col-sm-1 col-form-label-sm">Telefon</label> <label for="phone" class="col-sm-1 col-form-label-sm">Telefon</label>
<div class="col-sm-5"> <div class="col-sm-3">
<InputText id="phone" class="form-control" @bind-Value="Company.Phone"/> <InputText id="phone" class="form-control" @bind-Value="Company.Phone"/>
<ValidationMessage For="@(() => Company.Phone)"></ValidationMessage> <ValidationMessage For="@(() => Company.Phone)"></ValidationMessage>
</div> </div>
@* Mobile *@ @* Mobile *@
<label for="mobile" class="col-sm-1 col-form-label-sm">Mobil</label> <label for="mobile" class="col-sm-1 col-form-label-sm">Mobil</label>
<div class="col-sm-5"> <div class="col-sm-3">
<InputText id="mobile" class="form-control" @bind-Value="Company.Mobile"/> <InputText id="mobile" class="form-control" @bind-Value="Company.Mobile"/>
<ValidationMessage For="@(() => Company.Mobile)"></ValidationMessage> <ValidationMessage For="@(() => Company.Mobile)"></ValidationMessage>
</div> </div>
@* Email *@ <div class="col-sm-4 d-grid mx-auto">
<label for="email" class="col-sm-1 col-form-label-sm">Epost</label> <button type="button" class="btn btn-danger" @onclick="ToggleVisibility">@ToggleButtonText</button>
<div class="col-sm-7"> </div>
<InputText id="email" class="form-control" @bind-Value="Company.Email"/> @* Email *@
<ValidationMessage For="@(() => Company.Email)"></ValidationMessage> <label for="email" class="col-sm-1 col-form-label-sm">Epost</label>
</div> <div class="col-sm-5">
<div class="col-sm-2 d-grid mx-auto"> <InputText id="email" class="form-control" @bind-Value="Company.Email"/>
<button type="button" class="btn btn-primary d-block" disabled="@(Company.HasFolded == 0 || Company.Name == "ERROR")" onclick="@ForceActivity">Aktiver besøg</button> <ValidationMessage For="@(() => Company.Email)"></ValidationMessage>
</div> </div>
<div class="col-sm-2 d-grid mx-auto"> <div class="col-sm-3 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> <button type="button" class="btn btn-primary d-block" disabled="@(Company.HasFolded == 0 || Company.Name == "ERROR")" onclick="@ForceActivity">Aktiver besøg</button>
</div> </div>
<div class="col-sm-3 d-grid mx-auto">
@* account *@ <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>
<label for="account" class="col-sm-1 col-form-label-sm">Konto</label> </div>
<div class="col-sm-2"> </div>
<input id="account" type="text" class="form-control" readonly value="@Company.Account"/>
</div> <hr class="mb-3"/>
@* vat number*@ <div class="row">
<label for="vatNumber" class="col-sm-1 col-form-label-sm">Cvr/Org nr.</label> @* vat number*@
<div class="col-sm-4"> <label for="vatNumber" class="col-sm-2 col-form-label-sm">CVR/Org nr.</label>
<div class="input-group"> <div class="col-sm-4">
<span class="input-group-text"> <div class="input-group">
<DisplayStateComponent StateClass="@VatState"/> <span class="input-group-text">
</span> <DisplayStateComponent StateClass="@VatState"/>
<InputText id="vatNumber" class="form-control" @bind-Value="Company.VatNumber"/> </span>
<ValidationMessage For="@(() => Company.VatNumber)"></ValidationMessage> <InputText id="vatNumber" class="form-control" @bind-Value="Company.VatNumber"/>
</div> <ValidationMessage For="@(() => Company.VatNumber)"></ValidationMessage>
</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>
</div> </div>
</div> </div>
@* vat lookup *@
<hr class="mb-3"/> <div class="col-sm-3 d-grid mx-auto">
@* activity buttons *@ @switch (CountryCode)
<div class="row mt-3 mb-3"> {
<div class="col-sm-3"> case "dk":
<a class="btn btn-danger d-block" href="/advisor/customers/@Company.CompanyId/invoices">Faktura</a> <button type="button" class="btn btn-info" @onclick="OpenVatLookupModal"><i class="bi-search"></i> CVR</button>
</div> break;
<div class="col-sm-3"> case "no":
<a class="btn btn-warning d-block" href="/advisor/customers/@Company.CompanyId/activities">Tidl. Besøg</a> <a class="btn btn-info" href="https://brreg.no/" target="_blank"><i class="bi-search"></i> brreg.no</a>
</div> break;
<div class="col-sm-3"> case "se":
<a class="btn btn-success d-block" href="/advisor/customers/@Company.CompanyId/h/i">Produkter</a> <a class="btn btn-info" href="https://www.allabolag.se/what/@Company.Name" target="_blank"><i class="bi-search"></i> allabolag.se</a>
</div> break;
<div class="col-sm-3"> }
<ActivityButton ActionLink="@ActionLink"
ButtonText="Nyt Besøg"
ButtonType="primary"
Enabled="@EnableActivity">
</ActivityButton>
</div>
</div> </div>
@* save vat number *@
<hr class="mb-3"/> <div class="col-sm-3 d-grid mx-auto">
@* crm context - OBS note *@ <button type="button" class="btn btn-warning d-block" @onclick="UpdateVatNumber"><i class="bi-cloud-arrow-up"></i> Moms/Org Nr.</button>
<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>
</div> </div>
@* crm context - contacts *@ </div>
<div class="row mb-4">
<label for="contacts" class="col-sm-1 col-form-label-sm">Kontakt</label> <hr class="mb-3"/>
<div id="contacts" class="col-sm-11"> @* activity buttons *@
<div class="list-group"> <div class="row mt-3 mb-3">
<div class="list-group-item list-group-item-action bg-dark text-white" @onclick="() => OpenContactPopup(DefaultContact)"> <div class="col-sm-3">
<div class="row"> <a class="btn btn-danger d-block" href="/advisor/customers/@Company.CompanyId/invoices">Faktura</a>
<div class="col-sm-4">Stilling</div> </div>
<div class="col-sm-4">Navn</div> <div class="col-sm-3">
<div class="col-sm-3">Direkte</div> <a class="btn btn-warning d-block" href="/advisor/customers/@Company.CompanyId/activities">Tidl. Besøg</a>
<div class="col-sm-1 text-end"> </div>
<i class="bi-plus-circle"></i> <div class="col-sm-3">
</div> <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>
</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="list-group-item list-group-item-action" @onclick="() => OpenContactPopup(contact)"> <div class="col-sm-4">@contact.JobTitle</div>
<div class="row g-2"> <div class="col-sm-4">@contact.FirstName @contact.LastName</div>
<div class="col-sm-4">@contact.JobTitle</div> <div class="col-sm-3">
<div class="col-sm-4">@contact.FirstName @contact.LastName</div> @contact.PhoneDirect
<div class="col-sm-3"> </div>
@contact.PhoneDirect <div class="col-sm-1 text-end">
</div> <i class="bi-pencil"></i>
<div class="col-sm-1 text-end">
<i class="bi-pencil"></i>
</div>
</div> </div>
</div> </div>
} </div>
} }
</div> }
</div> </div>
</div> </div>
@* crm context - dates and interval *@ </div>
<div class="row mb-2"> @* crm context - dates and interval *@
<label for="nextVisit" class="col-sm-1 col-form-label-sm">Næste besøg</label> <div class="row mb-2">
<div class="col-sm-3"> <label for="nextVisit" class="col-sm-1 col-form-label-sm">Næste besøg</label>
<div class="input-group"> <div class="col-sm-3">
<span class="input-group-text"> <div class="input-group">
<DisplayStateComponent StateClass="@VisitState"/> <span class="input-group-text">
</span> <DisplayStateComponent StateClass="@VisitState"/>
<InputDate id="nextVisit" class="form-control" @bind-Value="@(NextVisit)"/> </span>
</div> <InputDate id="nextVisit" class="form-control" @bind-Value="@(NextVisit)"/>
</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> </div>
<div class="row mb-2"> <label for="lastVisit" class="col-sm-1 col-form-label-sm">Sidse besøg</label>
<label for="crmNotes" class="col-sm-1 col-form-label-sm">Noter</label> <div class="col-sm-3">
<div class="col-sm-11"> <InputDate id="lastVisit" class="form-control" @bind-Value="@LastVisit"/>
<InputTextArea id="crmNotes" class="form-control" @bind-Value="Company.CrmNotes"/>
</div>
</div> </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> </EditForm>
} }
@if (Working) @if (Working)
{ {
<WorkingThreeDots /> <WorkingThreeDots/>
} }
<VatLookupDkModal VatAddress="CompanyVatAddress" EntityName="@Company.Name" VatNumber="@Company.VatNumber" <VatLookupDkModal VatAddress="CompanyVatAddress" EntityName="@Company.Name" VatNumber="@Company.VatNumber"
@ref="VatLookupPopup" OnSelectedCompany="SelectedCompanyCallback" /> @ref="VatLookupPopup" OnSelectedCompany="SelectedCompanyCallback"/>
<ContactModal ParamContact="@SelectedContact" CompanyName="@Company.Name" <ContactModal ParamContact="@SelectedContact" CompanyName="@Company.Name"
@ref="ContactPopup" OnSaveClicked="WriteContactCallback" OnDeleteClicked="DeleteContactCallback"/> @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 IToastService Toaster { get; set; }
[Inject] public ILogger<AdvisorCustomerViewEditPage> Logger { get; set; } [Inject] public ILogger<AdvisorCustomerViewEditPage> Logger { get; set; }
[Inject] public NavigationManager Navigator { 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 IAdvisorCustomerHistoryRepository HistoryRepo { get; set; }
[Inject] public IAdvisorContactRepository AdvisorContactRepo { get; set; } [Inject] public IAdvisorContactRepository AdvisorContactRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { 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 SelectedContact { get; set; } = new();
private ContactDto DefaultContact { get; set; } = new(); private ContactDto DefaultContact { get; set; } = new();
private ContactModal ContactPopup { 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() protected override async Task OnInitializedAsync()
{ {
@ -86,19 +87,18 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
ErpContext.OnValidationStateChanged += ValidationChanged; ErpContext.OnValidationStateChanged += ValidationChanged;
// fetch user info from local storage // fetch user info from local storage
XUserInfo = await UserInfoService.GetUserInfo(); UserInfo = await UserInfoService.GetUserInfo();
CountryCode = XUserInfo.CountryCode.ToLower(); CountryCode = UserInfo.CountryCode.ToLower();
CountryIsDk = CountryCode == "dk"; CountryIsDk = CountryCode == "dk";
Logger.LogDebug("companyId => {}", CompanyId); Logger.LogDebug("companyId => {}", CompanyId);
Company = await CompanyRepo.GetCompanyById(CompanyId); Company = await CustomerRepo.GetCompanyById(CompanyId);
Logger.LogDebug("company => {}", JsonSerializer.Serialize(Company)); Logger.LogDebug("company => {}", JsonSerializer.Serialize(Company));
ToggleButtonText = Company.IsHidden == 0 ? "Skjul kunde" : "Vis kunde";
CurrentVat = Company.VatNumber; CurrentVat = Company.VatNumber;
Company.CountryCode = UserInfo.CountryCode.ToLower();
Company.CountryCode = XUserInfo.CountryCode.ToLower();
// internal flag // internal flag
EnableActivity = Company.ValidVat; EnableActivity = Company.ValidVat;
// override if canvas which has account property as empty string or "NY" // override if canvas which has account property as empty string or "NY"
@ -110,7 +110,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
// visit date init // visit date init
LastVisit = DateTime.Parse(Company.LastVisit); LastVisit = DateTime.Parse(Company.LastVisit);
NextVisit = DateTime.Parse(Company.NextVisit); 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) if (LastVisit.Year < 2020)
LastVisit = DateTime.Parse("2020-01-01"); LastVisit = DateTime.Parse("2020-01-01");
// set next visit according to last visit and interval // set next visit according to last visit and interval
@ -149,6 +149,13 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
await RequestErpUpdate(); 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() private async Task RequestErpUpdate()
{ {
if(Working) if(Working)
@ -277,7 +284,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Company.LastVisit = $"{LastVisit:yyyy-MM-dd}"; Company.LastVisit = $"{LastVisit:yyyy-MM-dd}";
Company.NextVisit = $"{NextVisit:yyyy-MM-dd}"; Company.NextVisit = $"{NextVisit:yyyy-MM-dd}";
Company.IsHidden = 0; Company.IsHidden = 0;
var result = await CompanyRepo.UpdateCrmData(CompanyId, Company); var result = await CustomerRepo.UpdateCrmData(CompanyId, Company);
if (!string.IsNullOrWhiteSpace(result.CompanyId)) if (!string.IsNullOrWhiteSpace(result.CompanyId))
{ {
Company = result; Company = result;
@ -297,7 +304,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
return; return;
Working = true; Working = true;
Toaster.ShowInfo("Vent venligst ...", "OPDATERER STAM DATA"); 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)) if (!string.IsNullOrWhiteSpace(result.CompanyId))
{ {
Company = result; Company = result;
@ -323,7 +330,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
return; return;
Working = true; Working = true;
Toaster.ShowInfo("Vent venligst ...", "OPDATERER MOMS NUMMER"); 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)) if (!string.IsNullOrWhiteSpace(result.CompanyId))
{ {
Company = result; Company = result;

View file

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