This commit is contained in:
Frede Hundewadt 2022-03-24 16:44:34 +01:00
parent 87a861ded4
commit 0e1f64ae88
8 changed files with 51 additions and 34 deletions

View file

@ -16,6 +16,7 @@
*@
@using Wonky.Client.Components;
@using Wonky.Client.Helpers;
@if (Companies.Any())
{
<table class="table">
@ -23,7 +24,7 @@
@foreach (var company in Companies)
{
<tr>
<td><DisplayStateComponent StateClass="@(VisitState(company.NextVisit))"></DisplayStateComponent></td>
<td><DisplayStateComponent StateClass="@(Utils.GetVisitState(company.NextVisit))"></DisplayStateComponent></td>
<td>@company.Name</td>
<td>@company.Account</td>
<td>@company.City</td>

View file

@ -15,7 +15,7 @@
//
*@
<img class="img-fluid float-start state rounded-circle @StateClass" src="state.png" alt="state"/>
<img class="img-fluid float-start state rounded-circle @StateClass mx-1" src="state.png" alt="state"/>
@code{
[Parameter] public string StateClass { get; set; } = "the-ugly";
}

View file

@ -23,4 +23,17 @@ public static class Utils
{
return DateTime.Now.ToFileTimeUtc().GetHashCode();
}
public static string GetVisitState(string dtNextVisit)
{
if (dtNextVisit == "1970-01-01")
return "the-draw";
var dtNow = DateTime.Now;
var dtValid = DateTime.TryParse(dtNextVisit, out var dtNext);
if (!dtValid)
return "the-draw";
if (dtNow >= dtNext)
return "the-ugly";
return (dtNow > dtNext.AddDays(-14)) ? "the-bad" : "the-good";
}
}

View file

@ -25,11 +25,13 @@
{
<div class="card">
<div class="card-header">
<div>CVR status "@RegState"</div>
<div><DisplayStateComponent StateClass="@RegState"></DisplayStateComponent> CVR status</div>
<div>Konto @_companyDto.Account</div>
<div>CompanyId @_companyDto.CompanyId</div>
<div>EDIT Næste besøg @NextVisit</div> <div>EDIT Sidst besøgt @LastVisit</div>
<div>DB Næste besøg @_companyDto.NextVisit</div> <div>DB Sidst besøgt @_companyDto.LastVisit</div>
<div>EDIT Næste besøg @NextVisit</div>
<div>EDIT Sidst besøgt @LastVisit</div>
<div>DB Næste besøg @_companyDto.NextVisit</div>
<div>DB Sidst besøgt @_companyDto.LastVisit</div>
</div>
<div class="card-body">
<EditForm EditContext="_editContext" OnValidSubmit="Update">

View file

@ -51,7 +51,7 @@ public partial class CompanyUpdate : IDisposable
_editContext = new EditContext(_companyDto);
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
if(!string.IsNullOrWhiteSpace(_companyDto.VatNumber))
await GetInfoFromVat(_companyDto.VatNumber);
}
@ -78,26 +78,25 @@ public partial class CompanyUpdate : IDisposable
ToastService.ShowError($"CVR nummer mangler.");
return;
}
var result = await VirkRegistryService
VInfos = await VirkRegistryService
.QueryVirkRegistry(
new VirkParams
{
VatNumber = vatNumber
});
if (string.IsNullOrWhiteSpace(result[0].VatNumber))
if (string.IsNullOrWhiteSpace(VInfos[0].VatNumber))
{
ToastService.ShowError($"CVR '{vatNumber}' findes ikke.");
ToastService.ShowError($"CVR nummer '{vatNumber}' findes ikke.");
return;
}
ToastService.ShowSuccess($"Data for '{vatNumber}' er hentet.");
_virkRegInfo = result[0];
RegState = _virkRegInfo.States[^1].State == "NORMAL" ? "the-good" : "the-ugly";
_companyDto.Name = _virkRegInfo.Name;
_companyDto.Address1 = _virkRegInfo.CoName;
_companyDto.Address2 = _virkRegInfo.Address;
_companyDto.ZipCode = _virkRegInfo.ZipCode;
_companyDto.City = _virkRegInfo.City;
_companyDto.VatNumber = _virkRegInfo.VatNumber;
// ToastService.ShowSuccess($"Data for '{vatNumber}' er hentet.");
// _virkRegInfo = result[0];
// _companyDto.Name = _virkRegInfo.Name;
// _companyDto.Address1 = _virkRegInfo.CoName;
// _companyDto.Address2 = _virkRegInfo.Address;
// _companyDto.ZipCode = _virkRegInfo.ZipCode;
// _companyDto.City = _virkRegInfo.City;
// _companyDto.VatNumber = _virkRegInfo.VatNumber;
}

View file

@ -19,9 +19,13 @@
@page "/company/id/{companyId}"
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components;
@using Wonky.Client.Helpers
@attribute [Authorize(Roles = "Adviser")]
<div class="card">
<div class="card-header">
</div>
<div class="card-body">
<table class="table table-sm table-striped table-bordered">
<tbody>
@ -64,18 +68,20 @@
</tr>
<tr>
<th scope="row">Næste besøg</th>
<td><DisplayStateComponent StateClass="@(VisitState)"></DisplayStateComponent></td>
<td><DisplayStateComponent StateClass="@(Utils.GetVisitState(CompanyDto.NextVisit))"></DisplayStateComponent></td>
<td>@CompanyDto.NextVisit</td>
</tr>
</tbody>
</table>
</div>
<div class="card-footer">
<div class="row">
<div class="col">
<a class="btn btn-primary" href="/companies">Tilbage</a>
<a class="btn btn-primary" href="/company/@CompanyDto.Account/Activity">Aktivitet</a>
<a href="/company/@CompanyDto.Account/update" class="btn btn-primary">Rediger</a>
<div class="row flex-row align-items-end">
<div class="col flex-column">
<a class="btn btn-primary float-start mx-2" href="/companies">Tilbage</a>
<a class="btn btn-primary float-start" href="/company/@CompanyDto.Account/update">Rediger</a>
</div>
<div class="col flex-column">
<a class="btn btn-primary float-end mx-2" href="/company/@CompanyDto.Account/Activity">Aktivitet</a>
</div>
</div>
</div>

View file

@ -7,12 +7,16 @@
height: 48px;
}
/* Display visit state classes */
.state {
width: 24px;
height: 24px;
min-width: 24px;
min-height: 24px;
}
.the-draw {
background-color: purple;
}
.the-good {
background-color: green;
}
@ -22,6 +26,7 @@
.the-ugly {
background-color: red;
}
/* end visit state classes*/
html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;

View file

@ -1,9 +0,0 @@
namespace Wonky.Entity;
public enum VirkState
{
None,
Good,
Bad,
Ugly
}