@credithub/harlan-components 1.62.7 → 1.62.9
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.
- package/dist/components/chart/quantityResult.js +6 -6
- package/dist/components/consultaRfb.js +8 -4
- package/dist/components/dossie/dossie.js +55 -25
- package/dist/components/dossie/dossieData.js +7 -4
- package/dist/components/dossie/generativeAi/generativeAi.d.ts +1 -0
- package/dist/components/dossie/generativeAi/generativeAi.js +62 -31
- package/dist/components/processos-juridicos/processosJuridicos.js +0 -1
- package/dist/utils/date.js +1 -1
- package/lib/cjs/index.js +1427 -1360
- package/lib/esm/index.js +1427 -1360
- package/package.json +1 -1
|
@@ -31,13 +31,13 @@ var QuantidadeResultados = function (_a) {
|
|
|
31
31
|
React.createElement(AddItemField, { name: "Total D\u00EDvidas P\u00FAblicas", value: formatMoney(valorTotalDividas) }),
|
|
32
32
|
React.createElement(AddItemField, { hidden: !ultimaOcorrenciaDividas, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaDividas })),
|
|
33
33
|
React.createElement(QuantityContainer, null,
|
|
34
|
-
React.createElement(AddItemField, { name: "Pefin Refin Serasa", value: formatValue(quantidadeDividasSerasa) }),
|
|
35
|
-
React.createElement(AddItemField, { name: "Total Pefin Refin Serasa", value: formatMoney(valorTotalDividasSerasa) }),
|
|
36
|
-
React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinSerasa, name: "
|
|
34
|
+
React.createElement(AddItemField, { name: "Pefin Refin Serasa", value: !ultimaOcorrenciaPefinSerasa ? 'Consulta nunca realizada. Seja o primeiro!' : formatValue(quantidadeDividasSerasa) }),
|
|
35
|
+
React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinSerasa, name: "Total Pefin Refin Serasa", value: formatMoney(valorTotalDividasSerasa) }),
|
|
36
|
+
React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinSerasa, name: valorTotalDividasSerasa ? "Última Ocorrência" : "Última Consulta", value: ultimaOcorrenciaPefinSerasa })),
|
|
37
37
|
React.createElement(QuantityContainer, null,
|
|
38
|
-
React.createElement(AddItemField, { name: "Pefin Refin Boa Vista", value: formatValue(quantidadeDividasBoaVista) }),
|
|
39
|
-
React.createElement(AddItemField, { name: "Total Pefin Refin Boa Vista", value: formatMoney(valorTotalDividasBoaVista) }),
|
|
40
|
-
React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinBoaVista, name: "
|
|
38
|
+
React.createElement(AddItemField, { name: "Pefin Refin Boa Vista", value: !ultimaOcorrenciaPefinBoaVista ? 'Consulta nunca realizada. Seja o primeiro!' : formatValue(quantidadeDividasBoaVista) }),
|
|
39
|
+
React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinBoaVista, name: "Total Pefin Refin Boa Vista", value: formatMoney(valorTotalDividasBoaVista) }),
|
|
40
|
+
React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinBoaVista, name: valorTotalDividasBoaVista ? "Última Ocorrência" : "Última Consulta", value: ultimaOcorrenciaPefinBoaVista })))));
|
|
41
41
|
};
|
|
42
42
|
export default QuantidadeResultados;
|
|
43
43
|
var templateObject_1;
|
|
@@ -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
|
|
6
|
+
var _b, _c;
|
|
7
7
|
var children = _a.children, documento = _a.documento;
|
|
8
|
-
var
|
|
9
|
-
var query = useQuery("SELECT FROM 'RFB'.'CERTIDAO'", {
|
|
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:
|
|
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,
|
|
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
|
-
|
|
29
|
-
var
|
|
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
|
|
40
|
-
var
|
|
41
|
-
//
|
|
42
|
-
var
|
|
43
|
-
//
|
|
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 &&
|
|
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
|
-
|
|
51
|
-
|
|
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,
|
|
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
|
-
}, [
|
|
65
|
-
|
|
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 &&
|
|
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,24 @@ 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
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
}
|
|
108
|
+
console.log(globalData);
|
|
79
109
|
}
|
|
80
|
-
}, [ctx.type, ctx.document,
|
|
81
|
-
// Only update global state once when data is available
|
|
110
|
+
}, [ctx.type, ctx.document, documento, rfbResponse, setData]);
|
|
82
111
|
useEffect(function () {
|
|
83
112
|
processDossieData();
|
|
84
113
|
}, [processDossieData]);
|
|
@@ -89,7 +118,8 @@ var Dossie = function (_a) {
|
|
|
89
118
|
var name = (isPF
|
|
90
119
|
? XPathUtils.select('string(//cadastro/nome)', data)
|
|
91
120
|
: XPathUtils.select('string(//cadastro/razaoSocial)', data) ||
|
|
92
|
-
(rfbResponse &&
|
|
121
|
+
(rfbResponse &&
|
|
122
|
+
XPathUtils.select('string(//RFB/nome)', rfbResponse)));
|
|
93
123
|
var document = isPF ? formatCpf(documento) : formatCnpj(documento);
|
|
94
124
|
return (React.createElement(React.Fragment, null,
|
|
95
125
|
React.createElement(DossieContainer, null,
|
|
@@ -98,9 +128,9 @@ var Dossie = function (_a) {
|
|
|
98
128
|
React.createElement(Summary, { finderResponse: data, document: document })),
|
|
99
129
|
React.createElement(TransactionsTable, { events: XPathUtils.select('//historico/consulta', data) || [] })),
|
|
100
130
|
!printMode && (React.createElement(GenerativeAIContainer, null,
|
|
101
|
-
React.createElement(GenerativeAI, { documento: document })))));
|
|
131
|
+
React.createElement(GenerativeAI, { documento: document, refreshQuery: refreshQuery })))));
|
|
102
132
|
};
|
|
103
|
-
}, [documento, rfbResponse, printMode, reclameAquiCompanies]);
|
|
133
|
+
}, [documento, rfbResponse, printMode, reclameAquiCompanies, refreshQuery]);
|
|
104
134
|
return (React.createElement(Section, { ctx: ctx, hideHeader: true, minimized: false, isError: function (e) { return response(e); }, onSuccess: response }));
|
|
105
135
|
};
|
|
106
136
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
XPathUtils.select('string(//
|
|
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,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,33 @@ 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
|
-
|
|
74
|
-
var
|
|
75
|
-
|
|
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
|
+
console.log('refreshQuery', refreshQuery);
|
|
98
|
+
// Atualiza o payload serializado sempre que os dados globais mudarem
|
|
83
99
|
useEffect(function () {
|
|
84
|
-
// Only update serializedData if globalData has actually changed and is loaded
|
|
85
100
|
if (globalData && documento && isGlobalDataLoaded) {
|
|
86
101
|
try {
|
|
87
102
|
var relevantData = selectRelevantData(globalData);
|
|
88
103
|
var serialized = flattenData(relevantData);
|
|
89
|
-
// Only update state if the data has actually changed
|
|
90
104
|
if (serialized !== serializedData) {
|
|
91
105
|
setSerializedData(serialized);
|
|
92
106
|
}
|
|
@@ -99,26 +113,45 @@ var GenerativeAI = function (_a) {
|
|
|
99
113
|
}
|
|
100
114
|
}
|
|
101
115
|
}, [documento, globalData, isGlobalDataLoaded, serializedData]);
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
streamMode === 'summary' &&
|
|
107
|
-
!summaryQueryData) {
|
|
116
|
+
// Deriva o payload para a consulta summary a partir do serializedData.
|
|
117
|
+
// Incluímos o refreshKey para forçar a atualização da query.
|
|
118
|
+
var summaryQueryData = useMemo(function () {
|
|
119
|
+
if (serializedData && serializedData !== '{}' && streamMode === 'summary') {
|
|
108
120
|
var queryData = createQueryAndMessages(serializedData, []);
|
|
109
|
-
|
|
121
|
+
return queryData
|
|
122
|
+
? __assign(__assign({}, queryData), { refreshKey: refreshKey.toString() }) : undefined;
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}, [serializedData, streamMode, refreshKey]);
|
|
126
|
+
// Configura a query summary com o hook useStreamQuery
|
|
127
|
+
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;
|
|
128
|
+
// Configura a query chat
|
|
129
|
+
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;
|
|
130
|
+
// Dispara o refetch inicial quando summaryQueryData estiver definido
|
|
131
|
+
useEffect(function () {
|
|
132
|
+
if (summaryQueryData) {
|
|
133
|
+
refetchSummary();
|
|
134
|
+
}
|
|
135
|
+
}, [summaryQueryData, refetchSummary]);
|
|
136
|
+
// Detecta a transição de refreshQuery de false para true para reiniciar a consulta
|
|
137
|
+
var prevRefreshQueryRef = useRef(refreshQuery);
|
|
138
|
+
useEffect(function () {
|
|
139
|
+
if (refreshQuery && !prevRefreshQueryRef.current) {
|
|
140
|
+
console.log('executou refreshQuery');
|
|
141
|
+
// Aborta o stream summary atual, se houver
|
|
142
|
+
abortSummary();
|
|
143
|
+
// Permite que o stream summary seja processado novamente
|
|
144
|
+
processedSummaryRef.current = false;
|
|
145
|
+
// Garante que o modo esteja definido como summary
|
|
146
|
+
if (streamMode !== 'summary') {
|
|
147
|
+
setStreamMode('summary');
|
|
148
|
+
}
|
|
149
|
+
// Incrementa o refreshKey para forçar a atualização da query
|
|
150
|
+
setRefreshKey(function (prev) { return prev + 1; });
|
|
110
151
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
|
152
|
+
prevRefreshQueryRef.current = refreshQuery;
|
|
153
|
+
}, [refreshQuery, abortSummary, streamMode]);
|
|
154
|
+
// Processa o stream da consulta summary (apenas uma vez)
|
|
122
155
|
var processedSummaryRef = useRef(false);
|
|
123
156
|
useEffect(function () {
|
|
124
157
|
if (summaryIterator && !processedSummaryRef.current) {
|
|
@@ -140,7 +173,7 @@ var GenerativeAI = function (_a) {
|
|
|
140
173
|
}); })();
|
|
141
174
|
}
|
|
142
175
|
}, [summaryIterator]);
|
|
143
|
-
//
|
|
176
|
+
// Processa o stream da consulta chat
|
|
144
177
|
var processedChatRef = useRef(new Map());
|
|
145
178
|
useEffect(function () {
|
|
146
179
|
if (chatIterator && !processedChatRef.current.get(chatIterator)) {
|
|
@@ -165,19 +198,17 @@ var GenerativeAI = function (_a) {
|
|
|
165
198
|
lastQueryRef.current = newChatQueryData.messages;
|
|
166
199
|
abortChat();
|
|
167
200
|
setChatQueryData(newChatQueryData);
|
|
168
|
-
setPendingRefetch(true);
|
|
169
201
|
}
|
|
170
202
|
}
|
|
171
203
|
}, [messageHistory, serializedData, streamMode, chatLoading, abortChat]);
|
|
172
204
|
useEffect(function () {
|
|
173
|
-
if (
|
|
174
|
-
chatQueryData &&
|
|
205
|
+
if (chatQueryData &&
|
|
175
206
|
streamMode === 'chat' &&
|
|
176
|
-
!chatLoading
|
|
207
|
+
!chatLoading &&
|
|
208
|
+
messageHistory.length > 0) {
|
|
177
209
|
refetchChat();
|
|
178
|
-
setPendingRefetch(false);
|
|
179
210
|
}
|
|
180
|
-
}, [
|
|
211
|
+
}, [chatQueryData, streamMode, chatLoading, refetchChat, messageHistory]);
|
|
181
212
|
var handleStopStream = function () {
|
|
182
213
|
abortChat();
|
|
183
214
|
};
|
|
@@ -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);
|
package/dist/utils/date.js
CHANGED
|
@@ -15,6 +15,6 @@ export function converterParaFormatoValido(data) {
|
|
|
15
15
|
export function formatDatePtBrToDate(date) {
|
|
16
16
|
var _a;
|
|
17
17
|
var x = (_a = date === null || date === void 0 ? void 0 : date.split('/')) === null || _a === void 0 ? void 0 : _a.reverse();
|
|
18
|
-
var b = x === null || x === void 0 ? void 0 : x.join('-');
|
|
18
|
+
var b = (x === null || x === void 0 ? void 0 : x.join('-')) + 'T00:00';
|
|
19
19
|
return new Date(b);
|
|
20
20
|
}
|