47 lines
2.1 KiB
JavaScript
47 lines
2.1 KiB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
import { respostaComuns } from "p-respostas";
|
|
import { z } from "zod";
|
|
import { PREFIXO, tiposSeriesAgregacoes, } from "./_variaveis";
|
|
//consultar compilação
|
|
export const zp_consultar_serie = z.object({
|
|
identificador: z.string(),
|
|
});
|
|
export const consultar_serie = ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }) => {
|
|
const dados = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
const url = new URL(`${emDesenvolvimento
|
|
? "http://127.0.0.1:5080"
|
|
: "https://carro-de-boi.idz.one"}${`${PREFIXO}/${tiposSeriesAgregacoes.enum.contagem}/${produto}/${conta}`}`);
|
|
const resp = yield fetch(url.toString(), {
|
|
method: "POST",
|
|
body: JSON.stringify({
|
|
identificador,
|
|
}),
|
|
headers: { "Content-Type": "application/json" },
|
|
})
|
|
.then((r) => r.json())
|
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
|
.then((r) => r);
|
|
return resp;
|
|
});
|
|
const url = () => {
|
|
const vUrl = new URL(`${emDesenvolvimento
|
|
? "http://127.0.0.1:5081"
|
|
: "https://carro-de-boi.idz.one"}${PREFIXO}/grafico`);
|
|
vUrl.searchParams.append("produto", produto);
|
|
vUrl.searchParams.append("conta", conta);
|
|
vUrl.searchParams.append("identificador", identificador);
|
|
return vUrl.href;
|
|
};
|
|
return {
|
|
dados,
|
|
url,
|
|
};
|
|
};
|