implementado drive pilão de dados
This commit is contained in:
parent
a1e543cfb8
commit
daae40f4b2
54 changed files with 1476 additions and 19 deletions
75
src/pilao-de-dados/consultar_serie.ts
Normal file
75
src/pilao-de-dados/consultar_serie.ts
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import type { tipoResposta } from "p-respostas"
|
||||
import { respostaComuns } from "p-respostas"
|
||||
import { z } from "zod"
|
||||
import { PREFIXO, type zp_produto_conta } from "./_variaveis"
|
||||
import type { zp_registrar_serie } from "./registrar_serie"
|
||||
|
||||
//consultar compilação
|
||||
|
||||
export const zp_consultar_serie = z.object({
|
||||
identificador: z.string(),
|
||||
})
|
||||
|
||||
export const consultar_serie = ({
|
||||
emDesenvolvimento,
|
||||
parametros: { identificador },
|
||||
cliente: { conta, produto },
|
||||
}: {
|
||||
emDesenvolvimento?: boolean | undefined | null
|
||||
|
||||
/** Identificação do cliente */
|
||||
cliente: z.infer<typeof zp_produto_conta>
|
||||
parametros: z.infer<typeof zp_consultar_serie>
|
||||
}) => {
|
||||
const dados = async (): Promise<
|
||||
tipoResposta<{
|
||||
registros: any[]
|
||||
legenda: string
|
||||
serie: z.infer<typeof zp_registrar_serie>
|
||||
}>
|
||||
> => {
|
||||
const url = new URL(
|
||||
`${
|
||||
emDesenvolvimento
|
||||
? "http://127.0.0.1:5080"
|
||||
: "https://carro-de-boi.idz.one"
|
||||
}${`${PREFIXO}/consultar-serie/${produto}/${conta}`}`,
|
||||
)
|
||||
|
||||
const resp = await 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 as tipoResposta<any>)
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
const url = (): string => {
|
||||
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,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue