@credithub/harlan-components 1.3.4 → 1.4.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.
Files changed (115) hide show
  1. package/lib/cjs/components/ccf/ccf.js +2 -5
  2. package/lib/cjs/components/chart/categoryProtestos.d.ts +4 -0
  3. package/lib/cjs/components/chart/categoryProtestos.js +97 -0
  4. package/lib/cjs/components/chart/chartContent.d.ts +7 -0
  5. package/lib/cjs/components/chart/chartContent.js +77 -0
  6. package/lib/cjs/components/chart/chartHelper.d.ts +7 -0
  7. package/lib/cjs/components/chart/chartHelper.js +66 -0
  8. package/lib/cjs/components/chart/customChart.d.ts +10 -0
  9. package/lib/cjs/components/chart/customChart.js +125 -0
  10. package/lib/cjs/components/chart/getUniqueDates.d.ts +2 -0
  11. package/lib/cjs/components/chart/getUniqueDates.js +8 -0
  12. package/lib/cjs/components/chart/plotly/barChartDataStrategy.d.ts +14 -0
  13. package/lib/cjs/components/chart/plotly/barChartDataStrategy.js +152 -0
  14. package/lib/cjs/components/chart/plotly/baseChartDataStrategy.d.ts +8 -0
  15. package/lib/cjs/components/chart/plotly/baseChartDataStrategy.js +31 -0
  16. package/lib/cjs/components/chart/plotly/getSeries.d.ts +3 -0
  17. package/lib/cjs/components/chart/plotly/getSeries.js +35 -0
  18. package/lib/cjs/components/chart/plotly/iChartDataStrategy.d.ts +35 -0
  19. package/lib/cjs/components/chart/plotly/iChartDataStrategy.js +2 -0
  20. package/lib/cjs/components/chart/plotly/index.d.ts +5 -0
  21. package/lib/cjs/components/chart/plotly/index.js +20 -0
  22. package/lib/cjs/components/chart/plotly/layoutLineBarChart.d.ts +39 -0
  23. package/lib/cjs/components/chart/plotly/layoutLineBarChart.js +65 -0
  24. package/lib/cjs/components/chart/plotly/lineChartDataStrategy.d.ts +17 -0
  25. package/lib/cjs/components/chart/plotly/lineChartDataStrategy.js +198 -0
  26. package/lib/cjs/components/chart/plotly/pieChartDataStrategy.d.ts +5 -0
  27. package/lib/cjs/components/chart/plotly/pieChartDataStrategy.js +45 -0
  28. package/lib/cjs/components/chart/plotly/types.d.ts +40 -0
  29. package/lib/cjs/components/chart/plotly/types.js +2 -0
  30. package/lib/cjs/components/chart/processChartData.d.ts +5 -0
  31. package/lib/cjs/components/chart/processChartData.js +41 -0
  32. package/lib/cjs/components/chart/quantityResult.d.ts +17 -0
  33. package/lib/cjs/components/chart/quantityResult.js +38 -0
  34. package/lib/cjs/components/chart/useCalculation.d.ts +6 -0
  35. package/lib/cjs/components/chart/useCalculation.js +12 -0
  36. package/lib/cjs/components/chart/useUltimaOcorrenciaCCF.d.ts +2 -0
  37. package/lib/cjs/components/chart/useUltimaOcorrenciaCCF.js +20 -0
  38. package/lib/cjs/components/protestos/getTotalProtestos.d.ts +1 -0
  39. package/lib/cjs/components/protestos/getTotalProtestos.js +10 -0
  40. package/lib/cjs/components/protestos/protestosCategory.js +1 -1
  41. package/lib/cjs/components/webservice.d.ts +14 -0
  42. package/lib/cjs/components/webservice.js +6 -5
  43. package/lib/cjs/consultaSimples.js +13 -11
  44. package/lib/cjs/index.d.ts +1 -0
  45. package/lib/cjs/index.js +4 -1
  46. package/lib/cjs/mock/mockDataInput.d.ts +34 -0
  47. package/lib/cjs/mock/mockDataInput.js +139 -0
  48. package/lib/cjs/utils/calculation.d.ts +9 -0
  49. package/lib/cjs/utils/calculation.js +23 -0
  50. package/lib/cjs/utils/date.d.ts +1 -0
  51. package/lib/cjs/utils/date.js +10 -0
  52. package/lib/cjs/utils/formatter.d.ts +2 -0
  53. package/lib/cjs/utils/formatter.js +7 -0
  54. package/lib/cjs/utils/number.d.ts +3 -2
  55. package/lib/cjs/utils/number.js +9 -5
  56. package/lib/cjs/utils/string.d.ts +1 -0
  57. package/lib/cjs/utils/string.js +8 -3
  58. package/lib/esm/components/ccf/ccf.js +2 -5
  59. package/lib/esm/components/chart/categoryProtestos.d.ts +4 -0
  60. package/lib/esm/components/chart/categoryProtestos.js +69 -0
  61. package/lib/esm/components/chart/chartContent.d.ts +7 -0
  62. package/lib/esm/components/chart/chartContent.js +49 -0
  63. package/lib/esm/components/chart/chartHelper.d.ts +7 -0
  64. package/lib/esm/components/chart/chartHelper.js +60 -0
  65. package/lib/esm/components/chart/customChart.d.ts +10 -0
  66. package/lib/esm/components/chart/customChart.js +95 -0
  67. package/lib/esm/components/chart/getUniqueDates.d.ts +2 -0
  68. package/lib/esm/components/chart/getUniqueDates.js +4 -0
  69. package/lib/esm/components/chart/plotly/barChartDataStrategy.d.ts +14 -0
  70. package/lib/esm/components/chart/plotly/barChartDataStrategy.js +149 -0
  71. package/lib/esm/components/chart/plotly/baseChartDataStrategy.d.ts +8 -0
  72. package/lib/esm/components/chart/plotly/baseChartDataStrategy.js +28 -0
  73. package/lib/esm/components/chart/plotly/getSeries.d.ts +3 -0
  74. package/lib/esm/components/chart/plotly/getSeries.js +31 -0
  75. package/lib/esm/components/chart/plotly/iChartDataStrategy.d.ts +35 -0
  76. package/lib/esm/components/chart/plotly/iChartDataStrategy.js +1 -0
  77. package/lib/esm/components/chart/plotly/index.d.ts +5 -0
  78. package/lib/esm/components/chart/plotly/index.js +5 -0
  79. package/lib/esm/components/chart/plotly/layoutLineBarChart.d.ts +39 -0
  80. package/lib/esm/components/chart/plotly/layoutLineBarChart.js +62 -0
  81. package/lib/esm/components/chart/plotly/lineChartDataStrategy.d.ts +17 -0
  82. package/lib/esm/components/chart/plotly/lineChartDataStrategy.js +195 -0
  83. package/lib/esm/components/chart/plotly/pieChartDataStrategy.d.ts +5 -0
  84. package/lib/esm/components/chart/plotly/pieChartDataStrategy.js +42 -0
  85. package/lib/esm/components/chart/plotly/types.d.ts +40 -0
  86. package/lib/esm/components/chart/plotly/types.js +1 -0
  87. package/lib/esm/components/chart/processChartData.d.ts +5 -0
  88. package/lib/esm/components/chart/processChartData.js +37 -0
  89. package/lib/esm/components/chart/quantityResult.d.ts +17 -0
  90. package/lib/esm/components/chart/quantityResult.js +33 -0
  91. package/lib/esm/components/chart/useCalculation.d.ts +6 -0
  92. package/lib/esm/components/chart/useCalculation.js +8 -0
  93. package/lib/esm/components/chart/useUltimaOcorrenciaCCF.d.ts +2 -0
  94. package/lib/esm/components/chart/useUltimaOcorrenciaCCF.js +15 -0
  95. package/lib/esm/components/protestos/getTotalProtestos.d.ts +1 -0
  96. package/lib/esm/components/protestos/getTotalProtestos.js +4 -0
  97. package/lib/esm/components/protestos/protestosCategory.js +1 -1
  98. package/lib/esm/components/webservice.d.ts +14 -0
  99. package/lib/esm/components/webservice.js +3 -2
  100. package/lib/esm/consultaSimples.js +14 -12
  101. package/lib/esm/index.d.ts +1 -0
  102. package/lib/esm/index.js +1 -0
  103. package/lib/esm/mock/mockDataInput.d.ts +34 -0
  104. package/lib/esm/mock/mockDataInput.js +137 -0
  105. package/lib/esm/utils/calculation.d.ts +9 -0
  106. package/lib/esm/utils/calculation.js +17 -0
  107. package/lib/esm/utils/date.d.ts +1 -0
  108. package/lib/esm/utils/date.js +6 -0
  109. package/lib/esm/utils/formatter.d.ts +2 -0
  110. package/lib/esm/utils/formatter.js +5 -0
  111. package/lib/esm/utils/number.d.ts +3 -2
  112. package/lib/esm/utils/number.js +7 -4
  113. package/lib/esm/utils/string.d.ts +1 -0
  114. package/lib/esm/utils/string.js +6 -2
  115. package/package.json +8 -2
@@ -43,16 +43,13 @@ var CCF = function () {
43
43
  ultimaOcorrencia: xpath_1.default.select("string(./ultimo)", node),
44
44
  motivo: xpath_1.default.select("string(./motivo)", node),
45
45
  }); };
46
- var calculateTotalOcorrencias = function (ccfData) {
47
- return ccfData.reduce(function (acc, item) { return acc + item.quantidadeDeOcorrencias; }, 0);
48
- };
49
- return (react_1.default.createElement(Section, { ctx: ctx, title: "Cheques Sem Fundo Em Institui\u00E7\u00E3o Banc\u00E1ria", subtitle: "Detalhes Acerca De Cheques Sem Fundo Emitidos", onLoading: function () { return react_1.default.createElement(react_1.default.Fragment, null, "Carregando..."); }, onError: function () { return react_1.default.createElement(react_1.default.Fragment, null, "Erro"); }, onSuccess: function (data) {
46
+ return (react_1.default.createElement(Section, { ctx: ctx, title: "Cheques Sem Fundo Em Institui\u00E7\u00E3o Banc\u00E1ria", subtitle: "Detalhes Acerca De Cheques Sem Fundo Emitidos", onSuccess: function (data) {
50
47
  var allItems = xpath_1.default.select("//list/*", data);
51
48
  var filteredItems = allItems.filter(function (node) {
52
49
  return node.nodeName.startsWith("item");
53
50
  });
54
51
  var ccfData = filteredItems.map(mapNodeToCCFData);
55
- var totalOcorrencias = calculateTotalOcorrencias(ccfData);
52
+ var totalOcorrencias = xpath_1.default.select('number(//sumQteOcorrencias)', data);
56
53
  var children = totalOcorrencias ? (react_1.default.createElement(result_1.Result, null, ccfData.map(function (ccf, key) { return (react_1.default.createElement(ccfList_1.default, { key: key, data: [ccf] })); }))) : (react_1.default.createElement(resultWithoutInformation_1.default, null));
57
54
  return {
58
55
  children: children,
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { CategoriaProtestoProps } from "./plotly/types";
3
+ declare const CategoriaProtesto: React.FC<CategoriaProtestoProps>;
4
+ export default CategoriaProtesto;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var react_1 = __importStar(require("react"));
30
+ var react_plotly_js_1 = __importDefault(require("react-plotly.js"));
31
+ var webservice_1 = require("../webservice");
32
+ var xpath_1 = __importDefault(require("../../utils/xpath"));
33
+ var regex_1 = require("../../constants/regex");
34
+ var CategoriaProtesto = function (_a) {
35
+ var _b = _a.width, width = _b === void 0 ? 600 : _b, _c = _a.height, height = _c === void 0 ? 400 : _c;
36
+ var ctx = (0, react_1.useContext)(webservice_1.Queries.Protestos);
37
+ var Section = ctx.Section;
38
+ return (react_1.default.createElement(Section, { hideHeader: true, onSuccess: function (document) {
39
+ var _a, _b, _c;
40
+ var filterProtestos = function (regex, data) {
41
+ return xpath_1.default.select("//body//protesto", data).filter(function (protesto) {
42
+ return regex.test(xpath_1.default.select("string(./nomeCedente)", protesto));
43
+ });
44
+ };
45
+ var data = [
46
+ {
47
+ categoria: 'Protestos de Crédito',
48
+ quantidade: (_a = filterProtestos(regex_1.REGEX_PROTESTOS_DE_CREDITO, document)) === null || _a === void 0 ? void 0 : _a.length
49
+ }, {
50
+ categoria: 'Protestos de Impostos',
51
+ quantidade: (_b = filterProtestos(regex_1.REGEX_PROTESTOS_DE_IMPOSTO, document)) === null || _b === void 0 ? void 0 : _b.length
52
+ }, {
53
+ categoria: 'Protestos em Geral',
54
+ quantidade: (_c = xpath_1.default.select("//body//protesto", document).filter(function (protesto) {
55
+ var nomeCedente = xpath_1.default.select("string(./nomeCedente)", protesto);
56
+ return (!regex_1.REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
57
+ !regex_1.REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
58
+ })) === null || _c === void 0 ? void 0 : _c.length
59
+ }
60
+ ];
61
+ // Filtrar dados com quantidade nula ou zero
62
+ var dadosFiltrados = data === null || data === void 0 ? void 0 : data.filter(function (dado) { return dado.quantidade > 0; });
63
+ if (dadosFiltrados.length === 0) {
64
+ return react_1.default.createElement(react_1.default.Fragment, null);
65
+ }
66
+ var categoriaParaCor = {
67
+ "Protestos de Crédito": 'red',
68
+ "Protestos de Impostos": "orange",
69
+ };
70
+ var categorias = dadosFiltrados.map(function (dado) { return dado.categoria; });
71
+ var quantidades = dadosFiltrados.map(function (dado) { return dado.quantidade; });
72
+ var cores = categorias.map(function (categoria) { return categoriaParaCor[categoria] || "rgb(30, 144, 255)"; });
73
+ var plotData = [
74
+ {
75
+ x: categorias,
76
+ y: quantidades,
77
+ type: "bar",
78
+ marker: {
79
+ color: cores,
80
+ },
81
+ text: quantidades.map(String),
82
+ textposition: "auto",
83
+ },
84
+ ];
85
+ var layout = {
86
+ title: "Protestos por Categoria",
87
+ width: width,
88
+ height: height,
89
+ yaxis: { fixedrange: true, autorange: true },
90
+ xaxis: { fixedrange: true },
91
+ margin: { l: 50, r: 50, b: 100, t: 50, pad: 4 },
92
+ };
93
+ var config = { displayModeBar: false, responsive: true };
94
+ return react_1.default.createElement(react_plotly_js_1.default, { data: plotData, layout: layout, config: config });
95
+ } }));
96
+ };
97
+ exports.default = CategoriaProtesto;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { DataInput } from "./plotly/types";
3
+ interface ChartContentProps {
4
+ dataInput: DataInput;
5
+ }
6
+ declare const ChartContent: React.FC<ChartContentProps>;
7
+ export default ChartContent;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var react_1 = __importStar(require("react"));
30
+ var react_plotly_js_1 = __importDefault(require("react-plotly.js"));
31
+ var classnames_1 = __importDefault(require("classnames"));
32
+ var chartHelper_1 = require("./chartHelper");
33
+ var plotly_1 = require("./plotly");
34
+ var processChartData_1 = require("./processChartData");
35
+ var pieChartDataStrategy_1 = require("./plotly/pieChartDataStrategy");
36
+ var getUniqueDates_1 = require("./getUniqueDates");
37
+ var underscore_1 = require("underscore");
38
+ var categoryProtestos_1 = __importDefault(require("./categoryProtestos"));
39
+ var ChartContent = function (_a) {
40
+ var dataInput = _a.dataInput;
41
+ var _b = (0, react_1.useState)(window.innerWidth), windowWidth = _b[0], setWindowWidth = _b[1];
42
+ // Atualiza a largura da janela
43
+ var updateWindowWidth = function () {
44
+ setWindowWidth(window.innerWidth);
45
+ };
46
+ (0, react_1.useEffect)(function () {
47
+ window.addEventListener("resize", updateWindowWidth);
48
+ return function () { return window.removeEventListener("resize", updateWindowWidth); };
49
+ }, []);
50
+ var pieChartData = (0, react_1.useMemo)(function () {
51
+ var pieChartStrategy = new pieChartDataStrategy_1.PieChartDataStrategy();
52
+ return (0, chartHelper_1.createPieChart)(pieChartStrategy.processData(dataInput));
53
+ }, [dataInput]);
54
+ var pieChartWidth = (windowWidth * (windowWidth > 1100 ? 4 : 11)) / 12;
55
+ var lineBarChartWidth = (windowWidth * (windowWidth > 1100 && pieChartData.possuiPendencias ? 7.8 : 11)) / 12;
56
+ var dates = (0, react_1.useMemo)(function () {
57
+ return (0, getUniqueDates_1.getUniqueDates)(dataInput);
58
+ }, [dataInput]);
59
+ var chartData = (0, react_1.useMemo)(function () {
60
+ return dataInput ? (0, processChartData_1.processChartData)({ dataInput: dataInput, dates: dates }) : [];
61
+ }, [dataInput, dates]);
62
+ var lastDate = (0, underscore_1.max)(dates, function (x) { return x.getTime(); });
63
+ var plotLayout = (0, plotly_1.layoutLineBarChart)(lineBarChartWidth, lastDate);
64
+ return (react_1.default.createElement(react_1.default.Fragment, null,
65
+ react_1.default.createElement("div", { className: (0, classnames_1.default)("container", "chart-container") },
66
+ react_1.default.createElement("div", { className: (0, classnames_1.default)("chart-content") },
67
+ react_1.default.createElement("div", { className: (0, classnames_1.default)("mdl-grid") },
68
+ react_1.default.createElement("div", { className: (0, classnames_1.default)("mdl-cell", "mdl-cell--".concat(windowWidth < 1100 ? 12 : 4, "-col")), hidden: !pieChartData.possuiPendencias },
69
+ react_1.default.createElement("h2", { className: (0, classnames_1.default)("title-chart") }, "Quantidade de Ocorr\u00EAncias"),
70
+ react_1.default.createElement(react_plotly_js_1.default, { config: { displayModeBar: false }, data: [pieChartData], layout: { width: pieChartWidth } })),
71
+ react_1.default.createElement("div", { className: (0, classnames_1.default)("mdl-cell", "mdl-cell--".concat(pieChartData.possuiPendencias ? 8 : 12, "-col")) },
72
+ react_1.default.createElement("h2", { className: (0, classnames_1.default)("title-chart") }, "Quantidade de Ocorr\u00EAncias por Consulta"),
73
+ react_1.default.createElement(react_plotly_js_1.default, { data: chartData, layout: plotLayout }))))),
74
+ react_1.default.createElement("div", { className: (0, classnames_1.default)("category-protestos") },
75
+ react_1.default.createElement(categoryProtestos_1.default, { width: windowWidth * 0.9, height: 256 }))));
76
+ };
77
+ exports.default = ChartContent;
@@ -0,0 +1,7 @@
1
+ import Plotly from "react-plotly.js";
2
+ import { ChartDataAndLayoutState } from "./plotly/types";
3
+ export declare const createPieChart: (data: ChartDataAndLayoutState) => Plotly.Data & {
4
+ possuiPendencias: boolean;
5
+ };
6
+ export declare const createBarChart: (data: ChartDataAndLayoutState) => Plotly.Data;
7
+ export declare const createLineChart: (data: ChartDataAndLayoutState) => Plotly.Data;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLineChart = exports.createBarChart = exports.createPieChart = void 0;
4
+ var number_1 = require("../../utils/number");
5
+ var createPieChart = function (data) {
6
+ var _a;
7
+ var defaultColors = [
8
+ "#ff4081",
9
+ "#3f51b5",
10
+ "#008cf8",
11
+ "#ffc107",
12
+ "#4caf50",
13
+ "#58508d",
14
+ ];
15
+ return {
16
+ values: data.data.map(function (d) { return d.y; }).filter(function (y) { return y !== null; }).map(function (value) { return (0, number_1.formatValue)(value); }),
17
+ labels: data.data.map(function (d) { return d.x; }),
18
+ possuiPendencias: !!data.data.map(function (d) { return d.y; }).filter(function (y) { return y; }).length,
19
+ type: "pie",
20
+ marker: {
21
+ colors: ((_a = data.marker) === null || _a === void 0 ? void 0 : _a.color) ? [data.marker.color] : defaultColors,
22
+ },
23
+ textinfo: "value",
24
+ hovertemplate: "Total de %{label}: %{value}<extra></extra>",
25
+ textfont: data.textfont || {
26
+ family: "Arial, sans-serif",
27
+ size: 14,
28
+ color: "white",
29
+ },
30
+ };
31
+ };
32
+ exports.createPieChart = createPieChart;
33
+ var createBarChart = function (data) {
34
+ var _a;
35
+ return {
36
+ x: data.data.map(function (d) { return d.x; }),
37
+ y: data.data.map(function (d) { return d.y; }),
38
+ type: "bar",
39
+ name: data.name,
40
+ yaxis: data.yaxis,
41
+ marker: { color: ((_a = data.marker) === null || _a === void 0 ? void 0 : _a.color) || "#000000" },
42
+ text: data.text,
43
+ textposition: "auto",
44
+ textfont: data.textfont,
45
+ hovertemplate: data.hovertemplate || "%{y}<extra></extra>",
46
+ };
47
+ };
48
+ exports.createBarChart = createBarChart;
49
+ var createLineChart = function (data) {
50
+ var _a;
51
+ return {
52
+ x: data.data.map(function (d) { return d.x; }),
53
+ y: data.data.map(function (d) { return d.y; }),
54
+ type: "scatter",
55
+ mode: "lines+markers",
56
+ name: data.name,
57
+ yaxis: data.yaxis,
58
+ line: { color: ((_a = data.marker) === null || _a === void 0 ? void 0 : _a.color) || "#000000" },
59
+ connectgaps: data.connectgaps || false,
60
+ text: data.text,
61
+ textposition: "auto",
62
+ textfont: data.textfont,
63
+ hovertemplate: data.hovertemplate || "%{x|%d/%m/%Y}<br>".concat(data.name, ": %{y} <extra></extra>"),
64
+ };
65
+ };
66
+ exports.createLineChart = createLineChart;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { DataInput } from "./plotly/types";
3
+ interface ChartProps {
4
+ dataInput: DataInput;
5
+ }
6
+ export declare const ResumoDeNegativacoesChartSection: ({ documento }: {
7
+ documento: string;
8
+ }) => React.JSX.Element;
9
+ declare const CustomChart: React.FC<ChartProps>;
10
+ export default CustomChart;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.ResumoDeNegativacoesChartSection = void 0;
41
+ /* eslint-disable react-hooks/exhaustive-deps */
42
+ var react_1 = __importStar(require("react"));
43
+ var result_1 = require("../interface/result");
44
+ var useCalculation_1 = require("./useCalculation");
45
+ var chartContent_1 = __importDefault(require("./chartContent"));
46
+ var quantityResult_1 = __importDefault(require("./quantityResult"));
47
+ var webservice_1 = require("../webservice");
48
+ var string_1 = require("../../utils/string");
49
+ var underscore_1 = require("underscore");
50
+ var header_1 = __importDefault(require("../interface/header"));
51
+ var classnames_1 = __importDefault(require("classnames"));
52
+ var useUltimaOcorrenciaCCF_1 = __importDefault(require("./useUltimaOcorrenciaCCF"));
53
+ var ResumoDeNegativacoesChartSection = function (_a) {
54
+ var documento = _a.documento;
55
+ var _b = (0, webservice_1.useQuery)("SELECT FROM 'DOCUMENTHISTORY'.'BASICHISTORY'", { documento: documento }), response = _b.response, error = _b.error, isLoading = _b.isLoading, refetch = _b.refetch;
56
+ var ctxProtestos = (0, react_1.useContext)(webservice_1.Queries.Protestos);
57
+ var ctxCCF = (0, react_1.useContext)(webservice_1.Queries.CCF);
58
+ var ctxProcessosJuridicos = (0, react_1.useContext)(webservice_1.Queries.ProcessosJuridicos);
59
+ var quantidadeProcessosJuridicos = (0, react_1.useMemo)(function () {
60
+ var _a, _b;
61
+ if ((ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.type) === webservice_1.RequestStatus.Success)
62
+ return (_b = (_a = ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.document) === null || _a === void 0 ? void 0 : _a.empresa) === null || _b === void 0 ? void 0 : _b.length;
63
+ return undefined;
64
+ }, [ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.type]);
65
+ var liveQueriesIsFinish = (0, react_1.useMemo)(function () {
66
+ return [ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type, ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type].map(function (type) { return type != webservice_1.RequestStatus.Loading; }).every(function (e) { return e; });
67
+ }, [ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type, ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type]);
68
+ (0, react_1.useEffect)(function () {
69
+ if (liveQueriesIsFinish) {
70
+ refetch();
71
+ }
72
+ }, [liveQueriesIsFinish]);
73
+ var process = function (_data) {
74
+ if (!_data)
75
+ return null;
76
+ var data = JSON.parse(_data);
77
+ data.pieChartTotalConfig = {
78
+ processosJuridicos: quantidadeProcessosJuridicos,
79
+ };
80
+ var removeZeros = function (current, index, arr) {
81
+ // Combine firstOrLastObjects check for efficiency
82
+ return index === 0 || index === arr.length - 1 || Number(current.quantidade) > 0;
83
+ };
84
+ var removeSameAsNext = function (current, index, arr) {
85
+ // Return early for first/last objects
86
+ if (index === 0 || index === arr.length - 1)
87
+ return true;
88
+ return current.quantidade !== arr[index + 1].quantidade;
89
+ };
90
+ var grouped = (0, underscore_1.groupBy)(data.protestos, function (e) { return e.data; });
91
+ data.protestos = Object.values(grouped).map(function (e) {
92
+ if (e.length === 1)
93
+ return e;
94
+ return e.filter(function (el) { return Number(el.quantidade) > 0; });
95
+ }).flat();
96
+ data.protestos = (0, underscore_1.sortBy)((0, underscore_1.unique)(data.protestos, function (x) { return x.data; }).filter(removeZeros).filter(removeSameAsNext).map(function (info) { return (__assign(__assign({}, info), { data: (0, string_1.formatDatePtBrToDate)(info.data) })); }), function (info) { return info.data; });
97
+ data.ccfs = (0, underscore_1.sortBy)((0, underscore_1.unique)(data.ccfs, function (x) { return x.data; }).filter(removeZeros)
98
+ .filter(removeSameAsNext)
99
+ .map(function (info) { return (__assign(__assign({}, info), { data: (0, string_1.formatDatePtBrToDate)(info.data) })); }), function (info) { return info.data; });
100
+ data.boaVista = data.boaVista.map(function (pefin) { return (__assign(__assign({}, pefin), { creation: (0, string_1.formatDatePtBrToDate)(pefin.creation) })); }).filter(function (info) { return info.creation; });
101
+ data.serasa = data.serasa.map(function (pefin) { return (__assign(__assign({}, pefin), { creation: (0, string_1.formatDatePtBrToDate)(pefin.creation) })); }).filter(function (info) { return info.creation; });
102
+ data.dividasPublicasGrafico = data.dividasPublicasGrafico.map(function (info) { return (__assign(__assign({}, info), { data: (0, string_1.formatDatePtBrToDate)(info.data) })); }).filter(function (info) { return info.data; });
103
+ return react_1.default.createElement(CustomChart, { dataInput: data });
104
+ };
105
+ return (react_1.default.createElement(react_1.default.Fragment, null,
106
+ react_1.default.createElement(header_1.default, { title: "Resumo de Negativa\u00E7\u00F5es", subtitle: "Veja a quantidade de ocorr\u00EAncias conforme o documento foi consultado ao longo do tempo", className: (0, classnames_1.default)({ 'external-source loading': isLoading, 'external-source error': error }) }),
107
+ !isLoading && (response === null || response === void 0 ? void 0 : response.document) && process(response === null || response === void 0 ? void 0 : response.document)));
108
+ };
109
+ exports.ResumoDeNegativacoesChartSection = ResumoDeNegativacoesChartSection;
110
+ var CustomChart = function (_a) {
111
+ var _b, _c, _d, _e;
112
+ var dataInput = _a.dataInput;
113
+ var ultimaOcorrenciaCCF = (0, useUltimaOcorrenciaCCF_1.default)();
114
+ var _f = (0, useCalculation_1.useCalculation)(dataInput.protestos), quantidadeProtestos = _f.quantidade, valorTotalProtestos = _f.valorTotal;
115
+ var _g = (0, useCalculation_1.useCalculation)(dataInput.dividasPublicasGrafico), quantidadeDividas = _g.quantidade, valorTotalDividas = _g.valorTotal;
116
+ var _h = (0, useCalculation_1.useCalculation)(dataInput.serasa), quantidadeDeNegativacoesSerasa = _h.quantidade, valorTotalDeNegativacoesSerasa = _h.valorTotal;
117
+ var _j = (0, useCalculation_1.useCalculation)(dataInput.boaVista), quantidadeDeNegativacoesBoaVista = _j.quantidade, valorTotalDeNegativacoesBoaVista = _j.valorTotal;
118
+ var quantidadeCCF = (0, useCalculation_1.useCalculation)(dataInput.ccfs).quantidade;
119
+ var ultimaOcorrenciaProtestos = (_d = (_c = dataInput === null || dataInput === void 0 ? void 0 : dataInput.protestos[((_b = dataInput === null || dataInput === void 0 ? void 0 : dataInput.protestos) === null || _b === void 0 ? void 0 : _b.length) - 1]) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.toLocaleDateString();
120
+ return (react_1.default.createElement(result_1.Result, null,
121
+ react_1.default.createElement("div", null,
122
+ react_1.default.createElement(chartContent_1.default, { dataInput: dataInput }),
123
+ react_1.default.createElement(quantityResult_1.default, { quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_e = dataInput === null || dataInput === void 0 ? void 0 : dataInput.pieChartTotalConfig) === null || _e === void 0 ? void 0 : _e.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeDeNegativacoesSerasa, quantidadeDividasBoaVista: quantidadeDeNegativacoesBoaVista, quantidadeChequesSemFundos: quantidadeCCF, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalDeNegativacoesSerasa, valorTotalDividasBoaVista: valorTotalDeNegativacoesBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos }))));
124
+ };
125
+ exports.default = CustomChart;
@@ -0,0 +1,2 @@
1
+ import { DataInput } from "./plotly/types";
2
+ export declare function getUniqueDates(data: DataInput): (string | Date | undefined)[];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUniqueDates = void 0;
4
+ var underscore_1 = require("underscore");
5
+ function getUniqueDates(data) {
6
+ return (0, underscore_1.union)(data.ccfs.map(function (ccf) { return ccf.data; }), (0, underscore_1.unique)(data.protestos, "data").map(function (protesto) { return protesto.data; }), (0, underscore_1.unique)(data.serasa, "creation").map(function (pefinRefin) { return pefinRefin.creation; }), (0, underscore_1.unique)(data.boaVista, "creation").map(function (pefinRefin) { return pefinRefin.creation; }), (0, underscore_1.unique)(data.dividasPublicasGrafico, "data").map(function (dividas) { return dividas.data; })).filter(function (date) { return date; }).sort(function (dateA, dateB) { return dateA.getTime() - dateB.getTime(); });
7
+ }
8
+ exports.getUniqueDates = getUniqueDates;
@@ -0,0 +1,14 @@
1
+ import { BaseChartDataStrategy } from "./";
2
+ import { ChartDataAndLayoutState, DataInput } from "./types";
3
+ export declare class barDividasPublicas extends BaseChartDataStrategy<DataInput> {
4
+ processData(data: DataInput): ChartDataAndLayoutState;
5
+ }
6
+ export declare class barProtestos extends BaseChartDataStrategy<DataInput> {
7
+ processData(data: DataInput): ChartDataAndLayoutState;
8
+ }
9
+ export declare class barSerasa extends BaseChartDataStrategy<DataInput> {
10
+ processData(data: DataInput): ChartDataAndLayoutState;
11
+ }
12
+ export declare class barBoaVista extends BaseChartDataStrategy<DataInput> {
13
+ processData(data: DataInput): ChartDataAndLayoutState;
14
+ }
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.barBoaVista = exports.barSerasa = exports.barProtestos = exports.barDividasPublicas = void 0;
19
+ var _1 = require("./");
20
+ var layout = {};
21
+ var barDividasPublicas = /** @class */ (function (_super) {
22
+ __extends(barDividasPublicas, _super);
23
+ function barDividasPublicas() {
24
+ return _super !== null && _super.apply(this, arguments) || this;
25
+ }
26
+ barDividasPublicas.prototype.processData = function (data) {
27
+ var dividasPublicasData = data.dividasPublicasGrafico
28
+ .filter(function (consulta) {
29
+ return consulta.valorTotal !== null;
30
+ })
31
+ .map(function (consulta) { return ({
32
+ x: consulta.data,
33
+ y: consulta.valorTotal,
34
+ }); });
35
+ if ((dividasPublicasData === null || dividasPublicasData === void 0 ? void 0 : dividasPublicasData.length) > 1) {
36
+ dividasPublicasData[(dividasPublicasData === null || dividasPublicasData === void 0 ? void 0 : dividasPublicasData.length) - 1].y = data.dividasPublicas.valorTotal;
37
+ }
38
+ var dividasPublicasState = {
39
+ name: "Dívidas",
40
+ yaxis: "y2",
41
+ type: "bar",
42
+ textposition: "auto",
43
+ marker: {
44
+ color: "#bb3b55",
45
+ opacity: 0.6,
46
+ line: {
47
+ color: "#bb3b55",
48
+ width: 1.5,
49
+ },
50
+ },
51
+ hovertemplate: "%{x|%d/%m/%Y}<br> Dívidas Públicas: R$ %{y} <extra></extra>",
52
+ data: dividasPublicasData,
53
+ layout: layout,
54
+ };
55
+ return dividasPublicasState;
56
+ };
57
+ return barDividasPublicas;
58
+ }(_1.BaseChartDataStrategy));
59
+ exports.barDividasPublicas = barDividasPublicas;
60
+ var barProtestos = /** @class */ (function (_super) {
61
+ __extends(barProtestos, _super);
62
+ function barProtestos() {
63
+ return _super !== null && _super.apply(this, arguments) || this;
64
+ }
65
+ barProtestos.prototype.processData = function (data) {
66
+ var protestosData = data.protestos
67
+ .filter(function (consulta) { return consulta.valorTotal !== null; })
68
+ .map(function (consulta) { return ({
69
+ x: consulta.data,
70
+ y: consulta.valorTotal,
71
+ }); });
72
+ var protestosState = {
73
+ name: "Protestos",
74
+ yaxis: "y2",
75
+ type: "bar",
76
+ textposition: "outside",
77
+ marker: {
78
+ color: "#800000",
79
+ opacity: 0.6,
80
+ line: {
81
+ color: "#800000",
82
+ width: 1.5,
83
+ },
84
+ },
85
+ hovertemplate: "%{x|%d/%m/%Y}<br> Protestos: R$ %{y} <extra></extra>",
86
+ data: protestosData,
87
+ layout: layout,
88
+ };
89
+ return protestosState;
90
+ };
91
+ return barProtestos;
92
+ }(_1.BaseChartDataStrategy));
93
+ exports.barProtestos = barProtestos;
94
+ var barSerasa = /** @class */ (function (_super) {
95
+ __extends(barSerasa, _super);
96
+ function barSerasa() {
97
+ return _super !== null && _super.apply(this, arguments) || this;
98
+ }
99
+ barSerasa.prototype.processData = function (data) {
100
+ var serasaData = data.serasa
101
+ .filter(function (consulta) { return consulta.valorTotal !== null; })
102
+ .map(function (consulta) { return ({
103
+ x: consulta.creation,
104
+ y: consulta.valorTotal,
105
+ }); });
106
+ var serasaState = {
107
+ name: "Pefin/Refin Serasa",
108
+ yaxis: "y2",
109
+ type: "bar",
110
+ color: "orange",
111
+ marker: {
112
+ color: "rgb(158,202,225)",
113
+ opacity: 0.6,
114
+ line: {
115
+ color: "rgb(8,48,107)",
116
+ width: 1.5,
117
+ },
118
+ },
119
+ hovertemplate: "%{x|%d/%m/%Y}<br> Serasa: R$ %{y} <extra></extra>",
120
+ data: serasaData,
121
+ layout: layout,
122
+ };
123
+ return serasaState;
124
+ };
125
+ return barSerasa;
126
+ }(_1.BaseChartDataStrategy));
127
+ exports.barSerasa = barSerasa;
128
+ var barBoaVista = /** @class */ (function (_super) {
129
+ __extends(barBoaVista, _super);
130
+ function barBoaVista() {
131
+ return _super !== null && _super.apply(this, arguments) || this;
132
+ }
133
+ barBoaVista.prototype.processData = function (data) {
134
+ var boaVistaData = data.boaVista
135
+ .filter(function (consulta) { return consulta.valorTotal !== null; })
136
+ .map(function (consulta) { return ({
137
+ x: consulta.creation,
138
+ y: consulta.valorTotal,
139
+ }); });
140
+ var boaVistaState = {
141
+ name: "Pefin/Refin Boa Vista",
142
+ yaxis: "y2",
143
+ type: "bar",
144
+ hovertemplate: "%{x|%d/%m/%Y}<br> Boa Vista: R$ %{y} <extra></extra>",
145
+ data: boaVistaData,
146
+ layout: layout,
147
+ };
148
+ return boaVistaState;
149
+ };
150
+ return barBoaVista;
151
+ }(_1.BaseChartDataStrategy));
152
+ exports.barBoaVista = barBoaVista;
@@ -0,0 +1,8 @@
1
+ import { ChartDataState, IChartDataStrategy } from "./iChartDataStrategy";
2
+ import { LayoutConfig } from "./layoutLineBarChart";
3
+ import { ChartDataAndLayoutState } from "./types";
4
+ export declare abstract class BaseChartDataStrategy<T> implements IChartDataStrategy<T> {
5
+ abstract processData(data: T): ChartDataAndLayoutState;
6
+ protected parseDate(dateStr: string): Date;
7
+ protected createProcessedData(chartData: ChartDataState, layout?: LayoutConfig): ChartDataAndLayoutState;
8
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.BaseChartDataStrategy = void 0;
15
+ var BaseChartDataStrategy = /** @class */ (function () {
16
+ function BaseChartDataStrategy() {
17
+ }
18
+ BaseChartDataStrategy.prototype.parseDate = function (dateStr) {
19
+ var _a = dateStr.split("/").map(Number), day = _a[0], month = _a[1], year = _a[2];
20
+ return new Date(year, month - 1, day);
21
+ };
22
+ BaseChartDataStrategy.prototype.createProcessedData = function (chartData, layout) {
23
+ var processedData = chartData.data.map(function (d) { return ({
24
+ x: d.x.toISOString(),
25
+ y: d.y,
26
+ }); });
27
+ return __assign(__assign({}, chartData), { data: processedData, text: processedData.map(function (d) { return (d.y !== null ? d.y.toString() : ""); }), layout: layout || {} });
28
+ };
29
+ return BaseChartDataStrategy;
30
+ }());
31
+ exports.BaseChartDataStrategy = BaseChartDataStrategy;
@@ -0,0 +1,3 @@
1
+ import { ChartDataState } from "./iChartDataStrategy";
2
+ import { DataInput } from "./types";
3
+ export declare function getSeries(data: DataInput): ChartDataState[];