Add Patch UI Customer
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 4m52s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 4m52s
This commit is contained in:
parent
559de37672
commit
686c06ae83
@ -1,10 +0,0 @@
|
|||||||
namespace phronCare.UIBlazor.Data
|
|
||||||
{
|
|
||||||
public class PagedResult<T>
|
|
||||||
{
|
|
||||||
public IEnumerable<T> Items { get; set; }
|
|
||||||
public int TotalItems { get; set; }
|
|
||||||
public int Page { get; set; }
|
|
||||||
public int PageSize { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +1,10 @@
|
|||||||
@page "/customers"
|
@page "/customers"
|
||||||
@using phronCare.UIBlazor.Services.Sales
|
@using phronCare.UIBlazor.Services.Sales
|
||||||
@using phronCare.UIBlazor.Data
|
@using phronCare.UIBlazor.Data
|
||||||
|
@using Domain.Generics
|
||||||
|
|
||||||
@inject CustomerHttpService CustomerService
|
@inject CustomerHttpService CustomerService
|
||||||
|
@inject NavigationManager Nav
|
||||||
|
|
||||||
<h3 class="text-xl font-bold mb-4">Buscar Clientes</h3>
|
<h3 class="text-xl font-bold mb-4">Buscar Clientes</h3>
|
||||||
|
|
||||||
@ -76,15 +77,36 @@ else
|
|||||||
private CustomerSearchParams SearchParams = new();
|
private CustomerSearchParams SearchParams = new();
|
||||||
private PagedResult<ECustomer>? PagedResult;
|
private PagedResult<ECustomer>? PagedResult;
|
||||||
|
|
||||||
|
[Parameter, SupplyParameterFromQuery] public string? Name { get; set; }
|
||||||
|
[Parameter, SupplyParameterFromQuery] public string? Email { get; set; }
|
||||||
|
[Parameter, SupplyParameterFromQuery] public string? Document { get; set; }
|
||||||
|
[Parameter, SupplyParameterFromQuery] public int? Page { get; set; }
|
||||||
|
[Parameter, SupplyParameterFromQuery] public int? PageSize { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
SearchParams = new CustomerSearchParams
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
Email = Email,
|
||||||
|
Document = Document,
|
||||||
|
Page = Page ?? 1,
|
||||||
|
PageSize = PageSize ?? 10
|
||||||
|
};
|
||||||
|
|
||||||
|
await CargarClientes();
|
||||||
|
}
|
||||||
|
|
||||||
private async Task BuscarClientes()
|
private async Task BuscarClientes()
|
||||||
{
|
{
|
||||||
SearchParams.Page = 1; // reset al buscar
|
SearchParams.Page = 1;
|
||||||
|
ActualizarUrl();
|
||||||
await CargarClientes();
|
await CargarClientes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CargarClientes()
|
private async Task CargarClientes()
|
||||||
{
|
{
|
||||||
// pagedResult = await CustomerHttpService.searcs(SearchParams);
|
PagedResult = await CustomerService.SearchCustomersAsync(SearchParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SiguientePagina()
|
private async Task SiguientePagina()
|
||||||
@ -92,6 +114,7 @@ else
|
|||||||
if (PuedeAvanzar)
|
if (PuedeAvanzar)
|
||||||
{
|
{
|
||||||
SearchParams.Page++;
|
SearchParams.Page++;
|
||||||
|
ActualizarUrl();
|
||||||
await CargarClientes();
|
await CargarClientes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,10 +124,17 @@ else
|
|||||||
if (PuedeRetroceder)
|
if (PuedeRetroceder)
|
||||||
{
|
{
|
||||||
SearchParams.Page--;
|
SearchParams.Page--;
|
||||||
|
ActualizarUrl();
|
||||||
await CargarClientes();
|
await CargarClientes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ActualizarUrl()
|
||||||
|
{
|
||||||
|
var query = $"/customers?name={SearchParams.Name}&email={SearchParams.Email}&document={SearchParams.Document}&page={SearchParams.Page}&pageSize={SearchParams.PageSize}";
|
||||||
|
Nav.NavigateTo(query);
|
||||||
|
}
|
||||||
|
|
||||||
private int TotalPaginas => PagedResult is null ? 1 :
|
private int TotalPaginas => PagedResult is null ? 1 :
|
||||||
(int)Math.Ceiling((double)(PagedResult.TotalItems) / SearchParams.PageSize);
|
(int)Math.Ceiling((double)(PagedResult.TotalItems) / SearchParams.PageSize);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user