@credithub/harlan-components 1.86.3 → 1.86.5

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.
@@ -21,28 +21,26 @@ import StatusMessage from '../interface/statusMessage';
21
21
  import Section from '../section';
22
22
  import { RequestStatus } from '../webservice';
23
23
  var parseProb = function (raw) {
24
- if (raw === null || raw === undefined)
25
- return 0;
26
- var str = String(raw).replace(',', '.');
27
- return Number(str) || 0;
24
+ return typeof raw === 'number' ? raw : Number(String(raw).replace(',', '.')) || 0;
28
25
  };
29
26
  var ConsultaScoreSerasa = function (_a) {
30
- var _b, _c, _d, _e, _f, _g, _h;
27
+ var _b, _c, _d, _e, _f, _g;
31
28
  var documento = _a.documento;
32
29
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
33
30
  var setData = useGlobalData().setData;
34
- var _j = useState(false), dataUpdated = _j[0], setDataUpdated = _j[1];
35
- var _k = useSafeQuery("SELECT FROM 'ScoreSerasa'.'Consulta'", { documento: documento }, (_c = (_b = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _b === void 0 ? void 0 : _b.scoreSerasa) === null || _c === void 0 ? void 0 : _c.consultaRealizada), response = _k.response, isLoading = _k.isLoading, error = _k.error, loadingProgress = _k.loadingProgress;
36
- var scoreData = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.dados;
31
+ var _h = useState(false), dataUpdated = _h[0], setDataUpdated = _h[1];
32
+ var _j = useSafeQuery("SELECT FROM 'ScoreSerasa'.'Consulta'", { documento: documento }, (_c = (_b = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _b === void 0 ? void 0 : _b.scoreSerasa) === null || _c === void 0 ? void 0 : _c.consultaRealizada), response = _j.response, isLoading = _j.isLoading, error = _j.error, loadingProgress = _j.loadingProgress;
33
+ var scoreData = (_e = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.dados) === null || _e === void 0 ? void 0 : _e.score;
34
+ var inadProb = parseProb(scoreData === null || scoreData === void 0 ? void 0 : scoreData.probabilidade_inadimplencia);
37
35
  var scoreRef = useRef(null);
38
36
  var consultaRealizada = useMemo(function () {
39
37
  var _a, _b;
40
38
  return (_b = (_a = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _a === void 0 ? void 0 : _a.scoreSerasa) === null || _b === void 0 ? void 0 : _b.consultaRealizada;
41
39
  }, [
42
- (_f = (_e = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _e === void 0 ? void 0 : _e.scoreSerasa) === null || _f === void 0 ? void 0 : _f.consultaRealizada
40
+ (_g = (_f = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _f === void 0 ? void 0 : _f.scoreSerasa) === null || _g === void 0 ? void 0 : _g.consultaRealizada
43
41
  ]);
44
- var description = ((_g = scoreData === null || scoreData === void 0 ? void 0 : scoreData.score) === null || _g === void 0 ? void 0 : _g.score_calculado) == 'S'
45
- ? "Score: ".concat((_h = scoreData === null || scoreData === void 0 ? void 0 : scoreData.score) === null || _h === void 0 ? void 0 : _h.pontuacao)
42
+ var description = (scoreData === null || scoreData === void 0 ? void 0 : scoreData.score_calculado) === 'S'
43
+ ? "Score: ".concat(scoreData.pontuacao)
46
44
  : 'Não há informação de score disponível para este documento.';
47
45
  useEffect(function () {
48
46
  var _a;
@@ -71,13 +69,10 @@ var ConsultaScoreSerasa = function (_a) {
71
69
  refetch: function () { },
72
70
  Section: Section,
73
71
  progress: loadingProgress
74
- }, title: "Score Serasa", subtitle: "Consulta de Score", icon: ScoreBoaVistaIcon, description: !error && (React.createElement(StatusMessage, { type: scoreData ? 'success' : 'default' }, description)), onSuccess: function () {
75
- var _a, _b, _c;
76
- return (React.createElement(Result, null, scoreData && (React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
77
- React.createElement(AddItemField, { name: "Score", value: String((_a = scoreData.score) === null || _a === void 0 ? void 0 : _a.pontuacao) }),
78
- React.createElement(AddItemField, { name: "Probabilidade de Inadimpl\u00EAncia", value: "".concat(parseProb((_b = scoreData.score) === null || _b === void 0 ? void 0 : _b.probabilidade_inadimplencia), "%") }),
79
- React.createElement(AddItemField, { name: "An\u00E1lise", value: "\n DE CADA 100 ".concat(isDocumentoPF(documento) ? 'PESSOAS' : 'EMPRESAS', "\n CLASSIFICADAS NESTA CLASSE DE SCORE, \u00C9 PROV\u00C1VEL QUE\n ").concat(Math.floor(parseProb((_c = scoreData.score) === null || _c === void 0 ? void 0 : _c.probabilidade_inadimplencia)), " APRESENTEM D\u00C9BITOS NO MERCADO NOS PR\u00D3XIMOS 6 MESES.") })))));
80
- }, isError: function (err) { return ({
72
+ }, title: "Score Serasa", subtitle: "Consulta de Score", icon: ScoreBoaVistaIcon, description: !error && (React.createElement(StatusMessage, { type: scoreData ? 'success' : 'default' }, description)), onSuccess: function () { return (React.createElement(Result, null, scoreData && (React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
73
+ React.createElement(AddItemField, { name: "Score", value: String(scoreData.pontuacao) }),
74
+ React.createElement(AddItemField, { name: "Probabilidade de Inadimpl\u00EAncia", value: "".concat(scoreData.probabilidade_inadimplencia, "%") }),
75
+ React.createElement(AddItemField, { name: "An\u00E1lise", value: "DE CADA 100 ".concat(isDocumentoPF(documento) ? 'PESSOAS' : 'EMPRESAS', " CLASSIFICADAS NESTA CLASSE DE SCORE, \u00C9 PROV\u00C1VEL QUE ").concat(Math.floor(inadProb), " APRESENTEM D\u00C9BITOS NO MERCADO NOS PR\u00D3XIMOS 6 MESES.") }))))); }, isError: function (err) { return ({
81
76
  children: React.createElement(React.Fragment, null),
82
77
  description: (React.createElement(StatusMessage, { type: "error" },
83
78
  "Erro ao realizar a consulta: ",