refactor component names and error page names

This commit is contained in:
Frede Hundewadt 2022-09-28 12:35:26 +02:00
parent 0e0484cdd2
commit c28830f1b1
22 changed files with 250 additions and 149 deletions

View file

@ -30,7 +30,7 @@
<th class="text-center" scope="col"><i class="oi oi-phone"></i></th> <th class="text-center" scope="col"><i class="oi oi-phone"></i></th>
<th class="text-center" scope="col"><i class="oi oi-flash"></i></th> <th class="text-center" scope="col"><i class="oi oi-flash"></i></th>
<th class="text-center" scope="col"><i class="oi oi-calculator"></i></th> <th class="text-center" scope="col"><i class="oi oi-calculator"></i></th>
<th class="text-center" scope="col"><i class="bi bi-box"></i></th> <th class="text-center" scope="col"><i class="bi bi-truck"></i></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -16,9 +16,7 @@
*@ *@
<i class="bi bi-@_icon @StateClass"></i> <i class="bi bi-@_icon @StateClass"></i>
@* <svg class="bi bi-exclamation-triangle text-success" width="32" height="32" fill="currentColor" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> *@
@* ... *@
@* </svg> *@
@code{ @code{
[Parameter] public string StateClass { get; set; } = ""; [Parameter] public string StateClass { get; set; } = "";
private string _icon { get; set; } = ""; private string _icon { get; set; } = "";
@ -27,9 +25,9 @@
{ {
_icon = StateClass switch _icon = StateClass switch
{ {
"the-ugly-fg" => "square", "the-ugly-fg" => "file-earmark",
"the-bad-fg" => "box2", "the-bad-fg" => "file-earmark-check",
"the-good-fg" => "box-seam-fill", "the-good-fg" => "box2-fill",
"the-draw-fg" => "truck", "the-draw-fg" => "truck",
_ => "question-square" _ => "question-square"
}; };

View file

@ -0,0 +1,12 @@
.the-good-fg {
color: black;
}
.the-bad-fg {
color: black;
}
.the-ugly-fg {
color: black;
}
.the-draw-fg {
color: black;
}

View file

@ -19,8 +19,9 @@
<AuthorizeView> <AuthorizeView>
<Authorized> <Authorized>
<div class="d-print-none"> <div class="d-print-none">
<a class="btn btn-outline-light" href="logout"><i class="oi oi-lock-unlocked"></i> LOG AF</a> <a class="btn btn-outline-light" href="logout" title="Log af" ><i class="bi-lock"></i></a>
<a class="btn btn-outline-light" href="info">HJÆLP</a> <a class="btn btn-outline-light" href="info" title="Information"><i class="bi-question"></i></a>
<a class="btn btn-outline-light" href="preferences" title="Indstillinger"><i class="bi-sliders"></i></a>
</div> </div>
</Authorized> </Authorized>
</AuthorizeView> </AuthorizeView>

View file

@ -27,4 +27,5 @@ public interface ICrmActivityHttpRepository
Task<ReportStatusView> GetActivities(string activityDate); Task<ReportStatusView> GetActivities(string activityDate);
Task<List<ReportItemView>> GetCustomerActivities(string customerId); Task<List<ReportItemView>> GetCustomerActivities(string customerId);
Task UpdateOfficeNote(ActivityOfficeNote model); Task UpdateOfficeNote(ActivityOfficeNote model);
Task UpdateExpressStatus(string id);
} }

View file

@ -43,7 +43,7 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository
private readonly NavigationManager _navigation; private readonly NavigationManager _navigation;
private ILogger<CrmActivityHttpRepository> _logger; private ILogger<CrmActivityHttpRepository> _logger;
private readonly HttpClient _client; private readonly HttpClient _client;
private readonly ApiConfig _apiConfig; private readonly ApiConfig _api;
public CrmActivityHttpRepository(HttpClient client, public CrmActivityHttpRepository(HttpClient client,
ILogger<CrmActivityHttpRepository> logger, ILogger<CrmActivityHttpRepository> logger,
@ -52,19 +52,24 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository
_client = client; _client = client;
_logger = logger; _logger = logger;
_navigation = navigation; _navigation = navigation;
_apiConfig = configuration.Value; _api = configuration.Value;
} }
public async Task UpdateExpressStatus(string id)
{
await _client.PostAsync($"{_api.CrmSales}/express/{id}/?status=express", null);
}
public async Task UpdateOfficeNote(ActivityOfficeNote model) public async Task UpdateOfficeNote(ActivityOfficeNote model)
{ {
_logger.LogDebug("UpdateOfficeNote => model \n{}", JsonSerializer.Serialize(model) ); _logger.LogDebug("UpdateOfficeNote => model \n{}", JsonSerializer.Serialize(model) );
_logger.LogDebug("UpdateOfficeNote => url \n{}", $"{_apiConfig.CrmSales}/activity/{model.ActivityId}" ); _logger.LogDebug("UpdateOfficeNote => url \n{}", $"{_api.CrmSales}/activity/{model.ActivityId}" );
await _client.PostAsJsonAsync($"{_apiConfig.CrmSales}/activity/{model.ActivityId}", model, _options); await _client.PostAsJsonAsync($"{_api.CrmSales}/activity/{model.ActivityId}", model, _options);
} }
public async Task<ReportStatusView> GetActivities(string activityDate) public async Task<ReportStatusView> GetActivities(string activityDate)
{ {
var response = await _client var response = await _client
.GetAsync($"{_apiConfig.CrmSales}/date/{activityDate}"); .GetAsync($"{_api.CrmSales}/date/{activityDate}");
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
return string.IsNullOrWhiteSpace(content) return string.IsNullOrWhiteSpace(content)
? new ReportStatusView() ? new ReportStatusView()
@ -73,7 +78,7 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository
public async Task<List<ReportItemView>> GetCustomerActivities(string customerId) public async Task<List<ReportItemView>> GetCustomerActivities(string customerId)
{ {
var response = await _client.GetAsync($"{_apiConfig.CrmSales}/company/{customerId}"); var response = await _client.GetAsync($"{_api.CrmSales}/company/{customerId}");
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<List<ReportItemView>>(content, _options); return JsonSerializer.Deserialize<List<ReportItemView>>(content, _options);
@ -81,29 +86,32 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository
public async Task<ApiResponseView> CreateActivity(ActivityDto model) public async Task<ApiResponseView> CreateActivity(ActivityDto model)
{ {
var response = await _client.PostAsJsonAsync($"{_apiConfig.CrmSales}", model, _options); var response = await _client.PostAsJsonAsync($"{_api.CrmSales}", model, _options);
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ApiResponseView>(content); _logger.LogDebug("ActivityRepo => CreateActivity => ResponseContent <= {}", content);
var result = JsonSerializer.Deserialize<ApiResponseView>(content, _options);
var msg = JsonSerializer.SerializeToElement(result.Message);
_logger.LogDebug("Message content <= {}", msg);
return result!; return result!;
} }
public async Task<ReportItemView> GetReportItem(string id) public async Task<ReportItemView> GetReportItem(string id)
{ {
var salesItem = await _client var salesItem = await _client
.GetFromJsonAsync<ReportItemView>($"{_apiConfig.CrmSales}/{id}"); .GetFromJsonAsync<ReportItemView>($"{_api.CrmSales}/{id}");
return salesItem ?? new ReportItemView(); return salesItem ?? new ReportItemView();
} }
public async Task<ActivityDto> GetActivity(string id) public async Task<ActivityDto> GetActivity(string id)
{ {
var salesItem = await _client var salesItem = await _client
.GetFromJsonAsync<ActivityDto>($"{_apiConfig.CrmSales}/{id}"); .GetFromJsonAsync<ActivityDto>($"{_api.CrmSales}/{id}");
return salesItem ?? new ActivityDto(); return salesItem ?? new ActivityDto();
} }
public async Task<ApiResponseView> AcceptOffer(string id) public async Task<ApiResponseView> AcceptOffer(string id)
{ {
var response = await _client.PostAsJsonAsync($"{_apiConfig.CrmSales}/{id}/accept", id); var response = await _client.PostAsJsonAsync($"{_api.CrmSales}/{id}/accept", id);
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ApiResponseView>(content); var result = JsonSerializer.Deserialize<ApiResponseView>(content);
return result!; return result!;

View file

@ -35,7 +35,7 @@
<div class="row bg-light border-1 border-dark rounded-3 p-3"> <div class="row bg-light border-1 border-dark rounded-3 p-3">
<div class="col"> <div class="col">
<h3>@_draft.Name - @_draft.Account</h3> <h3>@_activity.Name - @_activity.Account</h3>
</div> </div>
</div> </div>
@ -51,29 +51,29 @@ else
<div class="row mb-1"> <div class="row mb-1">
<label for="activityType" class="col-md-2 col-form-label">Ordre Type</label> <label for="activityType" class="col-md-2 col-form-label">Ordre Type</label>
<div class="col-md-4"> <div class="col-md-4">
<InputSelect id="activityType" class="form-select" @bind-Value="@_draft.ActivityTypeEnum"> <InputSelect id="activityType" class="form-select" @bind-Value="@_activity.ActivityTypeEnum">
<option value="">&rarr; TAG MIG &larr;</option> <option value="">&rarr; TAG MIG &larr;</option>
<option value="onSite">Besøg</option> <option value="onSite">Besøg</option>
<option value="phone">Telefon</option> <option value="phone">Telefon</option>
</InputSelect> </InputSelect>
<ValidationMessage For="@(() => _draft.ActivityTypeEnum)"></ValidationMessage> <ValidationMessage For="@(() => _activity.ActivityTypeEnum)"></ValidationMessage>
</div> </div>
<label for="statusType" class="col-md-2 col-form-label">Status</label> <label for="statusType" class="col-md-2 col-form-label">Status</label>
<div class="col-md-4"> <div class="col-md-4">
<InputSelect id="statusType" class="form-select" @bind-Value="@_draft.ActivityStatusEnum"> <InputSelect id="statusType" class="form-select" @bind-Value="@_activity.ActivityStatusEnum">
<option value="noSale" selected>Ingen salg</option> <option value="noSale" selected>Ingen salg</option>
@if (!string.IsNullOrEmpty(_draft.VatNumber) && !string.IsNullOrWhiteSpace(_draft.Address1) && _company.HasFolded == 0) @if (!string.IsNullOrEmpty(_activity.VatNumber) && !string.IsNullOrWhiteSpace(_activity.Address1) && _company.HasFolded == 0)
{ {
<option value="order">Bestilling</option> <option value="order">Bestilling</option>
<option value="quote">Tilbud</option> <option value="quote">Tilbud</option>
} }
</InputSelect> </InputSelect>
<ValidationMessage For="@(() => _draft.ActivityStatusEnum)"></ValidationMessage> <ValidationMessage For="@(() => _activity.ActivityStatusEnum)"></ValidationMessage>
@if (_draft.ActivityStatusEnum == "order") @if (_activity.ActivityStatusEnum == "order")
{ {
<div class="form-check"> <div class="form-check">
<InputCheckbox id="express" class="form-check-input" @bind-Value="@_draft.Express"/> <InputCheckbox id="express" class="form-check-input" @bind-Value="@_activity.Express"/>
<label class="form-check-label" for="express">Express</label> <label class="form-check-label" for="express">Express</label>
</div> </div>
} }
@ -83,63 +83,63 @@ else
<div class="row mb-1"> <div class="row mb-1">
<label for="demo" class="col-md-2 col-form-label">Demo</label> <label for="demo" class="col-md-2 col-form-label">Demo</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="demo" class="form-control" @bind-Value="_draft.Demo"/> <InputText id="demo" class="form-control" @bind-Value="_activity.Demo"/>
<ValidationMessage For="@(() => _draft.Demo)"></ValidationMessage> <ValidationMessage For="@(() => _activity.Demo)"></ValidationMessage>
</div> </div>
<label for="email" class="col-md-2 col-form-label">Epost</label> <label for="email" class="col-md-2 col-form-label">Epost</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="email" class="form-control" @bind-Value="_draft.Email"/> <InputText id="email" class="form-control" @bind-Value="_activity.Email"/>
<ValidationMessage For="@(() => _draft.Email)"></ValidationMessage> <ValidationMessage For="@(() => _activity.Email)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="referenceNumber" class="col-md-2 col-form-label">Rekvisition</label> <label for="referenceNumber" class="col-md-2 col-form-label">Rekvisition</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="referenceNumber" class="form-control" @bind-Value="_draft.ReferenceNumber" /> <InputText id="referenceNumber" class="form-control" @bind-Value="_activity.ReferenceNumber"/>
<ValidationMessage For="@(() => _draft.ReferenceNumber)"></ValidationMessage> <ValidationMessage For="@(() => _activity.ReferenceNumber)"></ValidationMessage>
</div> </div>
<label for="yourRef" class="col-md-2 col-form-label">Indkøber</label> <label for="yourRef" class="col-md-2 col-form-label">Indkøber</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="yourRef" class="form-control" @bind-Value="_draft.YourRef"/> <InputText id="yourRef" class="form-control" @bind-Value="_activity.YourRef"/>
<ValidationMessage For="@(() => _draft.YourRef)"></ValidationMessage> <ValidationMessage For="@(() => _activity.YourRef)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="orderMessage" class="col-md-2 col-form-label">Note /Kontor</label> <label for="orderMessage" class="col-md-2 col-form-label">Note /Kontor</label>
<div class="col-md-4"> <div class="col-md-4">
<InputTextArea id="orderMessage" class="form-control" @bind-Value="_draft.OrderMessage"/> <InputTextArea id="orderMessage" class="form-control" @bind-Value="_activity.OrderMessage"/>
<ValidationMessage For="@(() => _draft.OrderMessage)"></ValidationMessage> <ValidationMessage For="@(() => _activity.OrderMessage)"></ValidationMessage>
</div> </div>
<label for="crmNote" class="col-md-2 col-form-label">Note /Selv</label> <label for="crmNote" class="col-md-2 col-form-label">Note /Selv</label>
<div class="col-md-4"> <div class="col-md-4">
<InputTextArea id="crmNote" class="form-control" @bind-Value="_draft.CrmNote"/> <InputTextArea id="crmNote" class="form-control" @bind-Value="_activity.CrmNote"/>
<ValidationMessage For="@(() => _draft.CrmNote)"></ValidationMessage> <ValidationMessage For="@(() => _activity.CrmNote)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="attention" class="col-md-2 col-form-label">Att.</label> <label for="attention" class="col-md-2 col-form-label">Att.</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="attention" class="form-control" @bind-Value="_draft.Attention"/> <InputText id="attention" class="form-control" @bind-Value="_activity.Attention"/>
<ValidationMessage For="@(() => _draft.Attention)"></ValidationMessage> <ValidationMessage For="@(() => _activity.Attention)"></ValidationMessage>
</div> </div>
<label for="phone" class="col-md-2 col-form-label">Tlf.</label> <label for="phone" class="col-md-2 col-form-label">Tlf.</label>
<div class="col-md-4"> <div class="col-md-4">
<InputText id="phone" class="form-control" @bind-Value="_draft.Phone"/> <InputText id="phone" class="form-control" @bind-Value="_activity.Phone"/>
<ValidationMessage For="@(() => _draft.Phone)"></ValidationMessage> <ValidationMessage For="@(() => _activity.Phone)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="accordion" id="crmActivity"> <div class="accordion" id="crmActivity">
@* Order lines *@ @* Order lines *@
<div class="accordion-item" style="@(_draft.ActivityStatusEnum is "order" or "quote" ? "display: block" : "display:none")"> <div class="accordion-item" style="@(_activity.ActivityStatusEnum is "order" or "quote" ? "display: block" : "display:none")">
<h2 class="accordion-header" id="catalogHeader"> <h2 class="accordion-header" id="catalogHeader">
<button class="accordion-button collapsed bg-light" type="button" <button class="accordion-button collapsed bg-light" type="button"
data-bs-toggle="collapse" data-bs-target="#catalogBody" data-bs-toggle="collapse" data-bs-target="#catalogBody"
@ -198,7 +198,7 @@ else
<td class="align-middle text-black text-end fw-bold">@DraftStateProvider.Draft.Total</td> <td class="align-middle text-black text-end fw-bold">@DraftStateProvider.Draft.Total</td>
<td></td> <td></td>
<td class="align-middle text-end"> <td class="align-middle text-end">
<button class="btn btn-primary" type="button" @onclick="CallPriceListModal" > <button class="btn btn-primary" type="button" @onclick="CallPriceListModal">
<i class="oi oi-plus"></i> <i class="oi oi-plus"></i>
</button> </button>
</td> </td>
@ -264,7 +264,7 @@ else
</div> </div>
</div> </div>
@* Delivery address *@ @* Delivery address *@
<div class="accordion-item" style="@(_draft.ActivityStatusEnum == "order" ? "display: block" : "display:none")"> <div class="accordion-item" style="@(_activity.ActivityStatusEnum == "order" ? "display: block" : "display:none")">
<h2 class="accordion-header" id="deliveryHeader"> <h2 class="accordion-header" id="deliveryHeader">
<button class="accordion-button collapsed bg-light" type="button" data-bs-toggle="collapse" data-bs-target="#deliveryBody" aria-expanded="false" aria-controls="deliveryBody"> <button class="accordion-button collapsed bg-light" type="button" data-bs-toggle="collapse" data-bs-target="#deliveryBody" aria-expanded="false" aria-controls="deliveryBody">
Leveringsadresse Leveringsadresse
@ -276,31 +276,31 @@ else
<div class="row mb-1"> <div class="row mb-1">
<label for="dlvName" class="col-md-2 col-form-label">Lev. Navn</label> <label for="dlvName" class="col-md-2 col-form-label">Lev. Navn</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="dlvName" class="form-control" @bind-Value="_draft.DlvName"/> <InputText id="dlvName" class="form-control" @bind-Value="_activity.DlvName"/>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="dlvAddress1" class="col-md-2 col-form-label">Lev. Adresse</label> <label for="dlvAddress1" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="dlvAddress1" class="form-control" @bind-Value="_draft.DlvAddress1"/> <InputText id="dlvAddress1" class="form-control" @bind-Value="_activity.DlvAddress1"/>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="dlvAddress2" class="col-md-2 col-form-label">Lev. Adresse</label> <label for="dlvAddress2" class="col-md-2 col-form-label">Lev. Adresse</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="dlvAddress2" class="form-control" @bind-Value="_draft.DlvAddress2"/> <InputText id="dlvAddress2" class="form-control" @bind-Value="_activity.DlvAddress2"/>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="dlvZipCode" class="col-md-2 col-form-label">Lev. Postnr</label> <label for="dlvZipCode" class="col-md-2 col-form-label">Lev. Postnr</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="dlvZipCode" class="form-control" @bind-Value="_draft.DlvZipCode"/> <InputText id="dlvZipCode" class="form-control" @bind-Value="_activity.DlvZipCode"/>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label for="dlvCity" class="col-md-2 col-form-label">Lev. Bynavn</label> <label for="dlvCity" class="col-md-2 col-form-label">Lev. Bynavn</label>
<div class="col-md-10"> <div class="col-md-10">
<InputText id="dlvCity" class="form-control" @bind-Value="_draft.DlvCity"/> <InputText id="dlvCity" class="form-control" @bind-Value="_activity.DlvCity"/>
</div> </div>
</div> </div>
</div> </div>
@ -308,12 +308,6 @@ else
</div> </div>
</div> </div>
</EditForm> </EditForm>
@if (HideButtons)
{
<LoaderThreeDots/>
}
else
{
<div class="row mt-2 mb-2"> <div class="row mt-2 mb-2">
<div class="col"> <div class="col">
<a class="btn btn-info" href="/companies">Til Oversigt</a> <a class="btn btn-info" href="/companies">Til Oversigt</a>
@ -325,5 +319,4 @@ else
<button type="button" class="btn btn-primary" @onclick="CreateActivity" disabled="@_poFormInvalid">Opret besøg</button> <button type="button" class="btn btn-primary" @onclick="CreateActivity" disabled="@_poFormInvalid">Opret besøg</button>
</div> </div>
</div> </div>
} }
}

View file

@ -36,29 +36,25 @@ public partial class CrmNewActivityPage : IDisposable
[CascadingParameter] DraftStateProvider DraftStateProvider { get; set; } [CascadingParameter] DraftStateProvider DraftStateProvider { get; set; }
[Parameter] public string CompanyId { get; set; } [Parameter] public string CompanyId { get; set; }
// Services // Services
[Inject] public ILogger<CrmNewActivityPage> _logger { get; set; } [Inject] public ILogger<CrmNewActivityPage> Logger { get; set; }
[Inject] public HttpInterceptorService _interceptor { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public UserPreferenceService _userPrefs { get; set; } [Inject] public UserPreferenceService PreferenceService { get; set; }
[Inject] public IToastService _toast { get; set; } [Inject] public IToastService Toast { get; set; }
[Inject] public NavigationManager _navigator { get; set; } [Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILocalStorageService _storage { get; set; } [Inject] public ILocalStorageService Storage { get; set; }
[Inject] public ICatalogHttpRepository _itemRepo { get; set; } [Inject] public ICatalogHttpRepository Catalog { get; set; }
[Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; }
[Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; }
[Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; }
// variables // variables
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions{PropertyNameCaseInsensitive = true}; private readonly JsonSerializerOptions? _options = new JsonSerializerOptions{PropertyNameCaseInsensitive = true};
private PriceListModal _priceListModal { get; set; }
private ProductHistoryModal _historyModal { get; set; }
private ProductPriceHistoryModal _priceHistoryModal { get; set; }
private SalesItemView _selectedItem { get; set; } = new(); private SalesItemView _selectedItem { get; set; } = new();
private Preferences _prefs { get; set; } = new(); private Preferences _prefs { get; set; } = new();
private ActivityDto _draft { get; set; } = new(); private ActivityDto _activity { get; set; } = new();
private CompanyDto _company = new(); private CompanyDto _company = new();
private EditContext _editContext { get; set; } private EditContext _editContext { get; set; }
private bool _poFormInvalid { get; set; } = true; private bool _poFormInvalid { get; set; } = true;
private bool ShowItem { get; set; } private bool ShowItem { get; set; }
private bool HideButtons { get; set; }
private string Quantity = "1"; private string Quantity = "1";
private string Price = "0"; private string Price = "0";
private string Discount = "0"; private string Discount = "0";
@ -73,14 +69,17 @@ public partial class CrmNewActivityPage : IDisposable
private DateTime _workDate { get; set; } = DateTime.Now; private DateTime _workDate { get; set; } = DateTime.Now;
private string _selectedDate { get; set; } = ""; private string _selectedDate { get; set; } = "";
private string _phone { get; set; } = ""; private string _phone { get; set; } = "";
// MODAL DIALOGS
private PriceListModal _priceListModal { get; set; }
private ProductHistoryModal _historyModal { get; set; }
private ProductPriceHistoryModal _priceHistoryModal { get; set; }
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
_interceptor.RegisterEvent(); Interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
_prefs = await _userPrefs.GetPreferences(); _prefs = await PreferenceService.GetPreferences();
if (!string.IsNullOrWhiteSpace(_prefs.WorkDate)) if (!string.IsNullOrWhiteSpace(_prefs.WorkDate))
_workDate = DateTime.Parse(_prefs.WorkDate); _workDate = DateTime.Parse(_prefs.WorkDate);
@ -91,16 +90,16 @@ public partial class CrmNewActivityPage : IDisposable
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_editContext = new EditContext(_draft); _editContext = new EditContext(_activity);
_editContext.OnFieldChanged += HandleFieldChanged; _editContext.OnFieldChanged += HandleFieldChanged;
_editContext.OnValidationStateChanged += ValidationChanged; _editContext.OnValidationStateChanged += ValidationChanged;
_draft.ActivityDate = $"{_workDate:yyyy-MM-dd}" ; _activity.ActivityDate = $"{_workDate:yyyy-MM-dd}" ;
_ux = await _storage.GetItemAsync<UserInfoView>("_xu"); _ux = await Storage.GetItemAsync<UserInfoView>("_xu");
// get company // get company
_company = await _companyRepo.GetCompanyById(CompanyId); _company = await CompanyRepo.GetCompanyById(CompanyId);
// variable to validate if customer needs phone number update // variable to validate if customer needs phone number update
_phone = _company.Phone; _phone = _company.Phone;
@ -111,36 +110,36 @@ public partial class CrmNewActivityPage : IDisposable
_company.Phone = _company.Account[..8]; _company.Phone = _company.Account[..8];
} }
_draft.BcId = _company.BcId; _activity.BcId = _company.BcId;
_draft.ActivityStatusEnum = "noSale"; _activity.ActivityStatusEnum = "noSale";
_draft.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall"; _activity.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall";
if (_company.HasFolded == 1) if (_company.HasFolded == 1)
_draft.OrderMessage = "Virksomheden er ophørt."; _activity.OrderMessage = "Virksomheden er ophørt.";
// permanent identifications // permanent identifications
_draft.CompanyId = _company.CompanyId; _activity.CompanyId = _company.CompanyId;
_draft.SalesRepId = _company.SalesRepId; _activity.SalesRepId = _ux.Id;
_draft.SalesRep = _company.SalesRep; _activity.SalesRep = _ux.Advisor;
_draft.CountryCode = _company.CountryCode; _activity.CountryCode = _ux.CountryCode;
_draft.Account = _company.Account; _activity.Account = _company.Account;
_draft.VatNumber = _company.VatNumber; _activity.VatNumber = _company.VatNumber;
_draft.Email = _company.Email; _activity.Email = _company.Email;
_draft.Phone = _company.Phone; _activity.Phone = _company.Phone;
_draft.Mobile = _company.Mobile; _activity.Mobile = _company.Mobile;
_draft.Name = _company.Name; _activity.Name = _company.Name;
_draft.Address1 = _company.Address1; _activity.Address1 = _company.Address1;
_draft.Address2 = _company.Address2; _activity.Address2 = _company.Address2;
_draft.ZipCode = _company.ZipCode; _activity.ZipCode = _company.ZipCode;
_draft.City = _company.City; _activity.City = _company.City;
_draft.DlvName = _company.Name; _activity.DlvName = _company.Name;
_draft.DlvAddress1 = _company.Address1; _activity.DlvAddress1 = _company.Address1;
_draft.DlvAddress2 = _company.Address2; _activity.DlvAddress2 = _company.Address2;
_draft.DlvZipCode = _company.ZipCode; _activity.DlvZipCode = _company.ZipCode;
_draft.DlvCity = _company.City; _activity.DlvCity = _company.City;
} }
private void CallPriceListModal() private void CallPriceListModal()
@ -154,7 +153,7 @@ public partial class CrmNewActivityPage : IDisposable
if (string.IsNullOrWhiteSpace(sku.ItemId)) if (string.IsNullOrWhiteSpace(sku.ItemId))
return; return;
_selectedItem = await _itemRepo.GetSalesItemId(sku.ItemId); _selectedItem = await Catalog.GetSalesItemId(sku.ItemId);
ShowItem = true; ShowItem = true;
Price = sku.Rate; Price = sku.Rate;
Quantity = sku.Quantity; Quantity = sku.Quantity;
@ -181,46 +180,46 @@ public partial class CrmNewActivityPage : IDisposable
{ {
_selectedDate = workDate; _selectedDate = workDate;
_workDate = DateTime.Parse(_selectedDate); _workDate = DateTime.Parse(_selectedDate);
_draft.ActivityDate = _selectedDate; _activity.ActivityDate = _selectedDate;
_reportClosdd = await CrmReportRepo.ReportExist(_selectedDate); _reportClosdd = await CrmReportRepo.ReportExist(_selectedDate);
} }
private async Task CreateActivity() private async Task CreateActivity()
{ {
if (string.IsNullOrWhiteSpace(_draft.Address1)) _activity.CountryCode = "";
if (string.IsNullOrWhiteSpace(_activity.Address1))
{ {
_toast.ShowError("Kunde adresse er ufuldstændig."); Toast.ShowError("Kunde adresse er ufuldstændig.");
return; return;
} }
if (_draft.ActivityStatusEnum == "order") if (_activity.ActivityStatusEnum == "order")
{ {
if (DraftStateProvider.Draft.Items.Count == 0) if (DraftStateProvider.Draft.Items.Count == 0)
{ {
_toast.ShowError("Ved bestilling skal der angives et eller flere varenumre."); Toast.ShowError("Ved bestilling skal der angives et eller flere varenumre.");
return; return;
} }
if (string.IsNullOrWhiteSpace(_draft.Phone)) if (string.IsNullOrWhiteSpace(_activity.Phone))
{ {
_toast.ShowError("Ved bestilling til ny kunde skal telefon nummer angives."); Toast.ShowError("Ved bestilling til ny kunde skal telefon nummer angives.");
return; return;
} }
} }
HideButtons = true; _activity.ActivityDate = $"{_workDate:yyyy-MM-dd}";
_draft.ActivityDate = $"{_workDate:yyyy-MM-dd}"; _activity.OurRef = _activity.ActivityTypeEnum switch
_draft.OurRef = _draft.ActivityTypeEnum switch
{ {
"phone" => $"T:{_ux.FullName.Split(" ")[0]}", "phone" => $"T:{_ux.FullName.Split(" ")[0]}",
"onSite" => $"B:{_ux.FullName.Split(" ")[0]}", "onSite" => $"B:{_ux.FullName.Split(" ")[0]}",
_ => "" _ => ""
}; };
if (_draft.Express) if (_activity.Express)
_draft.OurRef = $"E{_draft.OurRef}"; _activity.OurRef = $"E{_activity.OurRef}";
_draft.Lines = new List<ActivityLineDto>(); _activity.Lines = new List<ActivityLineDto>();
var ln = 0; var ln = 0;
if (DraftStateProvider.Draft.Items.Count != 0) if (DraftStateProvider.Draft.Items.Count != 0)
{ {
@ -238,26 +237,39 @@ public partial class CrmNewActivityPage : IDisposable
Location = item.Item.Location Location = item.Item.Location
}) })
.ToList(); .ToList();
_draft.Lines = lines; _activity.Lines = lines;
} }
if (_phone != _draft.Phone) if (_phone != _activity.Phone)
{ {
_company.Phone = _draft.Phone; _company.Phone = _activity.Phone;
// update company phone record // update company phone record
await _companyRepo.UpdateCompany(_company.CompanyId, _company); await CompanyRepo.UpdateCompany(_company.CompanyId, _company);
} }
Logger.LogDebug("CrmNewActivityPage => \n {}", JsonSerializer.Serialize(_activity));
// post to api // post to api
var result = await CrmActivityRepo.CreateActivity(_draft); var result = await CrmActivityRepo.CreateActivity(_activity);
Logger.LogDebug("ApiResponseView => \n {}", JsonSerializer.Serialize(result));
// show result message // show result message
_toast.ShowSuccess($"{result.Message}."); if (result.IsSuccess)
{
Toast.ShowSuccess($"{result.Message}", "RESULTAT");
if(DraftStateProvider.Draft.Items.Any())
Toast.ShowSuccess($"{result.Message}.", "BESTILLING OPRETTET");
await DraftStateProvider.DeleteDraftAsync();
Navigator.NavigateTo($"/companies");
}
Toast.ShowError(result.Message, "ORDRE FEJL");
_selectedItem = new SalesItemView(); _selectedItem = new SalesItemView();
await DraftStateProvider.DeleteDraftAsync();
_navigator.NavigateTo($"/companies");
} }
private void CheckActivity() private void CheckActivity()
{ {
InvalidActivityType = string.IsNullOrWhiteSpace(_draft.ActivityTypeEnum); InvalidActivityType = string.IsNullOrWhiteSpace(_activity.ActivityTypeEnum);
} }
private async Task DeleteDraft() private async Task DeleteDraft()
@ -301,8 +313,8 @@ public partial class CrmNewActivityPage : IDisposable
InvalidActivity = InvalidActivityType InvalidActivity = InvalidActivityType
|| _poFormInvalid || _poFormInvalid
|| DraftStateProvider.Draft.Items.Count == 0 || DraftStateProvider.Draft.Items.Count == 0
|| (_draft.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_draft.Email)); || (_activity.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_activity.Email));
if (_draft.YourRef.Length > 35 || _draft.ReferenceNumber.Length > 20) if (_activity.YourRef.Length > 35 || _activity.ReferenceNumber.Length > 20)
{ {
_poFormInvalid = true; _poFormInvalid = true;
return; return;
@ -319,9 +331,9 @@ public partial class CrmNewActivityPage : IDisposable
} }
private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) private void ValidationChanged(object sender, ValidationStateChangedEventArgs e)
{ {
if (string.IsNullOrEmpty(_draft.ActivityTypeEnum) && !_reportClosdd) if (string.IsNullOrEmpty(_activity.ActivityTypeEnum) && !_reportClosdd)
{ {
_toast.ShowWarning("Aktivitet type kan ikke være tom"); Toast.ShowWarning("Aktivitet type kan ikke være tom");
return; return;
} }
@ -329,14 +341,14 @@ public partial class CrmNewActivityPage : IDisposable
_editContext.OnFieldChanged -= HandleFieldChanged; _editContext.OnFieldChanged -= HandleFieldChanged;
_editContext.OnValidationStateChanged -= ValidationChanged; _editContext.OnValidationStateChanged -= ValidationChanged;
_editContext = new EditContext(_draft); _editContext = new EditContext(_activity);
_editContext.OnFieldChanged += HandleFieldChanged; _editContext.OnFieldChanged += HandleFieldChanged;
_editContext.OnValidationStateChanged += ValidationChanged; _editContext.OnValidationStateChanged += ValidationChanged;
} }
public void Dispose() public void Dispose()
{ {
_interceptor.DisposeEvent(); Interceptor.DisposeEvent();
_editContext.OnFieldChanged -= HandleFieldChanged; _editContext.OnFieldChanged -= HandleFieldChanged;
_editContext.OnValidationStateChanged -= ValidationChanged; _editContext.OnValidationStateChanged -= ValidationChanged;
} }

View file

@ -1,4 +1,6 @@
@using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Authorization
@using System.Security.Claims
@attribute [Authorize(Roles = "Admin,Office,Warehouse,Advisor")] @attribute [Authorize(Roles = "Admin,Office,Warehouse,Advisor")]
@page "/companies/{CompanyId}/orders/{OrderId}" @page "/companies/{CompanyId}/orders/{OrderId}"
@ -20,11 +22,33 @@
} }
@if (ReportItem.Express) @if (ReportItem.Express)
{ {
<h2 class="fw-bold text-center">HASTER</h2> <h2 class="fw-bold text-center"><i class="bi-lightning-charge text-dark" style="font-size: 3rem;"></i> HASTER</h2>
} }
</div> </div>
</th> </th>
</tr> </tr>
@if (ReportItem.Express && ReportItem.ProcessStatusEnum.ToLower() == "none")
{
<div id="watermark">
<i class="bi-lightning-charge text-dark" style="font-size: 11rem;"></i>
</div>
<AuthorizeView Roles="Admin,Office,Advisor,Warehouse">
<Authorized>
<tr class="d-print-none">
<th colspan="3"></th>
<th>
<button type="button" class="btn btn-warning">PRINT</button>
</th>
</tr>
</Authorized>
</AuthorizeView>
}
else
{
<div id="watermark">
<i class="bi-check text-dark" style="font-size: 12rem;"></i>
</div>
}
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
@ -121,7 +145,10 @@
} }
else else
{ {
<div class="alert alert-dark"> @if (!string.IsNullOrWhiteSpace(ReportItem.OfficeNote))
<h4 class="text-center">@ReportItem.OfficeNote</h4> {
</div> <div class="alert alert-dark">
<h4 class="text-center">@ReportItem.OfficeNote</h4>
</div>
}
} }

View file

@ -37,6 +37,11 @@ public partial class CrmViewActivityPage : IDisposable
_logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(ReportItem)); _logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(ReportItem));
} }
private async Task SetExpressState()
{
}
private void HandleFieldChanged(object sender, FieldChangedEventArgs e) private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{ {
StateHasChanged(); StateHasChanged();

View file

@ -0,0 +1,6 @@
#watermark {
position: fixed;
z-index: 999;
top: 30px;
right: 0;
}

View file

@ -17,7 +17,7 @@ using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;
public partial class Page404 public partial class ErrorPage404
{ {
[Inject] public NavigationManager NavigationManager { get; set; } [Inject] public NavigationManager NavigationManager { get; set; }

View file

@ -17,7 +17,7 @@ using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Pages namespace Wonky.Client.Pages
{ {
public partial class SiteErrorReport public partial class ErrorReportPage
{ {
[Parameter] [Parameter]
public int ErrorCode { get; set; } public int ErrorCode { get; set; }

View file

@ -68,6 +68,7 @@ public partial class OfficeListCustomerPage : IDisposable
_paging.HasFolded = _includeFolded ? 1 : 0; _paging.HasFolded = _includeFolded ? 1 : 0;
await GetCompanies(); await GetCompanies();
} }
private async Task SelectedPage(int page) private async Task SelectedPage(int page)
{ {
_companyList = new List<CompanyDto>(); _companyList = new List<CompanyDto>();

View file

@ -61,7 +61,7 @@
@if (_items.Any()) @if (_items.Any())
{ {
@foreach (var item in _items) @foreach (var item in _items.Where(item => item.StatusTypeEnum.ToLower() != "offer" || item.ProcessStatusEnum.ToLower() == "none"))
{ {
<ReportItemComponent ReportItem="@item"></ReportItemComponent> <ReportItemComponent ReportItem="@item"></ReportItemComponent>
} }

View file

@ -1,5 +1,42 @@
@page "/PreferencesPage" @using Wonky.Client.Components
<h3>PreferencesPage</h3> @page "/preferences"
<h3>Indstillinger</h3>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Side længde</label>
<div class="col-md-3">
<PageSizeComponent ></PageSizeComponent>
</div>
</div>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Kunde søgning</label>
<div class="col-md-3">
<CompanySearchColumnComponent ></CompanySearchColumnComponent>
</div>
</div>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Kunde sortering</label>
<div class="col-md-3">
<CompanySortComponent ></CompanySortComponent>
</div>
</div>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Produkt søgning</label>
<div class="col-md-3">
<CatalogSearchComponent ></CatalogSearchComponent>
</div>
</div>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Produkt sortering</label>
<div class="col-md-3">
<CatalogSortComponent ></CatalogSortComponent>
</div>
</div>
@code { @code {

View file

@ -32,6 +32,6 @@
<div class="content d-none d-print-block"> <div class="content d-none d-print-block">
@Body @Body
</div> </div>
<BlazoredToasts Position="ToastPosition.BottomCenter" Timeout="3"/> <BlazoredToasts Position="ToastPosition.BottomCenter" Timeout="10"/>
</main> </main>
</div> </div>

View file

@ -27,10 +27,10 @@
<div class="sticky-top bg-dark rounded-2 p-3"> <div class="sticky-top bg-dark rounded-2 p-3">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<ItemSearchComponent OnChanged="SetSearchCol"/> <CatalogSearchComponent OnChanged="SetSearchCol"/>
</div> </div>
<div class="col"> <div class="col">
<ItemSearchPhraseComponent OnChanged="SetSearchPhrase"/> <CatalogSearchPhraseComponent OnChanged="SetSearchPhrase"/>
</div> </div>
@* <div class="col"> *@ @* <div class="col"> *@
@* <ItemSortComponent OnChanged="SetSortCol"/> *@ @* <ItemSortComponent OnChanged="SetSortCol"/> *@

View file

@ -1,7 +1,7 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Client", "name": "Wonky Client",
"version": "0.22.1", "version": "0.23.1",
"rc": true, "rc": true,
"sandBox": true, "sandBox": true,
"image": "grumpy-coder.png" "image": "grumpy-coder.png"

View file

@ -18,7 +18,7 @@
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" /> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="bootstrap/css/bootstrap-icons.css" rel="stylesheet" /> <link href="bootstrap/css/bootstrap-icons.css" rel="stylesheet" />
<link href="flag-icons/flag-icons.css" rel="stylesheet" /> <link href="flag-icons/flag-icons.css" rel="stylesheet" />
<link href="css/app-v0.12.0.css" rel="stylesheet" /> <link href="css/app-v0.20.0.css" rel="stylesheet" />
<link href="Wonky.Client.styles.css" rel="stylesheet" /> <link href="Wonky.Client.styles.css" rel="stylesheet" />
<link href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" /> <link href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" />
</head> </head>

View file

@ -22,7 +22,7 @@ public class ActivityDto
/// <summary> /// <summary>
/// Activity entity id /// Activity entity id
/// </summary> /// </summary>
public string ActivityId { get; set; } = ""; public string SalesHeadId { get; set; } = "";
/// <summary> /// <summary>
/// Sales representative identification /// Sales representative identification

View file

@ -20,7 +20,7 @@ namespace Wonky.Entity.Views;
public class ApiResponseView public class ApiResponseView
{ {
public bool IsSuccess { get; set; } public bool IsSuccess { get; set; }
public HttpStatusCode Code { get; set; } public int Code { get; set; }
public string Message { get; set; } = ""; public string Message { get; set; } = "";
public string Id { get; set; } = ""; public string Id { get; set; } = "";
} }