wip - office list customers - create order

This commit is contained in:
Frede Hundewadt 2022-09-26 10:00:48 +02:00
parent 2430c2f7d7
commit 9fb957d73d
35 changed files with 342 additions and 220 deletions

View file

@ -24,6 +24,7 @@
<thead>
<tr>
<th scope="col">BS</th>
<th scope="col"></th>
<th scope="col">Navn</th>
<th scope="col">Konto</th>
<th scope="col">Tlf</th>
@ -38,6 +39,9 @@
<td class="state align-middle">
<DisplayStateComponent StateClass="@(company.HasFolded == 1 ? "the-dead" : Utils.GetVisitState(company.NextVisit))" />
</td>
<td class="align-middle">
<span class="text-info"><i class="oi oi-info"></i></span>
</td>
<td class="align-middle">
@company.Name
</td>
@ -64,3 +68,4 @@ else
{
<LoaderThreeDots />
}
<Information BodyMessage="@_info" />

View file

@ -16,12 +16,15 @@
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Wonky.Client.Helpers;
using Wonky.Client.Pages;
using Wonky.Client.Services;
using Wonky.Client.Shared;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.Components
{
public partial class AdvisorCompanyTableComponent
@ -30,10 +33,14 @@ namespace Wonky.Client.Components
[Parameter] public EventCallback<string> OnDelete { get; set; }
[Parameter] public EventCallback<string> OnSelect { get; set; }
[Inject] public NavigationManager _navigator { get; set; }
[Inject] public IJSRuntime Js { get; set; }
private Confirmation _confirmation = new ();
private string _companyId = "";
private string _actionUrl = "";
private Lazy<IJSObjectReference> BsTooltip = new();
private Information _information { get; set; } = new();
private string _info { get; set; } = "";
private string _companyId { get; set; } = "";
// private string _actionUrl { get; set; } = "";
protected override async Task OnInitializedAsync()
{
@ -45,16 +52,10 @@ namespace Wonky.Client.Components
_navigator.NavigateTo($"/companies/{companyId}");
}
private void CallConfirmationModal(string companyId)
private void CallInformationModal(string info)
{
_companyId = companyId;
_confirmation.Show();
}
private async Task DeleteCompany()
{
_confirmation.Hide();
await OnDelete.InvokeAsync(_companyId);
_info = info;
_information.Show();
}
}
}

View file

@ -23,47 +23,50 @@
<div class="list-group list-group-flush">
<div class="list-group-item px-3 bg-black text-white opacity-75">
<div class="row">
<div class="col-md-1">
Sælger
</div>
<div class="col-md-1">
Konto
</div>
<div class="col-md-2">
Telefon
</div>
<div class="col">
Navn
</div>
<div class="col">
Konto
</div>
<div class="col">
Telefon
</div>
<div class="col">
Bynavn
</div>
<div class="col">
</div>
</div>
</div>
@foreach (var company in Companies)
{
<a class=" list-group-item list-group-item-action" href="#">
<a class=" list-group-item list-group-item-action" href="/office/customers/@company.CompanyId/orders/new">
<div class="row align-items-center">
<div class="col-md-1">
@company.SalesRep
</div>
<div class="col-md-1">
@company.Account
</div>
<div class="col-md-2">
@company.Phone
</div>
<div class="col">
@company.Name
</div>
<div class="col">
@company.Account
</div>
<div class="col">
@company.Phone
</div>
<div class="col">
@company.City
</div>
<div class="col justify-content-end">
<ActivityButton CompanyId="@company.CompanyId"
ActionLink="/office/customers/$ID$/orders/new"
ButtonText="Telefon Ordre"
ButtonType="primary"
Enabled=1>
</ActivityButton>
@company.CountryCode.ToUpper()-@company.ZipCode @company.City
</div>
@* <div class="col justify-content-end"> *@
@* <ActivityButton CompanyId="@company.CompanyId" *@
@* ActionLink="/office/customers/$ID$/orders/new" *@
@* ButtonText="Telefon Ordre" *@
@* ButtonType="primary" *@
@* Enabled=1> *@
@* </ActivityButton> *@
@* </div> *@
</div>
</a>
}

View file

@ -27,13 +27,13 @@ namespace Wonky.Client.Components
public partial class OfficeCustomerTableComponent
{
[Parameter] public List<CompanyDto> Companies { get; set; } = new();
[Parameter] public EventCallback<string> OnDelete { get; set; }
[Parameter] public EventCallback<string> OnSelect { get; set; }
private Confirmation _confirmation = new ();
private string _companyId = "";
private string _actionUrl = "";
// [Parameter] public EventCallback<string> OnDelete { get; set; }
// [Parameter] public EventCallback<string> OnSelect { get; set; }
//
// private Confirmation _confirmation = new ();
// private string _companyId = "";
// private string _actionUrl = "";
//
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();

View file

@ -23,5 +23,5 @@ public interface IOfficeCustomerHttpRepository
{
Task<PagingResponse<CompanyDto>> GetCompaniesPaged(CompanyPagingParams pagingParameters);
Task<PagingResponse<CompanyDto>> GetCompaniesPagedSalesRep(string salesRepId, CompanyPagingParams pagingParameters);
Task<CompanyDto> GetCompanyById(string companyId);
Task<CompanyDto> GetByCustomerId(string companyId);
}

View file

@ -21,7 +21,7 @@ namespace Wonky.Client.HttpInterfaces;
public interface IOfficeUserHttpRepository
{
Task<List<UserListAdminView>> GetAdvisors();
Task<UserInfoDto> GetAdvisorInfo(string userId);
Task<WebUserInfoView> GetAdvisorInfo(string userId);
Task UpdateAdvisor(string userId, UserUpdateDto model);
Task<List<UserListAdminView>> GetAdminUsers();
Task<UserInfoDto> GetAdminUserInfo(string userId);

View file

@ -73,12 +73,12 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository
["searchColumn"] = pagingParameters.SearchColumn,
["orderBy"] = pagingParameters.OrderBy,
["isHidden"] = pagingParameters.IsHidden.ToString(),
["hasFolded"] = pagingParameters.HasFolded.ToString()
["hasFolded"] = pagingParameters.HasFolded.ToString(),
["countryCode"] = pagingParameters.CountryCode
};
var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}", queryString));
var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}/", queryString));
var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<CompanyDto>
{
Items = JsonSerializer.Deserialize<List<CompanyDto>>(content, _options),
@ -103,10 +103,11 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository
["searchColumn"] = pagingParameters.SearchColumn,
["orderBy"] = pagingParameters.OrderBy,
["isHidden"] = pagingParameters.IsHidden.ToString(),
["hasFolded"] = pagingParameters.HasFolded.ToString()
["hasFolded"] = pagingParameters.HasFolded.ToString(),
["countryCode"] = pagingParameters.CountryCode
};
var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}", queryString));
var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}", queryString));
var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<CompanyDto>
@ -122,7 +123,7 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository
/// </summary>
/// <param name="companyId"></param>
/// <returns></returns>
public async Task<CompanyDto> GetCompanyById(string companyId)
public async Task<CompanyDto> GetByCustomerId(string companyId)
{
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_api.OfficeCustomers}/id/{companyId}");
return company ?? new CompanyDto();

View file

@ -37,10 +37,8 @@ public class OfficeUserHttpRepository : IOfficeUserHttpRepository
private readonly HttpClient _client;
private readonly ApiConfig _api;
public OfficeUserHttpRepository(HttpClient client,
ILogger<OfficeUserHttpRepository> logger,
NavigationManager navigation,
IOptions<ApiConfig> configuration)
public OfficeUserHttpRepository(HttpClient client, ILogger<OfficeUserHttpRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
@ -53,11 +51,9 @@ public class OfficeUserHttpRepository : IOfficeUserHttpRepository
return await _client.GetFromJsonAsync<List<UserListAdminView>>(_api.OfficeAdvisors);
}
public async Task<UserInfoDto> GetAdvisorInfo(string userId)
public async Task<WebUserInfoView> GetAdvisorInfo(string userId)
{
var user = await _client.GetFromJsonAsync<UserInfoDto>($"{_api.OfficeAdvisors}/{userId}");
Console.WriteLine(JsonSerializer.Serialize(user));
return user;
return await _client.GetFromJsonAsync<WebUserInfoView>($"{_api.OfficeAdvisors}/{userId}");
}
public async Task UpdateAdvisor(string userId, UserUpdateDto model)
@ -67,16 +63,12 @@ public class OfficeUserHttpRepository : IOfficeUserHttpRepository
public async Task<List<UserListAdminView>> GetAdminUsers()
{
var users =await _client.GetFromJsonAsync<List<UserListAdminView>>(_api.OfficeUsers);
Console.WriteLine(JsonSerializer.Serialize(users));
return users;
return await _client.GetFromJsonAsync<List<UserListAdminView>>(_api.OfficeUsers);
}
public async Task<UserInfoDto> GetAdminUserInfo(string userId)
{
var user = await _client.GetFromJsonAsync<UserInfoDto>($"{_api.OfficeUsers}/{userId}");
Console.WriteLine(JsonSerializer.Serialize(user));
return user;
return await _client.GetFromJsonAsync<UserInfoDto>($"{_api.OfficeUsers}/{userId}");
}
public async Task UpdateAdminUser(string userId, UserUpdateDto model)

View file

@ -25,10 +25,10 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class CrmListActivityTodayPage : IDisposable
public partial class CrmActivityTodayPage : IDisposable
{
[Inject] public UserPreferenceService _preferenceService { get; set; }
[Inject] public ILogger<CrmListActivityTodayPage> _logger { get; set; }
[Inject] public ILogger<CrmActivityTodayPage> _logger { get; set; }
[Inject] public HttpInterceptorService _interceptor { get; set; }
[Inject] public NavigationManager _navigator { get; set; }
[Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; }

View file

@ -22,7 +22,7 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class CrmHistoryItemPage : IDisposable
public partial class CrmItemHistoryPage : IDisposable
{
[Parameter] public string Sku { get; set; } = "";
[Parameter] public string CompanyId { get; set; } = "";

View file

@ -8,7 +8,7 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class CrmListActivityCompanyPage : IDisposable
public partial class CrmListActivityForCompanyPage : IDisposable
{
[Parameter] public string CompanyId { get; set; } = "";

View file

@ -24,6 +24,7 @@ using Wonky.Client.HttpInterfaces;
using Wonky.Client.Services;
using Wonky.Entity.DTO;
using Wonky.Entity.Requests;
using Wonky.Entity.Views;
namespace Wonky.Client.Pages
{
@ -38,6 +39,7 @@ namespace Wonky.Client.Pages
private MetaData _metaData { get; set; } = new();
private CompanyPagingParams _paging = new();
private Preferences _preferences { get; set; } = new();
private UserInfoView _userInfo { get; set; } = new();
private string _savedSearch { get; set; } = "";
private bool _includeFolded { get; set; }
@ -45,10 +47,12 @@ namespace Wonky.Client.Pages
{
// set preferences
_preferences = await _preferenceService.GetPreferences();
_userInfo = await _storage.GetItemAsync<UserInfoView>("_xu");
_paging.OrderBy = _preferences.CompanySort;
_paging.SearchColumn = _preferences.CompanySearch;
_paging.PageSize = Convert.ToInt32(_preferences.PageSize);
_paging.HasFolded = _includeFolded ? 1 : 0;
_paging.CountryCode = _userInfo.CountryCode;
// load saved search
_savedSearch = _preferences.CompanyFilterPhrase;

View file

@ -25,10 +25,10 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class CrmTaskItemListPage : IDisposable
public partial class CrmListTaskItemPage : IDisposable
{
[Inject] public UserPreferenceService UserPrefs { get; set; }
[Inject] public ILogger<CrmTaskItemListPage> Logger { get; set; }
[Inject] public ILogger<CrmListTaskItemPage> Logger { get; set; }
[Inject] public HttpInterceptorService _interceptor { get; set; }
[Inject] public NavigationManager _navigator { get; set; }
[Inject] public ICrmTaskItemHttpRepository CrmTaskItemRepo { get; set; }

View file

@ -16,7 +16,9 @@
*@
@using Wonky.Client.Components
@page "/office/companies"
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Office,Warehouse")]
@page "/office/companies/{CountryCode}"
<div class="sticky-top bg-dark text-light rounded-2 px-3">
<div class="container-fluid pt-3">

View file

@ -27,9 +27,9 @@ public partial class OfficeListCustomerPage : IDisposable
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string CountryCode { get; set; } = "dk";
[Inject] public ILogger<OfficeListCustomerPage> _logger { get; set; }
[Inject] public HttpInterceptorService _interceptor { get; set; }
[Inject] public IOfficeCustomerHttpRepository _companyRepo { get; set; }
[Inject] public ILogger<OfficeListCustomerPage> Logger { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IOfficeCustomerHttpRepository CustomerRepo { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
private List<CompanyDto> _companyList { get; set; } = new();
private MetaData _metaData { get; set; } = new();
@ -40,13 +40,13 @@ public partial class OfficeListCustomerPage : IDisposable
protected override async Task OnParametersSetAsync()
{
_interceptor.DisposeEvent();
_interceptor.RegisterBeforeSendEvent();
Interceptor.DisposeEvent();
Interceptor.RegisterBeforeSendEvent();
// set preferences
_preferences = await PreferenceService.GetPreferences();
_paging.Country = CountryCode;
_paging.CountryCode = CountryCode;
_paging.OrderBy = _preferences.CompanySort;
_paging.SearchColumn = _preferences.CompanySearch;
@ -114,13 +114,13 @@ public partial class OfficeListCustomerPage : IDisposable
private async Task GetCompanies()
{
var pagingResponse = await _companyRepo.GetCompaniesPagedSalesRep(UserId, _paging);
var pagingResponse = await CustomerRepo.GetCompaniesPagedSalesRep(UserId, _paging);
_companyList = pagingResponse.Items;
_metaData = pagingResponse.MetaData;
}
public void Dispose()
{
_interceptor.DisposeEvent();
Interceptor.DisposeEvent();
}
}

View file

@ -16,6 +16,8 @@
*@
@using Wonky.Client.Components
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Office,Warehouse")]
@page "/office/users/advisors/{CountryCode}/{UserId}/companies"
<div class="sticky-top bg-dark text-light rounded-2 px-3">
@ -51,4 +53,4 @@
</div>
</div>
<AdvisorCompanyTableComponent Companies="_companyList" />
<OfficeCustomerTableComponent Companies="_companyList" />

View file

@ -25,7 +25,7 @@ namespace Wonky.Client.Pages;
public partial class OfficeListCustomerSalesRepPage : IDisposable
{
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string CountryCode { get; set; } = "";
[Parameter] public string CountryCode { get; set; } = "dk";
[Inject] public ILogger<OfficeListCustomerSalesRepPage> Logger { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
@ -45,7 +45,7 @@ public partial class OfficeListCustomerSalesRepPage : IDisposable
// set preferences
_preferences = await PreferenceService.GetPreferences();
_paging.Country = CountryCode;
_paging.CountryCode = CountryCode;
_paging.OrderBy = _preferences.CompanySort;
_paging.SearchColumn = _preferences.CompanySearch;
_paging.PageSize = Convert.ToInt32(_preferences.PageSize);

View file

@ -8,37 +8,37 @@
<div class="row mb-1">
<label for="name" class="col-md-1 col-form-label">Navn</label>
<div class="col-md-5">
<InputText id="name" class="form-control" @bind-Value="_draft.Name" readonly/>
<InputText id="name" class="form-control" @bind-Value="_activity.Name" readonly/>
</div>
<label for="account" class="col-md-1 col-form-label">Konto</label>
<div class="col-md-2">
<InputText id="account" class="form-control" @bind-Value="_draft.Account" readonly/>
<InputText id="account" class="form-control" @bind-Value="_activity.Account" readonly/>
</div>
<label for="phone" class="col-md-1 col-form-label">Tlf</label>
<div class="col-md-2">
<InputText id="phone" class="form-control" @bind-Value="_draft.Phone"/>
<InputText id="phone" class="form-control" @bind-Value="_activity.Phone"/>
</div>
</div>
<div class="row mb-1">
<label for="referenceNumber" class="col-md-2 col-form-label">Rekvisition</label>
<div class="col-md-4">
<InputText id="referenceNumber" class="form-control" @bind-Value="_draft.ReferenceNumber"/>
<ValidationMessage For="@(() => _draft.ReferenceNumber)"></ValidationMessage>
<InputText id="referenceNumber" class="form-control" @bind-Value="_activity.ReferenceNumber"/>
<ValidationMessage For="@(() => _activity.ReferenceNumber)"></ValidationMessage>
</div>
<label for="yourRef" class="col-md-2 col-form-label">Indkøber</label>
<div class="col-md-4">
<InputText id="yourRef" class="form-control" @bind-Value="_draft.YourRef"/>
<ValidationMessage For="@(() => _draft.YourRef)"></ValidationMessage>
<InputText id="yourRef" class="form-control" @bind-Value="_activity.YourRef"/>
<ValidationMessage For="@(() => _activity.YourRef)"></ValidationMessage>
</div>
</div>
<div class="row mb-1">
<label for="orderMessage" class="col-md-2 col-form-label">Ordre notat</label>
<div class="col-md-10">
<InputTextArea id="orderMessage" class="form-control" @bind-Value="_draft.OrderMessage"/>
<ValidationMessage For="@(() => _draft.OrderMessage)"></ValidationMessage>
<InputTextArea id="orderMessage" class="form-control" @bind-Value="_activity.OrderMessage"/>
<ValidationMessage For="@(() => _activity.OrderMessage)"></ValidationMessage>
</div>
</div>
<div class="row">
@ -145,21 +145,21 @@
<div id="dlvAddress">
<div class="row mb-1">
<div class="col-md-4">
<InputText id="dlvName" class="form-control" @bind-Value="_draft.DlvName"/>
<InputText id="dlvName" class="form-control" @bind-Value="_activity.DlvName"/>
</div>
<div class="col-md-4">
<InputText id="dlvAddress1" class="form-control" @bind-Value="_draft.DlvAddress1"/>
<InputText id="dlvAddress1" class="form-control" @bind-Value="_activity.DlvAddress1"/>
</div>
<div class="col-md-4">
<InputText id="dlvAddress2" class="form-control" @bind-Value="_draft.DlvAddress2"/>
<InputText id="dlvAddress2" class="form-control" @bind-Value="_activity.DlvAddress2"/>
</div>
</div>
<div class="row mb-1">
<div class="col-md-4">
<InputText id="dlvZipCode" class="form-control" @bind-Value="_draft.DlvZipCode"/>
<InputText id="dlvZipCode" class="form-control" @bind-Value="_activity.DlvZipCode"/>
</div>
<div class="col-md-4">
<InputText id="dlvCity" class="form-control" @bind-Value="_draft.DlvCity"/>
<InputText id="dlvCity" class="form-control" @bind-Value="_activity.DlvCity"/>
</div>
</div>
</div>

View file

@ -16,17 +16,18 @@ public partial class OfficeNewOrderPage : IDisposable
{
[CascadingParameter] DraftStateProvider DraftStateProvider { get; set; }
[Parameter] public string CompanyId { get; set; }
[Inject] public HttpInterceptorService _interceptor { get; set; }
[Inject] public IOfficeCustomerHttpRepository _companyRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IOfficeCustomerHttpRepository OfficeCustomerRepo { get; set; }
[Inject] public IOfficeUserHttpRepository OfficeUserRepo { get; set; }
[Inject] public ICatalogHttpRepository _itemRepo { get; set; }
[Inject] public ICatalogHttpRepository CatalogRepo { get; set; }
[Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; }
[Inject] public ILogger<OfficeNewOrderPage> _logger { get; set; }
[Inject] public ILogger<OfficeNewOrderPage> Logger { get; set; }
private ActivityDto _activity { get; set; } = new();
private EditContext _editContext { get; set; }
private PriceListModal _priceList { get; set; } = new();
private CompanyDto _company { get; set; } = new();
private EditContext _editContext { get; set; }
private ActivityDto _draft { get; set; } = new();
private UserInfoDto _userInfo { get; set; } = new();
private WebUserInfoView _userInfo { get; set; } = new();
private SalesItemView _selectedItem { get; set; } = new();
private string Rate { get; set; } = "0";
private string Quantity { get; set; } = "1";
@ -39,23 +40,21 @@ public partial class OfficeNewOrderPage : IDisposable
protected override async Task OnParametersSetAsync()
{
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
_company = await _companyRepo.GetCompanyById(CompanyId);
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
_company = await OfficeCustomerRepo.GetByCustomerId(CompanyId);
}
protected override async Task OnInitializedAsync()
{
_userInfo = await OfficeUserRepo.GetAdvisorInfo(_company.SalesRepId);
_editContext = new EditContext(_draft);
_editContext = new EditContext(_activity);
_editContext.OnFieldChanged += HandleFieldChanged;
_editContext.OnValidationStateChanged += ValidationChanged;
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
_userInfo = await OfficeUserRepo.GetAdvisorInfo(_company.SalesRepId);
_draft.ActivityDate = $"{DateTime.Now:yyyy-MM-dd}" ;
_activity.ActivityDate = $"{DateTime.Now:yyyy-MM-dd}" ;
// variable to validate if customer needs phone number update
// _phone = _company.Phone;
@ -66,31 +65,31 @@ public partial class OfficeNewOrderPage : IDisposable
_company.Phone = _company.Account[..8];
}
_draft.ActivityStatusEnum = "order";
_draft.ActivityTypeEnum = "phone";
_activity.ActivityStatusEnum = "order";
_activity.ActivityTypeEnum = "phone";
// set up identification
_draft.CompanyId = _company.CompanyId;
_draft.BcId = _company.BcId;
_draft.SalesRepId = _company.SalesRepId;
_draft.SalesRep = _company.SalesRep;
_draft.Account = _company.Account;
_draft.VatNumber = _company.VatNumber;
_draft.Email = _company.Email;
_draft.Phone = _company.Phone;
_draft.Mobile = _company.Mobile;
_activity.CompanyId = _company.CompanyId;
_activity.BcId = _company.BcId;
_activity.SalesRepId = _company.SalesRepId;
_activity.SalesRep = _company.SalesRep;
_activity.Account = _company.Account;
_activity.VatNumber = _company.VatNumber;
_activity.Email = _company.Email;
_activity.Phone = _company.Phone;
_activity.Mobile = _company.Mobile;
_draft.Name = _company.Name;
_draft.Address1 = _company.Address1;
_draft.Address2 = _company.Address2;
_draft.ZipCode = _company.ZipCode;
_draft.City = _company.City;
_activity.Name = _company.Name;
_activity.Address1 = _company.Address1;
_activity.Address2 = _company.Address2;
_activity.ZipCode = _company.ZipCode;
_activity.City = _company.City;
_draft.DlvName = _company.Name;
_draft.DlvAddress1 = _company.Address1;
_draft.DlvAddress2 = _company.Address2;
_draft.DlvZipCode = _company.ZipCode;
_draft.DlvCity = _company.City;
_activity.DlvName = _company.Name;
_activity.DlvAddress1 = _company.Address1;
_activity.DlvAddress2 = _company.Address2;
_activity.DlvZipCode = _company.ZipCode;
_activity.DlvCity = _company.City;
}
private void CallPriceListModal()
@ -101,7 +100,7 @@ public partial class OfficeNewOrderPage : IDisposable
private async Task SelectSku(SelectedSku sku)
{
ShowItem = true;
_selectedItem = await _itemRepo.GetSalesVariantId(sku.ItemId);
_selectedItem = await CatalogRepo.GetSalesVariantId(sku.ItemId);
Price = sku.Rate;
Quantity = sku.Quantity;
}
@ -113,7 +112,7 @@ public partial class OfficeNewOrderPage : IDisposable
private async Task CreateOrder()
{
await CrmActivityRepo.CreateActivity(_draft);
await CrmActivityRepo.CreateActivity(_activity);
}
private async Task AddItem(SalesItemView salesItem)
{
@ -162,14 +161,14 @@ public partial class OfficeNewOrderPage : IDisposable
_editContext.OnFieldChanged -= HandleFieldChanged;
_editContext.OnValidationStateChanged -= ValidationChanged;
_editContext = new EditContext(_draft);
_editContext = new EditContext(_activity);
_editContext.OnFieldChanged += HandleFieldChanged;
_editContext.OnValidationStateChanged += ValidationChanged;
}
public void Dispose()
{
_interceptor.DisposeEvent();
Interceptor.DisposeEvent();
_editContext.OnFieldChanged -= HandleFieldChanged;
_editContext.OnValidationStateChanged -= ValidationChanged;
}

View file

@ -25,7 +25,7 @@
<h3>Bruger info</h3>
</div>
<div class="card-body">
@if (UserInfoDto != null)
@if (_userInfo != null)
{
<EditForm EditContext="_editContext" OnValidSubmit="UpdateAdvisor">
<DataAnnotationsValidator/>
@ -70,7 +70,7 @@
Sælgernr.
</th>
<td>
@UserInfoDto.Advisor
@_userInfo.Advisor
</td>
<th scope="col">
Landekode

View file

@ -22,6 +22,7 @@ using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpInterfaces;
using Wonky.Client.HttpRepository;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
@ -34,7 +35,7 @@ public partial class OfficeViewCrmUserPage : IDisposable
[Inject] public ILogger<OfficeViewCrmUserPage> _logger { get; set; }
[Inject] public NavigationManager _navigator { get; set; }
[Inject] public IToastService _toast { get; set; }
private UserInfoDto UserInfoDto { get; set; } = new();
private WebUserInfoView _userInfo { get; set; } = new();
private EditContext _editContext { get; set; }
private UserUpdateDto _updateInfo { get; set; } = new();
private AdminResetPasswordDto _passwords { get; set; } = new();
@ -54,14 +55,14 @@ public partial class OfficeViewCrmUserPage : IDisposable
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
UserInfoDto = await OfficeUserRepo.GetAdvisorInfo(UserId);
_userInfo = await OfficeUserRepo.GetAdvisorInfo(UserId);
_updateInfo.Email = UserInfoDto.Email;
_updateInfo.CountryCode = UserInfoDto.CountryCode;
_updateInfo.FirstName = UserInfoDto.FirstName;
_updateInfo.LastName = UserInfoDto.LastName;
_updateInfo.PhoneNumber = UserInfoDto.PhoneNumber;
_updateInfo.LockoutEnabled = UserInfoDto.LockoutEnabled;
_updateInfo.Email = _userInfo.Email;
_updateInfo.CountryCode = _userInfo.CountryCode;
_updateInfo.FirstName = _userInfo.FirstName;
_updateInfo.LastName = _userInfo.LastName;
_updateInfo.PhoneNumber = _userInfo.PhoneNumber;
_updateInfo.LockoutEnabled = _userInfo.LockoutEnabled;
_passwdContext.OnFieldChanged += PwHandleFieldChanged;
_passwdContext.OnValidationStateChanged += PwValidationChanged;

View file

@ -45,7 +45,9 @@ public partial class SalesCatalogPage : IDisposable
{
_preferences = await PreferenceService.GetPreferences();
_user = await Storage.GetItemAsync<UserInfoView>("_xu");
_paging.Country = _user.CountryCode;
_paging.CountryCode = _user.CountryCode;
_paging.OrderBy = _preferences.ItemSort;
_paging.SearchColumn = _preferences.ItemSearch;
_paging.PageSize = Convert.ToInt32(_preferences.PageSize);
@ -55,13 +57,6 @@ public partial class SalesCatalogPage : IDisposable
await GetSalesItems();
}
private async Task GetSalesItems()
{
var pagingResponse = await ItemRepo.GetSalesItemsPaged(_paging);
_items = pagingResponse.Items!;
_metaData = pagingResponse.MetaData;
}
private async Task SetSearchPhrase(string searchTerm)
{
_items = new List<SalesItemView>();
@ -108,6 +103,14 @@ public partial class SalesCatalogPage : IDisposable
await GetSalesItems();
}
private async Task GetSalesItems()
{
var pagingResponse = await ItemRepo.GetSalesItemsPaged(_paging);
_items = pagingResponse.Items!;
_metaData = pagingResponse.MetaData;
}
public void Dispose() => Interceptor.DisposeEvent();
}

View file

@ -0,0 +1,40 @@
@*
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
*@
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-info">
<h5 class="modal-title">Info</h5>
<button type="button" class="btn-close" @onclick="Hide" data-bs-dismiss="modal" aria-label="Luk"></button>
</div>
<div class="modal-body">
<div class="alert alert-info">
<p class="fw-bold">@BodyMessage</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="Hide">Luk</button>
@* <button type="button" class="btn btn-primary" data-bs-dismiss="modal" @onclick="() => OnOkClicked.InvokeAsync()">OK</button> *@
</div>
</div>
</div>
</div>
@if (_showBackdrop)
{
<div class="modal-backdrop fade show"></div>
}

View file

@ -0,0 +1,40 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Shared;
public partial class Information
{
private string _modalDisplay = "";
private bool _showBackdrop;
[Parameter] public string BodyMessage { get; set; } = "";
[Parameter] public EventCallback OnOkClicked { get; set; }
public void Show()
{
_modalDisplay = "block;";
_showBackdrop = true;
StateHasChanged();
}
public void Hide()
{
_modalDisplay = "none;";
_showBackdrop = false;
StateHasChanged();
}
}

View file

@ -42,7 +42,7 @@ public partial class PriceListModal : IDisposable
protected override async Task OnInitializedAsync()
{
_preferences = await PreferenceService.GetPreferences();
_paging.Country = CountryCode;
_paging.CountryCode = CountryCode;
_paging.OrderBy = _preferences.ItemSort;
_paging.SearchColumn = _preferences.ItemSearch;
_paging.PageSize = Convert.ToInt32(_preferences.PageSize);

View file

@ -29,7 +29,8 @@
<img src="/svg-loaders/three-dots.svg" alt="loading ..."/>
</div>
</div>
<script src="/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/bootstrap/js/bootstrap.bundle.js"></script>
<script src="/scripts/bsTooltip.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
</body>
</html>

View file

@ -0,0 +1,4 @@
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})

View file

@ -21,81 +21,71 @@ namespace Wonky.Entity.DTO;
public class UserInfoDto
{
/// <summary>
/// First name
/// User Id
/// </summary>
[Required(ErrorMessage = "Fornavn skal angives.")]
[MaxLength(50,ErrorMessage = "Der kan højst bruges 50 tegn.")]
public string FirstName { get; set; } = "";
/// <summary>
/// Last name
/// </summary>
[Required(ErrorMessage = "Efternavn skal angives.")]
[MaxLength(50,ErrorMessage = "Der kan højst bruges 50 tegn.")]
public string LastName { get; set; } = "";
/// <summary>
/// Country code
/// </summary>
[Required(ErrorMessage = "Landekode skal angives.")]
[MaxLength(50,ErrorMessage = "Der kan højst bruges 3 tegn.")]
public string CountryCode { get; set; } = "";
/// <summary>
/// Email
/// </summary>
[Required(ErrorMessage = "Email skal angives.")]
[MaxLength(50, ErrorMessage = "Der kan højst bruges 80 tegn.")]
public string Email { get; set; } = "";
/// <summary>
/// Phone number
/// </summary>
[MaxLength(20, ErrorMessage = "Der kan højst bruges 20 tegn.")]
public string PhoneNumber { get; set; } = "";
public string UserId { get; set; } = "";
/// <summary>
/// Sales representative identification
/// </summary>
[Required(ErrorMessage = "Sælger identifikation skal angives.")]
[MaxLength(50,ErrorMessage = "Der kan højst bruges 20 tegn.")]
public string Advisor { get; set; } = "";
/// <summary>
/// User Id
/// Country code
/// </summary>
public string UserId { get; set; } = "";
/// <summary>
/// Lockout flag
/// </summary>
public bool LockoutEnabled { get; set; }
[Required(ErrorMessage = "Landekode skal angives.")]
[MaxLength(50,ErrorMessage = "Der kan højst bruges 3 tegn.")]
public string CountryCode { get; set; } = "";
/// <summary>
/// Country name
/// </summary>
public string CountryName { get; set; } = "";
/// <summary>
/// Email
/// </summary>
[Required(ErrorMessage = "Email skal angives.")]
[MaxLength(50, ErrorMessage = "Der kan højst bruges 80 tegn.")]
public string Email { get; set; } = "";
/// <summary>
/// First name
/// </summary>
[Required(ErrorMessage = "Fornavn skal angives.")]
[MaxLength(50,ErrorMessage = "Der kan højst bruges 50 tegn.")]
public string FirstName { get; set; } = "";
/// <summary>
/// Last name
/// </summary>
[Required(ErrorMessage = "Efternavn skal angives.")]
[MaxLength(50,ErrorMessage = "Der kan højst bruges 50 tegn.")]
public string LastName { get; set; } = "";
/// <summary>
/// Phone number
/// </summary>
[MaxLength(20, ErrorMessage = "Der kan højst bruges 20 tegn.")]
public string PhoneNumber { get; set; } = "";
/// <summary>
/// Lockout flag
/// </summary>
public bool LockoutEnabled { get; set; }
/// <summary>
/// Email confirmed flag
/// </summary>
public bool EmailConfirmed { get; set; }
/// <summary>
/// Admin flag
/// </summary>
public bool IsAdmin { get; set; }
/// <summary>
/// Advisor flag
/// </summary>
public bool IsAdvisor { get; set; }
/// <summary>
/// Admin flag
/// </summary>
public bool IsAdmin { get; set; }
public bool IsEDoc { get; set; }
public bool IsEShop { get; set; }
public bool IsSupervisor { get; set; }
public bool IsOffice { get; set; }
public bool IsWarehouse { get; set; }
public string Roles { get; set; } = "";
public string ReferenceId { get; set; } = "";
// public bool IsEDoc { get; set; }
// public bool IsEShop { get; set; }
// public bool IsSupervisor { get; set; }
// public bool IsOffice { get; set; }
// public bool IsWarehouse { get; set; }
// public string Roles { get; set; } = "";
// public string ReferenceId { get; set; } = "";
}

View file

@ -64,5 +64,5 @@ public class CatalogPagingParams
/// <summary>
/// Country code
/// </summary>
public string Country { get; set; } = "dk";
public string CountryCode { get; set; } = "dk";
}

View file

@ -71,6 +71,6 @@ public class CompanyPagingParams
/// </summary>
public int HasFolded { get; set; }
public string Country { get; set; } = "dk";
public string CountryCode { get; set; } = "dk";
}

View file

@ -0,0 +1,34 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Text.Json.Serialization;
namespace Wonky.Entity.Views;
public class WebUserInfoView
{
[JsonPropertyName("userId")] public string UserId { get; set; } = "";
[JsonPropertyName("advisor")] public string Advisor { get; set; } = "";
[JsonPropertyName("countryCode")] public string CountryCode { get; set; } = "";
[JsonPropertyName("countryName")] public string CountryName { get; set; } = "";
[JsonPropertyName("email")] public string Email { get; set; } = "";
[JsonPropertyName("firstName")] public string FirstName { get; set; } = "";
[JsonPropertyName("lastName")]public string LastName { get; set; } = "";
[JsonPropertyName("phoneNumber")]public string PhoneNumber { get; set; } = "";
[JsonPropertyName("lockoutEnabled")] public bool LockoutEnabled { get; set; }
[JsonPropertyName("emailConfirmed")] public bool EmailConfirmed { get; set; }
[JsonPropertyName("isAdmin")] public bool IsAdmin { get; set; }
[JsonPropertyName("isAdvisor")] public bool IsAdvisor { get; set; }
}