removido bun
This commit is contained in:
parent
98bcbff6cf
commit
430ff53c68
26 changed files with 2086 additions and 371 deletions
48
dist-front/NPS/index.js
Normal file
48
dist-front/NPS/index.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { respostaComuns } from "p-respostas";
|
||||
const abrirNps = (emDesenvolvimento) => async (parametros) => {
|
||||
const base_site = emDesenvolvimento ? "http://localhost:5040/nps" : "https://carro-de-boi.idz.one/nps";
|
||||
const base_api = `${base_site}/api`;
|
||||
const { sistema, inquilino, codigo_usuario } = parametros;
|
||||
const nome_local_storage_proxima = `nps_proxima_avaliacao_${sistema}_${codigo_usuario}_${inquilino}_0`;
|
||||
const proxima_avaliacao = localStorage.getItem(nome_local_storage_proxima);
|
||||
if (!proxima_avaliacao) {
|
||||
const url_proxima_avaliacao = new URL(
|
||||
`${base_api}/${sistema}/proxima_avaliacao`
|
||||
);
|
||||
for (const [chave, valor] of Object.entries(parametros)) {
|
||||
url_proxima_avaliacao.searchParams.append(chave, valor);
|
||||
}
|
||||
const response = await fetch(url_proxima_avaliacao.href).then(
|
||||
(resposta) => resposta.json()
|
||||
).catch((error) => respostaComuns.erro(error.message));
|
||||
const proxima_avaliacao2 = response.valor;
|
||||
proxima_avaliacao2 && localStorage.setItem(nome_local_storage_proxima, proxima_avaliacao2);
|
||||
}
|
||||
const abrir_modal = proxima_avaliacao && (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) >= proxima_avaliacao;
|
||||
if (!abrir_modal) {
|
||||
return;
|
||||
}
|
||||
localStorage.removeItem(nome_local_storage_proxima);
|
||||
const urlIfrma = new URL(base_site);
|
||||
for (const [chave, valor] of Object.entries(parametros)) {
|
||||
urlIfrma.searchParams.append(chave, valor);
|
||||
}
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.src = urlIfrma.href;
|
||||
iframe.style.position = "fixed";
|
||||
iframe.style.top = "0";
|
||||
iframe.style.left = "0";
|
||||
iframe.style.width = "100%";
|
||||
iframe.style.height = "100%";
|
||||
iframe.style.border = "none";
|
||||
iframe.style.zIndex = "999999";
|
||||
document.body.appendChild(iframe);
|
||||
window.addEventListener("message", (event) => {
|
||||
if (event.data === "fechar") {
|
||||
document.body.removeChild(iframe);
|
||||
}
|
||||
});
|
||||
};
|
||||
export {
|
||||
abrirNps
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue