@grafosoft/excel-validator 1.1.7 → 1.1.9
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/README.md +15 -2
- package/dist/components/ExcelFile.d.ts +1 -1
- package/dist/components/ExcelFile.js +4 -3
- package/dist/components/ExcelLayout.js +6 -3
- package/dist/components/ExcelValidator.d.ts +1 -1
- package/dist/components/ExcelValidator.js +39 -15
- package/dist/types/SettingsProps.d.ts +1 -0
- package/dist/types/excelTypes.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ export default function Page() {
|
|
|
52
52
|
environment: "https://lab.globho.com/api/v1/",
|
|
53
53
|
title: "Catálogo Cuental",
|
|
54
54
|
type: "items",
|
|
55
|
+
redirect: "",
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
const jsonValidator = [
|
|
@@ -86,6 +87,7 @@ type SettingsProps = {
|
|
|
86
87
|
environment: string;
|
|
87
88
|
title: string;
|
|
88
89
|
type: string;
|
|
90
|
+
redirect: string;
|
|
89
91
|
};
|
|
90
92
|
```
|
|
91
93
|
|
|
@@ -105,11 +107,20 @@ type ExcelLayoutProps = {
|
|
|
105
107
|
- `"decimal"`: valida decimal
|
|
106
108
|
- `"bool"`: valida booleano
|
|
107
109
|
- `"string(n)"`: valida texto con longitud máxima `n`
|
|
110
|
+
- `"code(n)"`: valida texto alfanumérico con longitud máxima `n`; solo admite letras y números, sin caracteres especiales
|
|
108
111
|
- `"string(yyyy-mm-dd)"`: valida formato fecha
|
|
109
112
|
- Regla opcional: prefijo `$`, por ejemplo `"$string(20)"`
|
|
110
113
|
- `{ type: "fetch", url, prop }`: valida contra catálogo remoto
|
|
111
114
|
- `{ type: "string-empty", url, prop, validation }`: permite vacío o valida con consulta remota
|
|
112
115
|
|
|
116
|
+
## Redirect después del envío
|
|
117
|
+
|
|
118
|
+
El campo `redirect` en `initData` te permite redireccionar al usuario después de que la plantilla se envía correctamente.
|
|
119
|
+
|
|
120
|
+
- Si `redirect` tiene un valor, se redirige a esa URL.
|
|
121
|
+
- Si viene vacío, la página se recarga.
|
|
122
|
+
- Esto aplica en el flujo del botón `Enviar Plantilla`.
|
|
123
|
+
|
|
113
124
|
## Configuraciones de ejemplo (tomadas de `page.tsx`)
|
|
114
125
|
|
|
115
126
|
### PLAN DE CUENTAS
|
|
@@ -236,7 +247,7 @@ const jsonValidator = [
|
|
|
236
247
|
{
|
|
237
248
|
type: "fetch",
|
|
238
249
|
url: "valueset/identificationTypes",
|
|
239
|
-
prop: "
|
|
250
|
+
prop: "code",
|
|
240
251
|
},
|
|
241
252
|
{
|
|
242
253
|
type: "string-empty",
|
|
@@ -276,7 +287,7 @@ const jsonValidator = [
|
|
|
276
287
|
{
|
|
277
288
|
type: "fetch",
|
|
278
289
|
url: "valueset/activities",
|
|
279
|
-
prop: "
|
|
290
|
+
prop: "code",
|
|
280
291
|
},
|
|
281
292
|
{
|
|
282
293
|
type: "fetch",
|
|
@@ -344,9 +355,11 @@ const jsonValidator = [
|
|
|
344
355
|
|
|
345
356
|
- `environment` debe ser una URL base válida (ejemplo: `https://lab.globho.com/`).
|
|
346
357
|
- El componente normaliza automáticamente la barra final `/`.
|
|
358
|
+
- `redirect` puede ir vacío o con la ruta final a la que quieres enviar al usuario luego del envío exitoso.
|
|
347
359
|
- Las reglas `fetch` y `string-empty` construyen URL final con:
|
|
348
360
|
- `apikey`
|
|
349
361
|
- `companyId`
|
|
362
|
+
- El contenido TXT generado usa codificación UTF-8 para conservar caracteres como `ñ` y tildes al exportar y al enviarlo en base64.
|
|
350
363
|
|
|
351
364
|
## Publicación del paquete
|
|
352
365
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ExcelFileProps } from "../types/excelTypes";
|
|
2
|
-
export declare const ExcelFile: ({ initData, fileContent, matrix, error, onFileSelected, onReset, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference, onApplyStringEmptyFilter, onDownloadFilteredExcel, isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors, }: ExcelFileProps) => import("react").JSX.Element;
|
|
2
|
+
export declare const ExcelFile: ({ initData, fileContent, matrix, error, onFileSelected, onReset, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference, isBalances, onApplyStringEmptyFilter, onDownloadFilteredExcel, isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors, }: ExcelFileProps) => import("react").JSX.Element;
|
|
@@ -6,7 +6,8 @@ const react_1 = require("@heroui/react");
|
|
|
6
6
|
const react_2 = require("react");
|
|
7
7
|
const tb_1 = require("react-icons/tb");
|
|
8
8
|
const ExcelValidator_1 = require("./ExcelValidator");
|
|
9
|
-
const
|
|
9
|
+
const ThemeSwitcher_1 = require("./ThemeSwitcher");
|
|
10
|
+
const ExcelFile = ({ initData, fileContent, matrix, error, onFileSelected, onReset, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference = false, isBalances = false, onApplyStringEmptyFilter, onDownloadFilteredExcel, isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors, }) => {
|
|
10
11
|
var _a;
|
|
11
12
|
const [isVisible, setIsVisible] = (0, react_2.useState)(false);
|
|
12
13
|
const inputRef = (0, react_2.useRef)(null);
|
|
@@ -28,12 +29,12 @@ const ExcelFile = ({ initData, fileContent, matrix, error, onFileSelected, onRes
|
|
|
28
29
|
}
|
|
29
30
|
return (bytes / KB).toFixed(2) + " KB";
|
|
30
31
|
};
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-content1 p-4 border-none md:border-l border-default-200", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "text-xl font-semibold text-default-700", children: ["Importa ", initData.title] }), error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: error, className: "mt-3", radius: "sm", hideIconWrapper: true })) : isVisible ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { radius: "sm", hideIconWrapper: true, hideIcon: true, isVisible: isVisible, className: "mt-4 max-w-full overflow-hidden", classNames: {
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-content1 p-4 border-none md:border-l border-default-200", children: [(0, jsx_runtime_1.jsx)(ThemeSwitcher_1.ThemeSwitcher, {}), (0, jsx_runtime_1.jsxs)("h2", { className: "text-xl font-semibold text-default-700", children: ["Importa ", initData.title] }), error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: error, className: "mt-3", radius: "sm", hideIconWrapper: true })) : isVisible ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { radius: "sm", hideIconWrapper: true, hideIcon: true, isVisible: isVisible, className: "mt-4 max-w-full overflow-hidden", classNames: {
|
|
32
33
|
mainWrapper: "min-w-0 flex-1 overflow-hidden",
|
|
33
34
|
closeButton: "shrink-0",
|
|
34
35
|
}, variant: "bordered", onClose: handleReset, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-default-700", children: [(0, jsx_runtime_1.jsx)(tb_1.TbFile, { className: "shrink-0", size: 28 }), " ", (0, jsx_runtime_1.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden", children: [(0, jsx_runtime_1.jsx)("p", { className: "max-w-full truncate text-sm", title: fileContent === null || fileContent === void 0 ? void 0 : fileContent.name, children: fileContent === null || fileContent === void 0 ? void 0 : fileContent.name }), (0, jsx_runtime_1.jsx)("small", { className: "text-default-500", children: bytesFormat((_a = fileContent === null || fileContent === void 0 ? void 0 : fileContent.size) !== null && _a !== void 0 ? _a : 0) })] })] }) }), initData.type === "accounts" && ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 space-y-2 flex md:flex-col gap-5 md:gap-0", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { className: "w-full border-1", color: "warning", variant: "bordered", radius: "sm", startContent: (0, jsx_runtime_1.jsx)(tb_1.TbFilter, { size: 18 }), onPress: onApplyStringEmptyFilter, isDisabled: !hasStringEmptyDuplicateErrors || isStringEmptyFilterApplied, children: isStringEmptyFilterApplied
|
|
35
36
|
? "Filtro aplicado"
|
|
36
|
-
: "Quitar cuentas ya registradas" }), (0, jsx_runtime_1.jsx)(react_1.Button, { className: "w-full border-1", color: "success", variant: "bordered", radius: "sm", startContent: (0, jsx_runtime_1.jsx)(tb_1.TbDownload, { size: 18 }), onPress: onDownloadFilteredExcel, isDisabled: !isStringEmptyFilterApplied || !hasStringEmptyDuplicateErrors, children: "Descargar Nuevo Excel" })] })), (0, jsx_runtime_1.jsx)(ExcelValidator_1.ExcelValidator, { initData: initData, fileContent: fileContent, matrix: matrix, validationErrors: validationErrors, onSelectError: onSelectError, onClearSelectedError: onClearSelectedError, hasBalanceDifference: hasBalanceDifference })] })) : ((0, jsx_runtime_1.jsx)("label", { className: "mt-4 flex cursor-pointer items-center justify-center rounded-lg border border-dashed border-default-300 px-4 py-8 text-sm font-medium text-default-600 transition hover:border-primary hover:text-primary", htmlFor: "excel-upload", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-center flex flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)(tb_1.TbUpload, { size: 28 }), (0, jsx_runtime_1.jsx)("p", { className: "font-semibold text-lg", children: "Seleccionar plantilla" }), (0, jsx_runtime_1.jsx)("small", { className: "text-default-500", children: "Adjunta un archivo .xlsx o .xls para validar y previsualizar." })] }) })), (0, jsx_runtime_1.jsx)("input", { id: "excel-upload", ref: inputRef, className: "hidden", type: "file", accept: ".xlsx,.xls", onChange: (event) => {
|
|
37
|
+
: "Quitar cuentas ya registradas" }), (0, jsx_runtime_1.jsx)(react_1.Button, { className: "w-full border-1", color: "success", variant: "bordered", radius: "sm", startContent: (0, jsx_runtime_1.jsx)(tb_1.TbDownload, { size: 18 }), onPress: onDownloadFilteredExcel, isDisabled: !isStringEmptyFilterApplied || !hasStringEmptyDuplicateErrors, children: "Descargar Nuevo Excel" })] })), (0, jsx_runtime_1.jsx)(ExcelValidator_1.ExcelValidator, { initData: initData, fileContent: fileContent, matrix: matrix, validationErrors: validationErrors, onSelectError: onSelectError, onClearSelectedError: onClearSelectedError, hasBalanceDifference: hasBalanceDifference, isBalances: isBalances })] })) : ((0, jsx_runtime_1.jsx)("label", { className: "mt-4 flex cursor-pointer items-center justify-center rounded-lg border border-dashed border-default-300 px-4 py-8 text-sm font-medium text-default-600 transition hover:border-primary hover:text-primary", htmlFor: "excel-upload", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-center flex flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)(tb_1.TbUpload, { size: 28 }), (0, jsx_runtime_1.jsx)("p", { className: "font-semibold text-lg", children: "Seleccionar plantilla" }), (0, jsx_runtime_1.jsx)("small", { className: "text-default-500", children: "Adjunta un archivo .xlsx o .xls para validar y previsualizar." })] }) })), (0, jsx_runtime_1.jsx)("input", { id: "excel-upload", ref: inputRef, className: "hidden", type: "file", accept: ".xlsx,.xls", onChange: (event) => {
|
|
37
38
|
void onFileSelected(event);
|
|
38
39
|
setIsVisible(true);
|
|
39
40
|
} })] }));
|
|
@@ -387,14 +387,17 @@ function ExcelLayout({ initData, jsonValidator, isBalances = false, }) {
|
|
|
387
387
|
const isOptional = rule.type.trim().startsWith("$");
|
|
388
388
|
if (normalizedType === "fetch") {
|
|
389
389
|
const trimmedValue = value.trim();
|
|
390
|
+
const normalizedProp = rule.prop.trim();
|
|
391
|
+
const fetchProp = normalizedProp.replace(/^\$/, "");
|
|
392
|
+
const isFetchOptional = isOptional || normalizedProp.startsWith("$");
|
|
390
393
|
if (trimmedValue === "") {
|
|
391
|
-
return
|
|
394
|
+
return isFetchOptional
|
|
392
395
|
? { valid: true, message: "" }
|
|
393
396
|
: { valid: false, message: "Valor vacío" };
|
|
394
397
|
}
|
|
395
398
|
const catalog = (_a = fetchCatalogsByUrl[rule.url]) !== null && _a !== void 0 ? _a : [];
|
|
396
399
|
const hasMatch = catalog.some((catalogItem) => {
|
|
397
|
-
const propValue = catalogItem[
|
|
400
|
+
const propValue = catalogItem[fetchProp];
|
|
398
401
|
return String(propValue !== null && propValue !== void 0 ? propValue : "").trim() === trimmedValue;
|
|
399
402
|
});
|
|
400
403
|
return {
|
|
@@ -586,5 +589,5 @@ function ExcelLayout({ initData, jsonValidator, isBalances = false, }) {
|
|
|
586
589
|
setFocusTarget(null);
|
|
587
590
|
setIsStringEmptyFilterApplied(false);
|
|
588
591
|
};
|
|
589
|
-
return ((0, jsx_runtime_1.jsxs)("main", { ref: mainRef, className: "grid grid-cols-1 h-full grid-rows-2 md:grid-rows-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "space-y-4 col-span-1 order-2 ", children: (0, jsx_runtime_1.jsx)(ExcelFile_1.ExcelFile, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, onFileSelected: handleFileSelected, onReset: handleReset, validationErrors: validationErrorsForPanel, onSelectError: handleSelectError, onClearSelectedError: handleClearSelectedError, hasBalanceDifference: hasBalanceDifference, onApplyStringEmptyFilter: handleApplyStringEmptyFilter, onDownloadFilteredExcel: handleDownloadFilteredExcel, isStringEmptyFilterApplied: isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors: hasStringEmptyDuplicateErrors }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1 lg:col-span-2 xl:col-span-3", children: (0, jsx_runtime_1.jsx)(ExcelPreview_1.ExcelPreview, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, validationErrors: validationErrors, focusTarget: focusTarget, currentPage: currentPage, onPageChange: setCurrentPage, isBalances: isBalances, hiddenFilteredRowIndexes: isStringEmptyFilterApplied ? stringEmptyDuplicateRowIndexes : [] }) })] }));
|
|
592
|
+
return ((0, jsx_runtime_1.jsxs)("main", { ref: mainRef, className: "grid grid-cols-1 h-full grid-rows-2 md:grid-rows-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "space-y-4 col-span-1 order-2 ", children: (0, jsx_runtime_1.jsx)(ExcelFile_1.ExcelFile, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, onFileSelected: handleFileSelected, onReset: handleReset, validationErrors: validationErrorsForPanel, onSelectError: handleSelectError, onClearSelectedError: handleClearSelectedError, hasBalanceDifference: hasBalanceDifference, isBalances: isBalances, onApplyStringEmptyFilter: handleApplyStringEmptyFilter, onDownloadFilteredExcel: handleDownloadFilteredExcel, isStringEmptyFilterApplied: isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors: hasStringEmptyDuplicateErrors }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1 lg:col-span-2 xl:col-span-3", children: (0, jsx_runtime_1.jsx)(ExcelPreview_1.ExcelPreview, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, validationErrors: validationErrors, focusTarget: focusTarget, currentPage: currentPage, onPageChange: setCurrentPage, isBalances: isBalances, hiddenFilteredRowIndexes: isStringEmptyFilterApplied ? stringEmptyDuplicateRowIndexes : [] }) })] }));
|
|
590
593
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ExcelValidatorProps } from "../types/excelTypes";
|
|
2
|
-
export declare const ExcelValidator: ({ initData, fileContent, matrix, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference, }: ExcelValidatorProps) => import("react").JSX.Element | null;
|
|
2
|
+
export declare const ExcelValidator: ({ initData, fileContent, matrix, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference, isBalances, }: ExcelValidatorProps) => import("react").JSX.Element | null;
|
|
@@ -3,16 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExcelValidator = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@heroui/react");
|
|
6
|
+
const date_1 = require("@internationalized/date");
|
|
7
|
+
const navigation_1 = require("next/navigation");
|
|
6
8
|
const react_2 = require("react");
|
|
7
9
|
const tb_1 = require("react-icons/tb");
|
|
8
|
-
const ExcelValidator = ({ initData, fileContent, matrix, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference = false, }) => {
|
|
10
|
+
const ExcelValidator = ({ initData, fileContent, matrix, validationErrors, onSelectError, onClearSelectedError, hasBalanceDifference = false, isBalances = false, }) => {
|
|
11
|
+
const { replace } = (0, navigation_1.useRouter)();
|
|
9
12
|
const [selectedErrorId, setSelectedErrorId] = (0, react_2.useState)(null);
|
|
10
13
|
const [isUploadingTemplate, setIsUploadingTemplate] = (0, react_2.useState)(false);
|
|
11
14
|
const [uploadMessage, setUploadMessage] = (0, react_2.useState)(null);
|
|
15
|
+
const [balanceDate, setBalanceDate] = (0, react_2.useState)(() => isBalances ? (0, date_1.today)((0, date_1.getLocalTimeZone)()) : null);
|
|
12
16
|
if (!fileContent) {
|
|
13
17
|
return null;
|
|
14
18
|
}
|
|
19
|
+
const hasDataRows = matrix
|
|
20
|
+
.slice(1)
|
|
21
|
+
.some((row) => { var _a, _b; return ((_b = (_a = row[0]) === null || _a === void 0 ? void 0 : _a.toString().trim()) !== null && _b !== void 0 ? _b : "") !== ""; });
|
|
15
22
|
const handleTXTFormat = async () => {
|
|
23
|
+
var _a;
|
|
16
24
|
setIsUploadingTemplate(true);
|
|
17
25
|
setUploadMessage(null);
|
|
18
26
|
const dataRows = matrix
|
|
@@ -24,23 +32,33 @@ const ExcelValidator = ({ initData, fileContent, matrix, validationErrors, onSel
|
|
|
24
32
|
return padded.join("|");
|
|
25
33
|
});
|
|
26
34
|
const content = lines.join("\n");
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const dateBalances = balanceDate
|
|
36
|
+
? `${balanceDate.year.toString().padStart(4, "0")}-${balanceDate.month
|
|
37
|
+
.toString()
|
|
38
|
+
.padStart(2, "0")}-${balanceDate.day.toString().padStart(2, "0")}`
|
|
39
|
+
: "";
|
|
40
|
+
const utf8Content = `\uFEFF${content}`;
|
|
41
|
+
const base64Content = (() => {
|
|
42
|
+
const bytes = new TextEncoder().encode(utf8Content);
|
|
43
|
+
const chunkSize = 8192;
|
|
44
|
+
let binary = "";
|
|
45
|
+
for (let offset = 0; offset < bytes.length; offset += chunkSize) {
|
|
46
|
+
const chunk = bytes.subarray(offset, offset + chunkSize);
|
|
47
|
+
binary += String.fromCharCode(...chunk);
|
|
48
|
+
}
|
|
49
|
+
return btoa(binary);
|
|
50
|
+
})();
|
|
35
51
|
try {
|
|
36
52
|
const response = await fetch(`${initData.environment}plains/upload?companyId=${initData.companyId}&apikey=${initData.apikey}`, {
|
|
37
53
|
method: "POST",
|
|
38
54
|
headers: {
|
|
39
|
-
"Content-Type": "application/json",
|
|
55
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
40
56
|
},
|
|
41
57
|
body: JSON.stringify({
|
|
42
|
-
content:
|
|
58
|
+
content: base64Content,
|
|
43
59
|
extension: "txt",
|
|
60
|
+
encoding: "utf-8",
|
|
61
|
+
date: dateBalances,
|
|
44
62
|
name: `Plantilla ${initData.title}`,
|
|
45
63
|
type: initData.type,
|
|
46
64
|
}),
|
|
@@ -48,15 +66,21 @@ const ExcelValidator = ({ initData, fileContent, matrix, validationErrors, onSel
|
|
|
48
66
|
if (!response.ok) {
|
|
49
67
|
throw new Error("No se pudo enviar la plantilla");
|
|
50
68
|
}
|
|
69
|
+
const redirectUrl = ((_a = initData.redirect) !== null && _a !== void 0 ? _a : "").trim();
|
|
51
70
|
setUploadMessage({
|
|
52
71
|
type: "success",
|
|
53
|
-
text: "
|
|
72
|
+
text: "Se descargó y se envió la plantilla correctamente.",
|
|
54
73
|
});
|
|
74
|
+
if (redirectUrl) {
|
|
75
|
+
replace(redirectUrl);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
window.location.reload();
|
|
55
79
|
}
|
|
56
|
-
catch (
|
|
80
|
+
catch (_b) {
|
|
57
81
|
setUploadMessage({
|
|
58
82
|
type: "error",
|
|
59
|
-
text: "
|
|
83
|
+
text: "No se pudo enviar la plantilla.",
|
|
60
84
|
});
|
|
61
85
|
}
|
|
62
86
|
finally {
|
|
@@ -68,7 +92,7 @@ const ExcelValidator = ({ initData, fileContent, matrix, validationErrors, onSel
|
|
|
68
92
|
};
|
|
69
93
|
return ((0, jsx_runtime_1.jsxs)("section", { className: "mt-5 bg-content1 max-h-[calc(100vh-11.5rem)] overflow-y-auto pr-1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex xl:flex-row lg:flex-col mb-3 justify-between items-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-xl font-semibold text-default-700", children: "Validaciones" }), (0, jsx_runtime_1.jsx)(react_1.Chip, { color: validationErrors.length > 0 ? "danger" : "success", variant: "solid", className: "text-white", startContent: validationErrors.length > 0 ? ((0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { size: 20 })) : ((0, jsx_runtime_1.jsx)(tb_1.TbCheck, { size: 20 })), children: (0, jsx_runtime_1.jsxs)("p", { className: "pl-1", children: [validationErrors.length, " ", validationErrors.length === 1
|
|
70
94
|
? "error encontrado"
|
|
71
|
-
: "errores encontrados"] }) })] }), hasBalanceDifference ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: "Hay diferencias en los saldos iniciales", variant: "faded", hideIcon: true, startContent: (0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { size: 30 }), className: "mb-3" })) : null, validationErrors.length === 0 && !hasBalanceDifference ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { color: "success", title: "Sin errores de validaci\u00F3n.", variant: "faded", hideIcon: true, startContent: (0, jsx_runtime_1.jsx)(tb_1.TbCircleCheck, { size: 30 }) }), (0, jsx_runtime_1.jsx)(react_1.Button, { color: "success", className: "mt-4 w-full", variant: "flat", endContent: (0, jsx_runtime_1.jsx)(tb_1.TbUpload, { size: 20 }), radius: "sm", isLoading: isUploadingTemplate, onPress: handleTXTFormat, children: "Enviar Plantilla" }), uploadMessage ? ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 text-sm ${uploadMessage.type === "success"
|
|
95
|
+
: "errores encontrados"] }) })] }), hasBalanceDifference ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: "Hay diferencias en los saldos iniciales", variant: "faded", hideIcon: true, startContent: (0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { size: 30 }), className: "mb-3" })) : null, !hasDataRows ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: "No hay filas insertadas en la plantilla.", variant: "faded", hideIcon: true, startContent: (0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { size: 30 }) })) : validationErrors.length === 0 && !hasBalanceDifference ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { color: "success", title: "Sin errores de validaci\u00F3n.", variant: "faded", hideIcon: true, startContent: (0, jsx_runtime_1.jsx)(tb_1.TbCircleCheck, { size: 30 }) }), isBalances ? ((0, jsx_runtime_1.jsx)(react_1.DatePicker, { className: "mt-4 w-full", label: "Fecha de Corte", value: balanceDate, onChange: setBalanceDate, isRequired: true })) : null, (0, jsx_runtime_1.jsx)(react_1.Button, { color: "success", className: "mt-4 w-full", variant: "flat", endContent: (0, jsx_runtime_1.jsx)(tb_1.TbUpload, { size: 20 }), radius: "sm", isLoading: isUploadingTemplate, isDisabled: isBalances && balanceDate === null, onPress: handleTXTFormat, children: "Enviar Plantilla" }), uploadMessage ? ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 text-sm ${uploadMessage.type === "success"
|
|
72
96
|
? "text-success-600"
|
|
73
97
|
: "text-danger-600"}`, children: uploadMessage.text })) : null] })) : ((0, jsx_runtime_1.jsx)(react_1.Accordion, { selectionMode: "multiple", showDivider: false, children: Object.entries(validationErrors.reduce((groups, error) => {
|
|
74
98
|
const key = error.columnName;
|
|
@@ -27,6 +27,7 @@ export type ExcelFileProps = {
|
|
|
27
27
|
onSelectError: (error: ValidationError) => void;
|
|
28
28
|
onClearSelectedError: () => void;
|
|
29
29
|
hasBalanceDifference?: boolean;
|
|
30
|
+
isBalances?: boolean;
|
|
30
31
|
onApplyStringEmptyFilter: () => void;
|
|
31
32
|
onDownloadFilteredExcel: () => void;
|
|
32
33
|
isStringEmptyFilterApplied: boolean;
|
|
@@ -40,6 +41,7 @@ export type ExcelValidatorProps = {
|
|
|
40
41
|
onSelectError: (error: ValidationError) => void;
|
|
41
42
|
onClearSelectedError: () => void;
|
|
42
43
|
hasBalanceDifference?: boolean;
|
|
44
|
+
isBalances?: boolean;
|
|
43
45
|
};
|
|
44
46
|
export type ExcelPreviewProps = {
|
|
45
47
|
initData: SettingsProps;
|