@credithub/harlan-components 1.84.0 → 1.84.2

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.
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import { HasCreditsType } from '../consultasComplementares';
2
+ import React from 'react';
3
3
  interface LiminarProps {
4
4
  /**
5
5
  * Se verdadeiro, exibe ações exclusivas para instituições financeiras,
@@ -54,7 +54,7 @@ import { formatMoney } from '../../utils/number';
54
54
  import { normalizeName, normalizeNameStrong, similarCompanyNames } from '../../utils/similarNames';
55
55
  import { hasOneOfTags } from '../../utils/tags';
56
56
  import { WarningCircle } from 'phosphor-react';
57
- import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
57
+ import { useContext, useEffect, useMemo, useRef, useState } from 'react';
58
58
  import Button from '../common/button';
59
59
  import Modal from '../common/modal';
60
60
  import { SummaryButton } from '../dossie/summary/styles';
@@ -63,6 +63,7 @@ import Section from '../section';
63
63
  import { Queries, RequestStatus, useFetch } from '../webservice';
64
64
  import { TitleWithTooltip, TooltipContainer, TooltipText } from './liminarStyles';
65
65
  import useLiminarProtestosDoPassado from './useLiminarProtestosDoPassado';
66
+ import React from 'react';
66
67
  /* ----------------------------------
67
68
  * Constantes
68
69
  * ---------------------------------*/
@@ -98,10 +99,7 @@ var Liminar = function (_a) {
98
99
  var _s = useState(false), isTooltipVisible = _s[0], setTooltipVisible = _s[1];
99
100
  var _t = useState(false), isEmailModalOpen = _t[0], setIsEmailModalOpen = _t[1];
100
101
  var _u = useState(''), emailModalMessage = _u[0], setEmailModalMessage = _u[1];
101
- var liminarMailPrice = useMemo(function () {
102
- var isDiamanteNew = hasOneOfTags(tags, ['diamante-new']);
103
- return isDiamanteNew ? 0 : 50000;
104
- }, [tags]);
102
+ var liminarMailPrice = 50000;
105
103
  var _v = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _v.fetch, isEmailSending = _v.isLoading, emailError = _v.error;
106
104
  var hideTt = useRef();
107
105
  /*
@@ -315,7 +313,10 @@ var Liminar = function (_a) {
315
313
  setEmailModalMessage("Falha ao enviar e-mail: ".concat(emailError.message));
316
314
  }
317
315
  else {
318
- setEmailModalMessage('Você deve ter recebido um e-mail nosso com os detalhes que encontramos sobre esse indício.');
316
+ setEmailModalMessage(React.createElement(React.Fragment, null,
317
+ "Os detalhes dos protestos ocultados foram enviados para seu e-mail. ",
318
+ React.createElement("br", null),
319
+ "R$ 50 foram debitados automaticamente do seu saldo para essa opera\u00E7\u00E3o."));
319
320
  }
320
321
  setIsEmailModalOpen(true);
321
322
  return [2 /*return*/];
@@ -363,7 +364,7 @@ var Liminar = function (_a) {
363
364
  actions: (React.createElement("div", { style: { textAlign: 'center' }, onClick: function (e) { return e.stopPropagation(); } }, isFinancial &&
364
365
  ((_c = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminarProtestosDoPassado) &&
365
366
  /** mostra o botão apenas se existir ao menos 1 chave oculta */
366
- ((_f = (_e = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _d === void 0 ? void 0 : _d.protestosDoPassadoIds) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0 && (React.createElement(SummaryButton, { onClick: handleSendEmailIndicios, disabled: isEmailSending, smallContent: liminarMailPrice && !isEmailSending
367
+ ((_f = (_e = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _d === void 0 ? void 0 : _d.protestosDoPassadoIds) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0 && (React.createElement(SummaryButton, { onClick: handleSendEmailIndicios, disabled: isEmailSending, smallContent: !isEmailSending
367
368
  ? formatMoney(liminarMailPrice / 1000)
368
369
  : '' }, "Baixar Protestos Ocultos"))))
369
370
  };
@@ -372,8 +373,8 @@ var Liminar = function (_a) {
372
373
  React.createElement(Modal, { isOpen: isEmailModalOpen, onClose: function () {
373
374
  setIsEmailModalOpen(false);
374
375
  setEmailModalMessage('');
375
- }, title: "Envio de protestos ocultos por e-mail" },
376
- React.createElement("p", null, emailModalMessage),
376
+ }, title: "Protestos ocultos enviados por e-mail" },
377
+ React.createElement("div", { style: { textAlign: 'center', display: 'block', fontSize: 18, fontWeight: 400 } }, emailModalMessage),
377
378
  React.createElement("div", { style: { textAlign: 'center', marginTop: '16px' } },
378
379
  React.createElement(Button, { onClick: function () {
379
380
  setIsEmailModalOpen(false);
@@ -39,6 +39,7 @@ import { Client } from '@credithub/webservice';
39
39
  import { useCallback, useContext } from 'react';
40
40
  import { WebService } from '../webservice';
41
41
  import { useGlobalData } from '../../contexts/globalDataContext';
42
+ import { difference, uniq } from 'lodash';
42
43
  /**
43
44
  * Hook que identifica indícios de liminar de sustação de protesto.
44
45
  *
@@ -50,6 +51,7 @@ import { useGlobalData } from '../../contexts/globalDataContext';
50
51
  * timeout defensivo para cada requisição.
51
52
  */
52
53
  var useLiminarProtestosDoPassado = function (_a) {
54
+ var _b;
53
55
  var documento = _a.documento;
54
56
  var client = useContext(WebService);
55
57
  var globalData = useGlobalData().data;
@@ -87,22 +89,23 @@ var useLiminarProtestosDoPassado = function (_a) {
87
89
  });
88
90
  }); };
89
91
  var fetch = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
90
- var data, parsed, nodes, numerosChave, ocultos, idx, running, launch, _loop_1;
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
92
+ var data, parsed, nodes, numerosChave, ocultos, running, idx, launch, _loop_1;
93
+ var _a;
94
+ return __generator(this, function (_b) {
95
+ switch (_b.label) {
93
96
  case 0: return [4 /*yield*/, client.request("SELECT FROM 'IEPTB'.'PASTQUERIES'", {
94
97
  documento: documento
95
98
  })];
96
99
  case 1:
97
- data = _a.sent();
100
+ data = _b.sent();
98
101
  return [4 /*yield*/, Client.WebService.parse(data)];
99
102
  case 2:
100
- parsed = (_a.sent());
103
+ parsed = (_b.sent());
101
104
  nodes = XPathUtils.selectArray('//protesto/nm_chave', parsed);
102
- numerosChave = Array.from(new Set(nodes.map(function (n) { return n.textContent || ''; }))).filter(function (e) { var _a; return !(((_a = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _a === void 0 ? void 0 : _a.nmChaves) || []).includes(e); });
105
+ numerosChave = difference(uniq(nodes.map(function (n) { return n.textContent || ''; })), ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _a === void 0 ? void 0 : _a.nmChaves) || []);
103
106
  ocultos = [];
104
- idx = 0;
105
107
  running = [];
108
+ idx = 0;
106
109
  launch = function (chave) { return __awaiter(void 0, void 0, void 0, function () {
107
110
  return __generator(this, function (_a) {
108
111
  switch (_a.label) {
@@ -114,7 +117,7 @@ var useLiminarProtestosDoPassado = function (_a) {
114
117
  }
115
118
  });
116
119
  }); };
117
- _a.label = 3;
120
+ _b.label = 3;
118
121
  case 3:
119
122
  if (!(idx < numerosChave.length || running.length)) return [3 /*break*/, 6];
120
123
  _loop_1 = function () {
@@ -129,10 +132,10 @@ var useLiminarProtestosDoPassado = function (_a) {
129
132
  _loop_1();
130
133
  }
131
134
  if (!running.length) return [3 /*break*/, 5];
132
- return [4 /*yield*/, Promise.race(running)];
135
+ return [4 /*yield*/, Promise.all(running)];
133
136
  case 4:
134
- _a.sent();
135
- _a.label = 5;
137
+ _b.sent();
138
+ _b.label = 5;
136
139
  case 5: return [3 /*break*/, 3];
137
140
  case 6: return [2 /*return*/, {
138
141
  possuiIndiciosDeLiminarProtestosDoPassado: ocultos.length > 0,
@@ -140,7 +143,7 @@ var useLiminarProtestosDoPassado = function (_a) {
140
143
  }];
141
144
  }
142
145
  });
143
- }); }, [client, documento]);
146
+ }); }, [client, documento, (_b = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _b === void 0 ? void 0 : _b.nmChaves]);
144
147
  return { fetchLiminarProtestosDoPassado: fetch };
145
148
  };
146
149
  export default useLiminarProtestosDoPassado;