@credithub/harlan-components 1.114.0 → 1.115.1

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.
@@ -10,6 +10,7 @@ interface UseInstrumentoReturn {
10
10
  isEmailModalOpen: boolean;
11
11
  emailMessage: ReactNode;
12
12
  emailTitle: string;
13
+ isSuccess: boolean;
13
14
  isEnviandoEmail: boolean;
14
15
  isProcessandoDescoberta: boolean;
15
16
  openModalSP: () => void;
@@ -49,8 +49,9 @@ export var useInstrumento = function (_a) {
49
49
  var _c = useState(false), isEmailModalOpen = _c[0], setIsEmailModalOpen = _c[1];
50
50
  var _d = useState(''), emailMessage = _d[0], setEmailMessage = _d[1];
51
51
  var _e = useState('Instrumento de Protesto'), emailTitle = _e[0], setEmailTitle = _e[1];
52
- var _f = useState(false), isEnviandoEmail = _f[0], setIsEnviandoEmail = _f[1];
53
- var _g = useState(false), isProcessandoDescoberta = _g[0], setIsProcessandoDescoberta = _g[1];
52
+ var _f = useState(false), isSuccess = _f[0], setIsSuccess = _f[1];
53
+ var _g = useState(false), isEnviandoEmail = _g[0], setIsEnviandoEmail = _g[1];
54
+ var _h = useState(false), isProcessandoDescoberta = _h[0], setIsProcessandoDescoberta = _h[1];
54
55
  var openModalSP = useCallback(function () {
55
56
  setIsModalSPOpen(true);
56
57
  }, []);
@@ -61,6 +62,7 @@ export var useInstrumento = function (_a) {
61
62
  setIsEmailModalOpen(false);
62
63
  setEmailMessage('');
63
64
  setEmailTitle('Instrumento de Protesto');
65
+ setIsSuccess(false);
64
66
  }, []);
65
67
  var handleEnviarEmail = useCallback(function (livro, folha) { return __awaiter(void 0, void 0, void 0, function () {
66
68
  var res, error_1;
@@ -82,6 +84,7 @@ export var useInstrumento = function (_a) {
82
84
  setEmailTitle('Instrumento solicitado por e-mail');
83
85
  setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
84
86
  'Solicitação registrada. Vamos processar o instrumento e também agregar as informações do credor quando possível. Em alguns minutos, refaça a consulta de hoje para atualizar os dados.');
87
+ setIsSuccess(true);
85
88
  setIsEmailModalOpen(true);
86
89
  setIsModalSPOpen(false);
87
90
  return [3 /*break*/, 5];
@@ -89,6 +92,7 @@ export var useInstrumento = function (_a) {
89
92
  error_1 = _a.sent();
90
93
  setEmailTitle('Erro ao Enviar E-mail');
91
94
  setEmailMessage('Não foi possível solicitar o instrumento por e-mail agora. Tente novamente em instantes.');
95
+ setIsSuccess(false);
92
96
  setIsEmailModalOpen(true);
93
97
  return [3 /*break*/, 5];
94
98
  case 4:
@@ -116,12 +120,14 @@ export var useInstrumento = function (_a) {
116
120
  setEmailTitle('Solicitação enviada');
117
121
  setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
118
122
  'Solicitação registrada. Vamos processar o instrumento e também agregar as informações do credor quando possível. Em alguns minutos, refaça a consulta de hoje para atualizar os dados.');
123
+ setIsSuccess(true);
119
124
  setIsEmailModalOpen(true);
120
125
  return [3 /*break*/, 5];
121
126
  case 3:
122
127
  error_2 = _a.sent();
123
128
  setEmailTitle('Erro na solicitação');
124
129
  setEmailMessage('Não foi possível iniciar a solicitação por e-mail agora. Tente novamente em instantes.');
130
+ setIsSuccess(false);
125
131
  setIsEmailModalOpen(true);
126
132
  return [3 /*break*/, 5];
127
133
  case 4:
@@ -136,6 +142,7 @@ export var useInstrumento = function (_a) {
136
142
  isEmailModalOpen: isEmailModalOpen,
137
143
  emailMessage: emailMessage,
138
144
  emailTitle: emailTitle,
145
+ isSuccess: isSuccess,
139
146
  isEnviandoEmail: isEnviandoEmail,
140
147
  isProcessandoDescoberta: isProcessandoDescoberta,
141
148
  openModalSP: openModalSP,
@@ -1,3 +1,5 @@
1
1
  import React from 'react';
2
- declare const _default: React.NamedExoticComponent<{}>;
2
+ declare const _default: React.NamedExoticComponent<{
3
+ tags: (string | RegExp)[];
4
+ }>;
3
5
  export default _default;
@@ -39,25 +39,28 @@ import Section from '../section';
39
39
  import { Queries, RequestStatus } from '../webservice';
40
40
  import ProtestosCategory from './protestosCategory';
41
41
  import { ProtestoItem } from './protestosList';
42
+ import { hasOneOfTags } from '../../utils/tags';
42
43
  var ResultProtestos = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n row-gap: 20px;\n margin-top: 20px;\n"], ["\n display: flex;\n flex-direction: column;\n row-gap: 20px;\n margin-top: 20px;\n"])));
43
44
  var BtnWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n text-align: center;\n @media print {\n display: none;\n }\n"], ["\n text-align: center;\n @media print {\n display: none;\n }\n"])));
44
45
  // Função utilitária para extrair as chaves dos protestos
45
46
  var getChaves = function (arr) { return arr.map(function (p) { return p.nm_chave; }); };
46
47
  var PROTESTOS_ERROR_SUMMARY = 'Falha ao consultar protestos, tente novamente mais tarde.';
47
48
  var clearProtestosCollections = function (state) { return (__assign(__assign({}, (state || {})), { protestosDeCredito: undefined, protestosDeImposto: undefined, protestosGerais: undefined, totalProtestos: undefined, valorTotalProtestos: undefined, nmChaves: undefined })); };
48
- var Protestos = function () {
49
- var _a, _b;
49
+ var Protestos = function (_a) {
50
+ var _b, _c;
51
+ var tags = _a.tags;
50
52
  var ctx = useContext(Queries.Protestos);
51
53
  var ctxLiminar = useContext(Queries.Liminar);
52
- var _c = useGlobalData(), globalData = _c.data, setData = _c.setData;
53
- var _d = useState(false), dataUpdated = _d[0], setDataUpdated = _d[1];
54
+ var _d = useGlobalData(), globalData = _d.data, setData = _d.setData;
55
+ var _e = useState(false), dataUpdated = _e[0], setDataUpdated = _e[1];
56
+ var showInstrumento = !hasOneOfTags(tags, [/flex/, 'bronze']);
54
57
  var protestosAll = useMemo(function () {
55
58
  if (!ctx.document)
56
59
  return [];
57
60
  return XPathUtils.selectArray('//body//protesto', ctx.document).map(parseProtesto);
58
61
  }, [ctx.document]);
59
- var iaOverrides = (_a = globalData.protestosData) === null || _a === void 0 ? void 0 : _a.iaOverrides;
60
- var _e = useProtestosClassification(protestosAll, iaOverrides), protestosDeCredito = _e.protestosDeCredito, protestosDeImposto = _e.protestosDeImposto, protestosGerais = _e.protestosGerais;
62
+ var iaOverrides = (_b = globalData.protestosData) === null || _b === void 0 ? void 0 : _b.iaOverrides;
63
+ var _f = useProtestosClassification(protestosAll, iaOverrides), protestosDeCredito = _f.protestosDeCredito, protestosDeImposto = _f.protestosDeImposto, protestosGerais = _f.protestosGerais;
61
64
  useEffect(function () {
62
65
  var _a;
63
66
  var prevProtestos = globalData.protestosData;
@@ -140,15 +143,15 @@ var Protestos = function () {
140
143
  var elements = [
141
144
  {
142
145
  total: protestosDeCredito.length,
143
- element: (React.createElement(ProtestosCategory, { title: "Protestos de Cr\u00E9dito", subtitle: "Protestos de cr\u00E9dito em geral.", registros: protestosDeCredito.length, icon: ProtestosCreditoIcon }, protestosDeCredito.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i })); })))
146
+ element: (React.createElement(ProtestosCategory, { title: "Protestos de Cr\u00E9dito", subtitle: "Protestos de cr\u00E9dito em geral.", registros: protestosDeCredito.length, icon: ProtestosCreditoIcon }, protestosDeCredito.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i, showInstrumento: showInstrumento })); })))
144
147
  },
145
148
  {
146
149
  total: protestosDeImposto.length,
147
- element: (React.createElement(ProtestosCategory, { title: "Protestos de Imposto", subtitle: "Protestos de impostos federais, estaduais e municipais.", registros: protestosDeImposto.length, icon: ProtestosImpostosIcon }, protestosDeImposto.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i })); })))
150
+ element: (React.createElement(ProtestosCategory, { title: "Protestos de Imposto", subtitle: "Protestos de impostos federais, estaduais e municipais.", registros: protestosDeImposto.length, icon: ProtestosImpostosIcon }, protestosDeImposto.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i, showInstrumento: showInstrumento })); })))
148
151
  },
149
152
  {
150
153
  total: protestosGerais.length,
151
- element: (React.createElement(ProtestosCategory, { title: "Protestos Gerais", subtitle: "Protestos de outros tipos.", registros: protestosGerais.length, icon: ProtestosGeraisIcon }, protestosGerais.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i })); })))
154
+ element: (React.createElement(ProtestosCategory, { title: "Protestos Gerais", subtitle: "Protestos de outros tipos.", registros: protestosGerais.length, icon: ProtestosGeraisIcon }, protestosGerais.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i, showInstrumento: showInstrumento })); })))
152
155
  }
153
156
  ].sort(function (a, b) { return b.total - a.total; });
154
157
  var children = registros ? (React.createElement(ResultProtestos, null, elements.map(function (_a, i) {
@@ -176,7 +179,7 @@ var Protestos = function () {
176
179
  return __assign(__assign({}, ctx), { type: RequestStatus.Loading });
177
180
  }
178
181
  return ctx;
179
- }, [ctx, (_b = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _b === void 0 ? void 0 : _b.isLoading]);
182
+ }, [ctx, (_c = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _c === void 0 ? void 0 : _c.isLoading]);
180
183
  return (React.createElement(Section, { ctx: effectiveCtx, title: "Apontamentos na Central de Protestos (CENPROT)", subtitle: "Consulta de protestos de cr\u00E9dito, imposto e gerais.", icon: ProtestosIcon, onSuccess: handleSuccess, actions: typeof harlan !== 'undefined' ? (React.createElement(BtnWrapper, null,
181
184
  React.createElement(Button, { onClick: function () {
182
185
  var _a;
@@ -1,12 +1,10 @@
1
1
  import { Protesto } from '../../utils/parseProtesto';
2
2
  import React from 'react';
3
- export declare const ProtestoItem: React.MemoExoticComponent<({ protesto }: {
3
+ export declare const ProtestoItem: React.MemoExoticComponent<({ protesto, showInstrumento }: {
4
4
  protesto: Protesto;
5
+ showInstrumento: boolean;
5
6
  }) => React.JSX.Element>;
6
7
  export declare const Instrumento: ({ nm_chave, cpfCnpj }: {
7
8
  nm_chave?: string;
8
9
  cpfCnpj?: string;
9
10
  }) => React.JSX.Element | null;
10
- export declare const ProtestosList: React.FC<{
11
- protestos: Protesto[];
12
- }>;
@@ -148,7 +148,7 @@ var AIIndicator = function () { return (React.createElement("span", { title: "In
148
148
  } }, "*")); };
149
149
  export var ProtestoItem = memo(function (_a) {
150
150
  var _b, _c;
151
- var protesto = _a.protesto;
151
+ var protesto = _a.protesto, showInstrumento = _a.showInstrumento;
152
152
  var client = useContext(WebService);
153
153
  var _d = useGlobalData(), setData = _d.setData, globalData = _d.data;
154
154
  var iaOverrides = ((_b = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _b === void 0 ? void 0 : _b.iaOverrides) || {};
@@ -163,58 +163,10 @@ export var ProtestoItem = memo(function (_a) {
163
163
  return value === 'true' ? 'Sim' : 'Não';
164
164
  };
165
165
  var fetchQuemApresentou = function (nm_chave) { return __awaiter(void 0, void 0, void 0, function () {
166
- var normalizedKey, response, nomeDetectado_1, error_1;
167
166
  return __generator(this, function (_a) {
168
- switch (_a.label) {
169
- case 0:
170
- if (!isInstrumentKeyValid(nm_chave))
171
- return [2 /*return*/];
172
- normalizedKey = normalizeInstrumentKey(nm_chave);
173
- if (!normalizedKey)
174
- return [2 /*return*/];
175
- setLoading(true);
176
- _a.label = 1;
177
- case 1:
178
- _a.trys.push([1, 4, 5, 6]);
179
- return [4 /*yield*/, client.request("SELECT FROM 'PDFPROTESTO'.'AI'", {
180
- nm_chave: normalizedKey,
181
- documento: documento
182
- })];
183
- case 2: return [4 /*yield*/, (_a.sent()).json()];
184
- case 3:
185
- response = _a.sent();
186
- nomeDetectado_1 = null;
187
- if (response === null || response === void 0 ? void 0 : response['Quem Protestou']) {
188
- nomeDetectado_1 = response['Quem Protestou'];
189
- }
190
- else if (response === null || response === void 0 ? void 0 : response['Quem Apresentou']) {
191
- nomeDetectado_1 = response['Quem Apresentou'];
192
- }
193
- if (nomeDetectado_1) {
194
- setQuemApresentou(nomeDetectado_1);
195
- setIsAIData(true);
196
- // Salva IA override globalmente
197
- setData(function (prev) {
198
- var _a;
199
- var _b;
200
- // Garante que só string é atribuída
201
- if (!nomeDetectado_1)
202
- return prev;
203
- return __assign(__assign({}, prev), { protestosData: __assign(__assign({}, prev.protestosData), { iaOverrides: __assign(__assign({}, (((_b = prev.protestosData) === null || _b === void 0 ? void 0 : _b.iaOverrides) || {})), (_a = {}, _a[nm_chave] = nomeDetectado_1, _a)) }) });
204
- });
205
- }
206
- return [3 /*break*/, 6];
207
- case 4:
208
- error_1 = _a.sent();
209
- console.error('Erro ao buscar dados de protesto IA:', error_1);
210
- return [3 /*break*/, 6];
211
- case 5:
212
- setLoading(false);
213
- activeRequests--;
214
- processQueue();
215
- return [7 /*endfinally*/];
216
- case 6: return [2 /*return*/];
217
- }
167
+ // Desabilitado: endpoint PDFPROTESTO.AI está retornando erro 500 (serviço legado indisponível)
168
+ // TODO: Reativar quando novo endpoint de IA estiver disponível
169
+ return [2 /*return*/];
218
170
  });
219
171
  }); };
220
172
  var queueOrExecuteFetch = function (nm_chave) {
@@ -272,7 +224,7 @@ export var ProtestoItem = memo(function (_a) {
272
224
  React.createElement(AddItemField, { name: "Possui Anu\u00EAncia / Protesto Pago", value: formatBooleanField(String(protesto.temAnuencia)) }),
273
225
  React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(protesto.valor) }),
274
226
  protesto.vl_custas && (React.createElement(AddItemField, { name: "Custas de Cart\u00F3rio para Baixa", value: formatMoney(protesto.vl_custas) })),
275
- React.createElement(Instrumento, { nm_chave: nm_chave, cpfCnpj: documento })));
227
+ showInstrumento && React.createElement(Instrumento, { nm_chave: nm_chave, cpfCnpj: documento })));
276
228
  });
277
229
  export var Instrumento = function (_a) {
278
230
  var nm_chave = _a.nm_chave, cpfCnpj = _a.cpfCnpj;
@@ -536,13 +488,15 @@ export var Instrumento = function (_a) {
536
488
  });
537
489
  }); }, disabled: isDisabled }, getButtonLabel())),
538
490
  React.createElement(ModalInstrumentoProtestoSP, { isOpen: instrumentoHook.isModalSPOpen, onClose: instrumentoHook.closeModalSP, onEnviarEmail: instrumentoHook.handleEnviarEmail, isEnviandoEmail: instrumentoHook.isEnviandoEmail }),
539
- React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle, secondaryActionLabel: "Atualizar consulta (hoje)", secondaryActionDisabled: isPrefetching || isLoading, onSecondaryAction: function () {
540
- var _a;
541
- // Permite reconsultar no mesmo dia para tentar “desocultar” instrumento/nome
542
- resetInstrumentStateForKey();
543
- (_a = ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.refetch) === null || _a === void 0 ? void 0 : _a.call(ctxProtestos);
544
- instrumentoHook.closeEmailModal();
545
- } }),
491
+ React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle, secondaryActionLabel: instrumentoHook.isSuccess ? 'Atualizar consulta (hoje)' : undefined, secondaryActionDisabled: isPrefetching || isLoading, onSecondaryAction: instrumentoHook.isSuccess
492
+ ? function () {
493
+ var _a;
494
+ // Permite reconsultar no mesmo dia para tentar “desocultar” instrumento/nome
495
+ resetInstrumentStateForKey();
496
+ (_a = ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.refetch) === null || _a === void 0 ? void 0 : _a.call(ctxProtestos);
497
+ instrumentoHook.closeEmailModal();
498
+ }
499
+ : undefined }),
546
500
  React.createElement(InstrumentoDiscoveryConfirmModal, { isOpen: isDiscoveryConfirmOpen, onClose: function () { return setIsDiscoveryConfirmOpen(false); }, isLoading: instrumentoHook.isProcessandoDescoberta, onConfirm: function () { return __awaiter(void 0, void 0, void 0, function () {
547
501
  return __generator(this, function (_a) {
548
502
  switch (_a.label) {
@@ -560,7 +514,3 @@ export var Instrumento = function (_a) {
560
514
  });
561
515
  }); } })));
562
516
  };
563
- export var ProtestosList = function (_a) {
564
- var protestos = _a.protestos;
565
- return (React.createElement(ResultContent, null, (protestos === null || protestos === void 0 ? void 0 : protestos.length) ? (protestos.map(function (protesto) { return (React.createElement(ProtestoItem, { key: protesto.nm_chave, protesto: protesto })); })) : (React.createElement(AddItemField, { name: "Informa\u00E7\u00E3o", value: "N\u00E3o h\u00E1 registros de protestos." }))));
566
- };
@@ -123,7 +123,7 @@ var ConsultaSimples = function (_a) {
123
123
  React.createElement(ConsultaImoveis, { documento: documento }),
124
124
  React.createElement(Veiculos, { documento: documento })),
125
125
  React.createElement(ProtestosSP, null),
126
- React.createElement(Protestos, null),
126
+ React.createElement(Protestos, { tags: tags }),
127
127
  React.createElement(Edital, { isFinancial: isFinancial, tags: tags }),
128
128
  React.createElement(ProtestosPagosBaixados, { isFinancial: isFinancial }),
129
129
  React.createElement(CCF, null),