@credithub/harlan-components 1.85.3 → 1.85.4
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.
|
@@ -15,15 +15,15 @@ var parseXml = function (raw) {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
export var ConsultaRfbProvider = function (_a) {
|
|
18
|
-
var _b, _c;
|
|
18
|
+
var _b, _c, _d;
|
|
19
19
|
var children = _a.children, documento = _a.documento;
|
|
20
20
|
/** documento só com dígitos */
|
|
21
21
|
var cleanDoc = documento.replace(/\D+/g, '');
|
|
22
22
|
var isCnpj = cleanDoc.length === 14;
|
|
23
23
|
/** controle de fallback (somente CNPJ) */
|
|
24
|
-
var
|
|
24
|
+
var _e = useState(false), enableFallback = _e[0], setEnableFallback = _e[1];
|
|
25
25
|
/** flag genérica: já atualizou pelo menos uma vez */
|
|
26
|
-
var
|
|
26
|
+
var _f = useState(false), updatedOnce = _f[0], setUpdatedOnce = _f[1];
|
|
27
27
|
/* consulta primária – funciona tanto para CPF quanto CNPJ */
|
|
28
28
|
var query = useQuery("SELECT FROM 'RFB'.'CERTIDAO'", { documento: documento });
|
|
29
29
|
/* fallback ReceitaWS – apenas se CNPJ */
|
|
@@ -52,8 +52,8 @@ export var ConsultaRfbProvider = function (_a) {
|
|
|
52
52
|
}, [enableFallback, isCnpj]);
|
|
53
53
|
/* escolhe qual XML usar */
|
|
54
54
|
var rawResponse = isCnpj && enableFallback
|
|
55
|
-
? (_b = queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.response) === null ||
|
|
56
|
-
: (
|
|
55
|
+
? (queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.isLoading) ? (_b = query.response) === null || _b === void 0 ? void 0 : _b.document : (_c = queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.response) === null || _c === void 0 ? void 0 : _c.document
|
|
56
|
+
: (_d = query.response) === null || _d === void 0 ? void 0 : _d.document;
|
|
57
57
|
return (React.createElement(ConsultaRfbContext.Provider, { value: {
|
|
58
58
|
rfbResponse: parseXml(rawResponse),
|
|
59
59
|
executeFallback: executeFallback,
|
|
@@ -44,7 +44,7 @@ export function createDossieData(data, rfbResponse, name, document) {
|
|
|
44
44
|
cnaeDescricao: XPathUtils.select('string(//cadastro/cnaeDescricao)', data) ||
|
|
45
45
|
XPathUtils.select('string(//RFB/atividade-economica)', rfbResponse),
|
|
46
46
|
atividadesEconomicasSecundarias: getAtividadesEconomicasSecundarias(rfbResponse),
|
|
47
|
-
naturezaJuridica: XPathUtils.select('string(//cadastro/naturezaJuridica)', data),
|
|
47
|
+
naturezaJuridica: rfbResponse ? XPathUtils.select('string(//RFB/natureza-juridica)', rfbResponse) : XPathUtils.select('string(//cadastro/naturezaJuridica)', data),
|
|
48
48
|
dataAbertura: XPathUtils.select('string(//cadastro/dataAbertura)', data) ||
|
|
49
49
|
XPathUtils.select('string(//RFB/data-abertura)', rfbResponse),
|
|
50
50
|
idadeEmpresa: XPathUtils.select('string(//cadastro/idadeEmpresa)', data),
|
|
@@ -213,7 +213,7 @@ var useCardsAndProducts = function (_a) {
|
|
|
213
213
|
header: 'Atividades Econômicas Secundárias'
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
|
-
title: getField('naturezaJuridica', finderResponse),
|
|
216
|
+
title: XPathUtils.select('string(//RFB/natureza-juridica)', rfbResponse || undefined) || getField('naturezaJuridica', finderResponse),
|
|
217
217
|
header: 'Natureza Jurídica'
|
|
218
218
|
},
|
|
219
219
|
{
|