@credithub/harlan-components 1.51.0 → 1.51.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.
@@ -15,5 +15,5 @@ export type { ReclameAquiResponse, ReclameAquiState } from '@/@types/domain/recl
15
15
  export type { RefinBoaVistaResponse, RefinBoaVistaState, Spc } from '@/@types/domain/refinBoaVistaTypes';
16
16
  export type { PefinRefinSerasaResponse, RefinSerasaState } from '@/@types/domain/refinSerasaTypes';
17
17
  export type { ScoreResponse, ScoreState } from '@/@types/domain/scoreTypes';
18
- export type { Detalhamento, ResumoListProps, SCRListProps, SCRQuery, SCRResponse, SCRState, Vencimento } from '@/@types/domain/scrTypes';
19
18
  export type { RegistroVeiculo, VeiculosState } from '@/@types/domain/veiculosTypes';
19
+ export type { SCRState } from '@/@types/domain/scrTypes';
@@ -123,9 +123,10 @@ var ChartSystem = function (_a) {
123
123
  var _a;
124
124
  return (React.createElement(Content, { isOpen: isOpen },
125
125
  chartData && React.createElement(ChartContent, { dataInput: chartData }),
126
- React.createElement(QuantidadeResultados, { data: chartData, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_a = chartData === null || chartData === void 0 ? void 0 : chartData.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos, ultimaOcorrenciaDividas: ultimaOcorrenciaDividas, ultimaOcorrenciaPefinBoaVista: quantidadeBoaVista > 0
126
+ React.createElement(QuantidadeResultados, { data: chartData, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_a = chartData === null || chartData === void 0 ? void 0 : chartData.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos, ultimaOcorrenciaDividas: ultimaOcorrenciaDividas, ultimaOcorrenciaPefinBoaVista: Array.isArray(chartData === null || chartData === void 0 ? void 0 : chartData.boaVista) &&
127
+ chartData.boaVista.length > 0
127
128
  ? (ultimaOcorrenciaBoaVista !== null && ultimaOcorrenciaBoaVista !== void 0 ? ultimaOcorrenciaBoaVista : undefined)
128
- : undefined, ultimaOcorrenciaPefinSerasa: quantidadeSerasa > 0
129
+ : undefined, ultimaOcorrenciaPefinSerasa: Array.isArray(chartData === null || chartData === void 0 ? void 0 : chartData.serasa) && chartData.serasa.length > 0
129
130
  ? (ultimaOcorrenciaSerasa !== null && ultimaOcorrenciaSerasa !== void 0 ? ultimaOcorrenciaSerasa : undefined)
130
131
  : undefined })));
131
132
  }, isError: function (err) { return ({
@@ -29,15 +29,15 @@ var QuantidadeResultados = function (_a) {
29
29
  React.createElement(QuantityContainer, null,
30
30
  React.createElement(AddItemField, { name: "D\u00EDvidas P\u00FAblicas", value: formatValue(quantidadeDividas) }),
31
31
  React.createElement(AddItemField, { name: "Total D\u00EDvidas P\u00FAblicas", value: formatMoney(valorTotalDividas) }),
32
- React.createElement(AddItemField, { hidden: quantidadeDividas == 0, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaDividas })),
32
+ React.createElement(AddItemField, { hidden: !ultimaOcorrenciaDividas, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaDividas })),
33
33
  React.createElement(QuantityContainer, null,
34
34
  React.createElement(AddItemField, { name: "Pefin Refin Serasa", value: formatValue(quantidadeDividasSerasa) }),
35
35
  React.createElement(AddItemField, { name: "Total Pefin Refin Serasa", value: formatMoney(valorTotalDividasSerasa) }),
36
- React.createElement(AddItemField, { hidden: quantidadeDividasSerasa === 0 || !ultimaOcorrenciaPefinSerasa, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaPefinSerasa })),
36
+ React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinSerasa, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaPefinSerasa })),
37
37
  React.createElement(QuantityContainer, null,
38
38
  React.createElement(AddItemField, { name: "Pefin Refin Boa Vista", value: formatValue(quantidadeDividasBoaVista) }),
39
39
  React.createElement(AddItemField, { name: "Total Pefin Refin Boa Vista", value: formatMoney(valorTotalDividasBoaVista) }),
40
- React.createElement(AddItemField, { hidden: quantidadeDividasBoaVista === 0 || !ultimaOcorrenciaPefinBoaVista, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaPefinBoaVista })))));
40
+ React.createElement(AddItemField, { hidden: !ultimaOcorrenciaPefinBoaVista, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaPefinBoaVista })))));
41
41
  };
42
42
  export default QuantidadeResultados;
43
43
  var templateObject_1;
@@ -13,38 +13,75 @@ var __assign = (this && this.__assign) || function () {
13
13
  };
14
14
  return __assign.apply(this, arguments);
15
15
  };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ /* eslint-disable react-hooks/exhaustive-deps */
53
+ /* eslint-disable @typescript-eslint/no-unused-vars */
16
54
  import ScrIcon from '../../assets/icones/scr';
17
55
  import { useGlobalData } from '../../contexts/globalDataContext';
18
56
  import useToggle from '../../hooks/useToggle';
19
- import { formatMoney } from '../../utils/number';
20
57
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
21
58
  import styled from 'styled-components';
22
59
  import AddItemField from '../common/addItem';
23
- import Content from '../common/content';
24
60
  import { ConsultasComplementaresContext } from '../consultasComplementares';
25
61
  import { Result, ResultContent } from '../interface/result';
26
62
  import StatusMessage from '../interface/statusMessage';
27
63
  import Section from '../section';
28
- import { RequestStatus, useQuery } from '../webservice';
29
- import getResumoDeCreditos from './getResumoDeCreditos';
30
- import getResumoDeModalidades from './getResumoDeModalidades';
64
+ import { RequestStatus, useFetch, useQuery } from '../webservice';
65
+ import Button from '../common/button';
31
66
  var ResumosWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n flex-direction: column;\n gap: 20px;\n"], ["\n display: ", ";\n flex-direction: column;\n gap: 20px;\n"])), function (_a) {
32
67
  var _b = _a.isOpen, isOpen = _b === void 0 ? true : _b;
33
68
  return (isOpen ? 'flex' : 'none');
34
69
  });
35
70
  function ConsultaSCR(_a) {
36
- var _b, _c, _d, _e;
71
+ var _this = this;
72
+ var _b, _c;
37
73
  var documento = _a.documento;
38
74
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
39
75
  var setData = useGlobalData().setData;
40
- var _f = useState(false), dataUpdated = _f[0], setDataUpdated = _f[1];
41
- var _g = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _g.consultasComplementares, setConsultasComplementares = _g.setConsultasComplementares;
42
- var _h = useQuery("SELECT FROM 'SCR'.'CONSULTA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _h.response, isLoading = _h.isLoading, error = _h.error, loadingProgress = _h.loadingProgress;
76
+ var _d = useState(false), dataUpdated = _d[0], setDataUpdated = _d[1];
77
+ var _e = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _e.consultasComplementares, setConsultasComplementares = _e.setConsultasComplementares;
78
+ var _f = useQuery("SELECT FROM 'SCR'.'CONSULTA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _f.response, isLoading = _f.isLoading, error = _f.error, loadingProgress = _f.loadingProgress;
79
+ var fetch = useFetch("SELECT FROM 'SCR'.'PDF'").fetch;
43
80
  var isOpen = useToggle()[0];
44
- var scr = (_d = (_c = response === null || response === void 0 ? void 0 : response.document) === null || _c === void 0 ? void 0 : _c.ns2getResumoDoClienteResponse) === null || _d === void 0 ? void 0 : _d.return;
45
81
  var scrRef = useRef(null);
46
- var consultaRealizada = useMemo(function () { var _a; return (_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _a === void 0 ? void 0 : _a.consultaRealizada; }, [(_e = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _e === void 0 ? void 0 : _e.consultaRealizada]);
47
- var resumoDeCreditos = (scr && getResumoDeCreditos(scr)) || [];
82
+ var consultaRealizada = useMemo(function () { var _a; return (_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _a === void 0 ? void 0 : _a.consultaRealizada; }, [(_c = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _c === void 0 ? void 0 : _c.consultaRealizada]);
83
+ //const resumoDeCreditos = (scr && getResumoDeCreditos(scr)) || [];
84
+ var scr = response === null || response === void 0 ? void 0 : response.document;
48
85
  var description = scr
49
86
  ? 'Resumo do Cliente'
50
87
  : 'Não há informação disponível para este documento.';
@@ -61,7 +98,7 @@ function ConsultaSCR(_a) {
61
98
  setConsultasComplementares &&
62
99
  setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { scr: __assign(__assign({}, prev.scr), { data: response }) })); });
63
100
  var scrData_1 = {
64
- scrData: response.document.ns2getResumoDoClienteResponse.return
101
+ scrData: response === null || response === void 0 ? void 0 : response.document
65
102
  };
66
103
  setData(function (prevState) { return (__assign(__assign({}, prevState), { scr: scrData_1 })); });
67
104
  setDataUpdated(true);
@@ -81,15 +118,35 @@ function ConsultaSCR(_a) {
81
118
  progress: loadingProgress
82
119
  }, title: "SCR", subtitle: "Resumo do Cliente", icon: ScrIcon, description: !error && (React.createElement(StatusMessage, { type: scr ? 'success' : 'default' }, description)), onSuccess: function () { return (React.createElement(React.Fragment, null,
83
120
  React.createElement(Result, null,
121
+ React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" }, scr === null || scr === void 0 ? void 0 : scr.response.basicData.map(function (data) { return (React.createElement(AddItemField, { name: data.label, value: data.value })); })),
84
122
  React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
85
- React.createElement(AddItemField, { name: "CNPJ da IF Solicitante", value: scr === null || scr === void 0 ? void 0 : scr.cnpjDaIFSolicitante }),
86
- React.createElement(AddItemField, { name: "C\u00F3digo do Cliente", value: scr === null || scr === void 0 ? void 0 : scr.codigoDoCliente }),
87
- React.createElement(AddItemField, { name: "Coobriga\u00E7\u00E3o Assumida", value: scr === null || scr === void 0 ? void 0 : scr.coobrigacaoAssumida }),
88
- React.createElement(AddItemField, { name: "Coobriga\u00E7\u00E3o Recebida", value: scr === null || scr === void 0 ? void 0 : scr.coobrigacaoRecebida }))),
89
- React.createElement(ResumosWrapper, { isOpen: isOpen },
90
- React.createElement(FluxosDeVencimentosConsolidados, { isLoading: isLoading, error: error, scr: scr, loadingProgress: loadingProgress }),
91
- React.createElement(ResumoList, { title: 'SCR', subtitle: 'Crédito', resumos: resumoDeCreditos, isLoading: isLoading, error: error, loadingProgress: loadingProgress }),
92
- React.createElement(ResumoModalidades, { isLoading: isLoading, scr: scr, error: error, loadingProgress: loadingProgress })))); }, isError: function (err) { return ({
123
+ React.createElement(AddItemField, { name: "Total de cr\u00E9ditos a vencer", value: scr === null || scr === void 0 ? void 0 : scr.response.expiringTotal }),
124
+ React.createElement(AddItemField, { name: "Total de cr\u00E9ditos vencidos", value: scr === null || scr === void 0 ? void 0 : scr.response.expiredTotal }),
125
+ React.createElement(Button, { style: { maxWidth: 'fit-content', minHeight: '0' }, onClick: function () { return __awaiter(_this, void 0, void 0, function () {
126
+ var response, fileBlob, file, fileURL, pdfWindow;
127
+ return __generator(this, function (_a) {
128
+ switch (_a.label) {
129
+ case 0: return [4 /*yield*/, fetch({
130
+ uuid: scr === null || scr === void 0 ? void 0 : scr.uuidQuery
131
+ })];
132
+ case 1:
133
+ response = _a.sent();
134
+ if (!response) return [3 /*break*/, 3];
135
+ return [4 /*yield*/, response.blob()];
136
+ case 2:
137
+ fileBlob = _a.sent();
138
+ file = new Blob([fileBlob], {
139
+ type: 'application/pdf'
140
+ });
141
+ fileURL = URL.createObjectURL(file);
142
+ pdfWindow = window.open();
143
+ pdfWindow.location.href = fileURL;
144
+ _a.label = 3;
145
+ case 3: return [2 /*return*/];
146
+ }
147
+ });
148
+ }); } }, "Baixar relat\u00F3rio detalhado"))),
149
+ React.createElement(ResumosWrapper, { isOpen: isOpen }))); }, isError: function (err) { return ({
93
150
  children: React.createElement(React.Fragment, null),
94
151
  description: (React.createElement(StatusMessage, { type: "error" },
95
152
  "Erro ao realizar a consulta: ",
@@ -97,104 +154,5 @@ function ConsultaSCR(_a) {
97
154
  variant: 'error'
98
155
  }); } })) : null;
99
156
  }
100
- var FluxosDeVencimentosConsolidados = function (_a) {
101
- var scr = _a.scr, isLoading = _a.isLoading, error = _a.error, loadingProgress = _a.loadingProgress;
102
- var isOpen = useToggle(true)[0];
103
- return (React.createElement(Section, { ctx: {
104
- type: isLoading
105
- ? RequestStatus.Loading
106
- : error
107
- ? RequestStatus.Error
108
- : RequestStatus.Success,
109
- error: error || null,
110
- response: undefined,
111
- document: scr,
112
- refetch: function () { },
113
- Section: Section,
114
- progress: loadingProgress
115
- }, title: "SCR", subtitle: "Fluxo De Vencimentos Consolidados", icon: ScrIcon, description: !error && (React.createElement(StatusMessage, { type: scr ? 'success' : 'default' }, "Fluxo de vencimentos consolidados dispon\u00EDvel.")), onSuccess: function () {
116
- var _a;
117
- return (React.createElement(Content, { isOpen: isOpen },
118
- React.createElement(Result, null,
119
- React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", print: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
120
- React.createElement(AddItemField, { name: "Data-base", value: scr === null || scr === void 0 ? void 0 : scr.dataBaseConsultada }),
121
- React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o de processamento IF's", value: scr === null || scr === void 0 ? void 0 : scr.percentualDocumentosProcessados }),
122
- React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o de processamento Valor", value: scr === null || scr === void 0 ? void 0 : scr.percentualVolumeProcessado }),
123
- React.createElement(AddItemField, { name: "Quantidade de Opera\u00E7\u00F5es", value: scr === null || scr === void 0 ? void 0 : scr.quantidadeDeOperacoes }),
124
- React.createElement(AddItemField, { name: "Quantidade de Institui\u00E7\u00F5es", value: scr === null || scr === void 0 ? void 0 : scr.quantidadeDeInstituicoes }),
125
- React.createElement(AddItemField, { name: "Quantidade de opera\u00E7\u00F5es amparadas por sub-judice", value: scr === null || scr === void 0 ? void 0 : scr.quantidadeOperacoesSubJudice }),
126
- React.createElement(AddItemField, { name: "Quantidade de opera\u00E7\u00F5es com manifesta\u00E7\u00E3o por discord\u00E2ncia", value: scr === null || scr === void 0 ? void 0 : scr.quantidadeOperacoesDiscordancia }),
127
- React.createElement(AddItemField, { name: "Opera\u00E7\u00F5es com manifesta\u00E7\u00E3o de discord\u00E2ncia", value: scr === null || scr === void 0 ? void 0 : scr.responsabilidadeTotalDiscordancia }),
128
- React.createElement(AddItemField, { name: "Opera\u00E7\u00F5es amparadas por sub-judice", value: scr === null || scr === void 0 ? void 0 : scr.responsabilidadeTotalSubJudice }),
129
- React.createElement(AddItemField, { name: "Risco indireto fornecedor", value: scr === null || scr === void 0 ? void 0 : scr.riscoIndiretoVendor }),
130
- React.createElement(AddItemField, { name: "Data de in\u00EDcio do relacionamento com a IF", value: (scr === null || scr === void 0 ? void 0 : scr.dataInicioRelacionamento) &&
131
- ((_a = new Date(scr.dataInicioRelacionamento)) === null || _a === void 0 ? void 0 : _a.toLocaleDateString()) }),
132
- React.createElement(AddItemField, { name: "Tipo cliente", value: scr === null || scr === void 0 ? void 0 : scr.tipoDoCliente })))));
133
- }, isError: function (err) { return ({
134
- children: React.createElement(React.Fragment, null),
135
- description: (React.createElement(StatusMessage, { type: "error" },
136
- "Erro ao realizar a consulta: ",
137
- err.message)),
138
- variant: 'error'
139
- }); } }));
140
- };
141
- var ResumoList = function (_a) {
142
- var isLoading = _a.isLoading, className = _a.className, error = _a.error, resumos = _a.resumos, loadingProgress = _a.loadingProgress;
143
- var isOpen = useToggle(true)[0];
144
- if (!isLoading && !resumos.length)
145
- return null;
146
- return (React.createElement(Section, { ctx: {
147
- type: isLoading
148
- ? RequestStatus.Loading
149
- : error
150
- ? RequestStatus.Error
151
- : RequestStatus.Success,
152
- error: error || null,
153
- response: undefined,
154
- document: resumos,
155
- refetch: function () { },
156
- Section: Section,
157
- progress: loadingProgress
158
- }, icon: ScrIcon, description: !error && (React.createElement(StatusMessage, { type: resumos.length ? 'success' : 'default' }, "Resumo de cr\u00E9ditos dispon\u00EDvel.")), onSuccess: function () { return (React.createElement(Content, { isOpen: isOpen },
159
- React.createElement(Result, null,
160
- React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" }, resumos.map(function (item, index) { return (React.createElement(AddItemField, { key: "".concat(item.descricao, "-").concat(index), name: item.descricao, value: item.valor })); }))))); }, isError: function (err) { return ({
161
- children: React.createElement(React.Fragment, null),
162
- description: (React.createElement(StatusMessage, { type: "error" },
163
- "Erro ao realizar a consulta: ",
164
- err.message)),
165
- variant: 'error'
166
- }); } }));
167
- };
168
- var ResumoModalidades = function (_a) {
169
- var scr = _a.scr, isLoading = _a.isLoading, error = _a.error, loadingProgress = _a.loadingProgress;
170
- var isOpen = useToggle(true)[0];
171
- var resumoModalidades = (scr && getResumoDeModalidades(scr)) || [];
172
- if (!isLoading && !(resumoModalidades === null || resumoModalidades === void 0 ? void 0 : resumoModalidades.length))
173
- return null;
174
- return (React.createElement(Section, { ctx: {
175
- type: isLoading
176
- ? RequestStatus.Loading
177
- : error
178
- ? RequestStatus.Error
179
- : RequestStatus.Success,
180
- error: error || null,
181
- response: undefined,
182
- document: resumoModalidades,
183
- refetch: function () { },
184
- Section: Section,
185
- progress: loadingProgress
186
- }, title: "SCR", subtitle: "Modalidade x Data Base", icon: ScrIcon, description: !error && (React.createElement(StatusMessage, { type: resumoModalidades.length ? 'success' : 'default' }, "Resumo de modalidades dispon\u00EDvel.")), onSuccess: function () { return (React.createElement(Content, { isOpen: isOpen },
187
- React.createElement(Result, null, resumoModalidades.map(function (resumo, index) { return (React.createElement(ResultContent, { key: "".concat(resumo.modalidade, "-").concat(index), desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr", print: "repeat(4, 1fr)" },
188
- React.createElement(AddItemField, { name: "", value: resumo.modalidade }),
189
- React.createElement(AddItemField, { name: "Vencido", value: resumo.vencido && formatMoney(resumo.vencido) }),
190
- React.createElement(AddItemField, { name: "A Vencer", value: resumo.aVencer && formatMoney(resumo.aVencer) }),
191
- React.createElement(AddItemField, { name: "Valor", value: formatMoney(resumo.valor) }))); })))); }, isError: function (err) { return ({
192
- children: React.createElement(React.Fragment, null),
193
- description: (React.createElement(StatusMessage, { type: "error" },
194
- "Erro ao realizar a consulta: ",
195
- err.message)),
196
- variant: 'error'
197
- }); } }));
198
- };
199
157
  export default ConsultaSCR;
200
158
  var templateObject_1;
@@ -60,6 +60,12 @@ export declare function useMutation<R = unknown, T extends Client.Form = Client.
60
60
  response: ParsedResponse<R> | null;
61
61
  mutate: () => void;
62
62
  };
63
+ export declare function useFetch<R = unknown, T extends Client.Form = Client.Form>(query: string): {
64
+ isLoading: boolean;
65
+ error: Error | null;
66
+ response: Response | null;
67
+ fetch: (data: T) => Promise<void | Response>;
68
+ };
63
69
  export declare function query<T extends Client.Form = Client.Form, R = unknown>(query: string): React.Context<RequestContext<R>> & {
64
70
  Request: React.FC<React.PropsWithChildren<{
65
71
  data?: T | undefined;
@@ -1,3 +1,39 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  import { Client } from '@credithub/webservice';
2
38
  import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
3
39
  import Section from './section';
@@ -269,6 +305,37 @@ export function useMutation(query, data) {
269
305
  mutate: mutate
270
306
  };
271
307
  }
308
+ export function useFetch(query) {
309
+ var _this = this;
310
+ var client = useContext(WebService);
311
+ var abortController = useMemo(function () { return new AbortController(); }, []);
312
+ var _a = useState(null), response = _a[0], setResponse = _a[1];
313
+ var _b = useState(null), error = _b[0], setError = _b[1];
314
+ var _c = useState(true), isLoading = _c[0], setIsLoading = _c[1];
315
+ var fetch = useCallback(function (data) { return __awaiter(_this, void 0, void 0, function () {
316
+ return __generator(this, function (_a) {
317
+ setIsLoading(true);
318
+ return [2 /*return*/, client
319
+ .request(query, data, undefined, abortController.signal)
320
+ .then(function (document) {
321
+ setResponse(document);
322
+ return document;
323
+ })
324
+ .catch(function (requestError) {
325
+ return setError(requestError instanceof Error && requestError.name !== 'AbortError'
326
+ ? requestError
327
+ : new Error(requestError));
328
+ })
329
+ .finally(function () { return setIsLoading(false); })];
330
+ });
331
+ }); }, []);
332
+ return {
333
+ isLoading: isLoading,
334
+ error: error,
335
+ response: response,
336
+ fetch: fetch
337
+ };
338
+ }
272
339
  export function query(query) {
273
340
  var RequestContext = createContext({
274
341
  type: RequestStatus.Empty,
@@ -0,0 +1 @@
1
+ export declare const useScrPdf: (uuid: string) => void;
@@ -0,0 +1,6 @@
1
+ import { useMutation } from "../components/webservice";
2
+ export var useScrPdf = function (uuid) {
3
+ var _a = useMutation("SELECT FROM 'SCR'.'PDF'", {
4
+ uuid: uuid
5
+ }), mutatePdf = _a.mutate, responsePdf = _a.response;
6
+ };