@ssplib/react-components 0.0.111 → 0.0.112
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.
|
@@ -65,7 +65,8 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
65
65
|
headers: {
|
|
66
66
|
Authorization: `Bearer ${user ? user.token : ''}`,
|
|
67
67
|
},
|
|
68
|
-
})
|
|
68
|
+
})
|
|
69
|
+
.then((res) => {
|
|
69
70
|
if (!res.ok)
|
|
70
71
|
setFilesError((fl) => [...fl, id]);
|
|
71
72
|
res.json().then((j) => {
|
|
@@ -88,7 +89,8 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
88
89
|
setFilesError((fl) => [...fl, id]);
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
|
-
})
|
|
92
|
+
})
|
|
93
|
+
.catch((err) => console.log(err));
|
|
92
94
|
return { id: id, name: file.name, loading: true, error: false, file: file };
|
|
93
95
|
}),
|
|
94
96
|
]);
|
|
@@ -105,12 +107,14 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
105
107
|
headers: {
|
|
106
108
|
Authorization: `Bearer ${user === null || user === void 0 ? void 0 : user.token}`,
|
|
107
109
|
},
|
|
108
|
-
})
|
|
110
|
+
})
|
|
111
|
+
.then((res) => {
|
|
109
112
|
if (res.status === 200) {
|
|
110
113
|
setFiles(files.filter((x) => x.id !== id));
|
|
111
114
|
context.setFilesUid((fId) => fId.filter((idd) => idd.CO_SEQ_ARQUIVO !== id));
|
|
112
115
|
}
|
|
113
|
-
})
|
|
116
|
+
})
|
|
117
|
+
.catch((err) => console.log(err));
|
|
114
118
|
}
|
|
115
119
|
};
|
|
116
120
|
(0, react_1.useEffect)(() => {
|
|
@@ -132,12 +136,14 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
132
136
|
react_1.default.createElement(material_1.Box, { sx: { backgroundColor: '#e2eafc', padding: 1, borderRadius: 1, marginTop: 1 } },
|
|
133
137
|
react_1.default.createElement("input", Object.assign({ id: name, type: 'file', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
|
|
134
138
|
validate: (v, f) => {
|
|
139
|
+
console.log('v: ', v.length, 'filesupload: ', filesLoaded.length);
|
|
135
140
|
if (filesLoaded.length <= 0 && required)
|
|
136
141
|
return 'O campo de arquivo é obrigatório';
|
|
137
142
|
},
|
|
138
143
|
}), { onChange: onFile, accept: '.pdf', style: { display: 'none' } })),
|
|
139
144
|
react_1.default.createElement("input", Object.assign({ id: name + 'foto', type: 'file', capture: 'environment', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
|
|
140
145
|
validate: (v, f) => {
|
|
146
|
+
console.log('v: ', v.length, 'filesupload: ', filesLoaded.length);
|
|
141
147
|
if (filesLoaded.length <= 0 && required)
|
|
142
148
|
return 'O campo de arquivo é obrigatório';
|
|
143
149
|
},
|