@credithub/harlan-components 1.62.8 → 1.62.10

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.
@@ -3,10 +3,12 @@ import React, { createContext, useEffect, useState } from 'react';
3
3
  import { useQuery } from './webservice';
4
4
  export var ConsultaRfbContext = createContext(null);
5
5
  export var ConsultaRfbProvider = function (_a) {
6
- var _b, _c, _d, _e;
6
+ var _b, _c;
7
7
  var children = _a.children, documento = _a.documento;
8
- var _f = useState(false), enableFallback = _f[0], setEnableFallback = _f[1];
9
- var query = useQuery("SELECT FROM 'RFB'.'CERTIDAO'", { documento: documento });
8
+ var _d = useState(false), enableFallback = _d[0], setEnableFallback = _d[1];
9
+ var query = useQuery("SELECT FROM 'RFB'.'CERTIDAO'", {
10
+ documento: documento
11
+ });
10
12
  var queryFallback = useQuery("SELECT FROM 'RECEITAWS'.'CNPJ'", { documento: documento }, enableFallback);
11
13
  var executeFallback = function () { return setEnableFallback(true); };
12
14
  useEffect(function () {
@@ -15,7 +17,9 @@ export var ConsultaRfbProvider = function (_a) {
15
17
  }
16
18
  }, [enableFallback]);
17
19
  return (React.createElement(ConsultaRfbContext.Provider, { value: {
18
- rfbResponse: (_e = (_c = (_b = queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.response) === null || _b === void 0 ? void 0 : _b.document) !== null && _c !== void 0 ? _c : (_d = query === null || query === void 0 ? void 0 : query.response) === null || _d === void 0 ? void 0 : _d.document) !== null && _e !== void 0 ? _e : undefined,
20
+ rfbResponse: enableFallback
21
+ ? (_b = queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.response) === null || _b === void 0 ? void 0 : _b.document
22
+ : (_c = query === null || query === void 0 ? void 0 : query.response) === null || _c === void 0 ? void 0 : _c.document,
19
23
  executeFallback: executeFallback,
20
24
  refetch: query.refetch,
21
25
  error: query.error || queryFallback.error,
@@ -17,17 +17,17 @@ import { useGlobalData } from '../../contexts/globalDataContext';
17
17
  import { useConsultaRfb } from '../../hooks/useConsultaRfb';
18
18
  import { formatCnpj, formatCpf } from '../../utils/string';
19
19
  import XPathUtils from '../../utils/xpath';
20
- import React, { useContext, useEffect, useState, useCallback, useMemo } from 'react';
20
+ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
21
21
  import styled from 'styled-components';
22
22
  import { ReclameAquiCarousel } from '../reclameAqui/reclameAquiCarousel';
23
23
  import Section from '../section';
24
24
  import { Queries, RequestStatus, useQuery } from '../webservice';
25
25
  import { createDossieData } from './dossieData';
26
+ import GenerativeAI from './generativeAi/generativeAi';
26
27
  import { Summary } from './summary/summary';
27
28
  import { TransactionsTable } from './transactionTable/transactionTable';
28
- import GenerativeAI from './generativeAi/generativeAi';
29
- var DossieContent = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"], ["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"])));
30
- var DossieContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0px 70px;\n\n @media (max-width: 1000px) {\n padding: 0px 30px;\n }\n"], ["\n padding: 0px 70px;\n\n @media (max-width: 1000px) {\n padding: 0px 30px;\n }\n"])));
29
+ var DossieContent = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"], ["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"])));
30
+ var DossieContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0px 70px;\n @media (max-width: 1000px) {\n padding: 0px 30px;\n }\n"], ["\n padding: 0px 70px;\n @media (max-width: 1000px) {\n padding: 0px 30px;\n }\n"])));
31
31
  var GenerativeAIContainer = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 32px;\n background-color: ", ";\n"], ["\n padding: 32px;\n background-color: ", ";\n"])), function (_a) {
32
32
  var theme = _a.theme;
33
33
  return theme.colors.white;
@@ -36,21 +36,30 @@ var Dossie = function (_a) {
36
36
  var documento = _a.documento, printMode = _a.printMode;
37
37
  var ctx = useContext(Queries.Finder);
38
38
  var rfbResponse = useConsultaRfb().rfbResponse;
39
- var setData = useGlobalData().setData;
40
- var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
41
- // Fetch ReclameAqui data here instead of in the carousel component
42
- var _c = useQuery("SELECT FROM 'RECLAMEAQUI'.'CONSULTA'", { documento: documento }), reclameAquiResponse = _c.response, reclameAquiLoading = _c.isLoading, reclameAquiError = _c.error;
43
- // Parse ReclameAqui data
39
+ var _b = useGlobalData(), globalData = _b.data, setData = _b.setData;
40
+ var lastDossieRef = useRef();
41
+ // Ref para guardar o status de receita anterior
42
+ var prevReceitaStatusRef = useRef(undefined);
43
+ // Estado para sinalizar que houve mudança relevante no rfbResponse
44
+ var _c = useState(false), refreshQuery = _c[0], setRefreshQuery = _c[1];
45
+ // Consulta ReclameAqui
46
+ var _d = useQuery("SELECT FROM 'RECLAMEAQUI'.'CONSULTA'", {
47
+ documento: documento
48
+ }), reclameAquiResponse = _d.response, reclameAquiLoading = _d.isLoading, reclameAquiError = _d.error;
49
+ // Processa os dados do ReclameAqui
44
50
  var reclameAquiCompanies = useMemo(function () {
45
51
  var _a;
46
- if (!reclameAquiLoading && !reclameAquiError && ((_a = reclameAquiResponse === null || reclameAquiResponse === void 0 ? void 0 : reclameAquiResponse.document) === null || _a === void 0 ? void 0 : _a.length)) {
52
+ if (!reclameAquiLoading &&
53
+ !reclameAquiError &&
54
+ ((_a = reclameAquiResponse === null || reclameAquiResponse === void 0 ? void 0 : reclameAquiResponse.document) === null || _a === void 0 ? void 0 : _a.length)) {
47
55
  var isPF = (documento === null || documento === void 0 ? void 0 : documento.length) === 11;
48
56
  if (isPF)
49
57
  return undefined;
50
- // Get the name from the Finder document
51
- var name_1 = ctx.document && XPathUtils.select('string(//cadastro/razaoSocial)', ctx.document) || '';
58
+ var name_1 = (ctx.document &&
59
+ XPathUtils.select('string(//cadastro/razaoSocial)', ctx.document)) ||
60
+ '';
52
61
  return reclameAquiResponse.document.map(function (item) { return ({
53
- nome: name_1, // Use the name from Finder instead of from ReclameAqui response
62
+ nome: name_1,
54
63
  cnpj: documento,
55
64
  score: item.infos.finalScore,
56
65
  status: item.infos.status,
@@ -61,10 +70,19 @@ var Dossie = function (_a) {
61
70
  }); });
62
71
  }
63
72
  return undefined;
64
- }, [reclameAquiResponse, reclameAquiLoading, reclameAquiError, documento, ctx.document]);
65
- // Move the data processing to a useCallback to avoid recreating it on every render
73
+ }, [
74
+ reclameAquiResponse,
75
+ reclameAquiLoading,
76
+ reclameAquiError,
77
+ documento,
78
+ ctx.document
79
+ ]);
80
+ // Reseta o cache do dossiê sempre que o rfbResponse mudar
81
+ useEffect(function () {
82
+ lastDossieRef.current = undefined;
83
+ }, [rfbResponse]);
66
84
  var processDossieData = useCallback(function () {
67
- if (ctx.type === RequestStatus.Success && !dataUpdated && ctx.document) {
85
+ if (ctx.type === RequestStatus.Success && ctx.document) {
68
86
  var data = ctx.document;
69
87
  var isPF = (documento === null || documento === void 0 ? void 0 : documento.length) === 11;
70
88
  var name_2 = (isPF
@@ -72,13 +90,23 @@ var Dossie = function (_a) {
72
90
  : XPathUtils.select('string(//cadastro/razaoSocial)', data) ||
73
91
  (rfbResponse &&
74
92
  XPathUtils.select('string(//RFB/nome)', rfbResponse)));
75
- var document_1 = isPF ? formatCpf(documento) : formatCnpj(documento);
76
- var dossieData_1 = createDossieData(data, rfbResponse, name_2, document_1);
77
- setData(function (prevState) { return (__assign(__assign({}, prevState), { dossie: dossieData_1 })); });
78
- setDataUpdated(true);
93
+ var formattedDocument = isPF
94
+ ? formatCpf(documento)
95
+ : formatCnpj(documento);
96
+ var newDossie_1 = createDossieData(data, rfbResponse, name_2, formattedDocument);
97
+ var newReceitaStatus = newDossie_1.summary.receitaStatus;
98
+ var prevReceitaStatus = prevReceitaStatusRef.current;
99
+ if (JSON.stringify(lastDossieRef.current) !== JSON.stringify(newDossie_1)) {
100
+ lastDossieRef.current = newDossie_1;
101
+ setData(function (prevState) { return (__assign(__assign({}, prevState), { dossie: newDossie_1 })); });
102
+ if (prevReceitaStatus !== undefined &&
103
+ newReceitaStatus !== prevReceitaStatus) {
104
+ setRefreshQuery(true);
105
+ }
106
+ prevReceitaStatusRef.current = newReceitaStatus;
107
+ }
79
108
  }
80
- }, [ctx.type, ctx.document, dataUpdated, documento, rfbResponse, setData]);
81
- // Only update global state once when data is available
109
+ }, [ctx.type, ctx.document, documento, rfbResponse, setData]);
82
110
  useEffect(function () {
83
111
  processDossieData();
84
112
  }, [processDossieData]);
@@ -89,7 +117,8 @@ var Dossie = function (_a) {
89
117
  var name = (isPF
90
118
  ? XPathUtils.select('string(//cadastro/nome)', data)
91
119
  : XPathUtils.select('string(//cadastro/razaoSocial)', data) ||
92
- (rfbResponse && XPathUtils.select('string(//RFB/nome)', rfbResponse)));
120
+ (rfbResponse &&
121
+ XPathUtils.select('string(//RFB/nome)', rfbResponse)));
93
122
  var document = isPF ? formatCpf(documento) : formatCnpj(documento);
94
123
  return (React.createElement(React.Fragment, null,
95
124
  React.createElement(DossieContainer, null,
@@ -98,9 +127,9 @@ var Dossie = function (_a) {
98
127
  React.createElement(Summary, { finderResponse: data, document: document })),
99
128
  React.createElement(TransactionsTable, { events: XPathUtils.select('//historico/consulta', data) || [] })),
100
129
  !printMode && (React.createElement(GenerativeAIContainer, null,
101
- React.createElement(GenerativeAI, { documento: document })))));
130
+ React.createElement(GenerativeAI, { documento: document, refreshQuery: refreshQuery })))));
102
131
  };
103
- }, [documento, rfbResponse, printMode, reclameAquiCompanies]);
132
+ }, [documento, rfbResponse, printMode, reclameAquiCompanies, refreshQuery]);
104
133
  return (React.createElement(Section, { ctx: ctx, hideHeader: true, minimized: false, isError: function (e) { return response(e); }, onSuccess: response }));
105
134
  };
106
135
  export default React.memo(Dossie);
@@ -33,10 +33,13 @@ export function createDossieData(data, rfbResponse, name, document) {
33
33
  ppe: isPF ? XPathUtils.select('string(//cadastro/ppe)', data) : undefined,
34
34
  nomeFantasia: XPathUtils.select('string(//cadastro/nomeFantasia)', data) ||
35
35
  XPathUtils.select('string(//RFB/nome/@fantasia)', rfbResponse),
36
- receitaStatus: XPathUtils.select('string(//cadastro/receitaStatus)', data) ||
37
- XPathUtils.select('string(//RFB/situacao)', rfbResponse),
38
- dataReceitaStatus: XPathUtils.select('string(//cadastro/dataReceitaStatus)', data) ||
39
- XPathUtils.select('string(//RFB/dataSituacao)', rfbResponse),
36
+ // Se houver rfbResponse, use os valores do fallback
37
+ receitaStatus: rfbResponse
38
+ ? XPathUtils.select('string(//body/RFB/situacao)', rfbResponse)
39
+ : XPathUtils.select('string(//cadastro/receitaStatus)', data),
40
+ dataReceitaStatus: rfbResponse
41
+ ? XPathUtils.select('string(//body/RFB/data-situacao)', rfbResponse)
42
+ : XPathUtils.select('string(//cadastro/dataReceitaStatus)', data),
40
43
  tipoEmpresa: XPathUtils.select('string(//cadastro/tipoEmpresa)', data),
41
44
  cnaeDescricao: XPathUtils.select('string(//cadastro/cnaeDescricao)', data) ||
42
45
  XPathUtils.select('string(//RFB/atividade-economica)', rfbResponse),
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  interface GenerativeAIProps {
3
3
  documento: string;
4
+ refreshQuery?: boolean;
4
5
  }
5
6
  declare const GenerativeAI: React.FC<GenerativeAIProps>;
6
7
  export default GenerativeAI;
@@ -1,3 +1,14 @@
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
+ };
1
12
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -63,30 +74,32 @@ import { createQueryAndMessages } from './queryUtils';
63
74
  import { BetaTag, ChatInput, ChatInputContainer, Container, ContainerInput, GenerativeAi, Header, HeaderContent, InitialMessageBox, InitialMessageContent, LoadingDots, Message, MessageHistory, SendButton, Title } from './styles';
64
75
  var GenerativeAI = function (_a) {
65
76
  var _b, _c, _d;
66
- var documento = _a.documento;
77
+ var documento = _a.documento, refreshQuery = _a.refreshQuery;
67
78
  var globalData = useGlobalData().data;
68
79
  var _e = useState('{}'), serializedData = _e[0], setSerializedData = _e[1];
69
80
  var _f = useState(''), userInput = _f[0], setUserInput = _f[1];
70
81
  var _g = useState([]), messageHistory = _g[0], setMessageHistory = _g[1];
71
82
  var _h = useToggle(), isOpen = _h[0], toggleOpen = _h[1];
72
83
  var _j = useState('summary'), streamMode = _j[0], setStreamMode = _j[1];
73
- var _k = useState(null), summaryQueryData = _k[0], setSummaryQueryData = _k[1];
74
- var _l = useState(null), chatQueryData = _l[0], setChatQueryData = _l[1];
75
- var _m = useState(false), pendingRefetch = _m[0], setPendingRefetch = _m[1];
84
+ // Estado para a query de chat (inicia como undefined)
85
+ var _k = useState(undefined), chatQueryData = _k[0], setChatQueryData = _k[1];
86
+ // Estado para forçar o refresh da query summary
87
+ var _l = useState(0), refreshKey = _l[0], setRefreshKey = _l[1];
88
+ // Refs para guardar a última mensagem (evita refetch repetido)
76
89
  var lastQueryRef = useRef(null);
77
90
  var lastUserMessageRef = useRef(null);
78
91
  var messageHistoryRef = useRef(null);
92
+ // Verifica se os dados globais estão carregados
79
93
  var isGlobalDataLoaded = useMemo(function () {
80
94
  return (globalData.documentHistory !== undefined &&
81
95
  globalData.documentHistory !== null);
82
96
  }, [globalData]);
97
+ // Atualiza o payload serializado sempre que os dados globais mudarem
83
98
  useEffect(function () {
84
- // Only update serializedData if globalData has actually changed and is loaded
85
99
  if (globalData && documento && isGlobalDataLoaded) {
86
100
  try {
87
101
  var relevantData = selectRelevantData(globalData);
88
102
  var serialized = flattenData(relevantData);
89
- // Only update state if the data has actually changed
90
103
  if (serialized !== serializedData) {
91
104
  setSerializedData(serialized);
92
105
  }
@@ -99,26 +112,44 @@ var GenerativeAI = function (_a) {
99
112
  }
100
113
  }
101
114
  }, [documento, globalData, isGlobalDataLoaded, serializedData]);
102
- // Only set summary query data once when serializedData is available
103
- useEffect(function () {
104
- if (serializedData &&
105
- serializedData !== '{}' &&
106
- streamMode === 'summary' &&
107
- !summaryQueryData) {
115
+ // Deriva o payload para a consulta summary a partir do serializedData.
116
+ // Incluímos o refreshKey para forçar a atualização da query.
117
+ var summaryQueryData = useMemo(function () {
118
+ if (serializedData && serializedData !== '{}' && streamMode === 'summary') {
108
119
  var queryData = createQueryAndMessages(serializedData, []);
109
- setSummaryQueryData(queryData);
120
+ return queryData
121
+ ? __assign(__assign({}, queryData), { refreshKey: refreshKey.toString() }) : undefined;
122
+ }
123
+ return undefined;
124
+ }, [serializedData, streamMode, refreshKey]);
125
+ // Configura a query summary com o hook useStreamQuery
126
+ 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;
127
+ // Configura a query chat
128
+ 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;
129
+ // Dispara o refetch inicial quando summaryQueryData estiver definido
130
+ useEffect(function () {
131
+ if (summaryQueryData) {
132
+ refetchSummary();
133
+ }
134
+ }, [summaryQueryData, refetchSummary]);
135
+ // Detecta a transição de refreshQuery de false para true para reiniciar a consulta
136
+ var prevRefreshQueryRef = useRef(refreshQuery);
137
+ useEffect(function () {
138
+ if (refreshQuery && !prevRefreshQueryRef.current) {
139
+ // Aborta o stream summary atual, se houver
140
+ abortSummary();
141
+ // Permite que o stream summary seja processado novamente
142
+ processedSummaryRef.current = false;
143
+ // Garante que o modo esteja definido como summary
144
+ if (streamMode !== 'summary') {
145
+ setStreamMode('summary');
146
+ }
147
+ // Incrementa o refreshKey para forçar a atualização da query
148
+ setRefreshKey(function (prev) { return prev + 1; });
110
149
  }
111
- }, [serializedData, streamMode, summaryQueryData]);
112
- // Memoize the useStreamQuery parameters to prevent unnecessary API calls
113
- var summaryQueryEnabled = useMemo(function () {
114
- return streamMode === 'summary' && !!summaryQueryData;
115
- }, [streamMode, summaryQueryData]);
116
- var chatQueryEnabled = useMemo(function () {
117
- return streamMode === 'chat' && !!chatQueryData;
118
- }, [streamMode, chatQueryData]);
119
- var _o = useStreamQuery("SELECT FROM 'LlamaApi'.'Consulta'", summaryQueryData, summaryQueryEnabled), summaryIterator = _o.responseIterator, summaryError = _o.error, summaryLoading = _o.isLoading, refetchSummary = _o.refetch, abortSummary = _o.abort;
120
- var _p = useStreamQuery("SELECT FROM 'LlamaApi'.'Consulta'", chatQueryData, chatQueryEnabled), chatIterator = _p.responseIterator, chatError = _p.error, chatLoading = _p.isLoading, refetchChat = _p.refetch, abortChat = _p.abort;
121
- // Use a ref to track if we've already processed this iterator
150
+ prevRefreshQueryRef.current = refreshQuery;
151
+ }, [refreshQuery, abortSummary, streamMode]);
152
+ // Processa o stream da consulta summary (apenas uma vez)
122
153
  var processedSummaryRef = useRef(false);
123
154
  useEffect(function () {
124
155
  if (summaryIterator && !processedSummaryRef.current) {
@@ -140,7 +171,7 @@ var GenerativeAI = function (_a) {
140
171
  }); })();
141
172
  }
142
173
  }, [summaryIterator]);
143
- // Use a ref to track each chat iterator
174
+ // Processa o stream da consulta chat
144
175
  var processedChatRef = useRef(new Map());
145
176
  useEffect(function () {
146
177
  if (chatIterator && !processedChatRef.current.get(chatIterator)) {
@@ -165,19 +196,17 @@ var GenerativeAI = function (_a) {
165
196
  lastQueryRef.current = newChatQueryData.messages;
166
197
  abortChat();
167
198
  setChatQueryData(newChatQueryData);
168
- setPendingRefetch(true);
169
199
  }
170
200
  }
171
201
  }, [messageHistory, serializedData, streamMode, chatLoading, abortChat]);
172
202
  useEffect(function () {
173
- if (pendingRefetch &&
174
- chatQueryData &&
203
+ if (chatQueryData &&
175
204
  streamMode === 'chat' &&
176
- !chatLoading) {
205
+ !chatLoading &&
206
+ messageHistory.length > 0) {
177
207
  refetchChat();
178
- setPendingRefetch(false);
179
208
  }
180
- }, [pendingRefetch, chatQueryData, streamMode, chatLoading, refetchChat]);
209
+ }, [chatQueryData, streamMode, chatLoading, refetchChat, messageHistory]);
181
210
  var handleStopStream = function () {
182
211
  abortChat();
183
212
  };
@@ -20,7 +20,7 @@ import { ButtonsSummary, ButtonsWrapper, ContainerSummary, ContentSummary, Field
20
20
  export var Summary = function (_a) {
21
21
  var finderResponse = _a.finderResponse;
22
22
  var _b = useCardsAndProducts({
23
- finderResponse: finderResponse,
23
+ finderResponse: finderResponse
24
24
  }), cards = _b.cards, products = _b.products, isModalOpen = _b.isModalOpen, closeModal = _b.closeModal, isScrModalOpen = _b.isScrModalOpen, setScrModalOpen = _b.setScrModalOpen, setConsultasComplementares = _b.setConsultasComplementares;
25
25
  return (React.createElement(React.Fragment, null,
26
26
  React.createElement(ContainerSummary, { className: "credithub-container-summary" },
@@ -32,7 +32,6 @@ export var Summary = function (_a) {
32
32
  React.createElement(SummaryButton, { onClick: function () { return (product === null || product === void 0 ? void 0 : product.onClick) && (product === null || product === void 0 ? void 0 : product.onClick()); }, disabled: product.isLoading, smallContent: product.price ? formatMoney(product.price) : undefined }, product.isLoading ? React.createElement(Spinner, null) : product.title))); })),
33
33
  React.createElement(Modal, { isOpen: isModalOpen, onClose: closeModal, title: "\uD83D\uDEA7 Consulta temporariamente indispon\u00EDvel", message: "A consulta Pefin/Refin Serasa est\u00E1 fora do ar devido a mudan\u00E7as na fonte. Nossa equipe j\u00E1 est\u00E1 trabalhando para resolver, mas ainda n\u00E3o h\u00E1 previs\u00E3o de normaliza\u00E7\u00E3o.", incidentUrl: "https://credithub.statuspage.io/incidents/hnvx1dxby7rk" })),
34
34
  isScrModalOpen && (React.createElement(ScrDataBaseModal, { isOpen: isScrModalOpen, onClose: function () { return setScrModalOpen(false); }, onConfirm: function (selected) {
35
- console.log('Data-base selecionada:', selected);
36
35
  setScrModalOpen(false);
37
36
  setConsultasComplementares === null || setConsultasComplementares === void 0 ? void 0 : setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { scr: __assign(__assign({}, prev === null || prev === void 0 ? void 0 : prev.scr), { dataBase: selected, consultaRealizada: true }) })); });
38
37
  } }))));
@@ -18,7 +18,6 @@ import { Queries, RequestStatus } from '../webservice';
18
18
  import ProcessosJuridicosList from './processosJuridicosList';
19
19
  var ProcessosJuridicos = function (_a) {
20
20
  var onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico;
21
- console.log('Processos Juridicos Renderizou');
22
21
  var ctx = useContext(Queries.ProcessosJuridicos);
23
22
  var setData = useGlobalData().setData;
24
23
  var processedRef = useRef(false);
@@ -51,6 +51,13 @@ var Protestos = function () {
51
51
  }
52
52
  return 0;
53
53
  }, [ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.type, ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.document]);
54
+ useEffect(function () {
55
+ if ((ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Error ||
56
+ (ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Empty) {
57
+ setData(function (prevState) { return (__assign(__assign({}, prevState), { protestosData: { isLoaded: true } })); });
58
+ return;
59
+ }
60
+ }, [ctx.type]);
54
61
  // Processa os protestos e atualiza o contexto global (apenas quando ctx.document é válido e o processamento ainda não ocorreu)
55
62
  useEffect(function () {
56
63
  if (dataUpdated || !ctx.document) {