@credithub/harlan-components 1.92.0 → 1.92.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/refinSerasa/refinSerasa.d.ts +12 -8
- package/dist/components/refinSerasa/refinSerasa.js +24 -57
- package/dist/components/webservice.d.ts +0 -8
- package/dist/components/webservice.js +34 -63
- package/dist/consultaSimples.d.ts +0 -4
- package/dist/consultaSimples.js +2 -2
- package/lib/cjs/index.js +126 -189
- package/lib/esm/index.js +127 -189
- package/package.json +1 -1
|
@@ -6,17 +6,21 @@ export declare function useRefinSerasa(documento: string): {
|
|
|
6
6
|
pendencias: {
|
|
7
7
|
valor: string;
|
|
8
8
|
totalvalor: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
vencimento: string;
|
|
10
|
+
ocorrencia: string;
|
|
11
|
+
entrada: string;
|
|
12
|
+
informante: string;
|
|
13
13
|
contrato: string;
|
|
14
|
-
|
|
15
|
-
origem: string;
|
|
16
|
-
titulo_ocorrencia: string;
|
|
17
|
-
base_origem: string;
|
|
14
|
+
avalista: string;
|
|
18
15
|
cidade: string;
|
|
19
16
|
uf: string;
|
|
17
|
+
situacao: string;
|
|
18
|
+
credor: string;
|
|
19
|
+
orgaoemissor: string;
|
|
20
|
+
totalpendencias: string;
|
|
21
|
+
totalcredores: string;
|
|
22
|
+
categoria: "PEND\u00CANCIAS FINANCEIRAS" | "RESTRI\u00C7\u00D5ES FINANCEIRAS" | "D\u00CDVIDAS VENCIDAS";
|
|
23
|
+
modalidade: string;
|
|
20
24
|
}[];
|
|
21
25
|
consultaRealizada: boolean;
|
|
22
26
|
loadingProgress: number;
|
|
@@ -9,15 +9,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
12
|
import PefinRefinSerasaIcon from '../../assets/icones/pefinRefinSerasa';
|
|
22
13
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
23
14
|
import { formatMoney } from '../../utils/number';
|
|
@@ -46,18 +37,12 @@ export function useRefinSerasa(documento) {
|
|
|
46
37
|
return isNaN(parsed) ? '0' : valorFinal;
|
|
47
38
|
};
|
|
48
39
|
var pendenciasData = useMemo(function () {
|
|
49
|
-
var _a, _b, _c
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return __spreadArray(__spreadArray(__spreadArray([], pefin, true), refin, true), pendenciasVencidas, true).map(addNoValueContent)
|
|
56
|
-
.map(function (pendencia) { return (__assign(__assign({}, pendencia), { valor: clearValue(pendencia.valor), totalvalor: clearValue(pendencia.valor) })); })
|
|
57
|
-
.sort(function (a, b) {
|
|
58
|
-
var _a = a.data_ocorrencia.split('/').map(Number), mesA = _a[0], anoA = _a[1];
|
|
59
|
-
var _b = b.data_ocorrencia.split('/').map(Number), mesB = _b[0], anoB = _b[1];
|
|
60
|
-
return anoB - anoA || mesB - mesA;
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
return ((response && ((_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.informacoes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.bello)) || [])
|
|
42
|
+
.map(addNoValueContent)
|
|
43
|
+
.map(function (pendencia) {
|
|
44
|
+
var _a;
|
|
45
|
+
return (__assign(__assign({}, pendencia), { valor: clearValue(pendencia.valor), totalvalor: clearValue(pendencia.totalvalor), vencimento: (_a = pendencia === null || pendencia === void 0 ? void 0 : pendencia.vencimento) === null || _a === void 0 ? void 0 : _a.slice(0, 10) }));
|
|
61
46
|
});
|
|
62
47
|
}, [response]);
|
|
63
48
|
var pendencias = pendenciasData.filter(function (_a) {
|
|
@@ -103,22 +88,8 @@ var RefinSerasa = function (_a) {
|
|
|
103
88
|
behavior: 'smooth'
|
|
104
89
|
});
|
|
105
90
|
}, [consultaRealizada]);
|
|
106
|
-
var totalPendencias = useMemo(function () {
|
|
107
|
-
|
|
108
|
-
var resumo = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.resumo;
|
|
109
|
-
return ((((_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.quantidade) || 0) +
|
|
110
|
-
(((_d = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _d === void 0 ? void 0 : _d.quantidade) || 0) +
|
|
111
|
-
(((_e = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _e === void 0 ? void 0 : _e.quantidade) || 0));
|
|
112
|
-
}, [response === null || response === void 0 ? void 0 : response.document]);
|
|
113
|
-
var valorTotalPendencias = useMemo(function () {
|
|
114
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
115
|
-
var resumo = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.resumo;
|
|
116
|
-
return ((Number((_d = (_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.valor_total) === null || _d === void 0 ? void 0 : _d.replace(/\./g, '').replace(',', '.')) ||
|
|
117
|
-
0) +
|
|
118
|
-
(Number((_f = (_e = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _e === void 0 ? void 0 : _e.valor_total) === null || _f === void 0 ? void 0 : _f.replace(/\./g, '').replace(',', '.')) ||
|
|
119
|
-
0) +
|
|
120
|
-
(Number((_h = (_g = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _g === void 0 ? void 0 : _g.valor_total) === null || _h === void 0 ? void 0 : _h.replace(/\./g, '').replace(',', '.')) || 0));
|
|
121
|
-
}, [response === null || response === void 0 ? void 0 : response.document]);
|
|
91
|
+
var totalPendencias = useMemo(function () { var _a, _b, _c; return ((_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.informacoes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.total) || 0; }, [response === null || response === void 0 ? void 0 : response.document]);
|
|
92
|
+
var valorTotalPendencias = useMemo(function () { var _a, _b, _c; return ((_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.informacoes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.valorTotalPendencias) || 0; }, [response === null || response === void 0 ? void 0 : response.document]);
|
|
122
93
|
var description = totalPendencias === 0
|
|
123
94
|
? 'Não há ocorrência de Pefin/Refin Serasa'
|
|
124
95
|
: totalPendencias === 1
|
|
@@ -136,26 +107,22 @@ var RefinSerasa = function (_a) {
|
|
|
136
107
|
refetch: function () { },
|
|
137
108
|
Section: Section,
|
|
138
109
|
progress: loadingProgress
|
|
139
|
-
}, title: "Pefin/Refin e Contratos Vencidos Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", icon: PefinRefinSerasaIcon, description: !error && (React.createElement(StatusMessage, { type: totalPendencias === 0 ? 'default' : 'error' }, description)), variant: totalPendencias === 0 ? 'default' : 'error', onSuccess: function () { return (React.createElement(Result, null, pendencias.map(function (pendencia, i) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
React.createElement(AddItemField, { name: "Total de Pend\u00EAncias", value: "1" }),
|
|
156
|
-
React.createElement(AddItemField, { name: "Valor Total", value: formatMoney(pendencia === null || pendencia === void 0 ? void 0 : pendencia.totalvalor) }),
|
|
157
|
-
React.createElement(AddItemField, { name: "Categoria", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.categoria })));
|
|
158
|
-
}))); }, isError: function (err) { return ({
|
|
110
|
+
}, title: "Pefin/Refin e Contratos Vencidos Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", icon: PefinRefinSerasaIcon, description: !error && (React.createElement(StatusMessage, { type: totalPendencias === 0 ? 'default' : 'error' }, description)), variant: totalPendencias === 0 ? 'default' : 'error', onSuccess: function () { return (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" },
|
|
111
|
+
React.createElement(AddItemField, { name: "Tipo de Ocorr\u00EAncia", value: pendencia.ocorrencia }),
|
|
112
|
+
React.createElement(AddItemField, { name: "Credor", value: pendencia.credor }),
|
|
113
|
+
React.createElement(AddItemField, { name: "Data de Entrada", value: pendencia.entrada }),
|
|
114
|
+
React.createElement(AddItemField, { name: "Data de Vencimento", value: pendencia.vencimento }),
|
|
115
|
+
React.createElement(AddItemField, { name: "Valor", value: formatMoney(pendencia.valor) }),
|
|
116
|
+
React.createElement(AddItemField, { name: "Informante", value: pendencia.informante }),
|
|
117
|
+
React.createElement(AddItemField, { name: "N\u00FAmero de Contrato", value: pendencia.contrato }),
|
|
118
|
+
React.createElement(AddItemField, { name: "Avalista", value: pendencia.avalista }),
|
|
119
|
+
React.createElement(AddItemField, { name: "Cidade", value: pendencia.cidade }),
|
|
120
|
+
React.createElement(AddItemField, { name: "UF", value: pendencia.uf }),
|
|
121
|
+
React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o", value: pendencia.situacao }),
|
|
122
|
+
React.createElement(AddItemField, { name: "Org\u00E3o Emissor", value: pendencia.orgaoemissor }),
|
|
123
|
+
React.createElement(AddItemField, { name: "Total de Pend\u00EAncias", value: pendencia.totalpendencias }),
|
|
124
|
+
React.createElement(AddItemField, { name: "Valor Total", value: formatMoney(pendencia.totalvalor) }),
|
|
125
|
+
React.createElement(AddItemField, { name: "Categoria", value: pendencia.categoria }))); }))); }, isError: function (err) { return ({
|
|
159
126
|
children: React.createElement(React.Fragment, null),
|
|
160
127
|
description: (React.createElement(StatusMessage, { type: "error" },
|
|
161
128
|
"Erro ao realizar a consulta: ",
|
|
@@ -3,15 +3,8 @@ import { Client } from '@credithub/webservice';
|
|
|
3
3
|
import React, { ComponentProps, ComponentType, Context, FC, PropsWithChildren, ReactNode } from 'react';
|
|
4
4
|
import Header from './interface/header';
|
|
5
5
|
export declare const WebService: React.Context<Client.WebService>;
|
|
6
|
-
type RequestDefaults = {
|
|
7
|
-
data?: Client.Form;
|
|
8
|
-
urlData?: Client.Form;
|
|
9
|
-
};
|
|
10
|
-
export declare const RequestDefaultsContext: React.Context<RequestDefaults>;
|
|
11
6
|
export declare const WebServiceProvider: FC<PropsWithChildren<{
|
|
12
7
|
credential: string;
|
|
13
|
-
defaultData?: Client.Form;
|
|
14
|
-
defaultUrlData?: Client.Form;
|
|
15
8
|
}>>;
|
|
16
9
|
export declare enum RequestStatus {
|
|
17
10
|
Empty = 0,
|
|
@@ -176,4 +169,3 @@ export declare const Queries: {
|
|
|
176
169
|
}>>;
|
|
177
170
|
};
|
|
178
171
|
};
|
|
179
|
-
export {};
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -49,11 +38,9 @@ import { Client } from '@credithub/webservice';
|
|
|
49
38
|
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
50
39
|
import Section from './section';
|
|
51
40
|
export var WebService = createContext(new Client.WebService());
|
|
52
|
-
export var RequestDefaultsContext = createContext({});
|
|
53
41
|
export var WebServiceProvider = function (_a) {
|
|
54
|
-
var credential = _a.credential,
|
|
55
|
-
return (React.createElement(WebService.Provider, { value: new Client.WebService(credential) },
|
|
56
|
-
React.createElement(RequestDefaultsContext.Provider, { value: { data: defaultData, urlData: defaultUrlData } }, children)));
|
|
42
|
+
var credential = _a.credential, children = _a.children;
|
|
43
|
+
return (React.createElement(WebService.Provider, { value: new Client.WebService(credential) }, children));
|
|
57
44
|
};
|
|
58
45
|
export var RequestStatus;
|
|
59
46
|
(function (RequestStatus) {
|
|
@@ -66,15 +53,14 @@ export function CustomProvider(Provider, query) {
|
|
|
66
53
|
return function (_a) {
|
|
67
54
|
var children = _a.children, data = _a.data, urlData = _a.urlData, _b = _a.depends, depends = _b === void 0 ? [] : _b;
|
|
68
55
|
var client = useContext(WebService);
|
|
69
|
-
var _c =
|
|
70
|
-
var _d = useState(null),
|
|
71
|
-
var _e = useState(
|
|
72
|
-
var _f = useState(
|
|
73
|
-
var _g = useState(
|
|
74
|
-
var _h = useState(
|
|
75
|
-
var _j = useState(false),
|
|
76
|
-
var _k = useState(false),
|
|
77
|
-
var _l = useState(false), requestCompleted = _l[0], setRequestCompleted = _l[1];
|
|
56
|
+
var _c = useState(null), response = _c[0], setResponse = _c[1];
|
|
57
|
+
var _d = useState(null), error = _d[0], setError = _d[1];
|
|
58
|
+
var _e = useState(false), loading = _e[0], setLoading = _e[1];
|
|
59
|
+
var _f = useState(0), progress = _f[0], setProgress = _f[1];
|
|
60
|
+
var _g = useState(new Map()), requestsMap = _g[0], setRequestsMap = _g[1];
|
|
61
|
+
var _h = useState(false), showLoadingBar = _h[0], setShowLoadingBar = _h[1];
|
|
62
|
+
var _j = useState(false), shouldRetry = _j[0], setShouldRetry = _j[1];
|
|
63
|
+
var _k = useState(false), requestCompleted = _k[0], setRequestCompleted = _k[1];
|
|
78
64
|
var dependentRequestsCompleted = useMemo(function () {
|
|
79
65
|
return depends === null || depends === void 0 ? void 0 : depends.every(function (request) {
|
|
80
66
|
return (request === null || request === void 0 ? void 0 : request.type) === RequestStatus.Success ||
|
|
@@ -93,8 +79,6 @@ export function CustomProvider(Provider, query) {
|
|
|
93
79
|
}, 300);
|
|
94
80
|
return function () { return clearInterval(interval); };
|
|
95
81
|
}, []);
|
|
96
|
-
var mergedData = useMemo(function () { return (__assign(__assign({}, (defaultData !== null && defaultData !== void 0 ? defaultData : {})), (data !== null && data !== void 0 ? data : {}))); }, [defaultData, data]);
|
|
97
|
-
var mergedUrlData = useMemo(function () { return (__assign(__assign({}, (defaultUrlData !== null && defaultUrlData !== void 0 ? defaultUrlData : {})), (urlData !== null && urlData !== void 0 ? urlData : {}))); }, [defaultUrlData, urlData]);
|
|
98
82
|
var fetchData = useCallback(function () {
|
|
99
83
|
if (loading || requestCompleted || !dependentRequestsCompleted)
|
|
100
84
|
return;
|
|
@@ -106,7 +90,7 @@ export function CustomProvider(Provider, query) {
|
|
|
106
90
|
setRequestsMap(function (prev) { return new Map(prev.set(requestId, true)); });
|
|
107
91
|
var abortController = new AbortController();
|
|
108
92
|
client
|
|
109
|
-
.request(query,
|
|
93
|
+
.request(query, data, urlData, abortController.signal)
|
|
110
94
|
.then(function (response) {
|
|
111
95
|
return Client.WebService.parse(response).then(function (document) { return ({
|
|
112
96
|
response: response,
|
|
@@ -149,8 +133,8 @@ export function CustomProvider(Provider, query) {
|
|
|
149
133
|
}, [
|
|
150
134
|
client,
|
|
151
135
|
query,
|
|
152
|
-
|
|
153
|
-
|
|
136
|
+
data,
|
|
137
|
+
urlData,
|
|
154
138
|
loading,
|
|
155
139
|
simulateProgress,
|
|
156
140
|
requestCompleted,
|
|
@@ -190,8 +174,8 @@ export function CustomProvider(Provider, query) {
|
|
|
190
174
|
? RequestStatus.Loading
|
|
191
175
|
: RequestStatus.Empty,
|
|
192
176
|
error: error,
|
|
193
|
-
data:
|
|
194
|
-
urlData:
|
|
177
|
+
data: data,
|
|
178
|
+
urlData: urlData,
|
|
195
179
|
response: response === null || response === void 0 ? void 0 : response.response,
|
|
196
180
|
document: response === null || response === void 0 ? void 0 : response.document,
|
|
197
181
|
Section: Section,
|
|
@@ -206,8 +190,8 @@ export function CustomProvider(Provider, query) {
|
|
|
206
190
|
}, [
|
|
207
191
|
error,
|
|
208
192
|
response,
|
|
209
|
-
|
|
210
|
-
|
|
193
|
+
data,
|
|
194
|
+
urlData,
|
|
211
195
|
loading,
|
|
212
196
|
progress,
|
|
213
197
|
requestsMap,
|
|
@@ -219,14 +203,12 @@ export function CustomProvider(Provider, query) {
|
|
|
219
203
|
export function useQuery(query, data, enabled) {
|
|
220
204
|
if (enabled === void 0) { enabled = true; }
|
|
221
205
|
var client = useContext(WebService);
|
|
222
|
-
var _a =
|
|
223
|
-
var _b = useState(null),
|
|
224
|
-
var _c = useState(
|
|
225
|
-
var _d = useState(
|
|
226
|
-
var _e = useState(
|
|
227
|
-
var _f = useState(0), loadingProgress = _f[0], setProgress = _f[1];
|
|
206
|
+
var _a = useState(null), response = _a[0], setResponse = _a[1];
|
|
207
|
+
var _b = useState(null), error = _b[0], setError = _b[1];
|
|
208
|
+
var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
|
|
209
|
+
var _d = useState(true), shouldFetch = _d[0], setShouldFetch = _d[1];
|
|
210
|
+
var _e = useState(0), loadingProgress = _e[0], setProgress = _e[1];
|
|
228
211
|
var memoizedData = useMemo(function () { return data; }, [JSON.stringify(data)]);
|
|
229
|
-
var mergedData = useMemo(function () { return (__assign(__assign({}, (defaultData !== null && defaultData !== void 0 ? defaultData : {})), (memoizedData !== null && memoizedData !== void 0 ? memoizedData : {}))); }, [defaultData, memoizedData]);
|
|
230
212
|
var simulateProgress = useCallback(function () {
|
|
231
213
|
setProgress(0);
|
|
232
214
|
var p = 0;
|
|
@@ -245,7 +227,7 @@ export function useQuery(query, data, enabled) {
|
|
|
245
227
|
simulateProgress();
|
|
246
228
|
var abortController = new AbortController();
|
|
247
229
|
client
|
|
248
|
-
.request(query,
|
|
230
|
+
.request(query, memoizedData, undefined, abortController.signal)
|
|
249
231
|
.then(function (response) {
|
|
250
232
|
return Client.WebService.parse(response).then(function (document) { return ({
|
|
251
233
|
response: response,
|
|
@@ -270,15 +252,7 @@ export function useQuery(query, data, enabled) {
|
|
|
270
252
|
setShouldFetch(false);
|
|
271
253
|
});
|
|
272
254
|
return function () { return abortController.abort(); };
|
|
273
|
-
}, [
|
|
274
|
-
shouldFetch,
|
|
275
|
-
isLoading,
|
|
276
|
-
client,
|
|
277
|
-
query,
|
|
278
|
-
mergedData,
|
|
279
|
-
defaultUrlData,
|
|
280
|
-
simulateProgress
|
|
281
|
-
]);
|
|
255
|
+
}, [shouldFetch, isLoading, client, query, memoizedData, simulateProgress]);
|
|
282
256
|
useEffect(function () {
|
|
283
257
|
if (enabled && !response && !error && !isLoading && !shouldFetch) {
|
|
284
258
|
setShouldFetch(true);
|
|
@@ -302,16 +276,14 @@ export function useQuery(query, data, enabled) {
|
|
|
302
276
|
}
|
|
303
277
|
export function useMutation(query, data) {
|
|
304
278
|
var client = useContext(WebService);
|
|
305
|
-
var _a = useContext(RequestDefaultsContext), defaultData = _a.data, defaultUrlData = _a.urlData;
|
|
306
279
|
var abortController = useMemo(function () { return new AbortController(); }, []);
|
|
307
|
-
var
|
|
308
|
-
var
|
|
309
|
-
var
|
|
310
|
-
var mergedData = useMemo(function () { return (__assign(__assign({}, (defaultData !== null && defaultData !== void 0 ? defaultData : {})), (data !== null && data !== void 0 ? data : {}))); }, [defaultData, data]);
|
|
280
|
+
var _a = useState(null), response = _a[0], setResponse = _a[1];
|
|
281
|
+
var _b = useState(null), error = _b[0], setError = _b[1];
|
|
282
|
+
var _c = useState(true), isLoading = _c[0], setIsLoading = _c[1];
|
|
311
283
|
var mutate = useCallback(function () {
|
|
312
284
|
setIsLoading(true);
|
|
313
285
|
client
|
|
314
|
-
.request(query,
|
|
286
|
+
.request(query, data, undefined, abortController.signal)
|
|
315
287
|
.then(function (response) {
|
|
316
288
|
return Client.WebService.parse(response).then(function (document) { return ({
|
|
317
289
|
response: response,
|
|
@@ -325,7 +297,7 @@ export function useMutation(query, data) {
|
|
|
325
297
|
: new Error(requestError));
|
|
326
298
|
})
|
|
327
299
|
.finally(function () { return setIsLoading(false); });
|
|
328
|
-
}, [
|
|
300
|
+
}, []);
|
|
329
301
|
return {
|
|
330
302
|
isLoading: isLoading,
|
|
331
303
|
error: error,
|
|
@@ -336,17 +308,16 @@ export function useMutation(query, data) {
|
|
|
336
308
|
export function useFetch(query) {
|
|
337
309
|
var _this = this;
|
|
338
310
|
var client = useContext(WebService);
|
|
339
|
-
var _a = useContext(RequestDefaultsContext), defaultData = _a.data, defaultUrlData = _a.urlData;
|
|
340
311
|
var abortController = useMemo(function () { return new AbortController(); }, []);
|
|
341
|
-
var
|
|
342
|
-
var
|
|
343
|
-
var
|
|
312
|
+
var _a = useState(null), response = _a[0], setResponse = _a[1];
|
|
313
|
+
var _b = useState(null), error = _b[0], setError = _b[1];
|
|
314
|
+
var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
|
|
344
315
|
var fetch = useCallback(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
345
316
|
return __generator(this, function (_a) {
|
|
346
317
|
setIsLoading(true);
|
|
347
318
|
setError(null);
|
|
348
319
|
return [2 /*return*/, client
|
|
349
|
-
.request(query,
|
|
320
|
+
.request(query, data, undefined, abortController.signal)
|
|
350
321
|
.then(function (document) {
|
|
351
322
|
setResponse(document);
|
|
352
323
|
return document;
|
|
@@ -358,7 +329,7 @@ export function useFetch(query) {
|
|
|
358
329
|
})
|
|
359
330
|
.finally(function () { return setIsLoading(false); })];
|
|
360
331
|
});
|
|
361
|
-
}); }, [
|
|
332
|
+
}); }, []);
|
|
362
333
|
return {
|
|
363
334
|
isLoading: isLoading,
|
|
364
335
|
error: error,
|
|
@@ -7,10 +7,6 @@ type ConsultaSimplesProps = {
|
|
|
7
7
|
posthog?: ConsultaSimplesPosthog;
|
|
8
8
|
documento: string;
|
|
9
9
|
apiKey: string;
|
|
10
|
-
queryParams?: {
|
|
11
|
-
data?: Record<string, string>;
|
|
12
|
-
urlData?: Record<string, string>;
|
|
13
|
-
};
|
|
14
10
|
onClose?: () => void;
|
|
15
11
|
hasCredits?: HasCreditsType;
|
|
16
12
|
onClickPrint: () => void;
|
package/dist/consultaSimples.js
CHANGED
|
@@ -58,13 +58,13 @@ var HasCreditsVerification = function (_a) {
|
|
|
58
58
|
".")));
|
|
59
59
|
};
|
|
60
60
|
var ConsultaSimples = function (_a) {
|
|
61
|
-
var _documento = _a.documento, onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico, onClickQSA = _a.onClickQSA, onClickPrint = _a.onClickPrint, apiKey = _a.apiKey,
|
|
61
|
+
var _documento = _a.documento, onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico, onClickQSA = _a.onClickQSA, onClickPrint = _a.onClickPrint, apiKey = _a.apiKey, onClose = _a.onClose, hasCredits = _a.hasCredits, _b = _a.initRefinBoaVista, initRefinBoaVista = _b === void 0 ? false : _b, _c = _a.initRefinSerasa, initRefinSerasa = _c === void 0 ? false : _c, _d = _a.initVeiculos, initVeiculos = _d === void 0 ? false : _d, _e = _a.printMode, printMode = _e === void 0 ? false : _e, _f = _a.isFinancial, isFinancial = _f === void 0 ? false : _f, _g = _a.tags, tags = _g === void 0 ? [] : _g, posthog = _a.posthog;
|
|
62
62
|
var documento = _documento.replace(/\D+/g, '');
|
|
63
63
|
return (React.createElement(ThemeProvider, { theme: theme },
|
|
64
64
|
React.createElement(ErrorModalProvider, null,
|
|
65
65
|
React.createElement(PostHogProvider, { posthog: posthog },
|
|
66
66
|
React.createElement(ConsultasComplementaresProvider, { hasCredits: hasCredits, initRefinBoaVista: initRefinBoaVista, initRefinSerasa: initRefinSerasa, initVeiculos: initVeiculos },
|
|
67
|
-
React.createElement(WebServiceProvider, { credential: apiKey
|
|
67
|
+
React.createElement(WebServiceProvider, { credential: apiKey },
|
|
68
68
|
React.createElement(HasCreditsVerification, { documento: documento, apiKey: apiKey },
|
|
69
69
|
React.createElement(Queries.Dominios.Request, { data: { documento: documento, cnpj: documento } },
|
|
70
70
|
React.createElement(Queries.Finder.Request, { data: { documento: documento } },
|