diff --git a/src/App.js b/src/App.js
index f87f498..c10f8bd 100644
--- a/src/App.js
+++ b/src/App.js
@@ -24,6 +24,9 @@ const App = () => {
+ {(permissions === 2 || permissions === 1) && (
+ <>>
+ )}
} />
} />
diff --git a/src/components/CardUsuarios/MapeoUsuario.js b/src/components/CardUsuarios/MapeoUsuario.js
index 9b558d3..bf31502 100644
--- a/src/components/CardUsuarios/MapeoUsuario.js
+++ b/src/components/CardUsuarios/MapeoUsuario.js
@@ -6,7 +6,6 @@ const MapeoUsuario = ({ filters }) => {
const [usuarios, setUsuarios] = useState([]);
const [currentPage, setCurrentPage] = useState(1);
const [totalPages, setTotalPages] = useState(1);
- const [jwt,setJwt] = useState();
useEffect(() => {
fetchUsuarios();
diff --git a/src/components/CrearProfesor/FormProfesor.js b/src/components/CrearProfesor/FormProfesor.js
index 01ae408..7666b2f 100644
--- a/src/components/CrearProfesor/FormProfesor.js
+++ b/src/components/CrearProfesor/FormProfesor.js
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useCallback } from 'react';
import { useDropzone } from 'react-dropzone';
-import {PrivateRoutes, PublicRoutes} from '../../models/routes'
+import { PublicRoutes } from '../../models/routes'
import './FormProfesor.css';
const FormProfesor = () => {
@@ -30,12 +30,12 @@ const FormProfesor = () => {
const [ubicacion,setUbicacion] = useState('');
const [mostrar,setMostrar] = useState(true);
const [nombre,setNombre] =useState('');
+ let imageUrl = '';
+
const [grado_maximo,setGrado_maximo] =useState('');
const [grados_obtenidos,setGrados_obtenidos] =useState('');
- const [formData,setFormData] = useState()
-
const handlePageChange = (newPage) => {
setPage(newPage);
};
@@ -58,18 +58,6 @@ const FormProfesor = () => {
}, []);
- const handleFileChange = (event) => {
- const file = event.target.files[0];
- const reader = new FileReader();
- reader.onloadend = () => {
- setFormData({
- ...formData,
- fotografica: reader.result,
- });
- };
- reader.readAsDataURL(file);
- };
-
const handleLineaInvestigacionChange = (index, value) => {
const newLineas = [...lineasInvestigacion];
newLineas[index].lineas_inv = value;
@@ -104,6 +92,34 @@ const FormProfesor = () => {
event.preventDefault();
try {
+ const token = localStorage.getItem('Token');
+ if (!token) {
+ console.error('No tienes el token');
+ return;
+ }
+
+ if (fotoBase64) {
+ const imageUploadResponse = await fetch('http://localhost:3000/imagen', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${token}`,
+ },
+ body: JSON.stringify({
+ fotografia: fotoBase64,
+ nombre,
+ }),
+ });
+
+ if (!imageUploadResponse.ok) {
+ throw new Error('Error al subir la imagen');
+ }
+
+ const imageUploadResult = await imageUploadResponse.json();
+ console.log('Imagen subida con éxito:', imageUploadResult.imageUrl);
+ imageUrl = `http://localhost:3000${imageUploadResult.imageUrl}`;
+ }
+
const data = {
nombre,
id_usuario,
@@ -129,17 +145,10 @@ const FormProfesor = () => {
grados_obtenidos,
},
],
- fotografia:fotoBase64,
+ fotografia: imageUrl,
};
console.log(data);
- const token = localStorage.getItem('Token');
-
- if (!token) {
- console.error('No tienes el token');
- return;
- }
-
const response = await fetch('http://localhost:3000/profesor', {
method: 'POST',
headers: {
@@ -154,10 +163,8 @@ const FormProfesor = () => {
}
const result = await response.json();
- console.log('Profesor guardado con éxito:', result);
- console.log("Form submitted");
- console.log(fotoBase64);
- window.location.href = PublicRoutes.FILTER;
+
+ //window.location.href = PublicRoutes.FILTER;
} catch (error) {
console.error('Error al guardar el profesor:', error);
diff --git a/src/components/Login/LoginForm.js b/src/components/Login/LoginForm.js
index cbc44a3..de26339 100644
--- a/src/components/Login/LoginForm.js
+++ b/src/components/Login/LoginForm.js
@@ -53,7 +53,6 @@ const LoginForm = () => {
return (
- Hola mundo
Bienvenido al directorio de profesores
Iniciar sesión