Ongoing adaptation to new backend structure

This commit is contained in:
Jose
2026-01-25 23:43:25 +01:00
parent 5f5d54d642
commit 59efb7d81f
31 changed files with 505 additions and 514 deletions

View File

@@ -19,9 +19,8 @@ const Documentacion = () => {
const reqConfig = {
baseUrl: config.apiConfig.coreUrl + config.apiConfig.endpoints.files.all,
uploadUrl: config.apiConfig.coreUrl + config.apiConfig.endpoints.files.upload,
params: {
_sort: 'uploaded_at',
_sort: 'uploadedAt',
_order: 'desc'
}
};
@@ -40,22 +39,22 @@ const DocumentacionContent = ({ reqConfig }) => {
const handleSelectFiles = async (files) => {
const file = files[0];
if (!file || !reqConfig?.uploadUrl) return;
if (!file || !reqConfig?.baseUrl) return;
const file_name = file.name;
const mime_type = file.type || "application/octet-stream";
const uploaded_by = JSON.parse(localStorage.getItem("user"))?.user_id;
const fileName = file.name;
const mimeType = file.type || "application/octet-stream";
const uploadedBy = JSON.parse(localStorage.getItem("identity"))?.user?.userId;
const context = 1;
const formData = new FormData();
formData.append("file", file);
formData.append("file_name", file_name);
formData.append("mime_type", mime_type);
formData.append("uploaded_by", uploaded_by);
formData.append("fileName", fileName);
formData.append("mimeType", mimeType);
formData.append("uploadedBy", uploadedBy);
formData.append("context", context);
try {
await postData(reqConfig.uploadUrl, formData);
await postData(reqConfig.baseUrl, formData);
fileUploadRef.current?.resetSelectedFiles();
} catch (err) {
console.error("Error al subir archivo:", err);
@@ -100,8 +99,8 @@ const DocumentacionContent = ({ reqConfig }) => {
variant="danger"
onClick={async () => {
try {
await deleteDataWithBody(`${reqConfig.baseUrl}/${deleteTarget.file_id}`, {
file_path: deleteTarget.file_path
await deleteDataWithBody(`${reqConfig.baseUrl}/${deleteTarget.fileId}`, {
filePath: deleteTarget.filePath
});
setDeleteTarget(null);
} catch (err) {