@zauru-sdk/utils 2.0.200 → 2.0.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/zauru/form.utils.js +15 -6
- package/package.json +2 -2
|
@@ -22,24 +22,32 @@ export function transformFormSubmitObject(input) {
|
|
|
22
22
|
groups_path: "[]",
|
|
23
23
|
value: "",
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
// Verifica si se ha enviado un archivo (tipo File o signed_id acompañado de file_type)
|
|
26
|
+
if (input[key] instanceof File ||
|
|
27
|
+
(typeof input[key] === "string" && input[`${key}_file_type`])) {
|
|
28
|
+
if ((input[key] instanceof File && input[key]?.size > 0) ||
|
|
29
|
+
(typeof input[key] === "string" && input[`${key}_file_type`])) {
|
|
30
|
+
// Determina el tipo usando ya sea el file original o el file_type enviado
|
|
31
|
+
const fileType = input[key] instanceof File
|
|
32
|
+
? input[key].type
|
|
33
|
+
: input[`${key}_file_type`];
|
|
34
|
+
// Si es imagen
|
|
29
35
|
if (fileType.startsWith("image/")) {
|
|
30
36
|
newObj["image"] = input[key];
|
|
31
37
|
}
|
|
32
|
-
//
|
|
38
|
+
// Si es PDF
|
|
33
39
|
else if (fileType === "application/pdf") {
|
|
34
40
|
newObj["pdf"] = input[key];
|
|
35
41
|
}
|
|
36
|
-
//
|
|
42
|
+
// Para otros tipos de archivo
|
|
37
43
|
else {
|
|
38
44
|
newObj["file"] = input[key];
|
|
39
45
|
}
|
|
46
|
+
delete newObj.value;
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
49
|
else if (isJsonArray(input[key])) {
|
|
50
|
+
// Manejo de JSON array (para tablas, etc.)
|
|
43
51
|
const tableJsonArray = JSON.parse(input[key]);
|
|
44
52
|
if (tableJsonArray.length > 0) {
|
|
45
53
|
const form_table_values_attributes = [];
|
|
@@ -61,6 +69,7 @@ export function transformFormSubmitObject(input) {
|
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
else {
|
|
72
|
+
// Para otros valores simples
|
|
64
73
|
newObj["value"] = input[key];
|
|
65
74
|
}
|
|
66
75
|
form_submission_values.push(newObj);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.201",
|
|
4
4
|
"description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@zauru-sdk/services": "^2.0.200",
|
|
31
31
|
"@zauru-sdk/types": "^2.0.197"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "d5492dc01a6a06dbf6f94b6a273a3a5116147cac"
|
|
34
34
|
}
|