@credithub/harlan-components 1.53.5 → 1.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/liminar/liminar.js +33 -25
- package/dist/components/protestos/protestosList.d.ts +2 -1
- package/dist/components/protestos/protestosList.js +8 -2
- package/dist/utils/protestosp.d.ts +9 -0
- package/dist/utils/protestosp.js +67 -0
- package/lib/cjs/index.js +109 -28
- package/lib/esm/index.js +109 -28
- package/package.json +1 -1
|
@@ -17,44 +17,52 @@ import StatusMessage from '../interface/statusMessage';
|
|
|
17
17
|
import Section from '../section';
|
|
18
18
|
import { Queries, RequestStatus } from '../webservice';
|
|
19
19
|
var Liminar = function () {
|
|
20
|
+
var _a;
|
|
20
21
|
var ctx = useContext(Queries.LiminarCenprot);
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var _c = useState(false), hideSection = _c[0], setHideSection = _c[1];
|
|
22
|
+
var _b = useGlobalData(), globalData = _b.data, setData = _b.setData;
|
|
23
|
+
var _c = useState(false), checkCompleted = _c[0], setCheckCompleted = _c[1];
|
|
24
24
|
useEffect(function () {
|
|
25
|
-
var _a, _b, _c, _d, _e
|
|
25
|
+
var _a, _b, _c, _d, _e;
|
|
26
26
|
var processosJuridicosData = (_a = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) !== null && _a !== void 0 ? _a : {
|
|
27
27
|
isLoaded: true,
|
|
28
28
|
empresa: []
|
|
29
29
|
};
|
|
30
|
-
if (
|
|
31
|
-
((_b = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _b === void 0 ? void 0 : _b.carousel) &&
|
|
32
|
-
(processosJuridicosData === null || processosJuridicosData === void 0 ? void 0 : processosJuridicosData.isLoaded)) {
|
|
30
|
+
if (((_b = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _b === void 0 ? void 0 : _b.carousel) && (processosJuridicosData === null || processosJuridicosData === void 0 ? void 0 : processosJuridicosData.isLoaded)) {
|
|
33
31
|
var empresaNome = globalData.dossie.carousel.name || '';
|
|
34
32
|
var empresaNomeNormalizado_1 = normalizeName(empresaNome);
|
|
35
|
-
var
|
|
33
|
+
var validAssuntos_1 = [
|
|
34
|
+
'protesto indevido de títulos',
|
|
35
|
+
'inclusão indevida em cadastro de inadimplentes',
|
|
36
|
+
'liminar',
|
|
37
|
+
'sustação de Protesto',
|
|
38
|
+
'inexequibilidade do titulo / inexigibilidade da obrigação',
|
|
39
|
+
'Adimplemento e Extinção',
|
|
40
|
+
'Inexequibilidade do Título / Inexequibilidade da Obrigação | Tutela de Urgência | Protesto Indevido de Título'
|
|
41
|
+
].map(normalizeName);
|
|
42
|
+
var processosAtivo = (_d = (_c = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _c === void 0 ? void 0 : _c.empresa) === null || _d === void 0 ? void 0 : _d.filter(function (processo) {
|
|
36
43
|
var _a;
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
return (
|
|
40
|
-
|
|
44
|
+
var hasAtivoEnvolvido = (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (envolvido) {
|
|
45
|
+
var nomeEnvolvidoNormalizado = normalizeName(envolvido.nome_sem_filtro);
|
|
46
|
+
return (envolvido.envolvido_tipo === 'Ativo' &&
|
|
47
|
+
similarNames(nomeEnvolvidoNormalizado, empresaNomeNormalizado_1));
|
|
41
48
|
});
|
|
42
|
-
})) === null || _e === void 0 ? void 0 : _e.filter(function (processo) {
|
|
43
49
|
var assuntos = Array.isArray(processo.assuntos)
|
|
44
50
|
? processo.assuntos
|
|
45
51
|
: [processo.assuntos];
|
|
46
|
-
|
|
52
|
+
var hasValidAssunto = assuntos.some(function (assunto) {
|
|
47
53
|
var assuntoNormalizado = normalizeName(assunto);
|
|
48
|
-
return (
|
|
49
|
-
similarNames(assuntoNormalizado,
|
|
54
|
+
return validAssuntos_1.some(function (valid) {
|
|
55
|
+
return similarNames(assuntoNormalizado, valid);
|
|
56
|
+
});
|
|
50
57
|
});
|
|
58
|
+
return hasAtivoEnvolvido && hasValidAssunto;
|
|
51
59
|
});
|
|
52
60
|
var indiciosDeLiminar_1 = false;
|
|
53
61
|
if (ctx.type === RequestStatus.Error) {
|
|
54
62
|
console.error('Erro na requisição de liminares:', ctx.error || 'Erro desconhecido');
|
|
55
63
|
}
|
|
56
64
|
else if (ctx.type === RequestStatus.Success) {
|
|
57
|
-
indiciosDeLiminar_1 = ((
|
|
65
|
+
indiciosDeLiminar_1 = ((_e = ctx.document) === null || _e === void 0 ? void 0 : _e.indiciosDeLiminar) === true;
|
|
58
66
|
}
|
|
59
67
|
var hasLiminarFromProcessos = processosAtivo && processosAtivo.length > 0;
|
|
60
68
|
var finalStatus_1 = indiciosDeLiminar_1 || hasLiminarFromProcessos
|
|
@@ -64,18 +72,18 @@ var Liminar = function () {
|
|
|
64
72
|
indiciosDeLiminar: indiciosDeLiminar_1,
|
|
65
73
|
message: finalStatus_1
|
|
66
74
|
} })); });
|
|
67
|
-
|
|
68
|
-
if (!indiciosDeLiminar_1 && !hasLiminarFromProcessos) {
|
|
69
|
-
setHideSection(true);
|
|
70
|
-
}
|
|
75
|
+
setCheckCompleted(true);
|
|
71
76
|
}
|
|
72
|
-
}, [ctx,
|
|
73
|
-
|
|
77
|
+
}, [ctx, globalData, setData]);
|
|
78
|
+
// Se os dados foram processados e a liminar não foi encontrada, não renderiza a seção
|
|
79
|
+
if (checkCompleted && ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.message) === 'Não encontrado') {
|
|
74
80
|
return null;
|
|
75
|
-
|
|
81
|
+
}
|
|
82
|
+
var derivedCtx = !checkCompleted
|
|
83
|
+
? __assign(__assign({}, ctx), { type: RequestStatus.Loading }) : __assign(__assign({}, ctx), { type: ctx.type === RequestStatus.Error ? RequestStatus.Success : ctx.type, document: ctx.type === RequestStatus.Error
|
|
76
84
|
? { indiciosDeLiminar: false }
|
|
77
85
|
: ctx.document });
|
|
78
|
-
return (React.createElement(Section, { title: "Liminares para Remo\u00E7\u00E3o de Protesto", subtitle: "Ind\u00EDcios de liminares para oculta\u00E7\u00E3o de registros.", icon: ProtestosIcon, ctx:
|
|
86
|
+
return (React.createElement(Section, { title: "Liminares para Remo\u00E7\u00E3o de Protesto", subtitle: "Ind\u00EDcios de liminares para oculta\u00E7\u00E3o de registros.", icon: ProtestosIcon, ctx: derivedCtx, onSuccess: function (doc) {
|
|
79
87
|
var _a;
|
|
80
88
|
var globalMessage = ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.message) || 'Não encontrado';
|
|
81
89
|
return {
|
|
@@ -2,8 +2,9 @@ import React from 'react';
|
|
|
2
2
|
export declare const ProtestoItem: React.MemoExoticComponent<({ protesto }: {
|
|
3
3
|
protesto: Node;
|
|
4
4
|
}) => React.JSX.Element>;
|
|
5
|
-
export declare const Instrumento: ({ nm_chave }: {
|
|
5
|
+
export declare const Instrumento: ({ nm_chave, cpfCnpj }: {
|
|
6
6
|
nm_chave?: string;
|
|
7
|
+
cpfCnpj?: string;
|
|
7
8
|
}) => React.JSX.Element | null;
|
|
8
9
|
export declare const ProtestosList: React.FC<{
|
|
9
10
|
protestos: Node[];
|
|
@@ -42,6 +42,7 @@ import AddItemField from '../common/addItem';
|
|
|
42
42
|
import Button from '../common/button';
|
|
43
43
|
import { ResultContent } from '../interface/result';
|
|
44
44
|
import { WebService } from '../webservice';
|
|
45
|
+
import { openFormThenRedirect } from '../../utils/protestosp';
|
|
45
46
|
export var ProtestoItem = memo(function (_a) {
|
|
46
47
|
var protesto = _a.protesto;
|
|
47
48
|
var getField = function (path, formatter) {
|
|
@@ -59,10 +60,10 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
59
60
|
React.createElement(AddItemField, { name: "Possui Anu\u00EAncia / Protesto Pago", value: formatBooleanField(getField('./temAnuencia')) }),
|
|
60
61
|
React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(getField('./valor')) }),
|
|
61
62
|
getField('./vl_custas') && (React.createElement(AddItemField, { name: "Custas de Cart\u00F3rio para Baixa", value: formatMoney(getField('./vl_custas')) })),
|
|
62
|
-
React.createElement(Instrumento, { nm_chave: getField('./nm_chave') })));
|
|
63
|
+
React.createElement(Instrumento, { nm_chave: getField('./nm_chave'), cpfCnpj: getField('//consulta/@documento') })));
|
|
63
64
|
});
|
|
64
65
|
export var Instrumento = function (_a) {
|
|
65
|
-
var nm_chave = _a.nm_chave;
|
|
66
|
+
var nm_chave = _a.nm_chave, cpfCnpj = _a.cpfCnpj;
|
|
66
67
|
var client = useContext(WebService);
|
|
67
68
|
var _b = React.useState(), error = _b[0], setError = _b[1];
|
|
68
69
|
var _c = React.useState(false), isLoading = _c[0], setIsLoading = _c[1];
|
|
@@ -88,6 +89,11 @@ export var Instrumento = function (_a) {
|
|
|
88
89
|
return [3 /*break*/, 6];
|
|
89
90
|
case 4:
|
|
90
91
|
e_1 = _a.sent();
|
|
92
|
+
if (/^35/.test(nm_chave)) {
|
|
93
|
+
/* Instrumento de SP */
|
|
94
|
+
openFormThenRedirect(nm_chave, cpfCnpj);
|
|
95
|
+
return [2 /*return*/];
|
|
96
|
+
}
|
|
91
97
|
console.error(e_1);
|
|
92
98
|
setError(true);
|
|
93
99
|
return [3 /*break*/, 6];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opens a new window with a form that auto-submits via POST to the target URL.
|
|
3
|
+
* The new window then closes (after 2 seconds), and once closed,
|
|
4
|
+
* the "imprimir" page is opened in a new window.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} chaveUnica - The ChaveUnica value.
|
|
7
|
+
* @param {string} devedorPrincipal - A CPF (11 digits) or CNPJ (14 digits).
|
|
8
|
+
*/
|
|
9
|
+
export declare function openFormThenRedirect(chaveUnica: string, devedorPrincipal: string): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Helper to strip non-digit characters.
|
|
2
|
+
function getDigits(str) {
|
|
3
|
+
return str.replace(/\D/g, '');
|
|
4
|
+
}
|
|
5
|
+
// Format CPF (11 digits) as XXX.XXX.XXX-XX.
|
|
6
|
+
function formatCPF(cpf) {
|
|
7
|
+
var digits = getDigits(cpf);
|
|
8
|
+
if (digits.length !== 11)
|
|
9
|
+
return cpf;
|
|
10
|
+
return digits.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$4');
|
|
11
|
+
}
|
|
12
|
+
// Format CNPJ (14 digits) as XX.XXX.XXX/XXXX-XX.
|
|
13
|
+
function formatCNPJ(cnpj) {
|
|
14
|
+
var digits = getDigits(cnpj);
|
|
15
|
+
if (digits.length !== 14)
|
|
16
|
+
return cnpj;
|
|
17
|
+
return digits.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5');
|
|
18
|
+
}
|
|
19
|
+
// Format ChaveUnica if it has 23 digits into a dash-separated pattern.
|
|
20
|
+
function formatChaveUnica(chave) {
|
|
21
|
+
var digits = getDigits(chave);
|
|
22
|
+
if (digits.length !== 23)
|
|
23
|
+
return chave;
|
|
24
|
+
return digits.replace(/(\d{3})(\d{4})(\d{4})(\d{4})(\d{4})(\d{4})/, '$1-$2-$3-$4-$5-$6');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Opens a new window with a form that auto-submits via POST to the target URL.
|
|
28
|
+
* The new window then closes (after 2 seconds), and once closed,
|
|
29
|
+
* the "imprimir" page is opened in a new window.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} chaveUnica - The ChaveUnica value.
|
|
32
|
+
* @param {string} devedorPrincipal - A CPF (11 digits) or CNPJ (14 digits).
|
|
33
|
+
*/
|
|
34
|
+
export function openFormThenRedirect(chaveUnica, devedorPrincipal) {
|
|
35
|
+
// Format the ChaveUnica.
|
|
36
|
+
var formattedChaveUnica = formatChaveUnica(chaveUnica);
|
|
37
|
+
// Determine whether devedorPrincipal is CPF or CNPJ.
|
|
38
|
+
var devedorDigits = getDigits(devedorPrincipal);
|
|
39
|
+
var formattedDevedorPrincipal, devedorPrincipalTipo;
|
|
40
|
+
if (devedorDigits.length === 11) {
|
|
41
|
+
formattedDevedorPrincipal = formatCPF(devedorPrincipal);
|
|
42
|
+
devedorPrincipalTipo = '1';
|
|
43
|
+
}
|
|
44
|
+
else if (devedorDigits.length === 14) {
|
|
45
|
+
formattedDevedorPrincipal = formatCNPJ(devedorPrincipal);
|
|
46
|
+
devedorPrincipalTipo = '2';
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// If not recognized, use the provided value and default type.
|
|
50
|
+
formattedDevedorPrincipal = devedorPrincipal;
|
|
51
|
+
devedorPrincipalTipo = '1';
|
|
52
|
+
}
|
|
53
|
+
// Open a new window.
|
|
54
|
+
var newWindow = window.open('', '_blank');
|
|
55
|
+
if (!newWindow) {
|
|
56
|
+
alert('Please allow popups for this site.');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Build the HTML document for the new window with the form.
|
|
60
|
+
var html = "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Instrumento de S\u00E3o Paulo</title>\n </head>\n <body>\n <form id=\"submissionForm\" method=\"POST\" action=\"https://protestosp.com.br/Validacoes/Consultar\">\n <input type=\"hidden\" name=\"vTipoDocumento\" value=\"1\">\n <input type=\"hidden\" name=\"ChaveUnica\" value=\"".concat(formattedChaveUnica, "\">\n <input type=\"hidden\" name=\"DevedorPrincipalTipo\" value=\"").concat(devedorPrincipalTipo, "\">\n <input type=\"hidden\" name=\"DevedorPrincipal\" value=\"").concat(formattedDevedorPrincipal, "\">\n <input type=\"hidden\" name=\"ChaveValidacao\" value=\"P35-5030-8000-\">\n <input type=\"hidden\" name=\"PesquisadoDocumentoTipo\" value=\"0\">\n <input type=\"hidden\" name=\"PesquisadoDocumento\" value=\"\">\n <input type=\"hidden\" name=\"X-Requested-With\" value=\"XMLHttpRequest\">\n </form>\n <script>\n // Auto-submit the form.\n document.getElementById('submissionForm').submit();\n // After 2 seconds, close this window.\n </script>\n </body>\n </html>\n ");
|
|
61
|
+
newWindow.document.open();
|
|
62
|
+
newWindow.document.write(html);
|
|
63
|
+
setTimeout(function () {
|
|
64
|
+
newWindow.location.href = "https://protestosp.com.br/Validacoes/ImprimirDocumento";
|
|
65
|
+
}, 3000);
|
|
66
|
+
}
|
|
67
|
+
// openFormThenRedirect("35503080001809805230314", "37554311816");
|