Add Patch UI Customer
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 4m52s

This commit is contained in:
Leandro Hernan Rojas 2025-04-06 18:08:45 -03:00
parent 559de37672
commit 686c06ae83
2 changed files with 33 additions and 13 deletions

View File

@ -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; }
}
}

View File

@ -1,9 +1,10 @@
@page "/customers"
@using phronCare.UIBlazor.Services.Sales
@using phronCare.UIBlazor.Data
@using Domain.Generics
@inject CustomerHttpService CustomerService
@inject NavigationManager Nav
<h3 class="text-xl font-bold mb-4">Buscar Clientes</h3>
@ -76,15 +77,36 @@ else
private CustomerSearchParams SearchParams = new();
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()
{
SearchParams.Page = 1; // reset al buscar
SearchParams.Page = 1;
ActualizarUrl();
await CargarClientes();
}
private async Task CargarClientes()
{
// pagedResult = await CustomerHttpService.searcs(SearchParams);
PagedResult = await CustomerService.SearchCustomersAsync(SearchParams);
}
private async Task SiguientePagina()
@ -92,6 +114,7 @@ else
if (PuedeAvanzar)
{
SearchParams.Page++;
ActualizarUrl();
await CargarClientes();
}
}
@ -101,10 +124,17 @@ else
if (PuedeRetroceder)
{
SearchParams.Page--;
ActualizarUrl();
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 :
(int)Math.Ceiling((double)(PagedResult.TotalItems) / SearchParams.PageSize);