@credithub/harlan-components 1.80.2 → 1.81.2
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/assets/btn/buttonAtualizarDadosRfb.js +11 -5
- package/dist/components/common/button.d.ts +4 -2
- package/dist/components/common/button.js +41 -12
- package/dist/components/common/modal.d.ts +4 -4
- package/dist/components/common/modal.js +69 -20
- package/dist/components/consultaRfb.d.ts +26 -2
- package/dist/components/consultaRfb.js +51 -13
- package/dist/components/dossie/dossie.js +28 -22
- package/dist/components/dossie/summary/cardsAndProducts.js +22 -22
- package/dist/components/dossie/summary/styles.d.ts +2 -4
- package/dist/components/dossie/summary/styles.js +2 -2
- package/dist/components/refinBoaVista/refinBoaVista.js +3 -2
- package/dist/components/refinSerasa/refinSerasa.js +13 -8
- package/dist/components/score/scoreService.js +3 -2
- package/dist/components/scoreSerasa/scoreSerasa.js +5 -4
- package/dist/components/scr/scr.js +3 -2
- package/dist/components/veiculos/veiculos.js +3 -2
- package/dist/consultaSimples.js +34 -32
- package/dist/contexts/errorModalContext.d.ts +9 -0
- package/dist/contexts/errorModalContext.js +35 -0
- package/dist/hooks/useConsultaRfb.d.ts +9 -7
- package/dist/hooks/useConsultaRfb.js +14 -2
- package/dist/hooks/useSafeQuery.d.ts +7 -0
- package/dist/hooks/useSafeQuery.js +15 -0
- package/dist/styles/globalStyle.js +4 -4
- package/lib/cjs/index.js +27452 -31059
- package/lib/esm/index.js +27608 -31197
- package/package.json +1 -2
- package/dist/components/common/carousel.d.ts +0 -4
- package/dist/components/common/carousel.js +0 -19
- package/dist/components/dossie/carrousel/carrousel.d.ts +0 -8
- package/dist/components/dossie/carrousel/carrousel.js +0 -15
- package/dist/components/dossie/companyLogo/companyLogo.d.ts +0 -7
- package/dist/components/dossie/companyLogo/companyLogo.js +0 -53
- package/dist/components/reclameAqui/reclameAquiCarousel.d.ts +0 -17
- package/dist/components/reclameAqui/reclameAquiCarousel.js +0 -64
- package/dist/components/reclameAqui/styles.d.ts +0 -14
- package/dist/components/reclameAqui/styles.js +0 -31
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import Button from '../../components/common/button';
|
|
3
2
|
import { useConsultaRfb } from '../../hooks/useConsultaRfb';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
var ButtonAtualizarDadosRfb = function () {
|
|
5
|
-
var _a = useConsultaRfb(), executeFallback = _a.executeFallback, isLoading = _a.isLoading;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var _a = useConsultaRfb(), executeFallback = _a.executeFallback, isLoading = _a.isLoading, updatedOnce = _a.updatedOnce;
|
|
6
|
+
var label = isLoading
|
|
7
|
+
? 'Atualizando dados...'
|
|
8
|
+
: updatedOnce
|
|
9
|
+
? 'Dados RFB atualizados'
|
|
10
|
+
: 'Atualizar Dados RFB';
|
|
11
|
+
return (React.createElement(Button, { disabled: isLoading || updatedOnce, isLoading: isLoading, onClick: function () {
|
|
12
|
+
if (!updatedOnce && executeFallback)
|
|
13
|
+
executeFallback();
|
|
14
|
+
} }, label));
|
|
9
15
|
};
|
|
10
16
|
export default ButtonAtualizarDadosRfb;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
/** Props públicas que outros módulos podem consumir */
|
|
3
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
4
|
smallContent?: ReactNode;
|
|
4
5
|
isLoading?: boolean;
|
|
5
|
-
}
|
|
6
|
+
}
|
|
7
|
+
declare const Button: React.FC<ButtonProps>;
|
|
6
8
|
export default Button;
|
|
@@ -24,28 +24,57 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
}
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
|
-
import theme from '../../styles/theme';
|
|
28
27
|
import classNames from 'classnames';
|
|
28
|
+
import { SpinnerGap } from 'phosphor-react';
|
|
29
29
|
import React from 'react';
|
|
30
|
-
import styled, { css } from 'styled-components';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
import styled, { css, keyframes } from 'styled-components';
|
|
31
|
+
/* animação de rotação para o ícone */
|
|
32
|
+
var spin = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n"], ["\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n"])));
|
|
33
|
+
/* Ícone estilizado que gira indefinidamente */
|
|
34
|
+
var RotatingSpinner = styled(SpinnerGap)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n animation: ", " 1s linear infinite;\n"], ["\n animation: ", " 1s linear infinite;\n"])), spin);
|
|
35
|
+
var StyledButton = styled.button(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n\n background-color: ", ";\n color: ", ";\n\n padding: 8px 20px;\n border: none;\n border-radius: 60px;\n cursor: ", ";\n\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n text-align: center;\n\n transition:\n background-color 0.3s ease-in-out,\n color 0.3s ease-in-out;\n\n ", "\n\n width: 100% !important;\n min-height: 40px;\n gap: 6px;\n"], ["\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n\n background-color: ", ";\n color: ", ";\n\n padding: 8px 20px;\n border: none;\n border-radius: 60px;\n cursor: ", ";\n\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n text-align: center;\n\n transition:\n background-color 0.3s ease-in-out,\n color 0.3s ease-in-out;\n\n ", "\n\n width: 100% !important;\n min-height: 40px;\n gap: 6px;\n"])), function (_a) {
|
|
36
|
+
var theme = _a.theme;
|
|
37
|
+
return theme.typography.headline14.fontStyle;
|
|
38
|
+
}, function (_a) {
|
|
39
|
+
var theme = _a.theme;
|
|
40
|
+
return theme.typography.headline14.fontWeight;
|
|
41
|
+
}, function (_a) {
|
|
42
|
+
var theme = _a.theme;
|
|
43
|
+
return theme.typography.headline14.fontSize;
|
|
44
|
+
}, function (_a) {
|
|
45
|
+
var theme = _a.theme;
|
|
46
|
+
return theme.typography.headline14.lineHeight;
|
|
47
|
+
}, function (_a) {
|
|
48
|
+
var isLoading = _a.isLoading, disabled = _a.disabled, theme = _a.theme;
|
|
49
|
+
return isLoading || disabled
|
|
50
|
+
? theme.colors.cinzaClaro
|
|
51
|
+
: theme.colors.azulCredithub;
|
|
52
|
+
}, function (_a) {
|
|
53
|
+
var disabled = _a.disabled, theme = _a.theme;
|
|
54
|
+
return disabled ? theme.colors.cinzaEscuro : theme.colors.white;
|
|
55
|
+
}, function (_a) {
|
|
56
|
+
var isLoading = _a.isLoading, disabled = _a.disabled;
|
|
57
|
+
return isLoading ? 'wait' : disabled ? 'not-allowed' : 'pointer';
|
|
58
|
+
}, function (_a) {
|
|
59
|
+
var isLoading = _a.isLoading, disabled = _a.disabled;
|
|
60
|
+
return !isLoading &&
|
|
61
|
+
!disabled && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background-color: ", ";\n }\n "], ["\n &:hover {\n background-color: ", ";\n }\n "])), function (_a) {
|
|
35
62
|
var theme = _a.theme;
|
|
36
63
|
return theme.colors.azulApoio;
|
|
37
64
|
});
|
|
38
65
|
});
|
|
39
|
-
var SmallContent = styled.small(
|
|
66
|
+
var SmallContent = styled.small(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n display: block;\n margin-top: 4px;\n\n @media print {\n display: none;\n }\n"], ["\n color: ", ";\n display: block;\n margin-top: 4px;\n\n @media print {\n display: none;\n }\n"])), function (_a) {
|
|
40
67
|
var theme = _a.theme;
|
|
41
68
|
return theme.colors.alerta;
|
|
42
69
|
});
|
|
43
70
|
var Button = function (_a) {
|
|
44
|
-
var children = _a.children, className = _a.className, smallContent = _a.smallContent, props = __rest(_a, ["children", "className", "smallContent"]);
|
|
71
|
+
var children = _a.children, className = _a.className, smallContent = _a.smallContent, isLoading = _a.isLoading, props = __rest(_a, ["children", "className", "smallContent", "isLoading"]);
|
|
45
72
|
var buttonClassName = classNames(className);
|
|
46
|
-
return (React.createElement(StyledButton, __assign({ className: buttonClassName }, props),
|
|
47
|
-
React.createElement(
|
|
48
|
-
|
|
73
|
+
return (React.createElement(StyledButton, __assign({ className: buttonClassName, isLoading: isLoading }, props),
|
|
74
|
+
isLoading ? (React.createElement(React.Fragment, null,
|
|
75
|
+
React.createElement("span", null, children),
|
|
76
|
+
React.createElement(RotatingSpinner, { size: 20, weight: "bold" }))) : (React.createElement("span", null, children)),
|
|
77
|
+
!isLoading && smallContent && (React.createElement(SmallContent, null, smallContent))));
|
|
49
78
|
};
|
|
50
79
|
export default Button;
|
|
51
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
80
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
interface ModalProps {
|
|
3
3
|
isOpen: boolean;
|
|
4
4
|
onClose: () => void;
|
|
5
5
|
title?: string;
|
|
6
|
-
children:
|
|
7
|
-
footer?:
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
footer?: ReactNode;
|
|
8
8
|
}
|
|
9
|
-
declare const Modal:
|
|
9
|
+
declare const Modal: FC<ModalProps>;
|
|
10
10
|
export default Modal;
|
|
@@ -2,14 +2,18 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
-
import React, { useEffect } from 'react';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
var
|
|
5
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
var Overlay = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: fixed;\n inset: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 1000;\n\n opacity: 1;\n transition: opacity 0.25s ease;\n ", "\n"], ["\n position: fixed;\n inset: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 1000;\n\n opacity: 1;\n transition: opacity 0.25s ease;\n ", "\n"])), function (_a) {
|
|
9
|
+
var closing = _a.closing;
|
|
10
|
+
return closing && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0;\n pointer-events: none;\n "], ["\n opacity: 0;\n pointer-events: none;\n "])));
|
|
11
|
+
});
|
|
12
|
+
var Container = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: ", ";\n border-radius: 12px;\n max-width: 500px;\n width: 90%;\n padding: 32px;\n box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);\n position: relative;\n transition: transform 0.25s ease;\n transform: translateY(0);\n\n @media (max-width: 480px) {\n width: calc(100% - 32px);\n padding: 24px 20px;\n }\n"], ["\n background: ", ";\n border-radius: 12px;\n max-width: 500px;\n width: 90%;\n padding: 32px;\n box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);\n position: relative;\n transition: transform 0.25s ease;\n transform: translateY(0);\n\n @media (max-width: 480px) {\n width: calc(100% - 32px);\n padding: 24px 20px;\n }\n"])), function (_a) {
|
|
9
13
|
var theme = _a.theme;
|
|
10
14
|
return theme.colors.white;
|
|
11
15
|
});
|
|
12
|
-
var CloseButton = styled.button(
|
|
16
|
+
var CloseButton = styled.button(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n all: unset;\n position: absolute;\n top: 12px;\n right: 12px;\n width: 32px;\n height: 32px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 1.5rem;\n cursor: pointer;\n color: ", ";\n border-radius: 50%;\n transition:\n background 0.3s ease,\n color 0.3s ease;\n\n &:hover {\n background: ", ";\n color: ", ";\n }\n"], ["\n all: unset;\n position: absolute;\n top: 12px;\n right: 12px;\n width: 32px;\n height: 32px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 1.5rem;\n cursor: pointer;\n color: ", ";\n border-radius: 50%;\n transition:\n background 0.3s ease,\n color 0.3s ease;\n\n &:hover {\n background: ", ";\n color: ", ";\n }\n"])), function (_a) {
|
|
13
17
|
var theme = _a.theme;
|
|
14
18
|
return theme.colors.cinzaEscuro;
|
|
15
19
|
}, function (_a) {
|
|
@@ -19,42 +23,87 @@ var CloseButton = styled.button(templateObject_3 || (templateObject_3 = __makeTe
|
|
|
19
23
|
var theme = _a.theme;
|
|
20
24
|
return theme.colors.azulCredithub;
|
|
21
25
|
});
|
|
22
|
-
var Title = styled.h2(
|
|
26
|
+
var Title = styled.h2(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n color: ", ";\n text-align: center;\n margin-bottom: 16px;\n"], ["\n ", ";\n color: ", ";\n text-align: center;\n margin-bottom: 16px;\n"])), function (_a) {
|
|
23
27
|
var theme = _a.theme;
|
|
24
28
|
return theme.typography.headline20;
|
|
25
29
|
}, function (_a) {
|
|
26
30
|
var theme = _a.theme;
|
|
27
31
|
return theme.colors.azulCredithub;
|
|
28
32
|
});
|
|
29
|
-
var Content = styled.div(
|
|
33
|
+
var Content = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n color: ", ";\n margin-bottom: 24px;\n text-align: center;\n"], ["\n ", ";\n color: ", ";\n margin-bottom: 24px;\n text-align: center;\n"])), function (_a) {
|
|
30
34
|
var theme = _a.theme;
|
|
31
35
|
return theme.typography.body16;
|
|
32
36
|
}, function (_a) {
|
|
33
37
|
var theme = _a.theme;
|
|
34
38
|
return theme.colors.cinzaEscuro;
|
|
35
39
|
});
|
|
36
|
-
var Footer = styled.div(
|
|
40
|
+
var Footer = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n gap: 10px;\n"], ["\n display: flex;\n justify-content: center;\n gap: 10px;\n"])));
|
|
37
41
|
var Modal = function (_a) {
|
|
38
42
|
var isOpen = _a.isOpen, onClose = _a.onClose, title = _a.title, children = _a.children, footer = _a.footer;
|
|
43
|
+
var _b = useState(false), closing = _b[0], setClosing = _b[1];
|
|
44
|
+
var firstFocusable = useRef(null);
|
|
39
45
|
useEffect(function () {
|
|
40
46
|
if (!isOpen)
|
|
41
|
-
return;
|
|
42
|
-
var handleKeyDown = function (
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
return function () { };
|
|
48
|
+
var handleKeyDown = function (e) {
|
|
49
|
+
if (e.key === 'Escape')
|
|
50
|
+
startClose();
|
|
51
|
+
if (e.key === 'Tab')
|
|
52
|
+
trapFocus(e);
|
|
46
53
|
};
|
|
47
54
|
window.addEventListener('keydown', handleKeyDown);
|
|
48
55
|
return function () { return window.removeEventListener('keydown', handleKeyDown); };
|
|
49
|
-
}, [isOpen
|
|
50
|
-
|
|
56
|
+
}, [isOpen]);
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
if (isOpen) {
|
|
59
|
+
var overflow_1 = document.body.style.overflow;
|
|
60
|
+
document.body.style.overflow = 'hidden';
|
|
61
|
+
return function () {
|
|
62
|
+
document.body.style.overflow = overflow_1;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return function () { };
|
|
66
|
+
}, [isOpen]);
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
var _a;
|
|
69
|
+
if (isOpen)
|
|
70
|
+
(_a = firstFocusable.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
71
|
+
return function () { };
|
|
72
|
+
}, [isOpen]);
|
|
73
|
+
var startClose = useCallback(function () {
|
|
74
|
+
setClosing(true);
|
|
75
|
+
setTimeout(onClose, 250);
|
|
76
|
+
}, [onClose]);
|
|
77
|
+
var trapFocus = function (e) {
|
|
78
|
+
var node = ContainerRef.current;
|
|
79
|
+
if (!node)
|
|
80
|
+
return;
|
|
81
|
+
var focusable = node.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])');
|
|
82
|
+
if (focusable.length === 0)
|
|
83
|
+
return;
|
|
84
|
+
var first = focusable[0];
|
|
85
|
+
var last = focusable[focusable.length - 1];
|
|
86
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
87
|
+
last.focus();
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
}
|
|
90
|
+
else if (!e.shiftKey && document.activeElement === last) {
|
|
91
|
+
first.focus();
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var ContainerRef = useRef(null);
|
|
96
|
+
if (!isOpen && !closing)
|
|
51
97
|
return null;
|
|
52
|
-
|
|
53
|
-
React.createElement(
|
|
54
|
-
React.createElement(CloseButton, { onClick:
|
|
55
|
-
title && React.createElement(Title,
|
|
98
|
+
var dialog = (React.createElement(Overlay, { closing: closing, onClick: startClose, role: "dialog", "aria-modal": "true", "aria-labelledby": title ? 'modal-title' : undefined },
|
|
99
|
+
React.createElement(Container, { ref: ContainerRef, onClick: function (e) { return e.stopPropagation(); }, "data-testid": "modal-container" },
|
|
100
|
+
React.createElement(CloseButton, { "aria-label": "Fechar", onClick: startClose, ref: firstFocusable }, "\u00D7"),
|
|
101
|
+
title && (React.createElement(Title, { id: "modal-title", tabIndex: -1 }, title)),
|
|
56
102
|
React.createElement(Content, null, children),
|
|
57
103
|
footer && React.createElement(Footer, null, footer))));
|
|
104
|
+
return typeof document !== 'undefined'
|
|
105
|
+
? ReactDOM.createPortal(dialog, document.body)
|
|
106
|
+
: dialog;
|
|
58
107
|
};
|
|
59
108
|
export default Modal;
|
|
60
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
109
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
export type ConsultaRfbContextProps = Partial<{
|
|
3
|
-
|
|
3
|
+
/** XML já parseado vindo da Receita Federal (CPF ou CNPJ) */
|
|
4
|
+
rfbResponse?: Document;
|
|
5
|
+
/** refaz apenas a consulta principal (CERTIDAO) */
|
|
4
6
|
refetch: () => void;
|
|
5
7
|
error: Error | null;
|
|
8
|
+
/** `true` enquanto qualquer consulta estiver rodando */
|
|
6
9
|
isLoading: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Acionador de “atualizar dados”:
|
|
12
|
+
* * CNPJ → chama ReceitaWS
|
|
13
|
+
* * CPF → refaz CERTIDAO
|
|
14
|
+
*/
|
|
7
15
|
executeFallback: () => void;
|
|
16
|
+
/** já executou pelo menos uma atualização (CPF ou CNPJ) */
|
|
17
|
+
updatedOnce: boolean;
|
|
18
|
+
/** `true` quando o documento tem 14 dígitos */
|
|
19
|
+
isCnpj: boolean;
|
|
8
20
|
}>;
|
|
9
21
|
export declare const ConsultaRfbContext: React.Context<Partial<{
|
|
10
|
-
|
|
22
|
+
/** XML já parseado vindo da Receita Federal (CPF ou CNPJ) */
|
|
23
|
+
rfbResponse?: Document;
|
|
24
|
+
/** refaz apenas a consulta principal (CERTIDAO) */
|
|
11
25
|
refetch: () => void;
|
|
12
26
|
error: Error | null;
|
|
27
|
+
/** `true` enquanto qualquer consulta estiver rodando */
|
|
13
28
|
isLoading: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Acionador de “atualizar dados”:
|
|
31
|
+
* * CNPJ → chama ReceitaWS
|
|
32
|
+
* * CPF → refaz CERTIDAO
|
|
33
|
+
*/
|
|
14
34
|
executeFallback: () => void;
|
|
35
|
+
/** já executou pelo menos uma atualização (CPF ou CNPJ) */
|
|
36
|
+
updatedOnce: boolean;
|
|
37
|
+
/** `true` quando o documento tem 14 dígitos */
|
|
38
|
+
isCnpj: boolean;
|
|
15
39
|
}> | null>;
|
|
16
40
|
export declare const ConsultaRfbProvider: React.FC<PropsWithChildren<{
|
|
17
41
|
documento: string;
|
|
@@ -2,27 +2,65 @@
|
|
|
2
2
|
import React, { createContext, useEffect, useState } from 'react';
|
|
3
3
|
import { useQuery } from './webservice';
|
|
4
4
|
export var ConsultaRfbContext = createContext(null);
|
|
5
|
+
var parseXml = function (raw) {
|
|
6
|
+
if (!raw)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (typeof raw !== 'string')
|
|
9
|
+
return raw;
|
|
10
|
+
try {
|
|
11
|
+
return new DOMParser().parseFromString(raw, 'text/xml');
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
5
17
|
export var ConsultaRfbProvider = function (_a) {
|
|
6
18
|
var _b, _c;
|
|
7
19
|
var children = _a.children, documento = _a.documento;
|
|
20
|
+
/** documento só com dígitos */
|
|
21
|
+
var cleanDoc = documento.replace(/\D+/g, '');
|
|
22
|
+
var isCnpj = cleanDoc.length === 14;
|
|
23
|
+
/** controle de fallback (somente CNPJ) */
|
|
8
24
|
var _d = useState(false), enableFallback = _d[0], setEnableFallback = _d[1];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
25
|
+
/** flag genérica: já atualizou pelo menos uma vez */
|
|
26
|
+
var _e = useState(false), updatedOnce = _e[0], setUpdatedOnce = _e[1];
|
|
27
|
+
/* consulta primária – funciona tanto para CPF quanto CNPJ */
|
|
28
|
+
var query = useQuery("SELECT FROM 'RFB'.'CERTIDAO'", { documento: documento });
|
|
29
|
+
/* fallback ReceitaWS – apenas se CNPJ */
|
|
30
|
+
var queryFallback = isCnpj
|
|
31
|
+
? useQuery("SELECT FROM 'RECEITAWS'.'CNPJ'", { documento: documento }, enableFallback)
|
|
32
|
+
: undefined;
|
|
33
|
+
/** clique no botão “Atualizar Dados RFB” */
|
|
34
|
+
var executeFallback = function () {
|
|
35
|
+
if (updatedOnce)
|
|
36
|
+
return; // já atualizou
|
|
37
|
+
if (isCnpj) {
|
|
38
|
+
setEnableFallback(true);
|
|
39
|
+
queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.refetch();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
/* CPF → basta refazer CERTIDAO (sem fallback externo) */
|
|
43
|
+
query.refetch();
|
|
44
|
+
}
|
|
45
|
+
setUpdatedOnce(true);
|
|
46
|
+
};
|
|
47
|
+
/* se enableFallback virar true (CNPJ), força refetch */
|
|
14
48
|
useEffect(function () {
|
|
15
|
-
if (enableFallback) {
|
|
16
|
-
queryFallback.refetch();
|
|
49
|
+
if (enableFallback && isCnpj) {
|
|
50
|
+
queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.refetch();
|
|
17
51
|
}
|
|
18
|
-
}, [enableFallback]);
|
|
52
|
+
}, [enableFallback, isCnpj]);
|
|
53
|
+
/* escolhe qual XML usar */
|
|
54
|
+
var rawResponse = isCnpj && enableFallback
|
|
55
|
+
? (_b = queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.response) === null || _b === void 0 ? void 0 : _b.document
|
|
56
|
+
: (_c = query.response) === null || _c === void 0 ? void 0 : _c.document;
|
|
19
57
|
return (React.createElement(ConsultaRfbContext.Provider, { value: {
|
|
20
|
-
rfbResponse:
|
|
21
|
-
? (_b = queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.response) === null || _b === void 0 ? void 0 : _b.document
|
|
22
|
-
: (_c = query === null || query === void 0 ? void 0 : query.response) === null || _c === void 0 ? void 0 : _c.document,
|
|
58
|
+
rfbResponse: parseXml(rawResponse),
|
|
23
59
|
executeFallback: executeFallback,
|
|
60
|
+
updatedOnce: updatedOnce,
|
|
61
|
+
isCnpj: isCnpj,
|
|
24
62
|
refetch: query.refetch,
|
|
25
|
-
error: query.error || queryFallback.error,
|
|
26
|
-
isLoading: query.isLoading || queryFallback.isLoading
|
|
63
|
+
error: query.error || (queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.error),
|
|
64
|
+
isLoading: query.isLoading || (queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.isLoading)
|
|
27
65
|
} }, children));
|
|
28
66
|
};
|
|
@@ -19,11 +19,11 @@ import { formatCnpj, formatCpf } from '../../utils/string';
|
|
|
19
19
|
import XPathUtils from '../../utils/xpath';
|
|
20
20
|
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
21
21
|
import styled from 'styled-components';
|
|
22
|
-
import { ReclameAquiCarousel } from '../reclameAqui/reclameAquiCarousel';
|
|
23
22
|
import Section from '../section';
|
|
24
23
|
import { Queries, RequestStatus, useQuery } from '../webservice';
|
|
25
24
|
import { createDossieData } from './dossieData';
|
|
26
25
|
import GenerativeAI from './generativeAi/generativeAi';
|
|
26
|
+
import { ReclameAquiCarousel } from './sliderCompanyName/reclameAqui/reclameAquiCarousel';
|
|
27
27
|
import { Summary } from './summary/summary';
|
|
28
28
|
import { TransactionsTable } from './transactionTable/transactionTable';
|
|
29
29
|
var DossieContent = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"], ["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"])));
|
|
@@ -32,20 +32,35 @@ var GenerativeAIContainer = styled.div(templateObject_3 || (templateObject_3 = _
|
|
|
32
32
|
var theme = _a.theme;
|
|
33
33
|
return theme.colors.white;
|
|
34
34
|
});
|
|
35
|
+
// Utilitário para obter o nome da empresa, priorizando ReceitaWS
|
|
36
|
+
var getCompanyName = function (isPF, finderDoc, rfbDoc) {
|
|
37
|
+
if (isPF) {
|
|
38
|
+
return XPathUtils.select('string(//cadastro/nome)', finderDoc);
|
|
39
|
+
}
|
|
40
|
+
// prioridade 1 → ReceitaWS
|
|
41
|
+
var rfbName = (rfbDoc && XPathUtils.select('string(//RFB/nome)', rfbDoc)) ||
|
|
42
|
+
'';
|
|
43
|
+
if (rfbName)
|
|
44
|
+
return rfbName;
|
|
45
|
+
// prioridade 2 → Finder
|
|
46
|
+
return ((finderDoc &&
|
|
47
|
+
XPathUtils.select('string(//cadastro/razaoSocial)', finderDoc)) ||
|
|
48
|
+
'');
|
|
49
|
+
};
|
|
35
50
|
var Dossie = function (_a) {
|
|
36
51
|
var documento = _a.documento, printMode = _a.printMode;
|
|
37
52
|
var ctx = useContext(Queries.Finder);
|
|
38
|
-
var
|
|
39
|
-
var
|
|
53
|
+
var _b = useConsultaRfb(), rfbResponse = _b.rfbResponse, updatedOnce = _b.updatedOnce;
|
|
54
|
+
var _c = useGlobalData(), globalData = _c.data, setData = _c.setData;
|
|
40
55
|
var lastDossieRef = useRef();
|
|
41
56
|
// Ref para guardar o status de receita anterior
|
|
42
57
|
var prevReceitaStatusRef = useRef(undefined);
|
|
43
58
|
// Estado para sinalizar que houve mudança relevante no rfbResponse
|
|
44
|
-
var
|
|
59
|
+
var _d = useState(false), refreshQuery = _d[0], setRefreshQuery = _d[1];
|
|
45
60
|
// Consulta ReclameAqui
|
|
46
|
-
var
|
|
61
|
+
var _e = useQuery("SELECT FROM 'RECLAMEAQUI'.'CONSULTA'", {
|
|
47
62
|
documento: documento
|
|
48
|
-
}), reclameAquiResponse =
|
|
63
|
+
}), reclameAquiResponse = _e.response, reclameAquiLoading = _e.isLoading, reclameAquiError = _e.error;
|
|
49
64
|
// Processa os dados do ReclameAqui
|
|
50
65
|
var reclameAquiCompanies = useMemo(function () {
|
|
51
66
|
var _a;
|
|
@@ -55,9 +70,7 @@ var Dossie = function (_a) {
|
|
|
55
70
|
var isPF = (documento === null || documento === void 0 ? void 0 : documento.length) === 11;
|
|
56
71
|
if (isPF)
|
|
57
72
|
return undefined;
|
|
58
|
-
var name_1 = (ctx.document
|
|
59
|
-
XPathUtils.select('string(//cadastro/razaoSocial)', ctx.document)) ||
|
|
60
|
-
'';
|
|
73
|
+
var name_1 = getCompanyName(false, ctx.document, rfbResponse);
|
|
61
74
|
return reclameAquiResponse.document.map(function (item) { return ({
|
|
62
75
|
nome: name_1,
|
|
63
76
|
cnpj: documento,
|
|
@@ -75,7 +88,8 @@ var Dossie = function (_a) {
|
|
|
75
88
|
reclameAquiLoading,
|
|
76
89
|
reclameAquiError,
|
|
77
90
|
documento,
|
|
78
|
-
ctx.document
|
|
91
|
+
ctx.document,
|
|
92
|
+
rfbResponse
|
|
79
93
|
]);
|
|
80
94
|
// Reseta o cache do dossiê sempre que o rfbResponse mudar
|
|
81
95
|
useEffect(function () {
|
|
@@ -85,11 +99,7 @@ var Dossie = function (_a) {
|
|
|
85
99
|
if (ctx.type === RequestStatus.Success && ctx.document) {
|
|
86
100
|
var data = ctx.document;
|
|
87
101
|
var isPF = (documento === null || documento === void 0 ? void 0 : documento.length) === 11;
|
|
88
|
-
var name_2 = (isPF
|
|
89
|
-
? XPathUtils.select('string(//cadastro/nome)', data)
|
|
90
|
-
: XPathUtils.select('string(//cadastro/razaoSocial)', data) ||
|
|
91
|
-
(rfbResponse &&
|
|
92
|
-
XPathUtils.select('string(//RFB/nome)', rfbResponse)));
|
|
102
|
+
var name_2 = getCompanyName(isPF, data, rfbResponse);
|
|
93
103
|
var formattedDocument = isPF
|
|
94
104
|
? formatCpf(documento)
|
|
95
105
|
: formatCnpj(documento);
|
|
@@ -109,16 +119,12 @@ var Dossie = function (_a) {
|
|
|
109
119
|
}, [ctx.type, ctx.document, documento, rfbResponse, setData]);
|
|
110
120
|
useEffect(function () {
|
|
111
121
|
processDossieData();
|
|
112
|
-
}, [processDossieData]);
|
|
122
|
+
}, [processDossieData, updatedOnce]);
|
|
113
123
|
var response = useMemo(function () {
|
|
114
124
|
return function (_data) {
|
|
115
125
|
var data = _data instanceof Error ? undefined : _data;
|
|
116
126
|
var isPF = (documento === null || documento === void 0 ? void 0 : documento.length) === 11;
|
|
117
|
-
var name = (isPF
|
|
118
|
-
? XPathUtils.select('string(//cadastro/nome)', data)
|
|
119
|
-
: XPathUtils.select('string(//cadastro/razaoSocial)', data) ||
|
|
120
|
-
(rfbResponse &&
|
|
121
|
-
XPathUtils.select('string(//RFB/nome)', rfbResponse)));
|
|
127
|
+
var name = getCompanyName(isPF, data, rfbResponse);
|
|
122
128
|
var document = isPF ? formatCpf(documento) : formatCnpj(documento);
|
|
123
129
|
return (React.createElement(React.Fragment, null,
|
|
124
130
|
React.createElement(DossieContainer, null,
|
|
@@ -129,7 +135,7 @@ var Dossie = function (_a) {
|
|
|
129
135
|
!printMode && (React.createElement(GenerativeAIContainer, null,
|
|
130
136
|
React.createElement(GenerativeAI, { documento: document, refreshQuery: refreshQuery })))));
|
|
131
137
|
};
|
|
132
|
-
}, [documento,
|
|
138
|
+
}, [documento, printMode, rfbResponse, reclameAquiCompanies, refreshQuery]);
|
|
133
139
|
return (React.createElement(Section, { ctx: ctx, hideHeader: true, minimized: false, isError: function (e) { return response(e); }, onSuccess: response }));
|
|
134
140
|
};
|
|
135
141
|
export default React.memo(Dossie);
|
|
@@ -53,13 +53,13 @@ import React, { useState } from 'react';
|
|
|
53
53
|
import { LoadingDots } from '../generativeAi/styles';
|
|
54
54
|
import { getAtividadesEconomicasSecundarias, getField, getFieldRfb, getProductsPrices } from './utils';
|
|
55
55
|
var useCardsAndProducts = function (_a) {
|
|
56
|
-
var _b, _c, _d, _e, _f;
|
|
56
|
+
var _b, _c, _d, _e, _f, _g;
|
|
57
57
|
var finderResponse = _a.finderResponse;
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
58
|
+
var _h = useConsultaRfb(), rfbResponse = _h.rfbResponse, rfbIsLoading = _h.isLoading;
|
|
59
|
+
var _j = useState(false), isModalOpen = _j[0], setModalOpen = _j[1];
|
|
60
|
+
var _k = useConsultasComplementares(), consultasComplementares = _k.consultasComplementares, setConsultasComplementares = _k.setConsultasComplementares, hasCredits = _k.hasCredits;
|
|
61
|
+
var _l = useState(false), isScrModalOpen = _l[0], setScrModalOpen = _l[1];
|
|
62
|
+
var _m = useState({}), loadingButtons = _m[0], setLoadingButtons = _m[1];
|
|
63
63
|
var handleModalClick = function () { return setModalOpen(true); };
|
|
64
64
|
var closeModal = function () { return setModalOpen(false); };
|
|
65
65
|
var isPF = !!getField('cpf', finderResponse);
|
|
@@ -106,7 +106,7 @@ var useCardsAndProducts = function (_a) {
|
|
|
106
106
|
});
|
|
107
107
|
}); };
|
|
108
108
|
};
|
|
109
|
-
var
|
|
109
|
+
var _o = {
|
|
110
110
|
cards: [
|
|
111
111
|
{
|
|
112
112
|
title: getField('sexo', finderResponse, function (value) {
|
|
@@ -191,12 +191,12 @@ var useCardsAndProducts = function (_a) {
|
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
193
|
title: getField('nomeFantasia', finderResponse) ||
|
|
194
|
-
XPathUtils.select('string(//RFB/nome
|
|
194
|
+
XPathUtils.select('string(//RFB/nome)', rfbResponse || undefined),
|
|
195
195
|
header: 'Nome Fantasia'
|
|
196
196
|
},
|
|
197
197
|
{
|
|
198
198
|
title: getField('dataReceitaStatus', finderResponse) ||
|
|
199
|
-
getFieldRfb('
|
|
199
|
+
getFieldRfb('data-situacao', rfbResponse),
|
|
200
200
|
header: 'Data do Status na Receita'
|
|
201
201
|
},
|
|
202
202
|
{
|
|
@@ -204,8 +204,8 @@ var useCardsAndProducts = function (_a) {
|
|
|
204
204
|
header: 'Tipo da Empresa'
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
|
-
title:
|
|
208
|
-
|
|
207
|
+
title: getFieldRfb('atividade-economica', rfbResponse) ||
|
|
208
|
+
getField('cnaeDescricao', finderResponse),
|
|
209
209
|
header: 'Atividade Econômica'
|
|
210
210
|
},
|
|
211
211
|
{
|
|
@@ -242,8 +242,8 @@ var useCardsAndProducts = function (_a) {
|
|
|
242
242
|
header: 'Porte da Empresa'
|
|
243
243
|
},
|
|
244
244
|
{
|
|
245
|
-
title: formatMoney(
|
|
246
|
-
|
|
245
|
+
title: formatMoney(getFieldRfb('capitalSocial', rfbResponse) ||
|
|
246
|
+
getField('capitalSocial', finderResponse)),
|
|
247
247
|
header: 'Capital Social'
|
|
248
248
|
}
|
|
249
249
|
].filter(function (card) { return card.title; }),
|
|
@@ -276,18 +276,18 @@ var useCardsAndProducts = function (_a) {
|
|
|
276
276
|
hide: (_e = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scoreBoaVista) === null || _e === void 0 ? void 0 : _e.consultaRealizada,
|
|
277
277
|
isLoading: loadingButtons['scoreBoaVista']
|
|
278
278
|
},
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
279
|
+
{
|
|
280
|
+
title: 'Consultar Score Serasa',
|
|
281
|
+
price: productsPrices === null || productsPrices === void 0 ? void 0 : productsPrices.scoreSerasa,
|
|
282
|
+
onClick: handleOnClick('scoreSerasa'),
|
|
283
|
+
hide: (_f = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scoreSerasa) === null || _f === void 0 ? void 0 : _f.consultaRealizada,
|
|
284
|
+
isLoading: loadingButtons['scoreSerasa']
|
|
285
|
+
},
|
|
286
286
|
{
|
|
287
287
|
title: 'Consultar Pefin/Refin Serasa',
|
|
288
288
|
price: productsPrices === null || productsPrices === void 0 ? void 0 : productsPrices.refinSerasa,
|
|
289
289
|
onClick: handleOnClick('refinSerasa'),
|
|
290
|
-
hide: (
|
|
290
|
+
hide: (_g = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _g === void 0 ? void 0 : _g.consultaRealizada,
|
|
291
291
|
isLoading: loadingButtons['refinSerasa']
|
|
292
292
|
} /*,
|
|
293
293
|
{
|
|
@@ -298,7 +298,7 @@ var useCardsAndProducts = function (_a) {
|
|
|
298
298
|
isLoading: loadingButtons['imoveis']
|
|
299
299
|
}*/
|
|
300
300
|
]
|
|
301
|
-
}, cards =
|
|
301
|
+
}, cards = _o.cards, products = _o.products;
|
|
302
302
|
return {
|
|
303
303
|
cards: cards,
|
|
304
304
|
products: products,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ButtonProps } from '../../../components/common/button';
|
|
1
2
|
export declare const Spinner: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
3
|
export declare const ContainerSummary: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
4
|
export declare const ContentSummary: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -6,7 +7,4 @@ export declare const FieldSummary: import("styled-components").StyledComponent<"
|
|
|
6
7
|
}, never>;
|
|
7
8
|
export declare const ButtonsSummary: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
8
9
|
export declare const ButtonsWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
9
|
-
export declare const SummaryButton: import("styled-components").StyledComponent<import("react").FC<import("
|
|
10
|
-
smallContent?: import("react").ReactNode;
|
|
11
|
-
isLoading?: boolean;
|
|
12
|
-
}>, import("styled-components").DefaultTheme, {}, never>;
|
|
10
|
+
export declare const SummaryButton: import("styled-components").StyledComponent<import("react").FC<ButtonProps>, import("styled-components").DefaultTheme, ButtonProps, never>;
|