@credithub/harlan-components 1.27.6 → 1.27.8

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.
@@ -2,21 +2,4 @@ import React from 'react';
2
2
  declare function RefinBoaVista({ documento }: {
3
3
  documento: string;
4
4
  }): React.JSX.Element | null;
5
- export type PendenciaBoaVista = {
6
- ocorrencia: string;
7
- credor: string;
8
- entrada: string;
9
- vencimento: string;
10
- valor: string;
11
- informante: string;
12
- contrato: string;
13
- avalista: string;
14
- cidade: string;
15
- uf: string;
16
- situacao: string;
17
- orgaoemissor: string;
18
- totalpendencias: string;
19
- totalvalor: string;
20
- categoria: string;
21
- };
22
5
  export default RefinBoaVista;
@@ -20,54 +20,65 @@ import Header from '../interface/header';
20
20
  import { Result, ResultContent } from '../interface/result';
21
21
  import StatusMessage from '../interface/statusMessage';
22
22
  import { useQuery } from '../webservice';
23
- function RefinBoaVista(_a) {
24
- var _b, _c, _d;
25
- var documento = _a.documento;
23
+ function useRefinBoaVista(documento) {
24
+ var _a;
26
25
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
27
26
  var setData = useGlobalData().setData;
28
- var _e = useState(false), dataUpdated = _e[0], setDataUpdated = _e[1];
29
- var _f = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _f.consultasComplementares, setConsultasComplementares = _f.setConsultasComplementares;
30
- var _g = useQuery("SELECT FROM 'PROTESTOS'.'REFIN'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _g.response, isLoading = _g.isLoading, error = _g.error;
27
+ var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
28
+ var _c = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _c.consultasComplementares, setConsultasComplementares = _c.setConsultasComplementares;
29
+ var _d = useQuery("SELECT FROM 'PROTESTOS'.'REFIN'", { documento: documento }, !!((_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _a === void 0 ? void 0 : _a.consultaRealizada)), response = _d.response, isLoading = _d.isLoading, error = _d.error;
31
30
  var pendencias = useMemo(function () {
32
- if (response && response.document && response.document.spc) {
33
- return response.document.spc.map(addNoValueContent);
34
- }
35
- else {
36
- return [];
31
+ var _a;
32
+ if ((_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.spc) {
33
+ var spcData = response.document.spc;
34
+ if (Array.isArray(spcData) &&
35
+ spcData.length === 1 &&
36
+ Array.isArray(spcData[0]) &&
37
+ spcData[0].length === 0) {
38
+ return [];
39
+ }
40
+ return spcData.flat().map(addNoValueContent);
37
41
  }
42
+ return [];
38
43
  }, [response]);
39
- var refinBoaVistaRef = useRef(null);
40
- var description = pendencias.length
41
- ? "Foram encontrados ".concat(pendencias.length, " ocorr\u00EAncias")
42
- : 'Nenhuma ocorrência encontrada';
43
- var consultaRefinRealizada = useMemo(function () { var _a; return (_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _a === void 0 ? void 0 : _a.consultaRealizada; }, [(_c = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _c === void 0 ? void 0 : _c.consultaRealizada]);
44
- useEffect(function () {
45
- var _a;
46
- (_a = refinBoaVistaRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
47
- }, [consultaRefinRealizada]);
48
44
  useEffect(function () {
49
- response &&
50
- setConsultasComplementares &&
51
- setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinBoaVista: __assign(__assign({}, prev.refinBoaVista), { data: response }) })); });
52
- if (response && response.document && !dataUpdated) {
45
+ if ((response === null || response === void 0 ? void 0 : response.document) && !dataUpdated) {
53
46
  var refinBoaVistaData_1 = {
54
47
  refinBoaVistaData: response.document
55
48
  };
49
+ setConsultasComplementares === null || setConsultasComplementares === void 0 ? void 0 : setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinBoaVista: __assign(__assign({}, prev.refinBoaVista), { data: response }) })); });
56
50
  setData(function (prevState) { return (__assign(__assign({}, prevState), { refinBoaVista: refinBoaVistaData_1 })); });
57
51
  setDataUpdated(true);
58
52
  }
59
- }, [response, dataUpdated, setData]);
60
- if (!((_d = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _d === void 0 ? void 0 : _d.consultaRealizada))
53
+ }, [response, dataUpdated, setData, setConsultasComplementares]);
54
+ return { isLoading: isLoading, error: error, pendencias: pendencias, consultaRealizada: !!response };
55
+ }
56
+ function RefinBoaVista(_a) {
57
+ var documento = _a.documento;
58
+ var refinBoaVistaRef = useRef(null);
59
+ var _b = useRefinBoaVista(documento), isLoading = _b.isLoading, error = _b.error, pendencias = _b.pendencias, consultaRealizada = _b.consultaRealizada;
60
+ useEffect(function () {
61
+ var _a;
62
+ (_a = refinBoaVistaRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
63
+ }, [consultaRealizada]);
64
+ var statusType = pendencias.length > 0 ? 'success' : 'default';
65
+ var variant = isLoading
66
+ ? 'loading'
67
+ : error
68
+ ? 'error'
69
+ : 'default';
70
+ var description = pendencias.length
71
+ ? "Foram encontrados ".concat(pendencias.length, " ocorr\u00EAncias")
72
+ : 'Nenhuma ocorrência encontrada';
73
+ if (!consultaRealizada)
61
74
  return null;
62
75
  return (React.createElement("div", null,
63
- React.createElement(Header, { innerRef: refinBoaVistaRef, title: "Restri\u00E7\u00F5es Pefin/Refin Boa Vista", subtitle: "Apontamentos e Restri\u00E7\u00F5es Financeiras e Comerciais", variant: isLoading
64
- ? 'loading'
65
- : error || pendencias.length
66
- ? 'error'
67
- : 'default', description: React.createElement(StatusMessage, { type: (pendencias === null || pendencias === void 0 ? void 0 : pendencias.length) ? 'success' : 'default' }, error ? error.message : description), icon: PefinRefinBoaVistaIcon }),
68
- React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
76
+ React.createElement(Header, { innerRef: refinBoaVistaRef, title: "Restri\u00E7\u00F5es Pefin/Refin Boa Vista", subtitle: "Apontamentos e Restri\u00E7\u00F5es Financeiras e Comerciais", variant: variant, description: React.createElement(StatusMessage, { type: statusType }, error ? error.message : description), icon: PefinRefinBoaVistaIcon }),
77
+ pendencias.length > 0 && (React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
69
78
  React.createElement(AddItemField, { name: "Associado", value: pendencia.NomeAssociado }),
70
- React.createElement(AddItemField, { name: "Valor", value: "".concat(formatMoney(parseFloat(pendencia.Valor))) }),
79
+ React.createElement(AddItemField, { name: "Valor", value: pendencia.Valor && !isNaN(parseFloat(pendencia.Valor))
80
+ ? "".concat(formatMoney(parseFloat(pendencia.Valor)))
81
+ : 'Sem Valor' }),
71
82
  React.createElement(AddItemField, { name: "Data da Inclus\u00E3o", value: pendencia.DataDeInclusao }),
72
83
  React.createElement(AddItemField, { name: "Data do Vencimento", value: pendencia.DataDoVencimento }),
73
84
  React.createElement(AddItemField, { name: "Entidade", value: pendencia.Entidade }),
@@ -75,6 +86,6 @@ function RefinBoaVista(_a) {
75
86
  React.createElement(AddItemField, { name: "Comprador, Fiador ou Avalista", value: pendencia.CompradorFiadorAvalista }),
76
87
  React.createElement(AddItemField, { name: "Telefone Associado", value: pendencia.TelefoneAssociado }),
77
88
  React.createElement(AddItemField, { name: "Cidade Associado", value: pendencia.CidadeAssociado }),
78
- React.createElement(AddItemField, { name: "UF Associado", value: pendencia.UfAssociado }))); }))));
89
+ React.createElement(AddItemField, { name: "UF Associado", value: pendencia.UfAssociado }))); })))));
79
90
  }
80
91
  export default RefinBoaVista;