Compare commits

..

No commits in common. "cf868a92e946a75d3bbf944df5d430047e2a36dc" and "5d795107808b02afc810fa743e74502b5c9b1aca" have entirely different histories.

5 changed files with 5 additions and 79 deletions

View file

@ -11,7 +11,6 @@ import {
Producto,
Precio,
getPublications,
getPriceLists,
} from "../index.js";
// TODO: hacerlo input
@ -54,22 +53,18 @@ function objectToDom(object: any) {
}
async function showResponse(statusEl: Element | null, promise: Promise<any>) {
if (statusEl) clear(statusEl);
try {
const response = await promise;
if (statusEl) {
clear(statusEl);
statusEl.append("¡Funcionó!");
if (response) {
statusEl.append(" Respuesta:", objectToDom(response));
}
} else alert(`¡Funcionó!${response ? ` Respuesta: ${response}` : ""}`);
} catch (error) {
if (statusEl) {
clear(statusEl);
statusEl.append("Hubo un error :(", objectToDom(error));
} else {
alert(`Hubo un error: ${error}`);
}
if (statusEl) statusEl.append("Hubo un error :(", objectToDom(error));
else alert(`Hubo un error: ${error}`);
}
}
@ -99,11 +94,6 @@ setupForm("#price-by-customer", (event) =>
filter: (event.target! as any).filter.value,
})
);
setupForm("#price-list", (event) =>
getPriceLists(HOST, token(), {
filter: (event.target! as any).filter.value,
})
);
setupForm("#customers", () => getCustomers(HOST, token(), {}));
let customer: Customer | null = null;
@ -196,7 +186,7 @@ setupForm("#pedido", async () => {
})),
Customer: {
CustomerID: 1,
User: customer.BusinessName,
User: "ADMIN",
IVACategoryCode: customer.IvaCategoryCode,
Email: "api@axoft.com", // En prod: customer.Email, tenemos que usar esto porque el usuario de prueba no tiene Email
ProvinceCode: customer.ProvinceCode,

View file

@ -23,12 +23,6 @@
pre {
overflow-x: auto;
}
summary {
position: sticky;
top: 0px;
background: white;
}
</style>
<label for="token-input">Access token: </label>
@ -65,15 +59,9 @@
<p class="status"></p>
</form>
<form id="price-list">
<button>Conseguir listas de precios</button>
<input name="filter" type="text" placeholder="Filtro por ID (opcional)" />
<p class="status"></p>
</form>
<form id="customers">
<button>Conseguir clientes</button>
<p class="status"></p>
<button>Conseguir clientes</button>
</form>
<section>

View file

@ -4,7 +4,6 @@ export * from "./dummy.js";
export * from "./product.js";
export * from "./price.js";
export * from "./priceByCustomer.js";
export * from "./priceList.js";
export * from "./customer.js";
export * from "./order.js";
export * from "./publications.js";

View file

@ -2,9 +2,6 @@ import { Paginacion, paginacionToSearchParams, Paging } from "./common.js";
export interface PriceQuery {
paginacion?: Paginacion;
/**
* Filtrar por PriceListNumber
*/
filter?: string;
SKUCode?: string;
}

View file

@ -1,48 +0,0 @@
import { Paginacion, paginacionToSearchParams, Paging } from "./common.js";
export interface PriceListQuery {
paginacion?: Paginacion;
filter?: string;
}
export interface PriceList {
PriceListNumber: number;
Description: string;
CommonCurrency: boolean;
IvaIncluded: boolean;
InternalTaxIncluded: boolean;
ValidityDateSince: string;
ValidityDateUntil: string;
Disabled: boolean;
}
export interface PriceListResponse {
Paging: Paging;
Data: PriceList[];
}
export async function getPriceLists(
host: string,
token: string,
options: PriceListQuery
): Promise<PriceListResponse> {
let searchParams = new URLSearchParams();
paginacionToSearchParams(options.paginacion, searchParams);
if (options.filter) {
searchParams.set("filter", options.filter);
}
const res = await fetch(
`${host}/api/Aperture/PriceList?${searchParams.toString()}`,
{
headers: {
accesstoken: token,
},
}
);
const json = await res.json();
console.debug(json);
if (json.Message) {
throw new Error(`Tango: ${json.Message}`);
}
return json;
}