@credithub/harlan-components 1.3.1 → 1.3.3

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.
@@ -1,35 +1,6 @@
1
1
  import React from "react";
2
- import { ReclameAquiCarouselProps } from "../reclameAqui/reclameAquiCarousel";
3
- interface Target {
4
- "@types": string;
5
- "@version": string;
6
- about: {
7
- [name: string]: unknown;
8
- };
9
- identificator: {
10
- [name: string]: string;
11
- };
2
+ interface DossieProps {
3
+ onOpenNewTransactionModal?: () => void;
12
4
  }
13
- interface DossieUiProps {
14
- dossie?: {
15
- target: Target;
16
- identificator: string;
17
- webhook?: string | null;
18
- events: {
19
- [name: string]: {};
20
- }[];
21
- notations: {
22
- [name: string]: {};
23
- };
24
- relations: {
25
- [name: string]: {};
26
- };
27
- associates: {
28
- [name: string]: {};
29
- }[];
30
- };
31
- reclameAquiData?: Omit<ReclameAquiCarouselProps, "nome" | "cnpj">[];
32
- onOpenNewTransactionModal: () => void;
33
- }
34
- declare const Dossie: React.FC<DossieUiProps>;
5
+ declare const Dossie: React.FC<DossieProps>;
35
6
  export default Dossie;
@@ -1,15 +1,4 @@
1
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
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -48,11 +37,10 @@ var reclameAquiCarousel_1 = require("../reclameAqui/reclameAquiCarousel");
48
37
  var webservice_1 = require("../webservice");
49
38
  var xpath_1 = __importDefault(require("../../utils/xpath"));
50
39
  var string_1 = require("../../utils/string");
51
- var Dossie = function (_a) {
52
- var _b = _a.reclameAquiData, reclameAquiData = _b === void 0 ? [] : _b;
53
- var ctx = (0, react_1.useContext)(webservice_1.Queries.Finder);
54
- var Section = ctx.Section;
55
- return (react_1.default.createElement(Section, { ctx: ctx, hideHeader: true, onSuccess: function (data) {
40
+ var Dossie = function () {
41
+ var finderCtx = (0, react_1.useContext)(webservice_1.Queries.Finder);
42
+ var Section = finderCtx.Section;
43
+ return (react_1.default.createElement(Section, { ctx: finderCtx, hideHeader: true, onSuccess: function (data) {
56
44
  var isPF = !!xpath_1.default.select("string(//cadastro/cpf)", data);
57
45
  var name = isPF
58
46
  ? xpath_1.default.select("string(//cadastro/nome)", data)
@@ -60,9 +48,10 @@ var Dossie = function (_a) {
60
48
  var document = isPF
61
49
  ? (0, string_1.formatCpf)(xpath_1.default.select("string(//cadastro/cpf)", data))
62
50
  : (0, string_1.formatCnpj)(xpath_1.default.select("string(//cadastro/cnpj)", data));
51
+ var DossieCarrousel = function () { return !isPF ? (react_1.default.createElement(reclameAquiCarousel_1.ReclameAquiCarousel, { documento: document, nome: name })) : (react_1.default.createElement(carrousel_1.Carrousel, { name: name, document: document })); };
63
52
  return (react_1.default.createElement(result_1.Result, null,
64
53
  react_1.default.createElement("div", { className: (0, classnames_1.default)("dossie-grid", "dossie") },
65
- reclameAquiData && !isPF ? (react_1.default.createElement(reclameAquiCarousel_1.ReclameAquiCarousel, { data: reclameAquiData === null || reclameAquiData === void 0 ? void 0 : reclameAquiData.map(function (empresa) { return (__assign(__assign({}, empresa), { nome: name, cnpj: document })); }) })) : (react_1.default.createElement(carrousel_1.Carrousel, { name: name, document: document })),
54
+ react_1.default.createElement(DossieCarrousel, null),
66
55
  react_1.default.createElement(transactionTable_1.TransactionsTable, { events: xpath_1.default.select("//historico/consulta", data) })),
67
56
  react_1.default.createElement(summary_1.Summary, { finderResponse: data })));
68
57
  } }));
@@ -1,26 +1,5 @@
1
1
  import React from "react";
2
- export interface ReclameAquiCarouselProps extends ReclameAquiStatsProps {
3
- }
4
- declare const statusMap: {
5
- GREAT: string;
6
- GOOD: string;
7
- REGULAR: string;
8
- NOT_RECOMMENDED: string;
9
- NO_INDEX: string;
10
- BAD: string;
11
- };
12
- type StatusMapType = keyof typeof statusMap;
13
- type ReclameAquiStatsProps = {
14
- nome: string;
15
- cnpj: string;
16
- score: string;
17
- status: string | StatusMapType;
18
- shortname: string;
19
- imageUrl: string;
20
- quantidadeProblemasResolvidos: string;
21
- percentualProblemasResolvidos: string;
22
- };
23
2
  export declare const ReclameAquiCarousel: React.FC<{
24
- data: ReclameAquiCarouselProps[];
3
+ documento: string;
4
+ nome: string;
25
5
  }>;
26
- export {};
@@ -10,13 +10,38 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
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
+ };
13
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
38
  };
16
39
  Object.defineProperty(exports, "__esModule", { value: true });
17
40
  exports.ReclameAquiCarousel = void 0;
18
- var react_1 = __importDefault(require("react"));
41
+ var react_1 = __importStar(require("react"));
19
42
  var carousel_1 = __importDefault(require("../common/carousel"));
43
+ var webservice_1 = require("../webservice");
44
+ var carrousel_1 = __importDefault(require("../dossie/carrousel/carrousel"));
20
45
  var statusMap = {
21
46
  GREAT: "Ótimo",
22
47
  GOOD: "Bom",
@@ -52,13 +77,28 @@ var ReclameAquiStats = function (_a) {
52
77
  "/10")),
53
78
  react_1.default.createElement(ProblemasResolvidos, { value: percentualProblemasResolvidos + "%" }))));
54
79
  };
55
- var ReclameAquiCarousel = function (_a) {
56
- var data = _a.data;
80
+ exports.ReclameAquiCarousel = (0, react_1.memo)(function (_a) {
81
+ var _b, _c, _d;
82
+ var nome = _a.nome, documento = _a.documento;
83
+ var _e = (0, webservice_1.useQuery)("SELECT FROM 'RECLAMEAQUI'.'CONSULTA'", { documento: documento }), response = _e.response, isLoading = _e.isLoading, error = _e.error;
84
+ if (isLoading || error || (response === null || response === void 0 ? void 0 : response.document) && !((_b = response === null || response === void 0 ? void 0 : response.document) === null || _b === void 0 ? void 0 : _b.length))
85
+ return react_1.default.createElement(carrousel_1.default, { name: nome, document: documento });
57
86
  return (react_1.default.createElement("div", { className: "reclame-aqui-carousel" },
58
87
  react_1.default.createElement("div", { className: "carrossel-content" },
59
- react_1.default.createElement(carousel_1.default, { pagination: false, isRTL: false, showArrows: (data === null || data === void 0 ? void 0 : data.length) > 1, renderArrow: function (_a) {
88
+ react_1.default.createElement(carousel_1.default, { pagination: false, isRTL: false, showArrows: (response === null || response === void 0 ? void 0 : response.document) && ((_c = response === null || response === void 0 ? void 0 : response.document) === null || _c === void 0 ? void 0 : _c.length) > 1, renderArrow: function (_a) {
60
89
  var type = _a.type, onClick = _a.onClick;
61
90
  return (react_1.default.createElement("i", { className: "fa fa-angle-".concat(type == "PREV" ? "left" : "right", " reclame-aqui-carousel-btn"), onClick: onClick }));
62
- } }, data === null || data === void 0 ? void 0 : data.map(function (empresa, index) { return (react_1.default.createElement(ReclameAquiStats, __assign({ key: index }, empresa))); })))));
63
- };
64
- exports.ReclameAquiCarousel = ReclameAquiCarousel;
91
+ } }, (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.map(function (item) {
92
+ var infos = item.infos;
93
+ return {
94
+ nome: nome,
95
+ cnpj: documento,
96
+ score: infos.finalScore,
97
+ status: infos.status,
98
+ shortname: infos.shortname,
99
+ imageUrl: infos.logo,
100
+ quantidadeProblemasResolvidos: infos.count.toString(),
101
+ percentualProblemasResolvidos: infos.solvedPercentual,
102
+ };
103
+ }).map(function (empresa, index) { return (react_1.default.createElement(ReclameAquiStats, __assign({ key: index }, empresa))); })))));
104
+ });
@@ -0,0 +1,31 @@
1
+ export interface ReclameAquiResponse {
2
+ _id: Id;
3
+ reclameAquiId: string;
4
+ type: string;
5
+ document: string;
6
+ evaluated: number;
7
+ infos: ReclameAquiInfos;
8
+ document_data: DocumentData;
9
+ }
10
+ export interface Id {
11
+ $id: string;
12
+ }
13
+ export interface ReclameAquiInfos {
14
+ finalScore: string;
15
+ created: string;
16
+ companyName: string;
17
+ count: number;
18
+ solvedPercentual: string;
19
+ shortname: string;
20
+ url: string;
21
+ logo: string;
22
+ fantasyName: string;
23
+ status: string;
24
+ }
25
+ export interface DocumentData {
26
+ validity: Validity;
27
+ }
28
+ export interface Validity {
29
+ sec: number;
30
+ usec: number;
31
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -135,7 +135,7 @@ function useQuery(query, data) {
135
135
  : new Error(requestError));
136
136
  })
137
137
  .finally(function () { return setIsLoading(false); });
138
- }, [client, query, data, abortController.signal]);
138
+ }, []);
139
139
  (0, react_1.useEffect)(function () {
140
140
  fetch();
141
141
  }, [fetch]);
@@ -170,7 +170,7 @@ function useMutation(query, data) {
170
170
  : new Error(requestError));
171
171
  })
172
172
  .finally(function () { return setIsLoading(false); });
173
- }, [client, query, data, abortController.signal]);
173
+ }, []);
174
174
  return {
175
175
  isLoading: isLoading,
176
176
  error: error,
@@ -1,35 +1,6 @@
1
1
  import React from "react";
2
- import { ReclameAquiCarouselProps } from "../reclameAqui/reclameAquiCarousel";
3
- interface Target {
4
- "@types": string;
5
- "@version": string;
6
- about: {
7
- [name: string]: unknown;
8
- };
9
- identificator: {
10
- [name: string]: string;
11
- };
2
+ interface DossieProps {
3
+ onOpenNewTransactionModal?: () => void;
12
4
  }
13
- interface DossieUiProps {
14
- dossie?: {
15
- target: Target;
16
- identificator: string;
17
- webhook?: string | null;
18
- events: {
19
- [name: string]: {};
20
- }[];
21
- notations: {
22
- [name: string]: {};
23
- };
24
- relations: {
25
- [name: string]: {};
26
- };
27
- associates: {
28
- [name: string]: {};
29
- }[];
30
- };
31
- reclameAquiData?: Omit<ReclameAquiCarouselProps, "nome" | "cnpj">[];
32
- onOpenNewTransactionModal: () => void;
33
- }
34
- declare const Dossie: React.FC<DossieUiProps>;
5
+ declare const Dossie: React.FC<DossieProps>;
35
6
  export default Dossie;
@@ -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
  //eslint-disable-ban-types
13
2
  import React, { useContext } from "react";
14
3
  import cn from "classnames";
@@ -20,11 +9,10 @@ import { ReclameAquiCarousel, } from "../reclameAqui/reclameAquiCarousel";
20
9
  import { Queries } from "../webservice";
21
10
  import XPathUtils from "../../utils/xpath";
22
11
  import { formatCnpj, formatCpf } from "../../utils/string";
23
- var Dossie = function (_a) {
24
- var _b = _a.reclameAquiData, reclameAquiData = _b === void 0 ? [] : _b;
25
- var ctx = useContext(Queries.Finder);
26
- var Section = ctx.Section;
27
- return (React.createElement(Section, { ctx: ctx, hideHeader: true, onSuccess: function (data) {
12
+ var Dossie = function () {
13
+ var finderCtx = useContext(Queries.Finder);
14
+ var Section = finderCtx.Section;
15
+ return (React.createElement(Section, { ctx: finderCtx, hideHeader: true, onSuccess: function (data) {
28
16
  var isPF = !!XPathUtils.select("string(//cadastro/cpf)", data);
29
17
  var name = isPF
30
18
  ? XPathUtils.select("string(//cadastro/nome)", data)
@@ -32,9 +20,10 @@ var Dossie = function (_a) {
32
20
  var document = isPF
33
21
  ? formatCpf(XPathUtils.select("string(//cadastro/cpf)", data))
34
22
  : formatCnpj(XPathUtils.select("string(//cadastro/cnpj)", data));
23
+ var DossieCarrousel = function () { return !isPF ? (React.createElement(ReclameAquiCarousel, { documento: document, nome: name })) : (React.createElement(Carrousel, { name: name, document: document })); };
35
24
  return (React.createElement(Result, null,
36
25
  React.createElement("div", { className: cn("dossie-grid", "dossie") },
37
- reclameAquiData && !isPF ? (React.createElement(ReclameAquiCarousel, { data: reclameAquiData === null || reclameAquiData === void 0 ? void 0 : reclameAquiData.map(function (empresa) { return (__assign(__assign({}, empresa), { nome: name, cnpj: document })); }) })) : (React.createElement(Carrousel, { name: name, document: document })),
26
+ React.createElement(DossieCarrousel, null),
38
27
  React.createElement(TransactionsTable, { events: XPathUtils.select("//historico/consulta", data) })),
39
28
  React.createElement(Summary, { finderResponse: data })));
40
29
  } }));
@@ -1,26 +1,5 @@
1
1
  import React from "react";
2
- export interface ReclameAquiCarouselProps extends ReclameAquiStatsProps {
3
- }
4
- declare const statusMap: {
5
- GREAT: string;
6
- GOOD: string;
7
- REGULAR: string;
8
- NOT_RECOMMENDED: string;
9
- NO_INDEX: string;
10
- BAD: string;
11
- };
12
- type StatusMapType = keyof typeof statusMap;
13
- type ReclameAquiStatsProps = {
14
- nome: string;
15
- cnpj: string;
16
- score: string;
17
- status: string | StatusMapType;
18
- shortname: string;
19
- imageUrl: string;
20
- quantidadeProblemasResolvidos: string;
21
- percentualProblemasResolvidos: string;
22
- };
23
2
  export declare const ReclameAquiCarousel: React.FC<{
24
- data: ReclameAquiCarouselProps[];
3
+ documento: string;
4
+ nome: string;
25
5
  }>;
26
- export {};
@@ -9,8 +9,10 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import React from "react";
12
+ import React, { memo } from "react";
13
13
  import Carousel from "../common/carousel";
14
+ import { useQuery } from "../webservice";
15
+ import Carrousel from "../dossie/carrousel/carrousel";
14
16
  var statusMap = {
15
17
  GREAT: "Ótimo",
16
18
  GOOD: "Bom",
@@ -46,12 +48,28 @@ var ReclameAquiStats = function (_a) {
46
48
  "/10")),
47
49
  React.createElement(ProblemasResolvidos, { value: percentualProblemasResolvidos + "%" }))));
48
50
  };
49
- export var ReclameAquiCarousel = function (_a) {
50
- var data = _a.data;
51
+ export var ReclameAquiCarousel = memo(function (_a) {
52
+ var _b, _c, _d;
53
+ var nome = _a.nome, documento = _a.documento;
54
+ var _e = useQuery("SELECT FROM 'RECLAMEAQUI'.'CONSULTA'", { documento: documento }), response = _e.response, isLoading = _e.isLoading, error = _e.error;
55
+ if (isLoading || error || (response === null || response === void 0 ? void 0 : response.document) && !((_b = response === null || response === void 0 ? void 0 : response.document) === null || _b === void 0 ? void 0 : _b.length))
56
+ return React.createElement(Carrousel, { name: nome, document: documento });
51
57
  return (React.createElement("div", { className: "reclame-aqui-carousel" },
52
58
  React.createElement("div", { className: "carrossel-content" },
53
- React.createElement(Carousel, { pagination: false, isRTL: false, showArrows: (data === null || data === void 0 ? void 0 : data.length) > 1, renderArrow: function (_a) {
59
+ React.createElement(Carousel, { pagination: false, isRTL: false, showArrows: (response === null || response === void 0 ? void 0 : response.document) && ((_c = response === null || response === void 0 ? void 0 : response.document) === null || _c === void 0 ? void 0 : _c.length) > 1, renderArrow: function (_a) {
54
60
  var type = _a.type, onClick = _a.onClick;
55
61
  return (React.createElement("i", { className: "fa fa-angle-".concat(type == "PREV" ? "left" : "right", " reclame-aqui-carousel-btn"), onClick: onClick }));
56
- } }, data === null || data === void 0 ? void 0 : data.map(function (empresa, index) { return (React.createElement(ReclameAquiStats, __assign({ key: index }, empresa))); })))));
57
- };
62
+ } }, (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.map(function (item) {
63
+ var infos = item.infos;
64
+ return {
65
+ nome: nome,
66
+ cnpj: documento,
67
+ score: infos.finalScore,
68
+ status: infos.status,
69
+ shortname: infos.shortname,
70
+ imageUrl: infos.logo,
71
+ quantidadeProblemasResolvidos: infos.count.toString(),
72
+ percentualProblemasResolvidos: infos.solvedPercentual,
73
+ };
74
+ }).map(function (empresa, index) { return (React.createElement(ReclameAquiStats, __assign({ key: index }, empresa))); })))));
75
+ });
@@ -0,0 +1,31 @@
1
+ export interface ReclameAquiResponse {
2
+ _id: Id;
3
+ reclameAquiId: string;
4
+ type: string;
5
+ document: string;
6
+ evaluated: number;
7
+ infos: ReclameAquiInfos;
8
+ document_data: DocumentData;
9
+ }
10
+ export interface Id {
11
+ $id: string;
12
+ }
13
+ export interface ReclameAquiInfos {
14
+ finalScore: string;
15
+ created: string;
16
+ companyName: string;
17
+ count: number;
18
+ solvedPercentual: string;
19
+ shortname: string;
20
+ url: string;
21
+ logo: string;
22
+ fantasyName: string;
23
+ status: string;
24
+ }
25
+ export interface DocumentData {
26
+ validity: Validity;
27
+ }
28
+ export interface Validity {
29
+ sec: number;
30
+ usec: number;
31
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -105,7 +105,7 @@ export function useQuery(query, data) {
105
105
  : new Error(requestError));
106
106
  })
107
107
  .finally(function () { return setIsLoading(false); });
108
- }, [client, query, data, abortController.signal]);
108
+ }, []);
109
109
  useEffect(function () {
110
110
  fetch();
111
111
  }, [fetch]);
@@ -139,7 +139,7 @@ export function useMutation(query, data) {
139
139
  : new Error(requestError));
140
140
  })
141
141
  .finally(function () { return setIsLoading(false); });
142
- }, [client, query, data, abortController.signal]);
142
+ }, []);
143
143
  return {
144
144
  isLoading: isLoading,
145
145
  error: error,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credithub/harlan-components",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Provide a set of web components to be used in Harlan and other projects",
5
5
  "keywords": [
6
6
  "harlan",