diff --git a/phronCare.UIBlazor/Pages/Sales/Customers.razor b/phronCare.UIBlazor/Pages/Sales/Customers.razor index fb5cfb3..ddf2c92 100644 --- a/phronCare.UIBlazor/Pages/Sales/Customers.razor +++ b/phronCare.UIBlazor/Pages/Sales/Customers.razor @@ -19,7 +19,8 @@ { @@ -100,151 +101,4 @@ else private bool PuedeAvanzar => PagedResult != null && SearchParams.Page < TotalPaginas; private bool PuedeRetroceder => PagedResult != null && SearchParams.Page > 1; -} - - - -@* @page "/customers" -@using phronCare.UIBlazor.Services.Sales -@using phronCare.UIBlazor.Data -@using Domain.Generics - -@inject CustomerHttpService CustomerService -@inject NavigationManager Nav - -

Buscar Clientes

- -
- - - - -
- -@if (PagedResult != null) -{ - - - - - - - - - - - - - - - - - - @foreach (var c in PagedResult.Items) - { - var addr = c.PhSCustomerAddresses.FirstOrDefault(); - var doc = c.PhSCustomerDocuments.FirstOrDefault(); - - - - - - - - - - - - - - } - -
IdNameBusinessNameActiveExternalCodeHasCreditAccountCreditLimitEmailPhoneDirecciónDocumento
@c.Id@c.Name@c.BusinessName@(c.Active ? "Sí" : "No")@c.ExternalCode@(c.HasCreditAccount ? "Sí" : "No")@c.CreditLimit@addr?.Email@addr?.Phonenumber - @addr?.Streetaddress1 @addr?.Streetaddress2
- @addr?.City, @addr?.Postalcode, @addr?.Country -
- @doc?.DocumentNumber
- @doc?.IssueDate?.ToString("yyyy-MM-dd")
- @doc?.ExpiryDate?.ToString("yyyy-MM-dd") -
- -
- - Página @SearchParams.Page de @TotalPaginas - -
-} -else -{ -

No hay resultados.

-} - -@code { - private CustomerSearchParams SearchParams = new(); - private PagedResult? 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; - ActualizarUrl(); - await CargarClientes(); - } - - private async Task CargarClientes() - { - PagedResult = await CustomerService.SearchCustomersAsync(SearchParams); - } - - private async Task SiguientePagina() - { - if (PuedeAvanzar) - { - SearchParams.Page++; - ActualizarUrl(); - await CargarClientes(); - } - } - - private async Task AnteriorPagina() - { - 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); - - private bool PuedeAvanzar => PagedResult != null && SearchParams.Page < TotalPaginas; - private bool PuedeRetroceder => PagedResult != null && SearchParams.Page > 1; -} - *@ \ No newline at end of file +} \ No newline at end of file diff --git a/phronCare.UIBlazor/Shared/Components/PhTable.razor b/phronCare.UIBlazor/Shared/Components/PhTable.razor index 371b186..9f73579 100644 --- a/phronCare.UIBlazor/Shared/Components/PhTable.razor +++ b/phronCare.UIBlazor/Shared/Components/PhTable.razor @@ -14,58 +14,62 @@ } +
- + }
@@ -211,6 +215,8 @@ [Parameter] public int RowsPerPage { get; set; } = 10; [Parameter] + public bool ShowPageButtons { get; set; } = true; + [Parameter] public string SelectionField { get; set; } = string.Empty; [Parameter] public string TableTitle { get; set; } = string.Empty;