@credithub/harlan-components 1.85.3 → 1.86.0
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/consultaRfb.js +5 -5
- package/dist/components/contacts/contacts.js +37 -35
- package/dist/components/dossie/dossieData.js +1 -1
- package/dist/components/dossie/summary/cardsAndProducts.js +1 -1
- package/lib/cjs/index.js +45 -43
- package/lib/esm/index.js +45 -43
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -45,54 +45,56 @@ var Contacts = function (_a) {
|
|
|
45
45
|
var ctx = useContext(Queries.Finder);
|
|
46
46
|
var rfbResponse = useConsultaRfb().rfbResponse;
|
|
47
47
|
var setData = useGlobalData().setData;
|
|
48
|
-
var
|
|
48
|
+
var extractContacts = useCallback(function (data) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
var document = XPathUtils.select('string(//cpf|//cnpj)', data);
|
|
51
|
+
var telefonesRfb = ((_a = XPathUtils.select('string(//RFB/telefones)', rfbResponse)) === null || _a === void 0 ? void 0 : _a.match(/\(\d{2}\)\s?\d{4,5}-\d{4}/g)) || [];
|
|
52
|
+
var telefones = __spreadArray(__spreadArray([], telefonesRfb.map(function (telefone) { return ({
|
|
53
|
+
type: ContactType.TELEFONE,
|
|
54
|
+
value: telefone
|
|
55
|
+
}); }), true), __spreadArray(__spreadArray([], XPathUtils.selectArray('//telefones/fixos/fixos', data) || [], true), XPathUtils.selectArray('//telefones/moveis/moveis', data) || [], true).map(function (telefone) { return ({
|
|
56
|
+
type: ContactType.TELEFONE,
|
|
57
|
+
value: phoneMask(XPathUtils.select('string(./telefone)', telefone))
|
|
58
|
+
}); }), true);
|
|
59
|
+
var emails = __spreadArray([
|
|
60
|
+
{
|
|
61
|
+
type: ContactType.EMAIL,
|
|
62
|
+
value: (_b = XPathUtils.select('string(//RFB/email)', rfbResponse)) === null || _b === void 0 ? void 0 : _b.toLowerCase()
|
|
63
|
+
}
|
|
64
|
+
], XPathUtils.selectArray('//emails/emails', data).map(function (email) { return ({
|
|
65
|
+
type: ContactType.EMAIL,
|
|
66
|
+
value: XPathUtils.select('string(./email)', email)
|
|
67
|
+
}); }), true).filter(function (e) { return e.value; });
|
|
68
|
+
return { telefones: telefones, emails: emails, document: document };
|
|
69
|
+
}, [rfbResponse, ctx === null || ctx === void 0 ? void 0 : ctx.document]);
|
|
70
|
+
var updateGlobalState = useCallback(function () {
|
|
49
71
|
if (ctx.type === RequestStatus.Success && ctx.document) {
|
|
50
|
-
var
|
|
72
|
+
var telefones_1 = XPathUtils.selectArray('//telefones/*/*', ctx.document).map(function (telefone) { return ({
|
|
51
73
|
type: ContactType.TELEFONE,
|
|
52
74
|
value: phoneMask(XPathUtils.select('string(./telefone)', telefone))
|
|
53
75
|
}); });
|
|
54
|
-
var
|
|
76
|
+
var emails_1 = XPathUtils.selectArray('//emails/emails', ctx.document).map(function (email) { return ({
|
|
55
77
|
type: ContactType.EMAIL,
|
|
56
78
|
value: XPathUtils.select('string(./email)', email)
|
|
57
79
|
}); });
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
contacts: __spreadArray(__spreadArray([], telefones, true), emails, true)
|
|
61
|
-
};
|
|
62
|
-
setData(function (prevState) { return (__assign(__assign({}, prevState), { contacts: contactState_1.contacts })); });
|
|
80
|
+
if (telefones_1.length > 0 || emails_1.length > 0) {
|
|
81
|
+
setData(function (prevState) { return (__assign(__assign({}, prevState), { contacts: __spreadArray(__spreadArray([], telefones_1, true), emails_1, true) })); });
|
|
63
82
|
}
|
|
64
83
|
}
|
|
65
84
|
}, [ctx.type, ctx.document]);
|
|
66
85
|
useEffect(function () {
|
|
67
|
-
|
|
68
|
-
}, [
|
|
86
|
+
updateGlobalState();
|
|
87
|
+
}, [updateGlobalState]);
|
|
88
|
+
var renderContactItems = function (items, document, columns, tabletColumns, mobileColumns) { return (React.createElement(ResultContent, { desktop: columns, tablet: tabletColumns, mobile: mobileColumns }, items.map(function (_a, key) {
|
|
89
|
+
var type = _a.type, value = _a.value;
|
|
90
|
+
return (React.createElement(ContactLikeDislikeSection, { key: key, type: type, value: value, document: document }));
|
|
91
|
+
}))); };
|
|
69
92
|
return (React.createElement(Section, { ctx: ctx, title: "Contato", subtitle: "Informa\u00E7\u00F5es de contato do documento pesquisado.", description: "(Telefone, e-mail e outros)", minimized: false, icon: ContatoIcon, onSuccess: function (data) {
|
|
70
|
-
var _a;
|
|
71
|
-
var document = XPathUtils.select('string(//cpf|//cnpj)', data);
|
|
72
|
-
var telefones = __spreadArray(__spreadArray([], (XPathUtils.selectArray('//telefones/fixos/fixos', data) || []), true), (XPathUtils.selectArray('//telefones/moveis/moveis', data) || []), true).map(function (telefone) { return ({
|
|
73
|
-
type: ContactType.TELEFONE,
|
|
74
|
-
value: phoneMask(XPathUtils.select('string(./telefone)', telefone))
|
|
75
|
-
}); });
|
|
76
|
-
var emails = __spreadArray([
|
|
77
|
-
{
|
|
78
|
-
type: ContactType.EMAIL,
|
|
79
|
-
value: (_a = XPathUtils.select('string(//RFB/email)', rfbResponse)) === null || _a === void 0 ? void 0 : _a.toLowerCase()
|
|
80
|
-
}
|
|
81
|
-
], XPathUtils.selectArray('//emails/emails', data).map(function (email) { return ({
|
|
82
|
-
type: ContactType.EMAIL,
|
|
83
|
-
value: XPathUtils.select('string(./email)', email)
|
|
84
|
-
}); }), true).filter(function (e) { return e.value; });
|
|
85
|
-
var children = (React.createElement(Result, { resultContentStriped: false },
|
|
86
|
-
React.createElement(ResultContent, { desktop: "1fr 1fr 1fr", tablet: "1fr 1fr", mobile: "1fr 1fr" }, telefones.map(function (_a, key) {
|
|
87
|
-
var type = _a.type, value = _a.value;
|
|
88
|
-
return (React.createElement(ContactLikeDislikeSection, { key: key, type: type, value: value, document: document }));
|
|
89
|
-
})),
|
|
90
|
-
React.createElement(ResultContent, { desktop: "1fr 1fr 1fr", tablet: "1fr 1fr", mobile: "1fr" }, emails.map(function (_a, key) {
|
|
91
|
-
var type = _a.type, value = _a.value;
|
|
92
|
-
return (React.createElement(ContactLikeDislikeSection, { key: key, type: type, value: value, document: document }));
|
|
93
|
-
}))));
|
|
93
|
+
var _a = extractContacts(data), telefones = _a.telefones, emails = _a.emails, document = _a.document;
|
|
94
94
|
return {
|
|
95
|
-
children:
|
|
95
|
+
children: (React.createElement(Result, { resultContentStriped: false },
|
|
96
|
+
renderContactItems(telefones, document, "1fr 1fr 1fr", "1fr 1fr", "1fr 1fr"),
|
|
97
|
+
renderContactItems(emails, document, "1fr 1fr 1fr", "1fr 1fr", "1fr"))),
|
|
96
98
|
actions: (React.createElement(BtnWrapper, null,
|
|
97
99
|
React.createElement(Button, { onClick: onClickConsultarEmail }, "Consultar E-mail em Dom\u00EDnio")))
|
|
98
100
|
};
|
|
@@ -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
|
{
|