wip
This commit is contained in:
parent
87a861ded4
commit
0e1f64ae88
8 changed files with 51 additions and 34 deletions
|
@ -16,6 +16,7 @@
|
||||||
*@
|
*@
|
||||||
|
|
||||||
@using Wonky.Client.Components;
|
@using Wonky.Client.Components;
|
||||||
|
@using Wonky.Client.Helpers;
|
||||||
@if (Companies.Any())
|
@if (Companies.Any())
|
||||||
{
|
{
|
||||||
<table class="table">
|
<table class="table">
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
@foreach (var company in Companies)
|
@foreach (var company in Companies)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td><DisplayStateComponent StateClass="@(VisitState(company.NextVisit))"></DisplayStateComponent></td>
|
<td><DisplayStateComponent StateClass="@(Utils.GetVisitState(company.NextVisit))"></DisplayStateComponent></td>
|
||||||
<td>@company.Name</td>
|
<td>@company.Name</td>
|
||||||
<td>@company.Account</td>
|
<td>@company.Account</td>
|
||||||
<td>@company.City</td>
|
<td>@company.City</td>
|
||||||
|
|
|
@ -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{
|
@code{
|
||||||
[Parameter] public string StateClass { get; set; } = "the-ugly";
|
[Parameter] public string StateClass { get; set; } = "the-ugly";
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,17 @@ public static class Utils
|
||||||
{
|
{
|
||||||
return DateTime.Now.ToFileTimeUtc().GetHashCode();
|
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";
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,11 +25,13 @@
|
||||||
{
|
{
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div>CVR status "@RegState"</div>
|
<div><DisplayStateComponent StateClass="@RegState"></DisplayStateComponent> CVR status</div>
|
||||||
<div>Konto @_companyDto.Account</div>
|
<div>Konto @_companyDto.Account</div>
|
||||||
<div>CompanyId @_companyDto.CompanyId</div>
|
<div>CompanyId @_companyDto.CompanyId</div>
|
||||||
<div>EDIT Næste besøg @NextVisit</div> <div>EDIT Sidst besøgt @LastVisit</div>
|
<div>EDIT Næste besøg @NextVisit</div>
|
||||||
<div>DB Næste besøg @_companyDto.NextVisit</div> <div>DB Sidst besøgt @_companyDto.LastVisit</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>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<EditForm EditContext="_editContext" OnValidSubmit="Update">
|
<EditForm EditContext="_editContext" OnValidSubmit="Update">
|
||||||
|
|
|
@ -51,7 +51,7 @@ public partial class CompanyUpdate : IDisposable
|
||||||
_editContext = new EditContext(_companyDto);
|
_editContext = new EditContext(_companyDto);
|
||||||
Interceptor.RegisterEvent();
|
Interceptor.RegisterEvent();
|
||||||
Interceptor.RegisterBeforeSendEvent();
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
if(!string.IsNullOrWhiteSpace(_companyDto.VatNumber))
|
||||||
await GetInfoFromVat(_companyDto.VatNumber);
|
await GetInfoFromVat(_companyDto.VatNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,26 +78,25 @@ public partial class CompanyUpdate : IDisposable
|
||||||
ToastService.ShowError($"CVR nummer mangler.");
|
ToastService.ShowError($"CVR nummer mangler.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result = await VirkRegistryService
|
VInfos = await VirkRegistryService
|
||||||
.QueryVirkRegistry(
|
.QueryVirkRegistry(
|
||||||
new VirkParams
|
new VirkParams
|
||||||
{
|
{
|
||||||
VatNumber = vatNumber
|
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;
|
return;
|
||||||
}
|
}
|
||||||
ToastService.ShowSuccess($"Data for '{vatNumber}' er hentet.");
|
// ToastService.ShowSuccess($"Data for '{vatNumber}' er hentet.");
|
||||||
_virkRegInfo = result[0];
|
// _virkRegInfo = result[0];
|
||||||
RegState = _virkRegInfo.States[^1].State == "NORMAL" ? "the-good" : "the-ugly";
|
// _companyDto.Name = _virkRegInfo.Name;
|
||||||
_companyDto.Name = _virkRegInfo.Name;
|
// _companyDto.Address1 = _virkRegInfo.CoName;
|
||||||
_companyDto.Address1 = _virkRegInfo.CoName;
|
// _companyDto.Address2 = _virkRegInfo.Address;
|
||||||
_companyDto.Address2 = _virkRegInfo.Address;
|
// _companyDto.ZipCode = _virkRegInfo.ZipCode;
|
||||||
_companyDto.ZipCode = _virkRegInfo.ZipCode;
|
// _companyDto.City = _virkRegInfo.City;
|
||||||
_companyDto.City = _virkRegInfo.City;
|
// _companyDto.VatNumber = _virkRegInfo.VatNumber;
|
||||||
_companyDto.VatNumber = _virkRegInfo.VatNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,13 @@
|
||||||
@page "/company/id/{companyId}"
|
@page "/company/id/{companyId}"
|
||||||
@using Microsoft.AspNetCore.Authorization
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using Wonky.Client.Components;
|
@using Wonky.Client.Components;
|
||||||
|
@using Wonky.Client.Helpers
|
||||||
@attribute [Authorize(Roles = "Adviser")]
|
@attribute [Authorize(Roles = "Adviser")]
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
|
||||||
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<table class="table table-sm table-striped table-bordered">
|
<table class="table table-sm table-striped table-bordered">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -64,18 +68,20 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Næste besøg</th>
|
<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>
|
<td>@CompanyDto.NextVisit</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<div class="row">
|
<div class="row flex-row align-items-end">
|
||||||
<div class="col">
|
<div class="col flex-column">
|
||||||
<a class="btn btn-primary" href="/companies">Tilbage</a>
|
<a class="btn btn-primary float-start mx-2" href="/companies">Tilbage</a>
|
||||||
<a class="btn btn-primary" href="/company/@CompanyDto.Account/Activity">Aktivitet</a>
|
<a class="btn btn-primary float-start" href="/company/@CompanyDto.Account/update">Rediger</a>
|
||||||
<a href="/company/@CompanyDto.Account/update" class="btn btn-primary">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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,12 +7,16 @@
|
||||||
height: 48px;
|
height: 48px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Display visit state classes */
|
||||||
.state {
|
.state {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
min-width: 24px;
|
min-width: 24px;
|
||||||
min-height: 24px;
|
min-height: 24px;
|
||||||
}
|
}
|
||||||
|
.the-draw {
|
||||||
|
background-color: purple;
|
||||||
|
}
|
||||||
.the-good {
|
.the-good {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +26,7 @@
|
||||||
.the-ugly {
|
.the-ugly {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
}
|
}
|
||||||
|
/* end visit state classes*/
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
namespace Wonky.Entity;
|
|
||||||
|
|
||||||
public enum VirkState
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
Good,
|
|
||||||
Bad,
|
|
||||||
Ugly
|
|
||||||
}
|
|
Loading…
Reference in a new issue