@credithub/harlan-components 1.82.2 → 1.82.3

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.
@@ -49,6 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  import ProtestosIcon from '../../assets/icones/protestos';
50
50
  import { useGlobalData } from '../../contexts/globalDataContext';
51
51
  import theme from '../../styles/theme';
52
+ import { isDocumentHistoryReady } from '../../utils/isGlobalReady';
52
53
  import { formatMoney } from '../../utils/number';
53
54
  import { normalizeName, normalizeNameStrong, similarCompanyNames } from '../../utils/similarNames';
54
55
  import { hasOneOfTags } from '../../utils/tags';
@@ -83,25 +84,26 @@ var businessTypes = [
83
84
  'cooperativa'
84
85
  ];
85
86
  var Liminar = function (_a) {
86
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
87
- var _o = _a.isFinancial, isFinancial = _o === void 0 ? false : _o, hasCredits = _a.hasCredits, _p = _a.tags, tags = _p === void 0 ? [] : _p;
87
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
88
+ var _p = _a.isFinancial, isFinancial = _p === void 0 ? true : _p, hasCredits = _a.hasCredits, _q = _a.tags, tags = _q === void 0 ? [] : _q;
88
89
  var ctx = useContext(Queries.LiminarCenprot);
89
- var _q = useGlobalData(), globalData = _q.data, setData = _q.setData;
90
+ var _r = useGlobalData(), globalData = _r.data, setData = _r.setData;
90
91
  var fetchLiminarProtestosDoPassado = useLiminarProtestosDoPassado({
91
92
  documento: ((_c = (_b = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _b === void 0 ? void 0 : _b.carousel) === null || _c === void 0 ? void 0 : _c.document) || ''
92
93
  }).fetchLiminarProtestosDoPassado;
93
- var _r = useState(false), isLoadingLiminarProtestosDoPassado = _r[0], setIsLoadingLiminarProtestosDoPassado = _r[1];
94
+ console.log((_d = globalData === null || globalData === void 0 ? void 0 : globalData.documentHistory) === null || _d === void 0 ? void 0 : _d.protestoLiminar);
95
+ var _s = useState(false), isLoadingLiminarProtestosDoPassado = _s[0], setIsLoadingLiminarProtestosDoPassado = _s[1];
94
96
  var processedRef = useRef(false);
95
97
  var dataHashRef = useRef('');
96
98
  var invertedIdsRef = useRef([]);
97
- var _s = useState(false), isTooltipVisible = _s[0], setTooltipVisible = _s[1];
98
- var _t = useState(false), isEmailModalOpen = _t[0], setIsEmailModalOpen = _t[1];
99
- var _u = useState(''), emailModalMessage = _u[0], setEmailModalMessage = _u[1];
99
+ var _t = useState(false), isTooltipVisible = _t[0], setTooltipVisible = _t[1];
100
+ var _u = useState(false), isEmailModalOpen = _u[0], setIsEmailModalOpen = _u[1];
101
+ var _v = useState(''), emailModalMessage = _v[0], setEmailModalMessage = _v[1];
100
102
  var liminarMailPrice = useMemo(function () {
101
103
  var isDiamanteNew = hasOneOfTags(tags, ['diamante-new']);
102
104
  return isDiamanteNew ? 0 : 50000;
103
105
  }, [tags]);
104
- var _v = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _v.fetch, isEmailSending = _v.isLoading, emailError = _v.error;
106
+ var _w = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _w.fetch, isEmailSending = _w.isLoading, emailError = _w.error;
105
107
  var hideTt = useRef();
106
108
  /*
107
109
  * Extrai e normaliza os tipos de documento presentes em ctx.document, retornando sempre um array de strings em minúsculo.
@@ -121,7 +123,6 @@ var Liminar = function (_a) {
121
123
  var carouselName = (_c = (_b = (_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '';
122
124
  var empresas = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa;
123
125
  var nomeNormTokens = normalizeNameStrong(carouselName);
124
- console.log('nomeNormTokens', nomeNormTokens);
125
126
  if (!Array.isArray(empresas))
126
127
  return [];
127
128
  return empresas.filter(function (proc) {
@@ -140,14 +141,13 @@ var Liminar = function (_a) {
140
141
  });
141
142
  });
142
143
  }, [
143
- (_d = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _d === void 0 ? void 0 : _d.carousel,
144
- (_e = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _e === void 0 ? void 0 : _e.empresa
144
+ (_e = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _e === void 0 ? void 0 : _e.carousel,
145
+ (_f = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _f === void 0 ? void 0 : _f.empresa
145
146
  ]);
146
- console.log('processosComAssuntoValido', processosComAssuntoValido);
147
147
  /*
148
148
  * Identifica as origens de liminares detectadas e verifica se existe liminar de protesto invertida
149
149
  */
150
- var _w = useMemo(function () {
150
+ var _x = useMemo(function () {
151
151
  var _a, _b;
152
152
  var labels = new Set();
153
153
  var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
@@ -182,14 +182,17 @@ var Liminar = function (_a) {
182
182
  ctx.document,
183
183
  tiposDocumento,
184
184
  processosComAssuntoValido,
185
- (_f = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _f === void 0 ? void 0 : _f.indiciosDeLiminarProtestosDoPassado
186
- ]), origensDetectadas = _w.origensDetectadas, foundBusinessEntity = _w.foundBusinessEntity;
185
+ (_g = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _g === void 0 ? void 0 : _g.indiciosDeLiminarProtestosDoPassado
186
+ ]), origensDetectadas = _x.origensDetectadas, foundBusinessEntity = _x.foundBusinessEntity;
187
+ var documentHistoryReady = useMemo(function () { return isDocumentHistoryReady(globalData); }, [globalData]);
187
188
  useEffect(function () {
189
+ if (!documentHistoryReady)
190
+ return;
188
191
  var fetch = function () { return __awaiter(void 0, void 0, void 0, function () {
189
192
  var dossie, processosJuridicos, depsLoaded, newIds, hash, indiciosApi, indiciosDeLiminarProtestosDoPassado, protestosDoPassadoIds, _a, possuiIndiciosDeLiminarProtestosDoPassado, protestosIds, finalStatus, descricaoLiminar;
190
- var _b, _c, _d;
191
- return __generator(this, function (_e) {
192
- switch (_e.label) {
193
+ var _b, _c, _d, _e;
194
+ return __generator(this, function (_f) {
195
+ switch (_f.label) {
193
196
  case 0:
194
197
  dossie = globalData === null || globalData === void 0 ? void 0 : globalData.dossie;
195
198
  processosJuridicos = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData;
@@ -211,13 +214,13 @@ var Liminar = function (_a) {
211
214
  indiciosApi = ((_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar) === true;
212
215
  indiciosDeLiminarProtestosDoPassado = false;
213
216
  protestosDoPassadoIds = '';
214
- if (!(!indiciosApi &&
215
- !processosComAssuntoValido.length &&
216
- ((_d = globalData === null || globalData === void 0 ? void 0 : globalData.documentHistory) === null || _d === void 0 ? void 0 : _d.protestoLiminar))) return [3 /*break*/, 2];
217
+ console.log('status Protesto Liminar', (_d = globalData === null || globalData === void 0 ? void 0 : globalData.documentHistory) === null || _d === void 0 ? void 0 : _d.protestoLiminar);
218
+ if (!((_e = globalData === null || globalData === void 0 ? void 0 : globalData.documentHistory) === null || _e === void 0 ? void 0 : _e.protestoLiminar)) return [3 /*break*/, 2];
219
+ console.log('entrou');
217
220
  setIsLoadingLiminarProtestosDoPassado(true);
218
221
  return [4 /*yield*/, fetchLiminarProtestosDoPassado()];
219
222
  case 1:
220
- _a = _e.sent(), possuiIndiciosDeLiminarProtestosDoPassado = _a.possuiIndiciosDeLiminarProtestosDoPassado, protestosIds = _a.protestosDoPassadoIds;
223
+ _a = _f.sent(), possuiIndiciosDeLiminarProtestosDoPassado = _a.possuiIndiciosDeLiminarProtestosDoPassado, protestosIds = _a.protestosDoPassadoIds;
221
224
  if (possuiIndiciosDeLiminarProtestosDoPassado) {
222
225
  origensDetectadas.push('Liminar no Cenprot');
223
226
  indiciosDeLiminarProtestosDoPassado =
@@ -225,7 +228,7 @@ var Liminar = function (_a) {
225
228
  protestosDoPassadoIds = protestosIds.join(',');
226
229
  }
227
230
  setIsLoadingLiminarProtestosDoPassado(false);
228
- _e.label = 2;
231
+ _f.label = 2;
229
232
  case 2:
230
233
  finalStatus = indiciosApi ||
231
234
  processosComAssuntoValido.length ||
@@ -262,13 +265,14 @@ var Liminar = function (_a) {
262
265
  ctx.document,
263
266
  globalData === null || globalData === void 0 ? void 0 : globalData.dossie,
264
267
  globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData,
268
+ globalData === null || globalData === void 0 ? void 0 : globalData.documentHistory,
265
269
  processosComAssuntoValido,
266
270
  setData,
267
271
  foundBusinessEntity
268
272
  ]);
269
273
  var ready = processedRef.current &&
270
- !!((_g = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _g === void 0 ? void 0 : _g.isLoaded) &&
271
- !!((_h = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _h === void 0 ? void 0 : _h.carousel) &&
274
+ !!((_h = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _h === void 0 ? void 0 : _h.isLoaded) &&
275
+ !!((_j = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _j === void 0 ? void 0 : _j.carousel) &&
272
276
  !isLoadingLiminarProtestosDoPassado &&
273
277
  ctx.type !== RequestStatus.Loading;
274
278
  var ctxLoading = useMemo(function () { return (__assign(__assign({}, ctx), { type: RequestStatus.Loading })); }, [ctx]);
@@ -288,8 +292,8 @@ var Liminar = function (_a) {
288
292
  : 'Processos com indícios encontrados:';
289
293
  var shouldRender = isLoadingLiminarProtestosDoPassado ||
290
294
  (ready &&
291
- (((_j = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _j === void 0 ? void 0 : _j.indiciosDeLiminar) ||
292
- ((_m = (_l = (_k = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _k === void 0 ? void 0 : _k.processosComLiminarIds) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0) > 0));
295
+ (((_k = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _k === void 0 ? void 0 : _k.indiciosDeLiminar) ||
296
+ ((_o = (_m = (_l = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _l === void 0 ? void 0 : _l.processosComLiminarIds) === null || _m === void 0 ? void 0 : _m.length) !== null && _o !== void 0 ? _o : 0) > 0));
293
297
  // Função para disparar o envio do e-mail e configurar a mensagem do modal
294
298
  var handleSendEmailIndicios = function (e) { return __awaiter(void 0, void 0, void 0, function () {
295
299
  var callback;
@@ -93,6 +93,7 @@ var useLiminarProtestosDoPassado = function (_a) {
93
93
  })];
94
94
  case 1:
95
95
  data = _a.sent();
96
+ console.log('data', data);
96
97
  return [4 /*yield*/, Client.WebService.parse(data)];
97
98
  case 2:
98
99
  parsed = (_a.sent());
@@ -1,3 +1,4 @@
1
1
  import { GlobalState } from '@/types/globalState.d';
2
2
  export declare const isGlobalReady: (g: GlobalState) => boolean | undefined;
3
3
  export declare const areModulesLoaded: (g: GlobalState) => boolean | undefined;
4
+ export declare const isDocumentHistoryReady: (g: GlobalState) => boolean;
@@ -14,3 +14,4 @@ export var areModulesLoaded = function (g) {
14
14
  ((_c = g.ccfData) === null || _c === void 0 ? void 0 : _c.isLoaded) &&
15
15
  ((_d = g.divida) === null || _d === void 0 ? void 0 : _d.isLoaded);
16
16
  };
17
+ export var isDocumentHistoryReady = function (g) { return !!g.documentHistory; };