@credithub/harlan-components 1.88.1 → 1.90.0

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.
@@ -96,7 +96,8 @@ function deepCleanData(data) {
96
96
  // -----------------------------------------------------------------------------
97
97
  export var selectRelevantData = function (data) {
98
98
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
99
- var _l = data || {}, protestosNumero = _l.protestos, ccfNumero = _l.ccf, dividasPublicas = _l.dividasPublicas, contasBancarias = _l.bankAccounts, ccfData = _l.ccfData, dividas = _l.divida, _m = _l.dossie, dossie = _m === void 0 ? {} : _m, liminar = _l.liminar, socios = _l.partners, dadosPessoasExpostasPoliticamente = _l.pepData, detalhesProcessosJuridicos = _l.processosJuridicosData, dadosReclameAqui = _l.reclameAqui, refinBoaVista = _l.refinBoaVista, refinSerasa = _l.refinSerasa, dadosScore = _l.scoreData, _o = _l.scr, scr = _o === void 0 ? { isLoaded: false } : _o, _p = _l.veiculos, veiculos = _p === void 0 ? [] : _p, ResumoDosDados = _l.documentHistory;
99
+ var _l = data || {}, protestosNumero = _l.protestos, ccfNumero = _l.ccf, dividasPublicas = _l.dividasPublicas, contasBancarias = _l.bankAccounts, ccfData = _l.ccfData, dividas = _l.divida, _m = _l.dossie, dossie = _m === void 0 ? {} : _m, liminar = _l.liminar, socios = _l.partners, dadosPessoasExpostasPoliticamente = _l.pepData, detalhesProcessosJuridicos = _l.processosJuridicosData, dadosReclameAqui = _l.reclameAqui, refinBoaVista = _l.refinBoaVista, refinSerasa = _l.refinSerasa, dadosScore = _l.scoreData, _o = _l.scr, scr = _o === void 0 ? { isLoaded: false } : _o, _p = _l.veiculos, veiculos = _p === void 0 ? [] : _p, ResumoDosDados = _l.documentHistory, insolvencia = _l.insolvencia // ← novo
100
+ ;
100
101
  // ────────────────────────────────────────────────
101
102
  // 1. Protestos – somente a entrada mais recente
102
103
  // ────────────────────────────────────────────────
@@ -162,6 +163,12 @@ export var selectRelevantData = function (data) {
162
163
  });
163
164
  });
164
165
  // ────────────────────────────────────────────────
166
+ // 0‑bis. Falência / Insolvência
167
+ // ────────────────────────────────────────────────
168
+ var insolvenciaInfo = insolvencia
169
+ ? 'Registro de falência encontrado'
170
+ : undefined;
171
+ // ────────────────────────────────────────────────
165
172
  // 6. Construção final
166
173
  // ────────────────────────────────────────────────
167
174
  var dadosOrganizados = {
@@ -184,7 +191,8 @@ export var selectRelevantData = function (data) {
184
191
  dadosReclameAqui: dadosReclameAqui,
185
192
  dadosScore: dadosScore,
186
193
  ResumoDosDados: ResumoSafe,
187
- tipoPessoa: tipoPessoa
194
+ tipoPessoa: tipoPessoa,
195
+ insolvencia: insolvenciaInfo
188
196
  };
189
197
  var dadosFiltrados = deepCleanData(dadosOrganizados);
190
198
  return { dadosFiltrados: dadosFiltrados };
@@ -1,5 +1,17 @@
1
- import React, { useMemo } from 'react';
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import React, { useEffect, useMemo, useState } from 'react';
2
13
  import FalenciaIcon from '../../assets/icones/falenciaIcon';
14
+ import { useGlobalData } from '../../contexts/globalDataContext';
3
15
  import Section from '../section';
4
16
  import { RequestStatus, useQuery } from '../webservice';
5
17
  function parseFalencia(document) {
@@ -36,23 +48,36 @@ function parseFalencia(document) {
36
48
  }
37
49
  var Falencia = function (_a) {
38
50
  var documento = _a.documento;
39
- var _b = useQuery("SELECT FROM 'ValorEconomico'.'Falencia'", { documento: documento }), response = _b.response, error = _b.error, isLoading = _b.isLoading, refetch = _b.refetch;
51
+ var setData = useGlobalData().setData;
52
+ var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
53
+ var _c = useQuery("SELECT FROM 'ValorEconomico'.'Falencia'", { documento: documento }), response = _c.response, error = _c.error, isLoading = _c.isLoading, loadingProgress = _c.loadingProgress, refetch = _c.refetch;
40
54
  var items = useMemo(function () { return parseFalencia(response === null || response === void 0 ? void 0 : response.document); }, [response]);
41
- var shouldRender = isLoading || items.length > 0;
42
- if (!shouldRender)
55
+ var insolvencia = useMemo(function () { return items.length > 0; }, [items]);
56
+ useEffect(function () {
57
+ if (insolvencia && !dataUpdated) {
58
+ setData(function (prev) { return (__assign(__assign({}, prev), { insolvencia: insolvencia })); });
59
+ setDataUpdated(true);
60
+ }
61
+ }, [insolvencia, setData, dataUpdated]);
62
+ if (!isLoading && items.length === 0)
43
63
  return null;
44
64
  var variant = isLoading
45
65
  ? 'loading'
46
- : items.length > 0
66
+ : insolvencia
47
67
  ? 'error'
48
68
  : 'default';
49
69
  var ctx = {
50
- type: isLoading ? RequestStatus.Loading : RequestStatus.Success,
70
+ type: isLoading
71
+ ? RequestStatus.Loading
72
+ : error
73
+ ? RequestStatus.Error
74
+ : RequestStatus.Success,
51
75
  error: error,
52
76
  document: response === null || response === void 0 ? void 0 : response.document,
53
77
  response: response === null || response === void 0 ? void 0 : response.response,
54
78
  refetch: refetch,
55
- Section: Section
79
+ Section: Section,
80
+ progress: loadingProgress
56
81
  };
57
82
  return (React.createElement(Section, { title: "Fal\u00EAncias", subtitle: "Movimentos falimentares encontrados.", icon: FalenciaIcon, variant: variant, minimized: false, ctx: ctx }));
58
83
  };
@@ -35,7 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import { Client } from '@credithub/webservice';
38
- import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
38
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
39
39
  import Section from './section';
40
40
  export var WebService = createContext(new Client.WebService());
41
41
  export var WebServiceProvider = function (_a) {
@@ -207,17 +207,16 @@ export function useQuery(query, data, enabled) {
207
207
  var _b = useState(null), error = _b[0], setError = _b[1];
208
208
  var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
209
209
  var _d = useState(true), shouldFetch = _d[0], setShouldFetch = _d[1];
210
- var loadingProgressRef = useRef(0);
210
+ var _e = useState(0), loadingProgress = _e[0], setProgress = _e[1];
211
211
  var memoizedData = useMemo(function () { return data; }, [JSON.stringify(data)]);
212
212
  var simulateProgress = useCallback(function () {
213
- loadingProgressRef.current = 0;
214
- var progress = 0;
213
+ setProgress(0);
214
+ var p = 0;
215
215
  var interval = setInterval(function () {
216
- progress += 15;
217
- loadingProgressRef.current = progress;
218
- if (progress >= 90) {
216
+ p += 15;
217
+ setProgress(Math.min(p, 90));
218
+ if (p >= 90)
219
219
  clearInterval(interval);
220
- }
221
220
  }, 300);
222
221
  return function () { return clearInterval(interval); };
223
222
  }, []);
@@ -238,7 +237,7 @@ export function useQuery(query, data, enabled) {
238
237
  .then(function (parsedResponse) {
239
238
  setResponse(parsedResponse);
240
239
  setError(null);
241
- loadingProgressRef.current = 100;
240
+ setProgress(100);
242
241
  })
243
242
  .catch(function (requestError) {
244
243
  if (requestError.name !== 'AbortError') {
@@ -246,7 +245,7 @@ export function useQuery(query, data, enabled) {
246
245
  ? requestError
247
246
  : new Error(String(requestError)));
248
247
  }
249
- loadingProgressRef.current = 100;
248
+ setProgress(100);
250
249
  })
251
250
  .finally(function () {
252
251
  setIsLoading(false);
@@ -271,7 +270,7 @@ export function useQuery(query, data, enabled) {
271
270
  response: response,
272
271
  error: error,
273
272
  isLoading: isLoading,
274
- loadingProgress: loadingProgressRef.current,
273
+ loadingProgress: loadingProgress,
275
274
  refetch: refetch
276
275
  };
277
276
  }