WIP - B2B restock
This commit is contained in:
parent
11340a95fb
commit
d5b0b29cb1
2 changed files with 135 additions and 85 deletions
|
@ -19,79 +19,100 @@
|
|||
@attribute [Authorize(Roles = "EShop")]
|
||||
@page "/b2b/{countryCode}/{companyId}"
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-6">
|
||||
@if (!string.IsNullOrWhiteSpace(_businessInfo.Name))
|
||||
{
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
@_businessInfo.Name
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
@_businessInfo.Address1<br/>
|
||||
@_businessInfo.Address2<br/>
|
||||
@_businessInfo.ZipCode @_businessInfo.City<br/>
|
||||
</p>
|
||||
<p class="card-text">
|
||||
<i class="bi-card-heading"></i> @_businessInfo.Account<br/>
|
||||
<i class="bi-phone"></i> @_businessInfo.Phone<br/>
|
||||
<i class="bi-at"></i> @_businessInfo.Email<br/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="row g-2 mb-2">
|
||||
<div class="card col-md-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
@_businessInfo.Name
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
<i class="bi-card-heading"></i> @_businessInfo.Account<br/>
|
||||
<i class="bi-phone"></i> @_businessInfo.Phone<br/>
|
||||
<i class="bi-at"></i> @_businessInfo.Email<br/>
|
||||
</p>
|
||||
</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="card col-md-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
@_advisorInfo.Name
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
<i class="bi-phone"></i> @_advisorInfo.Phone<br/>
|
||||
<i class="bi-at"></i> @_advisorInfo.Email<br/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6">
|
||||
@if (!string.IsNullOrWhiteSpace(_advisorInfo.Name))
|
||||
{
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
@_advisorInfo.Name
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
<i class="bi-phone"></i> @_advisorInfo.Phone<br/>
|
||||
<i class="bi-at"></i> @_advisorInfo.Email<br/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@if (_productInventory.Any())
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Produkter</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var product in _productInventory)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<img src="@(product.PictureLink)?height=100" alt="@product.Description"
|
||||
@if (_productInventory.Any())
|
||||
{
|
||||
<div class="row row-cols-1 row-cols-md-2 g-2">
|
||||
@foreach (var product in _productInventory)
|
||||
{
|
||||
<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'"/>
|
||||
</td>
|
||||
<td>@product.LastInvoiceDate</td>
|
||||
<td>@product.Description</td>
|
||||
<td>@product.Quantity</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary">Genbestil</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<B2BProductHistoryOverlay CompanyId="@CompanyId" ItemSku="" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<WorkingThreeDots/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
@product.Description
|
||||
</h5>
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Sidste køb</th>
|
||||
<th scope="col">Forbrug</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
@product.LastInvoiceDate
|
||||
</td>
|
||||
<td>
|
||||
@product.Quantity
|
||||
</td>
|
||||
<td>
|
||||
<a role="button" class="btn-link" @onclick="() => ShowProductHistoryOverlay(product.Sku)">
|
||||
Historik
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<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>
|
||||
}
|
||||
</div>
|
||||
<B2BProductPriceHistoryOverlay CompanyId="@CompanyId" Sku="@_sku" @ref="PriceHistoryOverlay"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<WorkingThreeDots/>
|
||||
}
|
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components;
|
|||
using Microsoft.Extensions.Options;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Client.Models;
|
||||
using Wonky.Client.OverlayB2B;
|
||||
using Wonky.Client.Shared;
|
||||
using Wonky.Entity.Configuration;
|
||||
|
@ -18,11 +19,14 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
|||
// ##############################################################
|
||||
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||
[Inject] public IB2BRepository B2BRepo { get; set; }
|
||||
|
||||
[Inject]
|
||||
public ICountryCatalogRepository Catalog { get; set; }
|
||||
[Inject] private IOptions<ApiConfig> Config { get; set; }
|
||||
|
||||
|
||||
// ##############################################################
|
||||
[CascadingParameter] private DraftStateProvider DraftProvider { get; set; } = new();
|
||||
|
||||
|
||||
[Parameter] public string CountryCode { get; set; } = "";
|
||||
[Parameter] public string CompanyId { get; set; } = "";
|
||||
|
||||
|
@ -32,10 +36,13 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
|||
private List<ProductHistoryView> _productHistory = new();
|
||||
private List<ProductInventoryItemView> _productInventory = new();
|
||||
private ApiConfig _config = new();
|
||||
private B2BProductHistoryOverlay PriceOverlay { get; set; }
|
||||
private string Price { get; set; } = "0";
|
||||
|
||||
|
||||
private B2BProductPriceHistoryOverlay PriceHistoryOverlay { get; set; }
|
||||
private string _price = "0";
|
||||
private string _quantity = "1";
|
||||
private ItemSelect _selectedItem = new();
|
||||
private string _sku = "";
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Interceptor.RegisterEvent();
|
||||
|
@ -47,15 +54,37 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
|||
if (_productInventory.Any())
|
||||
{
|
||||
_productInventory = _productInventory
|
||||
.OrderByDescending(x => x.LastInvoiceDate)
|
||||
.OrderByDescending(x => x.Quantity)
|
||||
.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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,18 +102,18 @@ public partial class BusinessCustomerLandingPage : IDisposable
|
|||
// StateHasChanged();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
private void PriceHistoryOverlayCallback(decimal price)
|
||||
{
|
||||
if (price == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Price = price.ToString("N2", CultureInfo.InvariantCulture);
|
||||
|
||||
_price = price.ToString("N2", CultureInfo.InvariantCulture);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue