built v0.2.37
This commit is contained in:
parent
327aecaffe
commit
9c5c698ecf
10 changed files with 47 additions and 32 deletions
|
@ -17,7 +17,7 @@
|
|||
<span class="version">@Name</span> <span class="version">@Version</span>@if(IsBeta){<span class="version">-beta</span>}
|
||||
@code
|
||||
{
|
||||
private const string Version = "0.2.36";
|
||||
private const string Version = "0.2.37";
|
||||
private const string Name = "wwo";
|
||||
private const bool IsBeta = true;
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ public class ActivityHttpRepository : IActivityHttpRepository
|
|||
};
|
||||
|
||||
private readonly NavigationManager _navigation;
|
||||
private ILogger<SalesItemHttpRepository> _logger;
|
||||
private ILogger<ActivityHttpRepository> _logger;
|
||||
private readonly HttpClient _client;
|
||||
private readonly ApiConfig _apiConfig;
|
||||
|
||||
public ActivityHttpRepository(HttpClient client,
|
||||
ILogger<SalesItemHttpRepository> logger,
|
||||
ILogger<ActivityHttpRepository> logger,
|
||||
NavigationManager navigation, IOptions<ApiConfig> configuration)
|
||||
{
|
||||
_client = client;
|
||||
|
@ -77,6 +77,7 @@ public class ActivityHttpRepository : IActivityHttpRepository
|
|||
|
||||
public async Task<ActivityResponseView> CreateActivity(DtoNgActivity model)
|
||||
{
|
||||
Console.WriteLine(JsonSerializer.Serialize(model));
|
||||
var response = await _client.PostAsJsonAsync($"{_apiConfig.ActivityEndpoint}", model).ConfigureAwait(true);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonSerializer.Deserialize<ActivityResponseView>(content);
|
||||
|
|
|
@ -87,7 +87,9 @@ public partial class CompanyUpdate : IDisposable
|
|||
}
|
||||
DtoNgCompany.LastVisit = $"{LastVisit:yyyy-MM-dd}";
|
||||
DtoNgCompany.NextVisit = $"{NextVisit:yyyy-MM-dd}";
|
||||
|
||||
Console.WriteLine(JsonSerializer.Serialize(DtoNgCompany));
|
||||
|
||||
await CompanyRepo.UpdateCompany(DtoNgCompany);
|
||||
|
||||
ToastService.ShowSuccess($"Godt så. Firma '{DtoNgCompany!.Name}' er opdateret.");
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<div class="row mb-1">
|
||||
<label for="activityDate" class="col-md-2 col-form-label">Dato</label>
|
||||
<div class="col-md-4">
|
||||
<InputDate id="activityDate" class="form-control" @bind-Value="@(_poDraft.ActivityDate)"/>
|
||||
<InputDate id="activityDate" class="form-control" @bind-Value="@(_draftDate)"/>
|
||||
</div>
|
||||
<label for="checkDate" class="col-md-2 form-check-label">Bekræft dato?</label>
|
||||
<div class="col-md-4">
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using System.Text.Json;
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.Toast.Services;
|
||||
using Wonky.Client.Helpers;
|
||||
|
@ -62,6 +63,7 @@ public partial class CrmActivityCreate : IDisposable
|
|||
private bool InvalidDate { get; set; } = true;
|
||||
private UserInfoView Ux { get; set; } = new();
|
||||
private VatUtils _vatUtils { get; set; }
|
||||
private DateTime _draftDate { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
@ -70,9 +72,10 @@ public partial class CrmActivityCreate : IDisposable
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_vatUtils = new VatUtils();
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
|
||||
_vatUtils = new VatUtils();
|
||||
_prefs = await UserPrefs.GetPreferences();
|
||||
_paging.SearchColumn = _prefs.ItemSearch;
|
||||
_paging.PageSize = Convert.ToInt32(_prefs.PageSize);
|
||||
|
@ -83,12 +86,13 @@ public partial class CrmActivityCreate : IDisposable
|
|||
DraftContext = new EditContext(_poDraft);
|
||||
DraftContext.OnFieldChanged += HandleFieldChanged;
|
||||
|
||||
// set up indexdb identification
|
||||
_poDraft.SalesHeadId = Guid.NewGuid().ToString();
|
||||
// set up identification
|
||||
_poDraft.SalesHeadId = "";
|
||||
_poDraft.CompanyId = CompanyId;
|
||||
_poDraft.ActivityDate = string.IsNullOrWhiteSpace(_prefs.WorkDate)
|
||||
_draftDate = string.IsNullOrWhiteSpace(_prefs.WorkDate)
|
||||
? DateTime.Now
|
||||
: DateTime.Parse(_prefs.WorkDate);
|
||||
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
|
||||
|
||||
// permanent identifications
|
||||
_poDraft.SalesRep = Ux.Adviser;
|
||||
|
@ -114,34 +118,40 @@ public partial class CrmActivityCreate : IDisposable
|
|||
{
|
||||
HideButtons = true;
|
||||
// write work date to preference
|
||||
await UserPrefs.SetWorkDate(_poDraft.ActivityDate);
|
||||
await UserPrefs.SetWorkDate(_draftDate);
|
||||
var activityType = _poDraft.ActivityTypeEnum switch
|
||||
{
|
||||
"phone" => "Tlf. ",
|
||||
"onSite" => "Bsg. ",
|
||||
"phone" => "Tlf",
|
||||
"onSite" => "Bsg",
|
||||
_ => ""
|
||||
};
|
||||
_poDraft.OurRef = $"{activityType}{Ux.FullName.Split(" ")[0]}";
|
||||
|
||||
_poDraft.OurRef = $"{Ux.FullName.Split(" ")[0]} {activityType}";
|
||||
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
|
||||
var ln = 0;
|
||||
|
||||
// post to create activity endpoint
|
||||
foreach (var line in DraftStateProvider.Draft.Items.Select(item => new DtoNgActivityLine
|
||||
{
|
||||
Price = item.Price,
|
||||
Discount = item.Discount,
|
||||
Qty = item.Quantity,
|
||||
Sku = item.Item.Sku,
|
||||
Text = item.Item.Name,
|
||||
LineAmount = item.LineTotal,
|
||||
LineNumber = ++ln,
|
||||
Sas = item.Sas
|
||||
}))
|
||||
var lines = new List<DtoNgActivityLine>();
|
||||
foreach (var item in DraftStateProvider.Draft.Items)
|
||||
{
|
||||
_poDraft.Lines.Add(line);
|
||||
var line = new DtoNgActivityLine{
|
||||
Price = item.Price,
|
||||
Discount = item.Discount,
|
||||
Qty = item.Quantity,
|
||||
Sku = item.Item.Sku,
|
||||
Text = item.Item.Name,
|
||||
LineAmount = item.LineTotal,
|
||||
LineNumber = ++ln,
|
||||
Sas = item.Sas
|
||||
};
|
||||
lines.Add(line);
|
||||
}
|
||||
//await StorageService.SetItemAsync(CompanyId, _poDraft);
|
||||
await ActivityRepo.CreateActivity(_poDraft);
|
||||
ToastService.ShowSuccess($"Godt så! Aktivitet oprettet for {_poDraft.Name}.");
|
||||
_poDraft.Lines = lines;
|
||||
|
||||
await StorageService.SetItemAsync(CompanyId, _poDraft);
|
||||
|
||||
var result = await ActivityRepo.CreateActivity(_poDraft).ConfigureAwait(true);
|
||||
Console.WriteLine(JsonSerializer.Serialize(result));
|
||||
ToastService.ShowSuccess($"{result.Message}.");
|
||||
NavigationManager.NavigateTo($"/companies");
|
||||
}
|
||||
|
||||
|
@ -158,6 +168,7 @@ public partial class CrmActivityCreate : IDisposable
|
|||
|
||||
private void CheckDate()
|
||||
{
|
||||
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
|
||||
InvalidDate = _poDraft.CheckDate;
|
||||
Console.WriteLine($"InvalidDate => {InvalidDate}");
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ using Blazored.Toast;
|
|||
using Wonky.Client;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Client.Providers;
|
||||
using Wonky.Client.Services;
|
||||
using Wonky.Client.Shared;
|
||||
using Wonky.Entity.Configuration;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
|
|
@ -19,7 +19,7 @@ using System.Text.Json;
|
|||
using Blazored.LocalStorage;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Wonky.Client.Providers;
|
||||
using Wonky.Client.Shared;
|
||||
using Wonky.Entity.Configuration;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ using Blazored.LocalStorage;
|
|||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Providers
|
||||
namespace Wonky.Client.Shared
|
||||
{
|
||||
public class AuthStateProvider : AuthenticationStateProvider
|
||||
{
|
|
@ -33,6 +33,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Providers" />
|
||||
<Folder Include="wwwroot\scripts" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Wonky.Entity.DTO
|
|||
[Required(ErrorMessage = "Vælg aktivitetstype")] public string ActivityTypeEnum { get; set; } = "";
|
||||
[Required(ErrorMessage = "Vælg status for besøg ")] public string ActivityStatusEnum { get; set; } = "";
|
||||
public bool CheckDate { get; set; }
|
||||
[Required] public DateTime ActivityDate { get; set; }
|
||||
[Required] public string ActivityDate { get; set; } = "";
|
||||
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Demo { get; set; } = "";
|
||||
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string OurRef { get; set; } = "";
|
||||
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ReferenceNumber { get; set; } = "";
|
||||
|
|
Loading…
Reference in a new issue