diff --git a/demo/demo.ts b/demo/demo.ts index 729b712..862fa6a 100644 --- a/demo/demo.ts +++ b/demo/demo.ts @@ -58,7 +58,7 @@ async function showResponse(statusEl: Element | null, promise: Promise) { } } -function setupForm(selector: string, listener: () => Promise) { +function setupForm(selector: string, listener: (event: Event) => Promise) { const formEl = document.querySelector(selector); if (!formEl) throw new Error(`No existe el formulario ${selector}`); const statusEl = formEl.querySelector(".status"); @@ -68,7 +68,7 @@ function setupForm(selector: string, listener: () => Promise) { ); formEl.addEventListener("submit", async (event) => { event.preventDefault(); - showResponse(statusEl, listener()); + showResponse(statusEl, listener(event)); }); } @@ -78,5 +78,7 @@ setupForm("#save-token", async () => { }); setupForm("#productos", () => getProductos(token(), {})); setupForm("#price", () => getPrices(token(), {})); -setupForm("#price-by-customer", () => getPricesByCustomer(token(), {})); +setupForm("#price-by-customer", (event) => + getPricesByCustomer(token(), { filter: (event.target! as any).filter.value }) +); setupForm("#customer", () => getCustomers(token(), {})); diff --git a/demo/index.html b/demo/index.html index 1e9b66a..d6e8e26 100644 --- a/demo/index.html +++ b/demo/index.html @@ -45,6 +45,7 @@
+

diff --git a/priceByCustomer.ts b/priceByCustomer.ts index c8e012a..052fc8a 100644 --- a/priceByCustomer.ts +++ b/priceByCustomer.ts @@ -7,6 +7,8 @@ import { export interface PriceByCustomerQuery { paginacion?: Paginacion; + /// Filtro por el código del cliente ("Code" en Customer.) + filter?: string; } export interface Precio { @@ -27,6 +29,9 @@ export async function getPricesByCustomer( ): Promise { let searchParams = new URLSearchParams(); paginacionToSearchParams(options.paginacion, searchParams); + if (options.filter) { + searchParams.set("filter", options.filter); + } const res = await fetch( `${HOST}/api/Aperture/PriceByCustomer?${searchParams.toString()}`, {