WIP - B2B restock
This commit is contained in:
parent
11340a95fb
commit
d5b0b29cb1
2 changed files with 135 additions and 85 deletions
|
@ -19,20 +19,12 @@
|
||||||
@attribute [Authorize(Roles = "EShop")]
|
@attribute [Authorize(Roles = "EShop")]
|
||||||
@page "/b2b/{countryCode}/{companyId}"
|
@page "/b2b/{countryCode}/{companyId}"
|
||||||
|
|
||||||
<div class="row">
|
<div class="row g-2 mb-2">
|
||||||
<div class="col-sm-12 col-md-6">
|
<div class="card col-md-4">
|
||||||
@if (!string.IsNullOrWhiteSpace(_businessInfo.Name))
|
|
||||||
{
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
@_businessInfo.Name
|
@_businessInfo.Name
|
||||||
</h5>
|
</h5>
|
||||||
<p class="card-text">
|
|
||||||
@_businessInfo.Address1<br/>
|
|
||||||
@_businessInfo.Address2<br/>
|
|
||||||
@_businessInfo.ZipCode @_businessInfo.City<br/>
|
|
||||||
</p>
|
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<i class="bi-card-heading"></i> @_businessInfo.Account<br/>
|
<i class="bi-card-heading"></i> @_businessInfo.Account<br/>
|
||||||
<i class="bi-phone"></i> @_businessInfo.Phone<br/>
|
<i class="bi-phone"></i> @_businessInfo.Phone<br/>
|
||||||
|
@ -40,12 +32,19 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
<div class="card col-md-4">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">
|
||||||
|
Leveringsadresse
|
||||||
|
</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
@_businessInfo.Address1<br/>
|
||||||
|
@_businessInfo.Address2<br/>
|
||||||
|
@_businessInfo.ZipCode @_businessInfo.City<br/>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-6">
|
</div>
|
||||||
@if (!string.IsNullOrWhiteSpace(_advisorInfo.Name))
|
<div class="card col-md-4">
|
||||||
{
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
@_advisorInfo.Name
|
@_advisorInfo.Name
|
||||||
|
@ -56,42 +55,64 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
@if (_productInventory.Any())
|
||||||
@if (_productInventory.Any())
|
{
|
||||||
|
<div class="row row-cols-1 row-cols-md-2 g-2">
|
||||||
|
@foreach (var product in _productInventory)
|
||||||
{
|
{
|
||||||
<table class="table">
|
<div class="card col-md-6 col-xl-4">
|
||||||
|
<div class="row g-0">
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<img class="img-fluid rounded-start" src="@(product.PictureLink)?height=125" alt="@product.Description"
|
||||||
|
onerror="this.onerror=null;this.src='@(_config.AssetUrl)/images/no-image.png?height=100'"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">
|
||||||
|
@product.Description
|
||||||
|
</h5>
|
||||||
|
<table class="table table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Produkter</th>
|
<th scope="col">Sidste køb</th>
|
||||||
|
<th scope="col">Forbrug</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var product in _productInventory)
|
|
||||||
{
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<img src="@(product.PictureLink)?height=100" alt="@product.Description"
|
@product.LastInvoiceDate
|
||||||
onerror="this.onerror=null;this.src='@(_config.AssetUrl)/images/no-image.png?height=100'"/>
|
|
||||||
</td>
|
</td>
|
||||||
<td>@product.LastInvoiceDate</td>
|
|
||||||
<td>@product.Description</td>
|
|
||||||
<td>@product.Quantity</td>
|
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn btn-primary">Genbestil</button>
|
@product.Quantity
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a role="button" class="btn-link" @onclick="() => ShowProductHistoryOverlay(product.Sku)">
|
||||||
|
Historik
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<B2BProductHistoryOverlay CompanyId="@CompanyId" ItemSku="" />
|
<div class="mt-3 d-grid align-content-end">
|
||||||
|
<button type="button" class="btn btn-primary btn-sm"
|
||||||
|
@onclick="() => ShowProductHistoryOverlay(product.Sku)">
|
||||||
|
Genbestil
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
else
|
</div>
|
||||||
{
|
<B2BProductPriceHistoryOverlay CompanyId="@CompanyId" Sku="@_sku" @ref="PriceHistoryOverlay"/>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
<WorkingThreeDots/>
|
<WorkingThreeDots/>
|
||||||
}
|
}
|
||||||
</div>
|
|
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Wonky.Client.HttpInterceptors;
|
using Wonky.Client.HttpInterceptors;
|
||||||
using Wonky.Client.HttpRepository;
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Wonky.Client.Models;
|
||||||
using Wonky.Client.OverlayB2B;
|
using Wonky.Client.OverlayB2B;
|
||||||
using Wonky.Client.Shared;
|
using Wonky.Client.Shared;
|
||||||
using Wonky.Entity.Configuration;
|
using Wonky.Entity.Configuration;
|
||||||
|
@ -18,6 +19,9 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
||||||
// ##############################################################
|
// ##############################################################
|
||||||
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||||
[Inject] public IB2BRepository B2BRepo { get; set; }
|
[Inject] public IB2BRepository B2BRepo { get; set; }
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public ICountryCatalogRepository Catalog { get; set; }
|
||||||
[Inject] private IOptions<ApiConfig> Config { get; set; }
|
[Inject] private IOptions<ApiConfig> Config { get; set; }
|
||||||
|
|
||||||
// ##############################################################
|
// ##############################################################
|
||||||
|
@ -32,8 +36,11 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
||||||
private List<ProductHistoryView> _productHistory = new();
|
private List<ProductHistoryView> _productHistory = new();
|
||||||
private List<ProductInventoryItemView> _productInventory = new();
|
private List<ProductInventoryItemView> _productInventory = new();
|
||||||
private ApiConfig _config = new();
|
private ApiConfig _config = new();
|
||||||
private B2BProductHistoryOverlay PriceOverlay { get; set; }
|
private B2BProductPriceHistoryOverlay PriceHistoryOverlay { get; set; }
|
||||||
private string Price { get; set; } = "0";
|
private string _price = "0";
|
||||||
|
private string _quantity = "1";
|
||||||
|
private ItemSelect _selectedItem = new();
|
||||||
|
private string _sku = "";
|
||||||
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
@ -47,15 +54,37 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
||||||
if (_productInventory.Any())
|
if (_productInventory.Any())
|
||||||
{
|
{
|
||||||
_productInventory = _productInventory
|
_productInventory = _productInventory
|
||||||
.OrderByDescending(x => x.LastInvoiceDate)
|
.OrderByDescending(x => x.Quantity)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ShowPriceHistoryOverlay()
|
private async Task AddItemToOrder(string sku)
|
||||||
{
|
{
|
||||||
PriceOverlay.Show();
|
var item = await Catalog.GetSalesItemSku(CountryCode, sku);
|
||||||
|
var history = await B2BRepo.GetCustomerProductHistory(CompanyId, sku);
|
||||||
|
var line = history
|
||||||
|
.OrderByDescending(x => x.DeliveryDate)
|
||||||
|
.Where(x => x.Price != 0).Take(1).ToList()[0];
|
||||||
|
DraftProvider.Draft.DraftId = CompanyId;
|
||||||
|
DraftProvider.Draft.Items.Add(
|
||||||
|
new DraftItem()
|
||||||
|
{
|
||||||
|
Price = line.Price,
|
||||||
|
Quantity = line.Quantity,
|
||||||
|
Discount = 0,
|
||||||
|
Sas = false,
|
||||||
|
Item = item
|
||||||
|
});
|
||||||
|
await DraftProvider.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowProductHistoryOverlay(string sku)
|
||||||
|
{
|
||||||
|
_sku = sku;
|
||||||
|
PriceHistoryOverlay.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,12 +109,12 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Price = price.ToString("N2", CultureInfo.InvariantCulture);
|
|
||||||
|
_price = price.ToString("N2", CultureInfo.InvariantCulture);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Interceptor.DisposeEvent();
|
Interceptor.DisposeEvent();
|
||||||
|
|
Loading…
Reference in a new issue