@credithub/harlan-components 1.51.3 → 1.52.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.
- package/dist/components/chart/chartSystem.js +1 -1
- package/dist/components/chart/hooks/useChartData.js +1 -1
- package/dist/components/chart/utils/chartCustomization.d.ts +1 -1
- package/dist/components/chart/utils/chartCustomization.js +17 -1
- package/dist/components/chart/utils/chartUtils.js +1 -1
- package/dist/components/chart/utils/dataProcessing.js +1 -1
- package/dist/components/scr/scr.d.ts +5 -1
- package/dist/components/scr/scr.js +24 -11
- package/dist/consultaSimples.d.ts +4 -0
- package/lib/cjs/index.js +45 -14
- package/lib/esm/index.js +45 -14
- package/package.json +1 -1
|
@@ -67,7 +67,7 @@ var ChartSystem = function (_a) {
|
|
|
67
67
|
})
|
|
68
68
|
.filter(function (timestamp) { return timestamp !== null; });
|
|
69
69
|
if (datasOcorrencias.length > 0) {
|
|
70
|
-
ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
|
|
70
|
+
ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString('pt-BR');
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
var loadingProgress = (chartDataProgress + dividasProgress) / 2;
|
|
@@ -36,7 +36,7 @@ export var useDividasPublicas = function () {
|
|
|
36
36
|
.map(function (data) { return new Date(data).getTime(); })
|
|
37
37
|
.filter(function (timestamp) { return !isNaN(timestamp); });
|
|
38
38
|
var ultimaOcorrencia = datasValidas.length > 0
|
|
39
|
-
? new Date(Math.max.apply(Math, datasValidas)).toLocaleDateString()
|
|
39
|
+
? new Date(Math.max.apply(Math, datasValidas)).toLocaleDateString('pt-BR')
|
|
40
40
|
: '';
|
|
41
41
|
return {
|
|
42
42
|
quantidade: quantidade,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataInput, TimeFilter } from '../types/iChart';
|
|
2
1
|
import { ChartDataset, ChartOptions } from 'chart.js';
|
|
2
|
+
import { DataInput, TimeFilter } from '../types/iChart';
|
|
3
3
|
export declare function createDatasets(data: DataInput, uniqueDates: string[], timeFilter: TimeFilter): ChartDataset<'line' | 'bar', (number | {
|
|
4
4
|
x: string;
|
|
5
5
|
y: number | null;
|
|
@@ -133,11 +133,27 @@ export function getChartOptions(timeFilter) {
|
|
|
133
133
|
type: 'time',
|
|
134
134
|
time: {
|
|
135
135
|
unit: unit,
|
|
136
|
-
parser: 'yyyy-MM-dd'
|
|
136
|
+
parser: 'yyyy-MM-dd',
|
|
137
|
+
tooltipFormat: 'dd MMM yyyy',
|
|
138
|
+
displayFormats: {
|
|
139
|
+
day: 'dd MMM',
|
|
140
|
+
week: 'dd MMM',
|
|
141
|
+
month: 'MMM yyyy',
|
|
142
|
+
quarter: 'MMM yyyy',
|
|
143
|
+
year: 'yyyy'
|
|
144
|
+
}
|
|
137
145
|
},
|
|
138
146
|
title: {
|
|
139
147
|
display: true,
|
|
140
148
|
text: 'Data'
|
|
149
|
+
},
|
|
150
|
+
ticks: {
|
|
151
|
+
callback: function (value, index, values) {
|
|
152
|
+
return new Intl.DateTimeFormat('pt-BR', {
|
|
153
|
+
month: 'short',
|
|
154
|
+
year: 'numeric'
|
|
155
|
+
}).format(new Date(value));
|
|
156
|
+
}
|
|
141
157
|
}
|
|
142
158
|
}
|
|
143
159
|
},
|
|
@@ -14,7 +14,7 @@ export var useCalculation = function (itens, dataKey) {
|
|
|
14
14
|
.map(function (data) { return new Date(data).getTime(); })
|
|
15
15
|
.filter(function (timestamp) { return !isNaN(timestamp); });
|
|
16
16
|
return datas.length
|
|
17
|
-
? new Date(Math.max.apply(Math, datas)).toLocaleDateString()
|
|
17
|
+
? new Date(Math.max.apply(Math, datas)).toLocaleDateString('pt-BR')
|
|
18
18
|
: null;
|
|
19
19
|
})();
|
|
20
20
|
return { quantidade: quantidade, valorTotal: valorTotal, dataMaisRecente: dataMaisRecente };
|
|
@@ -67,7 +67,7 @@ var obterUltimaData = function (protestos) {
|
|
|
67
67
|
.map(function (p) { return new Date(converterParaFormatoValido(p.dataProtesto)).getTime(); })
|
|
68
68
|
.filter(function (d) { return !isNaN(d); });
|
|
69
69
|
return datas.length
|
|
70
|
-
? new Date(Math.max.apply(Math, datas)).toLocaleDateString()
|
|
70
|
+
? new Date(Math.max.apply(Math, datas)).toLocaleDateString('pt-BR')
|
|
71
71
|
: null;
|
|
72
72
|
};
|
|
73
73
|
export function processProtestData(document) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare function ConsultaSCR({ documento }: {
|
|
2
|
+
declare function ConsultaSCR({ documento, onAlert }: {
|
|
3
3
|
documento: string;
|
|
4
|
+
onAlert?: (parameters: {
|
|
5
|
+
title?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}) => void;
|
|
4
8
|
}): React.JSX.Element | null;
|
|
5
9
|
export default ConsultaSCR;
|
|
@@ -49,40 +49,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
53
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
54
52
|
import ScrIcon from '../../assets/icones/scr';
|
|
55
53
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
56
54
|
import useToggle from '../../hooks/useToggle';
|
|
57
55
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
58
56
|
import styled from 'styled-components';
|
|
59
57
|
import AddItemField from '../common/addItem';
|
|
58
|
+
import Button from '../common/button';
|
|
60
59
|
import { ConsultasComplementaresContext } from '../consultasComplementares';
|
|
61
60
|
import { Result, ResultContent } from '../interface/result';
|
|
62
61
|
import StatusMessage from '../interface/statusMessage';
|
|
63
62
|
import Section from '../section';
|
|
64
63
|
import { RequestStatus, useFetch, useQuery } from '../webservice';
|
|
65
|
-
import Button from '../common/button';
|
|
66
64
|
var ResumosWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n flex-direction: column;\n gap: 20px;\n"], ["\n display: ", ";\n flex-direction: column;\n gap: 20px;\n"])), function (_a) {
|
|
67
65
|
var _b = _a.isOpen, isOpen = _b === void 0 ? true : _b;
|
|
68
66
|
return (isOpen ? 'flex' : 'none');
|
|
69
67
|
});
|
|
70
68
|
function ConsultaSCR(_a) {
|
|
71
69
|
var _this = this;
|
|
72
|
-
var _b, _c;
|
|
73
|
-
var documento = _a.documento;
|
|
70
|
+
var _b, _c, _d, _e;
|
|
71
|
+
var documento = _a.documento, onAlert = _a.onAlert;
|
|
74
72
|
var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
|
|
75
73
|
var setData = useGlobalData().setData;
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
-
var
|
|
74
|
+
var _f = useState(false), dataUpdated = _f[0], setDataUpdated = _f[1];
|
|
75
|
+
var _g = useState(false), alertShown = _g[0], setAlertShown = _g[1];
|
|
76
|
+
var _h = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _h.consultasComplementares, setConsultasComplementares = _h.setConsultasComplementares;
|
|
77
|
+
var _j = useQuery("SELECT FROM 'SCR'.'CONSULTA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _j.response, isLoading = _j.isLoading, error = _j.error, loadingProgress = _j.loadingProgress;
|
|
79
78
|
var fetch = useFetch("SELECT FROM 'SCR'.'PDF'").fetch;
|
|
80
79
|
var isOpen = useToggle()[0];
|
|
81
80
|
var scrRef = useRef(null);
|
|
82
81
|
var consultaRealizada = useMemo(function () { var _a; return (_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _a === void 0 ? void 0 : _a.consultaRealizada; }, [(_c = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _c === void 0 ? void 0 : _c.consultaRealizada]);
|
|
83
|
-
//const resumoDeCreditos = (scr && getResumoDeCreditos(scr)) || [];
|
|
84
82
|
var scr = response === null || response === void 0 ? void 0 : response.document;
|
|
85
|
-
var
|
|
83
|
+
var basicData = useMemo(function () { var _a; return (_a = scr === null || scr === void 0 ? void 0 : scr.response) === null || _a === void 0 ? void 0 : _a.basicData; }, [scr]);
|
|
84
|
+
var description = ((_e = (_d = scr === null || scr === void 0 ? void 0 : scr.response) === null || _d === void 0 ? void 0 : _d.basicData) === null || _e === void 0 ? void 0 : _e.length)
|
|
86
85
|
? 'Resumo do Cliente'
|
|
87
86
|
: 'Não há informação disponível para este documento.';
|
|
88
87
|
useEffect(function () {
|
|
@@ -104,6 +103,18 @@ function ConsultaSCR(_a) {
|
|
|
104
103
|
setDataUpdated(true);
|
|
105
104
|
}
|
|
106
105
|
}, [response, consultaRealizada, dataUpdated, setData]);
|
|
106
|
+
useEffect(function () {
|
|
107
|
+
if (consultaRealizada &&
|
|
108
|
+
onAlert &&
|
|
109
|
+
!alertShown &&
|
|
110
|
+
(!Array.isArray(basicData) || basicData.length === 0)) {
|
|
111
|
+
onAlert({
|
|
112
|
+
title: 'Dados não encontrados',
|
|
113
|
+
message: 'Nenhuma informação foi retornada pela fonte de dados. No momento, não há informações disponíveis para exibição para este documento. Nossa equipe de suporte já está analisando o caso.'
|
|
114
|
+
});
|
|
115
|
+
setAlertShown(true);
|
|
116
|
+
}
|
|
117
|
+
}, [consultaRealizada, basicData, onAlert, alertShown]);
|
|
107
118
|
return consultaRealizada ? (React.createElement(Section, { ref: scrRef, ctx: {
|
|
108
119
|
type: isLoading
|
|
109
120
|
? RequestStatus.Loading
|
|
@@ -118,7 +129,9 @@ function ConsultaSCR(_a) {
|
|
|
118
129
|
progress: loadingProgress
|
|
119
130
|
}, title: "SCR", subtitle: "Resumo do Cliente", icon: ScrIcon, description: !error && (React.createElement(StatusMessage, { type: scr ? 'success' : 'default' }, description)), onSuccess: function () { return (React.createElement(React.Fragment, null,
|
|
120
131
|
React.createElement(Result, null,
|
|
121
|
-
React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
|
|
132
|
+
React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" }, Array.isArray(basicData)
|
|
133
|
+
? basicData.map(function (data) { return (React.createElement(AddItemField, { key: data.label, name: data.label, value: data.value })); })
|
|
134
|
+
: null),
|
|
122
135
|
React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
|
|
123
136
|
React.createElement(AddItemField, { name: "Total de cr\u00E9ditos a vencer", value: scr === null || scr === void 0 ? void 0 : scr.response.expiringTotal }),
|
|
124
137
|
React.createElement(AddItemField, { name: "Total de cr\u00E9ditos vencidos", value: scr === null || scr === void 0 ? void 0 : scr.response.expiredTotal }),
|
|
@@ -7,6 +7,10 @@ type ConsultaSimplesProps = {
|
|
|
7
7
|
onClose?: () => void;
|
|
8
8
|
hasCredits?: HasCreditsType;
|
|
9
9
|
onClickPrint: () => void;
|
|
10
|
+
onAlert?: (parameters: {
|
|
11
|
+
title?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}) => void;
|
|
10
14
|
onClickConsultarProcessoJuridico?: (processoId: string) => void;
|
|
11
15
|
initRefinBoaVista?: boolean;
|
|
12
16
|
initRefinSerasa?: boolean;
|