@credithub/harlan-components 1.84.2 → 1.85.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.
@@ -4,6 +4,7 @@ interface DossieProps {
4
4
  rfbResponse?: Document;
5
5
  onOpenNewTransactionModal?: () => void;
6
6
  printMode?: boolean;
7
+ isFinancial?: boolean;
7
8
  }
8
9
  declare const _default: React.NamedExoticComponent<DossieProps>;
9
10
  export default _default;
@@ -48,19 +48,21 @@ var getCompanyName = function (isPF, finderDoc, rfbDoc) {
48
48
  '');
49
49
  };
50
50
  var Dossie = function (_a) {
51
- var documento = _a.documento, printMode = _a.printMode;
51
+ var documento = _a.documento, printMode = _a.printMode, _b = _a.isFinancial // default
52
+ , isFinancial = _b === void 0 ? false : _b // default
53
+ ;
52
54
  var ctx = useContext(Queries.Finder);
53
- var _b = useConsultaRfb(), rfbResponse = _b.rfbResponse, updatedOnce = _b.updatedOnce;
54
- var _c = useGlobalData(), globalData = _c.data, setData = _c.setData;
55
+ var _c = useConsultaRfb(), rfbResponse = _c.rfbResponse, updatedOnce = _c.updatedOnce;
56
+ var _d = useGlobalData(), globalData = _d.data, setData = _d.setData;
55
57
  var lastDossieRef = useRef();
56
58
  // Ref para guardar o status de receita anterior
57
59
  var prevReceitaStatusRef = useRef(undefined);
58
60
  // Estado para sinalizar que houve mudança relevante no rfbResponse
59
- var _d = useState(false), refreshQuery = _d[0], setRefreshQuery = _d[1];
61
+ var _e = useState(false), refreshQuery = _e[0], setRefreshQuery = _e[1];
60
62
  // Consulta ReclameAqui
61
- var _e = useQuery("SELECT FROM 'RECLAMEAQUI'.'CONSULTA'", {
63
+ var _f = useQuery("SELECT FROM 'RECLAMEAQUI'.'CONSULTA'", {
62
64
  documento: documento
63
- }), reclameAquiResponse = _e.response, reclameAquiLoading = _e.isLoading, reclameAquiError = _e.error;
65
+ }), reclameAquiResponse = _f.response, reclameAquiLoading = _f.isLoading, reclameAquiError = _f.error;
64
66
  // Processa os dados do ReclameAqui
65
67
  var reclameAquiCompanies = useMemo(function () {
66
68
  var _a;
@@ -133,9 +135,16 @@ var Dossie = function (_a) {
133
135
  React.createElement(Summary, { finderResponse: data, document: document })),
134
136
  React.createElement(TransactionsTable, { events: XPathUtils.select('//historico/consulta', data) || [] })),
135
137
  !printMode && (React.createElement(GenerativeAIContainer, null,
136
- React.createElement(GenerativeAI, { documento: document, refreshQuery: refreshQuery })))));
138
+ React.createElement(GenerativeAI, { documento: document, refreshQuery: refreshQuery, isFinancial: isFinancial })))));
137
139
  };
138
- }, [documento, printMode, rfbResponse, reclameAquiCompanies, refreshQuery]);
140
+ }, [
141
+ documento,
142
+ printMode,
143
+ rfbResponse,
144
+ reclameAquiCompanies,
145
+ refreshQuery,
146
+ isFinancial
147
+ ]);
139
148
  return (React.createElement(Section, { ctx: ctx, hideHeader: true, minimized: false, isError: function (e) { return response(e); }, onSuccess: response }));
140
149
  };
141
150
  export default React.memo(Dossie);
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface GenerativeAIProps {
3
3
  documento: string;
4
4
  refreshQuery?: boolean;
5
+ isFinancial?: boolean;
5
6
  }
6
7
  declare const GenerativeAI: React.FC<GenerativeAIProps>;
7
8
  export default GenerativeAI;
@@ -65,7 +65,7 @@ import StatusMessage from '../../../components/interface/statusMessage';
65
65
  import { useStreamQuery } from '../../../components/streamQuery';
66
66
  import { useGlobalData } from '../../../contexts/globalDataContext';
67
67
  import useToggle from '../../../hooks/useToggle';
68
- import { isGlobalReady } from '../../../utils/isGlobalReady';
68
+ import { isDocumentHistoryReady, isGlobalReady } from '../../../utils/isGlobalReady';
69
69
  import React, { useEffect, useMemo, useRef, useState } from 'react';
70
70
  import ReactMarkdown from 'react-markdown';
71
71
  import remarkGfm from 'remark-gfm';
@@ -75,22 +75,26 @@ import { createQueryAndMessages } from './queryUtils';
75
75
  import { BetaTag, ChatInput, ChatInputContainer, Container, ContainerInput, GenerativeAi, Header, HeaderContent, InitialMessageBox, InitialMessageContent, LoadingDots, Message, MessageHistory, SendButton, Title } from './styles';
76
76
  var GenerativeAI = function (_a) {
77
77
  var _b, _c, _d;
78
- var documento = _a.documento, refreshQuery = _a.refreshQuery;
78
+ var documento = _a.documento, refreshQuery = _a.refreshQuery, _e = _a.isFinancial, isFinancial = _e === void 0 ? false : _e;
79
79
  var globalData = useGlobalData().data;
80
- var _e = useState('{}'), serializedData = _e[0], setSerializedData = _e[1];
81
- var _f = useState(''), userInput = _f[0], setUserInput = _f[1];
82
- var _g = useState([]), messageHistory = _g[0], setMessageHistory = _g[1];
83
- var _h = useToggle(), isOpen = _h[0], toggleOpen = _h[1];
84
- var _j = useState('summary'), streamMode = _j[0], setStreamMode = _j[1];
80
+ var _f = useState('{}'), serializedData = _f[0], setSerializedData = _f[1];
81
+ var _g = useState(''), userInput = _g[0], setUserInput = _g[1];
82
+ var _h = useState([]), messageHistory = _h[0], setMessageHistory = _h[1];
83
+ var _j = useToggle(), isOpen = _j[0], toggleOpen = _j[1];
84
+ var _k = useState('summary'), streamMode = _k[0], setStreamMode = _k[1];
85
85
  // Estado para a query de chat (inicia como undefined)
86
- var _k = useState(undefined), chatQueryData = _k[0], setChatQueryData = _k[1];
86
+ var _l = useState(undefined), chatQueryData = _l[0], setChatQueryData = _l[1];
87
87
  // Estado para forçar o refresh da query summary
88
- var _l = useState(0), refreshKey = _l[0], setRefreshKey = _l[1];
88
+ var _m = useState(0), refreshKey = _m[0], setRefreshKey = _m[1];
89
89
  // Refs para guardar a última mensagem (evita refetch repetido)
90
90
  var lastQueryRef = useRef(null);
91
91
  var lastUserMessageRef = useRef(null);
92
92
  var messageHistoryRef = useRef(null);
93
- var isGlobalDataReady = useMemo(function () { return isGlobalReady(globalData); }, [globalData]);
93
+ var isGlobalDataReady = useMemo(function () {
94
+ return isFinancial
95
+ ? isGlobalReady(globalData) // clientes financeiros
96
+ : isDocumentHistoryReady(globalData); // demais clientes
97
+ }, [globalData, isFinancial]);
94
98
  // Atualiza o payload serializado sempre que os dados globais mudarem
95
99
  useEffect(function () {
96
100
  if (globalData && documento && isGlobalDataReady) {
@@ -118,9 +122,9 @@ var GenerativeAI = function (_a) {
118
122
  return undefined;
119
123
  }, [serializedData, streamMode, refreshKey]);
120
124
  // Configura a query summary com o hook useStreamQuery
121
- var _m = useStreamQuery("SELECT FROM 'LlamaApi'.'Consulta'", summaryQueryData, streamMode === 'summary' && !!summaryQueryData), summaryIterator = _m.responseIterator, summaryError = _m.error, summaryLoading = _m.isLoading, refetchSummary = _m.refetch, abortSummary = _m.abort;
125
+ var _o = useStreamQuery("SELECT FROM 'LlamaApi'.'Consulta'", summaryQueryData, streamMode === 'summary' && !!summaryQueryData), summaryIterator = _o.responseIterator, summaryError = _o.error, summaryLoading = _o.isLoading, refetchSummary = _o.refetch, abortSummary = _o.abort;
122
126
  // Configura a query chat
123
- var _o = useStreamQuery("SELECT FROM 'LlamaApi'.'Consulta'", chatQueryData, streamMode === 'chat' && !!chatQueryData), chatIterator = _o.responseIterator, chatError = _o.error, chatLoading = _o.isLoading, refetchChat = _o.refetch, abortChat = _o.abort;
127
+ var _p = useStreamQuery("SELECT FROM 'LlamaApi'.'Consulta'", chatQueryData, streamMode === 'chat' && !!chatQueryData), chatIterator = _p.responseIterator, chatError = _p.error, chatLoading = _p.isLoading, refetchChat = _p.refetch, abortChat = _p.abort;
124
128
  // Dispara o refetch inicial quando summaryQueryData estiver definido
125
129
  useEffect(function () {
126
130
  if (summaryQueryData) {
@@ -12,6 +12,7 @@ import { ConsultasComplementaresProvider } from './components/consultasComplemen
12
12
  import Dominios from './components/dominios/dominios';
13
13
  import ConsultaImoveis from './components/imoveis/imoveisService';
14
14
  import Liminar from './components/liminar/liminar';
15
+ import ProtestosSP from './components/protestos/protestosSp';
15
16
  import ConsultaScore from './components/score/scoreService';
16
17
  import ConsultaScoreSerasa from './components/scoreSerasa/scoreSerasa';
17
18
  import ConsultaSCR from './components/scr/scr';
@@ -19,7 +20,6 @@ import { ErrorModalProvider } from './contexts/errorModalContext';
19
20
  import { GlobalDataProvider } from './contexts/globalDataContext';
20
21
  import GlobalStyle from './styles/globalStyle';
21
22
  import theme from './styles/theme';
22
- import ProtestosSP from './components/protestos/protestosSp';
23
23
  Chart.register.apply(Chart, registerables);
24
24
  var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n margin-bottom: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"], ["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n margin-bottom: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"])));
25
25
  var FinderDependency = function (_a) {
@@ -52,7 +52,7 @@ var ConsultaSimples = function (_a) {
52
52
  React.createElement(GlobalDataProvider, null,
53
53
  React.createElement(ConsultaSimplesSection, { documento: documento, onClose: onClose, onClickPrint: onClickPrint, isFinancial: isFinancial },
54
54
  React.createElement(ConsultaRfbProvider, { documento: documento },
55
- React.createElement(Dossie, { documento: documento, printMode: printMode }),
55
+ React.createElement(Dossie, { documento: documento, printMode: printMode, isFinancial: isFinancial }),
56
56
  React.createElement(Liminar, { isFinancial: isFinancial, hasCredits: hasCredits, tags: tags }),
57
57
  React.createElement(Addresses, { apiKey: apiKey }),
58
58
  React.createElement(Contacts, null),
@@ -1,11 +1,7 @@
1
1
  export var isGlobalReady = function (g) {
2
- var _a, _b, _c, _d, _e;
2
+ var _a;
3
3
  return !!g.documentHistory && // veio do dossiê
4
- ((_a = g.liminar) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
5
- ((_b = g.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded) &&
6
- ((_c = g.protestosData) === null || _c === void 0 ? void 0 : _c.isLoaded) &&
7
- ((_d = g.ccfData) === null || _d === void 0 ? void 0 : _d.isLoaded) &&
8
- ((_e = g.divida) === null || _e === void 0 ? void 0 : _e.isLoaded);
4
+ ((_a = g.liminar) === null || _a === void 0 ? void 0 : _a.isLoaded);
9
5
  };
10
6
  export var areModulesLoaded = function (g) {
11
7
  var _a, _b, _c, _d;