@credithub/harlan-components 1.97.9 → 1.98.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.
@@ -5,8 +5,9 @@ export type { Contact, ContactsState } from '@/@types/domain/contactsTypes';
5
5
  export type { Divida, DividasPublicasState } from '@/@types/domain/dividasTypes';
6
6
  export type { DocumentHistoryData } from '@/@types/domain/documentHistoryData';
7
7
  export type { CarouselState, DossieState, SummaryState, TransactionTableState } from '@/@types/domain/dossieTypes';
8
- export type { ImoveisConsultaResponse, IPTUItem } from '@/@types/domain/imoveisTypes';
8
+ export type { IPTUItem, ImoveisConsultaResponse } from '@/@types/domain/imoveisTypes';
9
9
  export type { LiminarResponse } from '@/@types/domain/liminarTypes';
10
+ export type { LiteError } from '@/@types/domain/liteError';
10
11
  export type { Partner, PartnersState } from '@/@types/domain/partnersTypes';
11
12
  export type { PepData, PepState } from '@/@types/domain/pepTypes';
12
13
  export type { EnvolvidoUltimaMovimentacao, ProcessoJuridicoResume, ProcessosJuridicosState } from '@/@types/domain/processosJuridicosTypes';
@@ -26,6 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  };
27
27
  import ConsultaSimplesIcon from '../../assets/icones/consultaSimples';
28
28
  import { useGlobalData } from '../../contexts/globalDataContext';
29
+ import { usePostHog } from '../../contexts/PostHogContext';
29
30
  import { formatMoney } from '../../utils/number';
30
31
  import { formatDocument } from '../../utils/string';
31
32
  import { format } from 'date-fns';
@@ -34,7 +35,6 @@ import styled, { keyframes } from 'styled-components';
34
35
  import Section from '../interface/section';
35
36
  import StatusMessage from '../interface/statusMessage';
36
37
  import { Queries, RequestStatus } from '../webservice';
37
- import { usePostHog } from '../../contexts/PostHogContext';
38
38
  // Animação do spinner
39
39
  var spin = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"], ["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"])));
40
40
  // Componente Spinner sutil
@@ -51,51 +51,35 @@ var ConsultaSimplesSection = function (_a) {
51
51
  ? data.dossie.summary.receitaStatus
52
52
  : null;
53
53
  // Cria um array com cada tag de pendência, seu texto e sua flag de carregamento
54
+ var makeItem = function (label, loaded, text, error) { return ({
55
+ label: label,
56
+ loaded: Boolean(loaded),
57
+ text: text,
58
+ error: error
59
+ }); };
54
60
  var pendencias = [
55
- {
56
- label: 'Situação Receita',
57
- text: receitaStatus ? "".concat(receitaStatus) : '',
58
- loaded: true // assume que essa informação está disponível
59
- },
60
- {
61
- label: 'Dívidas Públicas',
62
- text: data.dividasPublicas
63
- ? "".concat(formatMoney(data.dividasPublicas), " em D\u00EDvidas P\u00FAblicas")
64
- : '',
65
- loaded: (_e = (_d = data.divida) === null || _d === void 0 ? void 0 : _d.isLoaded) !== null && _e !== void 0 ? _e : false
66
- },
67
- {
68
- label: 'Cheques sem Fundo',
69
- text: data.ccf
70
- ? "".concat(data.ccf === 1 ? 'Cheque sem Fundo' : "".concat(data.ccf, " Cheques sem Fundo"), " com \u00DAltima Ocorr\u00EAncia em ").concat(data.ultimoRegistroCCF)
71
- : '',
72
- loaded: (_g = (_f = data.ccfData) === null || _f === void 0 ? void 0 : _f.isLoaded) !== null && _g !== void 0 ? _g : false
73
- },
74
- {
75
- label: 'Protestos',
76
- text: data.protestos
77
- ? data.protestos === 1
78
- ? 'Protesto Encontrado'
79
- : "".concat(data.protestos, " Protestos")
80
- : '',
81
- loaded: (_j = (_h = data.protestosData) === null || _h === void 0 ? void 0 : _h.isLoaded) !== null && _j !== void 0 ? _j : false
82
- },
83
- {
84
- label: 'Processos Jurídicos',
85
- text: data.processosJuridicos
86
- ? "".concat(data.processosJuridicos, " ").concat(data.processosJuridicos === 1 ? 'Processo Jurídico' : 'Processos Jurídicos')
87
- : '',
88
- loaded: (_l = (_k = data.processosJuridicosData) === null || _k === void 0 ? void 0 : _k.isLoaded) !== null && _l !== void 0 ? _l : false
89
- },
90
- {
91
- label: 'Liminar',
92
- text: data.liminar &&
93
- (data.liminar.totalProtestos === 'NADA CONSTA' ||
94
- data.liminar.message === 'Encontrado')
95
- ? 'Indício de Liminar'
96
- : '',
97
- loaded: (_o = (_m = data.liminar) === null || _m === void 0 ? void 0 : _m.isLoaded) !== null && _o !== void 0 ? _o : false
98
- }
61
+ makeItem('Situação Receita', true, receitaStatus ? "".concat(receitaStatus) : ''),
62
+ makeItem('Dívidas Públicas', (_d = data.divida) === null || _d === void 0 ? void 0 : _d.isLoaded, data.dividasPublicas
63
+ ? "".concat(formatMoney(data.dividasPublicas), " em D\u00EDvidas P\u00FAblicas")
64
+ : '', (_e = data.divida) === null || _e === void 0 ? void 0 : _e.error),
65
+ makeItem('Cheques sem Fundo', (_f = data.ccfData) === null || _f === void 0 ? void 0 : _f.isLoaded, data.ccf
66
+ ? "".concat(data.ccf === 1 ? 'Cheque sem Fundo' : "".concat(data.ccf, " Cheques sem Fundo"), " com \u00DAltima Ocorr\u00EAncia em ").concat(data.ultimoRegistroCCF)
67
+ : '', (_g = data.ccfData) === null || _g === void 0 ? void 0 : _g.error),
68
+ makeItem('Protestos', (_h = data.protestosData) === null || _h === void 0 ? void 0 : _h.isLoaded, data.protestos
69
+ ? data.protestos === 1
70
+ ? 'Protesto Encontrado'
71
+ : "".concat(data.protestos, " Protestos")
72
+ : '', (_j = data.protestosData) === null || _j === void 0 ? void 0 : _j.error),
73
+ makeItem('Processos Jurídicos', (_k = data.processosJuridicosData) === null || _k === void 0 ? void 0 : _k.isLoaded, data.processosJuridicos
74
+ ? "".concat(data.processosJuridicos, " ").concat(data.processosJuridicos === 1
75
+ ? 'Processo Jurídico'
76
+ : 'Processos Jurídicos')
77
+ : '', (_l = data.processosJuridicosData) === null || _l === void 0 ? void 0 : _l.error),
78
+ makeItem('Liminar', (_m = data.liminar) === null || _m === void 0 ? void 0 : _m.isLoaded, data.liminar &&
79
+ (data.liminar.totalProtestos === 'NADA CONSTA' ||
80
+ data.liminar.message === 'Encontrado')
81
+ ? 'Indício de Liminar'
82
+ : '', (_o = data.liminar) === null || _o === void 0 ? void 0 : _o.error)
99
83
  ].filter(function (e) { return (e.label === 'Liminar' ? isFinancial : e); });
100
84
  var isError = (ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Error;
101
85
  var isLoading = (ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Loading;
@@ -112,8 +96,8 @@ var ConsultaSimplesSection = function (_a) {
112
96
  documento: documento,
113
97
  pendencias: pendencias.map(function (pendencia) { return ({
114
98
  label: pendencia.label,
115
- text: pendencia.text,
116
- }); }),
99
+ text: pendencia.text
100
+ }); })
117
101
  });
118
102
  }, [posthog, pendencias]);
119
103
  return (React.createElement(Section, __assign({ title: "Consulta Simples", subtitle: "Consulta de informa\u00E7\u00F5es do documento.", description: React.createElement(React.Fragment, null,
@@ -121,7 +105,7 @@ var ConsultaSimplesSection = function (_a) {
121
105
  React.createElement(StatusMessage, { type: "found" }, formatDocument(documento)),
122
106
  isError && (ctx === null || ctx === void 0 ? void 0 : ctx.error) && (React.createElement(StatusMessage, { type: statusType }, ctx.error.message)),
123
107
  pendencias.map(function (item) {
124
- // Se a tag não está carregada, mostra o spinner com a mensagem de carregamento
108
+ var _a;
125
109
  if (!item.loaded) {
126
110
  return (React.createElement(StatusMessage, { key: item.label, type: "loading" },
127
111
  React.createElement(Spinner, null),
@@ -129,7 +113,9 @@ var ConsultaSimplesSection = function (_a) {
129
113
  item.label,
130
114
  "..."));
131
115
  }
132
- // Se carregado e houver texto, exibe-o; caso contrário, não renderiza nada
116
+ if ((_a = item.error) === null || _a === void 0 ? void 0 : _a.summary) {
117
+ return (React.createElement(StatusMessage, { key: item.label, type: "warning" }, item.error.summary));
118
+ }
133
119
  return item.text ? (React.createElement(StatusMessage, { key: item.label, type: "error" }, item.text)) : null;
134
120
  })), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
135
121
  percentage: (ctx === null || ctx === void 0 ? void 0 : ctx.progress) || 0,
@@ -31,6 +31,7 @@ import React, { useCallback, useContext, useEffect } from 'react';
31
31
  import styled from 'styled-components';
32
32
  import Button from '../common/button';
33
33
  import { Result, ResultContent } from '../interface/result';
34
+ import StatusMessage from '../interface/statusMessage';
34
35
  import Section from '../section';
35
36
  import { Queries, RequestStatus } from '../webservice';
36
37
  import ContactLikeDislikeSection from './contactLikeDislikeSection';
@@ -52,7 +53,7 @@ var Contacts = function (_a) {
52
53
  var telefones = __spreadArray(__spreadArray([], telefonesRfb.map(function (telefone) { return ({
53
54
  type: ContactType.TELEFONE,
54
55
  value: telefone
55
- }); }), true), __spreadArray(__spreadArray([], XPathUtils.selectArray('//telefones/fixos/fixos', data) || [], true), XPathUtils.selectArray('//telefones/moveis/moveis', data) || [], true).map(function (telefone) { return ({
56
+ }); }), true), __spreadArray(__spreadArray([], (XPathUtils.selectArray('//telefones/fixos/fixos', data) || []), true), (XPathUtils.selectArray('//telefones/moveis/moveis', data) || []), true).map(function (telefone) { return ({
56
57
  type: ContactType.TELEFONE,
57
58
  value: phoneMask(XPathUtils.select('string(./telefone)', telefone))
58
59
  }); }), true);
@@ -91,13 +92,15 @@ var Contacts = function (_a) {
91
92
  }))); };
92
93
  return (React.createElement(Section, { ctx: ctx, title: "Contato", subtitle: "Informa\u00E7\u00F5es de contato do documento pesquisado.", description: "(Telefone, e-mail e outros)", minimized: false, icon: ContatoIcon, onSuccess: function (data) {
93
94
  var _a = extractContacts(data), telefones = _a.telefones, emails = _a.emails, document = _a.document;
94
- return {
95
- children: (React.createElement(Result, { resultContentStriped: false },
96
- renderContactItems(telefones, document, "1fr 1fr 1fr", "1fr 1fr", "1fr 1fr"),
97
- renderContactItems(emails, document, "1fr 1fr 1fr", "1fr 1fr", "1fr"))),
98
- actions: (React.createElement(BtnWrapper, null,
99
- React.createElement(Button, { onClick: onClickConsultarEmail }, "Consultar E-mail em Dom\u00EDnio")))
100
- };
95
+ var isEmpty = telefones.length === 0 && emails.length === 0;
96
+ return __assign(__assign({ children: isEmpty ? null : (React.createElement(Result, { resultContentStriped: false },
97
+ renderContactItems(telefones, document, '1fr 1fr 1fr', '1fr 1fr', '1fr 1fr'),
98
+ renderContactItems(emails, document, '1fr 1fr 1fr', '1fr 1fr', '1fr'))) }, (isEmpty
99
+ ? {
100
+ description: (React.createElement(StatusMessage, { type: "default" }, "Sem apontamentos"))
101
+ }
102
+ : {})), { actions: (React.createElement(BtnWrapper, null,
103
+ React.createElement(Button, { onClick: onClickConsultarEmail }, "Consultar E-mail em Dom\u00EDnio"))) });
101
104
  } }));
102
105
  };
103
106
  export default Contacts;
@@ -34,15 +34,19 @@ var ProcessosJuridicos = function (_a) {
34
34
  ctxHashRef.current = currentCtxHash;
35
35
  if (ctx.type === RequestStatus.Error && !processedRef.current) {
36
36
  setData(function (prevState) {
37
- var _a;
38
- if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
37
+ var _a, _b;
38
+ var alreadyEmpty = ((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
39
39
  Array.isArray(prevState.processosJuridicosData.empresa) &&
40
- prevState.processosJuridicosData.empresa.length === 0) {
40
+ prevState.processosJuridicosData.empresa.length === 0;
41
+ if (alreadyEmpty && ((_b = prevState.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.error)) {
41
42
  return prevState;
42
43
  }
43
44
  return __assign(__assign({}, prevState), { processosJuridicosData: {
44
45
  empresa: [],
45
- isLoaded: true
46
+ isLoaded: true,
47
+ error: {
48
+ summary: 'Falha ao consultar processos jurídicos, tente novamente mais tarde.'
49
+ }
46
50
  } });
47
51
  });
48
52
  processedRef.current = true;
@@ -56,7 +60,8 @@ var ProcessosJuridicos = function (_a) {
56
60
  if (qtyProcessos_1 > 0) {
57
61
  var processosJuridicosData_1 = {
58
62
  empresa: documentData_1.empresa,
59
- isLoaded: true
63
+ isLoaded: true,
64
+ error: undefined
60
65
  };
61
66
  setData(function (prevState) {
62
67
  var _a;
@@ -69,18 +74,11 @@ var ProcessosJuridicos = function (_a) {
69
74
  });
70
75
  }
71
76
  else {
72
- setData(function (prevState) {
73
- var _a;
74
- if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
75
- Array.isArray(prevState.processosJuridicosData.empresa) &&
76
- prevState.processosJuridicosData.empresa.length === 0) {
77
- return prevState;
78
- }
79
- return __assign(__assign({}, prevState), { processosJuridicosData: {
80
- empresa: [],
81
- isLoaded: true
82
- } });
83
- });
77
+ setData(function (prevState) { return (__assign(__assign({}, prevState), { processosJuridicosData: {
78
+ empresa: [],
79
+ isLoaded: true,
80
+ error: undefined
81
+ } })); });
84
82
  }
85
83
  processedRef.current = true;
86
84
  }