@credithub/harlan-components 1.59.7 → 1.59.8
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.
|
@@ -16,6 +16,15 @@ import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
|
16
16
|
import StatusMessage from '../interface/statusMessage';
|
|
17
17
|
import Section from '../section';
|
|
18
18
|
import { Queries, RequestStatus } from '../webservice';
|
|
19
|
+
var validAssuntos = [
|
|
20
|
+
'protesto indevido de títulos',
|
|
21
|
+
'inclusão indevida em cadastro de inadimplentes',
|
|
22
|
+
'liminar',
|
|
23
|
+
'sustação de Protesto',
|
|
24
|
+
'inexequibilidade do titulo / inexequibilidade da obrigação',
|
|
25
|
+
'Adimplemento e Extinção',
|
|
26
|
+
'Inexequibilidade do Título / Inexequibilidade da Obrigação | Tutela de Urgência | Protesto Indevido de Título'
|
|
27
|
+
].map(normalizeName);
|
|
19
28
|
var Liminar = function () {
|
|
20
29
|
var _a, _b, _c;
|
|
21
30
|
var ctx = useContext(Queries.LiminarCenprot);
|
|
@@ -63,6 +72,7 @@ var Liminar = function () {
|
|
|
63
72
|
error: ctx.error ? String(ctx.error) : null
|
|
64
73
|
}
|
|
65
74
|
});
|
|
75
|
+
debugger;
|
|
66
76
|
// If data hasn't changed and we've already processed, skip reprocessing
|
|
67
77
|
if (currentDataHash === dataHashRef.current && processedRef.current) {
|
|
68
78
|
return;
|
|
@@ -73,15 +83,6 @@ var Liminar = function () {
|
|
|
73
83
|
var empresas = globalData.processosJuridicosData.empresa;
|
|
74
84
|
// Begin the actual data processing
|
|
75
85
|
var empresaNomeNormalizado = normalizeName((carousel === null || carousel === void 0 ? void 0 : carousel.name) || '');
|
|
76
|
-
var validAssuntos = [
|
|
77
|
-
'protesto indevido de títulos',
|
|
78
|
-
'inclusão indevida em cadastro de inadimplentes',
|
|
79
|
-
'liminar',
|
|
80
|
-
'sustação de Protesto',
|
|
81
|
-
'inexequibilidade do titulo / inexequibilidade da obrigação',
|
|
82
|
-
'Adimplemento e Extinção',
|
|
83
|
-
'Inexequibilidade do Título / Inexequibilidade da Obrigação | Tutela de Urgência | Protesto Indevido de Título'
|
|
84
|
-
].map(normalizeName);
|
|
85
86
|
// Look for valid processes
|
|
86
87
|
var processosAtivo = empresas === null || empresas === void 0 ? void 0 : empresas.filter(function (processo) {
|
|
87
88
|
var _a;
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import ProcessosJuridicosIcon from '../../assets/icones/processosJuridicos';
|
|
13
13
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
14
|
-
import React, { useContext, useEffect,
|
|
14
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
15
15
|
import StatusMessage from '../interface/statusMessage';
|
|
16
16
|
import Section from '../section';
|
|
17
17
|
import { Queries, RequestStatus } from '../webservice';
|
|
@@ -20,28 +20,68 @@ var ProcessosJuridicos = function (_a) {
|
|
|
20
20
|
var onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico;
|
|
21
21
|
var ctx = useContext(Queries.ProcessosJuridicos);
|
|
22
22
|
var setData = useGlobalData().setData;
|
|
23
|
-
|
|
23
|
+
// Use a ref instead of state to track whether data has been processed
|
|
24
|
+
var processedRef = useRef(false);
|
|
25
|
+
var ctxHashRef = useRef('');
|
|
24
26
|
useEffect(function () {
|
|
25
27
|
var _a;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// Create a hash of the current context state to detect changes
|
|
29
|
+
var currentCtxHash = JSON.stringify({
|
|
30
|
+
type: ctx.type,
|
|
31
|
+
documentId: ctx.document ? true : false
|
|
32
|
+
});
|
|
33
|
+
// Skip if we've already processed this data state
|
|
34
|
+
if (currentCtxHash === ctxHashRef.current && processedRef.current) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Update our reference to the current context
|
|
38
|
+
ctxHashRef.current = currentCtxHash;
|
|
39
|
+
// Handle error or empty response
|
|
40
|
+
if ((ctx.type === RequestStatus.Error || ctx.type === RequestStatus.Empty) && !processedRef.current) {
|
|
41
|
+
setData(function (prevState) {
|
|
42
|
+
var _a;
|
|
43
|
+
// Avoid unnecessary state updates if data hasn't changed
|
|
44
|
+
if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
|
|
45
|
+
Array.isArray(prevState.processosJuridicosData.empresa) &&
|
|
46
|
+
prevState.processosJuridicosData.empresa.length === 0) {
|
|
47
|
+
return prevState;
|
|
48
|
+
}
|
|
49
|
+
return __assign(__assign({}, prevState), { processosJuridicosData: {
|
|
50
|
+
empresa: [],
|
|
51
|
+
isLoaded: true
|
|
52
|
+
} });
|
|
53
|
+
});
|
|
54
|
+
processedRef.current = true;
|
|
31
55
|
return;
|
|
32
56
|
}
|
|
33
|
-
|
|
57
|
+
// Handle successful response
|
|
58
|
+
if (ctx.type === RequestStatus.Success && !processedRef.current && ctx.document) {
|
|
34
59
|
var qtyProcessos_1 = (_a = ctx.document.empresa) === null || _a === void 0 ? void 0 : _a.length;
|
|
35
60
|
if (qtyProcessos_1) {
|
|
36
61
|
var processosJuridicosData_1 = {
|
|
37
62
|
empresa: ctx.document.empresa,
|
|
38
63
|
isLoaded: true
|
|
39
64
|
};
|
|
40
|
-
setData(function (prevState) {
|
|
41
|
-
|
|
65
|
+
setData(function (prevState) {
|
|
66
|
+
var _a;
|
|
67
|
+
// Avoid unnecessary state updates
|
|
68
|
+
if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
|
|
69
|
+
JSON.stringify(prevState.processosJuridicosData.empresa) ===
|
|
70
|
+
JSON.stringify(processosJuridicosData_1.empresa)) {
|
|
71
|
+
return prevState;
|
|
72
|
+
}
|
|
73
|
+
return __assign(__assign({}, prevState), { processosJuridicos: qtyProcessos_1 || 0, processosJuridicosData: processosJuridicosData_1 });
|
|
74
|
+
});
|
|
75
|
+
processedRef.current = true;
|
|
42
76
|
}
|
|
43
77
|
}
|
|
44
|
-
}, [ctx.type, ctx.document,
|
|
78
|
+
}, [ctx.type, ctx.document, setData]);
|
|
79
|
+
// Reset processed state when context changes to loading
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
if (ctx.type === RequestStatus.Loading) {
|
|
82
|
+
processedRef.current = false;
|
|
83
|
+
}
|
|
84
|
+
}, [ctx.type]);
|
|
45
85
|
return (React.createElement(Section, { ctx: ctx, title: "Processos Jur\u00EDdicos", subtitle: "Veja os processos jur\u00EDdicos para este documento.", icon: ProcessosJuridicosIcon, minimized: false, onSuccess: function (data) {
|
|
46
86
|
var _a;
|
|
47
87
|
var qtyProcessos = (_a = data.empresa) === null || _a === void 0 ? void 0 : _a.length;
|