cambios de documentos

This commit is contained in:
Soka_jplr 2024-05-24 23:34:59 -06:00
parent 796ca2bae7
commit f0f6c8bf47
16 changed files with 385 additions and 204 deletions

View File

@ -1,9 +1,7 @@
create database universidad;
drop database universidad;
CREATE USER 'UserRemoto' @'localhost' IDENTIFIED BY 'password123';
DROP USER 'UserRemoto'@'localhost';
GRANT ALL PRIVILEGES ON universidad.* TO 'UserRemoto'@'LOCALHOST';
FLUSH PRIVILEGES;
@ -36,9 +34,11 @@ create table tutor(
id integer auto_increment primary key,
nombre varchar(40),
apellido varchar(40),
numeroDeTelefono integer,
numeroDeTelefono double,
idUsuario integer references usuario
);
ALTER TABLE usuario
MODIFY COLUMN inscrito int;
create table documento(
id integer auto_increment primary key,
@ -63,6 +63,7 @@ INSERT INTO usuario (
) VALUES (
'Juan', 'Perez', 'SIU241001', 'password123', 'juan.perez@example.com', 'Mexicana', 'O+', '1990-05-15', 'JUAP900515HDFLRN03', 'estudiante', 1, 1
);
ALTER TABLE carrera
ADD COLUMN campus VARCHAR(40),
ADD COLUMN descripcion VARCHAR(600),
@ -126,6 +127,9 @@ SET campus = 'Xalapa',
objetivo = 'Nuestro objetivo es formar psicólogos con una sólida base científica y habilidades prácticas para evaluar, diagnosticar y tratar problemas psicológicos. Fomentamos el pensamiento crítico, la empatía y la ética profesional, preparando a los estudiantes para contribuir al bienestar mental y emocional de las personas y comunidades que atienden.'
WHERE id = 6;
UPDATE `tutor` SET `nombre` = ?, `apellido` = ?, `numeroDeTelefono` = ? WHERE `idUsuario` = ?;

3
backend/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}

View File

@ -4,11 +4,15 @@ import static spark.Spark.*;
import java.util.HashMap;
import com.google.gson.*;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import mx.uv.Controller.DAO;
import mx.uv.Controller.DAOTutor;
import mx.uv.Controller.DAO_Carrrera;
import mx.uv.Model.*;
import mx.uv.Model.Mensaje;
import mx.uv.Model.Tutor;
import mx.uv.Model.Usuario;
public class App {
static Gson gson = new Gson();
@ -51,7 +55,7 @@ public class App {
return respuesta;
});
put("/editarAlumno", (request, response) -> {
put("/editarUsuario", (request, response) -> {
String payload = request.body();
Usuario usuario = gson.fromJson(payload, Usuario.class);
boolean verificado = DAO.editarAlumno(usuario);
@ -60,12 +64,21 @@ public class App {
return respuesta;
});
delete("/eliminarAlumno", (request, response) -> {
put("/editarTutor", (request, response) -> {
String payload = request.body();
Usuario usuario = gson.fromJson(payload, Usuario.class);
boolean verificado = DAO.eliminarAlumno(usuario.getId());
Tutor tutor = gson.fromJson(payload, Tutor.class);
boolean verificado = DAOTutor.editarTutor(tutor);
JsonObject respuesta = new JsonObject();
respuesta.addProperty("existe", verificado);
respuesta.addProperty("Editado", verificado);
return respuesta;
});
post("/agregarTutor", (request, response) -> {
String payload = request.body();
Tutor tutor = gson.fromJson(payload, Tutor.class);
Boolean agregado = DAOTutor.agregarTutor(tutor);
JsonObject respuesta = new JsonObject();
respuesta.addProperty("msj", agregado);
return respuesta;
});
@ -82,6 +95,7 @@ public class App {
respuesta.addProperty("matricula", usuario.getMatricula());
respuesta.addProperty("authToken", usuario.crearToken());
respuesta.addProperty("authRol", usuario.getRol());
respuesta.addProperty("authId", usuario.getId());
respuesta.addProperty("message", "Binevenido " + usuario.getNombre());
return gson.toJson(respuesta);
});
@ -95,9 +109,24 @@ public class App {
return respuesta;
});
post("/traerDatosAlumno", (request, response) -> {
String payload = request.body();
response.type("application/json");
Usuario u = gson.fromJson(payload, Usuario.class);
return gson.toJson(DAO.traeUsuario(u.getId()));
});
get("/carreras", (request, response) -> {
response.type("application/json");
return gson.toJson(DAO_Carrrera.dameCarreras());
});
post("/traerDatosTutor", (request, response) -> {
String payload = request.body();
response.type("application/json");
Usuario u = gson.fromJson(payload, Usuario.class);
return gson.toJson(DAOTutor.tarerTutor(u.getId()));
});
}
}

View File

@ -6,6 +6,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.google.gson.JsonElement;
import mx.uv.Model.Usuario;
import mx.uv.Model.Mensaje;
import mx.uv.Model.Registro;
@ -52,7 +54,6 @@ public class DAO {
} catch (Exception e) {
System.out.println(e);
} finally {
cerrarConexiones(null, conn);
}
return resultado;
}
@ -78,7 +79,6 @@ public class DAO {
} catch (SQLException ex) {
System.err.println(ex);
} finally {
cerrarConexiones(stm, conn);
}
return verificacion;
}
@ -113,7 +113,6 @@ public class DAO {
} catch (Exception e) {
System.out.println(e);
} finally {
cerrarConexiones(stm, conn);
}
return mensaje;
}
@ -129,24 +128,6 @@ public class DAO {
return contrasena.toString();
}
private static void cerrarConexiones(PreparedStatement stm, Connection conn) {
if (stm != null) {
try {
stm.close();
} catch (Exception e) {
System.out.println(e);
}
}
try {
if (conn != null) {
conn.close();
cn.cerrarConexion();
}
} catch (Exception e) {
System.out.println(e);
}
}
public static boolean eliminarAlumno(int idAlumno) {
return false;
}
@ -157,23 +138,23 @@ public class DAO {
boolean verificacion = false;
conn = cn.conectar();
try {
String sql = "UPDATE " + nombreTabla + " SET " + colNombre + " = ?, " + colApellido + " = ?, "
+ colFechaNacimiento + " = ?, " + colNacionalidad + " = ?, " + colTipoSangre + " = ?, "
+ colContrasena + " = ? WHERE " + colId + " = ?";
String sql = "UPDATE `usuario` SET `nombre` = ?, `apellido` = ?, `correo` = ?, `nacionalidad` = ?, `tipoSangre` = ?, `fecha_nacimiento` = ?, `curp` = ?, `idCarrera` = ? WHERE `id` = ?;";
stm = conn.prepareStatement(sql);
stm.setString(1, usuario.getNombre());
stm.setString(2, usuario.getApellido());
stm.setString(3, usuario.getFecha_nacimiento());
stm.setString(3, usuario.getCorreo());
stm.setString(4, usuario.getNacionalidad());
stm.setString(5, usuario.getTipoSangre());
stm.setString(6, usuario.getContrasena());
stm.setInt(7, usuario.getId());
stm.executeUpdate();
verificacion = true;
stm.setString(6, usuario.getFecha_nacimiento());
stm.setString(7, usuario.getCurp());
stm.setInt(8, usuario.getIdCarrera());
stm.setInt(9, usuario.getId());
if (stm.executeUpdate() > 0) {
verificacion = true;
}
} catch (SQLException ex) {
System.err.println(ex);
} finally {
cerrarConexiones(stm, conn);
cn.cerrarConexion();
}
return verificacion;
@ -199,7 +180,6 @@ public class DAO {
} catch (Exception e) {
System.out.println(e);
} finally {
cerrarConexiones(null, conn);
}
return usuario;
}
@ -233,4 +213,31 @@ public class DAO {
}
return ultimoID;
}
public static Usuario traeUsuario(int id) {
PreparedStatement stm = null;
Connection conn = null;
Usuario user = null;
ResultSet rs = null;
conn = cn.conectar();
try {
String sql = "SELECT `id`,`nombre`,`apellido`,`matricula`,`correo`,`nacionalidad`,`tipoSangre`,`fecha_nacimiento`,`curp`,`idCarrera`,`inscrito`\n"
+ //
"FROM `usuario` where id = ? ;";
stm = conn.prepareStatement(sql);
stm.setInt(1, id);
rs = stm.executeQuery();
while (rs.next()) {
user = new Usuario(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9), rs.getInt(10),
rs.getInt(11));
}
} catch (SQLException ex) {
System.err.println(ex);
} finally {
}
return user;
}
}

View File

@ -27,7 +27,7 @@ public class DAOTutor {
stm = conn.createStatement();
rs = stm.executeQuery(sql);
while (rs.next()) {
Tutor u = new Tutor(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getInt(5));
Tutor u = new Tutor(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getInt(4), rs.getInt(5));
resultado.add(u);
}
} catch (Exception e) {
@ -72,7 +72,7 @@ public class DAOTutor {
stm = (PreparedStatement) conn.prepareStatement(sql);
stm.setString(1, tutor.getNombre());
stm.setString(2, tutor.getApellido());
stm.setString(3, tutor.getNumeroDeTelefono());
stm.setInt(3, tutor.getNumeroDeTelefono());
stm.setInt(4, tutor.getIdUsuario());
} catch (Exception e) {
System.out.println(e);
@ -109,11 +109,15 @@ public class DAOTutor {
boolean verificacion = false;
conn = cn.conectar();
try {
String sql = "UPDATE `tutor` SET `nombre` = '" + tutor.getNombre() + "',`apellido` = '"
+ tutor.getApellido() + "';";
String sql = "UPDATE `tutor` SET `nombre` = ?, `apellido` = ?, `numeroDeTelefono` = ? WHERE `idUsuario` = ?;";
stm = conn.prepareStatement(sql);
stm.executeQuery();
verificacion = true;
stm.setString(1, tutor.getNombre());
stm.setString(2, tutor.getApellido());
stm.setInt(3, tutor.getNumeroDeTelefono());
stm.setInt(4, tutor.getIdUsuario());
if (stm.executeUpdate() > 0) {
verificacion = true;
}
} catch (SQLException ex) {
System.out.println(ex);
} finally {
@ -123,4 +127,30 @@ public class DAOTutor {
return verificacion;
}
public static Tutor tarerTutor(int id) {
PreparedStatement stm = null;
Connection conn = null;
Tutor tutor = null;
ResultSet rs = null;
conn = cn.conectar();
try {
String sql = "SELECT `id`,`nombre`,`apellido`,`numeroDeTelefono`,`idUsuario`\n"
+
"FROM `tutor` where idUsuario = ? ;";
stm = conn.prepareStatement(sql);
stm.setInt(1, id);
rs = stm.executeQuery();
if (rs.next()) {
tutor = new Tutor(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getInt(4), rs.getInt(5));
}
} catch (SQLException ex) {
System.err.println(ex);
} finally {
cerrarConexiones(stm, conn);
cn.cerrarConexion();
}
return tutor;
}
}

View File

@ -15,7 +15,7 @@ public class DAO_Carrrera {
ResultSet rs = null;
Connection conn = null;
List<Carrera> resultado = new ArrayList<>();
System.out.println("Aqui");
conn = cn.conectar();
try {
@ -30,86 +30,9 @@ public class DAO_Carrrera {
} catch (Exception e) {
System.out.println(e);
} finally {
cerrarConexiones(null, conn);
}
return resultado;
}
/*
* public static boolean agregarCarrera(Carrera carrera) {
* PreparedStatement stm = null;
* Connection conn = null;
* boolean msj = false;
*
* conn = cn.conectar();
*
* try {
* String sql =
* "INSERT INTO `carrera` (`area`,`nombre`, `modalidad`, `campus`, `costo`) VALUES(?,?,?,?,?);"
* ;
* stm = (PreparedStatement) conn.prepareStatement(sql);
* stm.setString(1, carrera.getArea());
* stm.setString(2, carrera.getNombre());
* stm.setString(3, carrera.getModalidad());
* stm.setString(4, carrera.getCampus());
* stm.setDouble(5, carrera.getCosto());
*
* } catch (Exception e) {
* System.out.println(e);
* } finally {
* cerrarConexiones(stm, conn);
* }
* return msj;
* }
*/
private static void cerrarConexiones(PreparedStatement stm, Connection conn) {
if (stm != null) {
try {
stm.close();
} catch (Exception e) {
System.out.println(e);
}
stm = null;
}
try {
conn.close();
cn.cerrarConexion();
} catch (Exception e) {
System.out.println(e);
}
}
public static boolean eliminarCarrera(int idCarrera) {
return false;
}
/*
* public static boolean editarCarrera(Carrera carrera) {
* PreparedStatement stm = null;
* Connection conn = null;
* boolean verificacion = false;
* conn = cn.conectar();
*
* try {
* String sql = "UPDATE `alumno` SET `area` = '" + carrera.getArea() +
* "',`nombre` = '" + carrera.getNombre()
* + "',`modalidad` = '" + carrera.getModalidad() + "',`campus` = '"
* + carrera.getCampus() + "', `costo` = '" + carrera.getCosto() +
* "' WHERE `id` = '"
* + carrera.getId() + "';";
* stm = conn.prepareStatement(sql);
* stm.executeUpdate();
* verificacion = true;
* } catch (SQLException ex) {
* System.err.println(ex);
* } finally {
* cerrarConexiones(stm, conn);
* cn.cerrarConexion();
* }
* return verificacion;
* }
*/
}

View File

@ -81,37 +81,27 @@ public class DAO_Documentacion {
return false;
}
public static boolean editarDocumentacion(Documento documentacion) {
public static boolean agregarDocumento(Documento doc) {
PreparedStatement stm = null;
Connection conn = null;
boolean verificacion = false;
conn = cn.conectar();
boolean msj = false;
conn = cn.conectar();
String sql = "INSERT INTO documento (titulo, archivo, idUsuario, valido) VALUES (?, ?, ?, ?)";
try {
/*
* String sql = "UPDATE `documentacion` SET `acta_nacimiento` = '" +
* documentacion.getActaNacimiento()
* + "',`certificado_bachillerato` = '" +
* documentacion.getCertificadoBachillerato() + "',`curp` = '"
* + documentacion.getCurp() + "',`ine` = '" + documentacion.getIne() +
* "', `ine_tutor` = '"
* + documentacion.getIneTutor() + "',`certificado_medico` = '" +
* documentacion.getCertificadoMedico()
* + "',`comprobante` = '" + documentacion.getComprobante() +
* "',`fotografia` = '"
* + documentacion.getFotografia() + "',`constancia` = '" +
* documentacion.getConstancia()
* + "' WHERE `id` = '" + documentacion.getId() + "';";
*/
stm = conn.prepareStatement("");
stm.executeUpdate();
verificacion = true;
} catch (SQLException ex) {
System.err.println(ex);
} finally {
cerrarConexiones(stm, conn);
cn.cerrarConexion();
stm = conn.prepareStatement(sql);
stm.setString(1, doc.getTitulo());
stm.setBlob(2, doc.getArchivo());
stm.setInt(3, doc.getIdUsuario());
stm.setInt(4, doc.getValido());
if (stm.executeUpdate() > 0) {
msj = true;
}
} catch (SQLException e) {
e.printStackTrace();
// Manejar cualquier excepción y retornar falso en caso de error
}
return verificacion;
return msj;
}
}

View File

@ -1,14 +1,16 @@
package mx.uv.Model;
import java.io.InputStream;
public class Documento {
private int id;
private String titulo;
private byte[] archivo;
private InputStream archivo;
private int idUsuario;
private int valido;
public Documento(int id, String titulo, byte[] archivo, int idUsuario, int valido) {
this.id = id;
public Documento(String titulo, InputStream archivo, int idUsuario, int valido) {
this.titulo = titulo;
this.archivo = archivo;
this.idUsuario = idUsuario;
@ -23,7 +25,7 @@ public class Documento {
return titulo;
}
public byte[] getArchivo() {
public InputStream getArchivo() {
return archivo;
}
@ -43,7 +45,7 @@ public class Documento {
this.titulo = titulo;
}
public void setArchivo(byte[] archivo) {
public void setArchivo(InputStream archivo) {
this.archivo = archivo;
}

View File

@ -4,10 +4,10 @@ public class Tutor {
private int id;
private String nombre;
private String apellido;
private String numeroDeTelefono;
private int numeroDeTelefono;
private int idUsuario;
public Tutor(int id, String nombre, String apellido, String numeroDeTelefono, int idUsuario) {
public Tutor(int id, String nombre, String apellido, int numeroDeTelefono, int idUsuario) {
this.id = id;
this.nombre = nombre;
this.apellido = apellido;
@ -27,7 +27,7 @@ public class Tutor {
return apellido;
}
public String getNumeroDeTelefono() {
public int getNumeroDeTelefono() {
return numeroDeTelefono;
}
@ -47,7 +47,7 @@ public class Tutor {
this.apellido = apellido;
}
public void setNumeroDeTelefono(String numeroDeTelefono) {
public void setNumeroDeTelefono(int numeroDeTelefono) {
this.numeroDeTelefono = numeroDeTelefono;
}

View File

@ -35,7 +35,6 @@ public class Usuario {
this.inscrito = inscrito;
}
public Usuario(int id, String nombre, String apellido, String matricula) {
this.id = id;
this.nombre = nombre;
@ -43,8 +42,6 @@ public class Usuario {
this.matricula = matricula;
}
public Usuario(int id, String nombre, String apellido, String matricula, String rol) {
this.id = id;
this.nombre = nombre;
@ -53,6 +50,20 @@ public class Usuario {
this.rol = rol;
}
public Usuario(int id, String nombre, String apellido, String matricula, String correo, String nacionalidad,
String tipoSangre, String fecha_nacimiento, String curp, int idCarrera, int inscrito) {
this.id = id;
this.nombre = nombre;
this.apellido = apellido;
this.matricula = matricula;
this.correo = correo;
this.nacionalidad = nacionalidad;
this.tipoSangre = tipoSangre;
this.fecha_nacimiento = fecha_nacimiento;
this.curp = curp;
this.idCarrera = idCarrera;
this.inscrito = inscrito;
}
public Usuario(String matricula, String contrasena) {
this.matricula = matricula;

View File

@ -17,11 +17,13 @@ function App() {
<BrowserRouter>
<Nav />
<Routes>
<Route path="/login" element={<Login />} />
<Route path="/registro" element={<Registro />} />
<Route element={<ProtectorDeRutas />}>
<Route path="/home" element={<OfertaEducativa />} />
<Route path="/info" element={<Informacion />} />
<Route path="/" />
<Route element={<ProtectorAdmin />}>
<Route path="/inscripcion" element={<Inscripcion />} />
</Route>

View File

@ -7,6 +7,7 @@ const Nav = () => {
storage.remove("authToken");
storage.remove("authUser");
storage.remove("authRol");
storage.remove("authId");
go("/login");
};
return (

View File

@ -4,7 +4,7 @@ import storage from "../Storage/storage";
export const ProtectorDeRutas = ({ children }) => {
const authUser = storage.get("authToken");
if (!authUser) {
if (!authUser ) {
return <Navigate to="/login" />;
}
return <Outlet />;

View File

@ -1,134 +1,312 @@
import React from 'react';
import { useNavigate, NavLink } from "react-router-dom";
import { sendRequest } from "../funciones";
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import DivInput from "../Components/divInput";
import storage from "../Storage/storage";
import { useNavigate } from 'react-router-dom';
const Inscripcion = () => {
const go = useNavigate();
const [user] = useState({ id: storage.get('authId') });
const [carreraSeleccionada, setCarreraSeleccionada] = useState('');
const [usuario, setUsuario] = useState({
id: 0,
nombre: "",
apellido: "",
matricula: "",
correo: "",
nacionalidad: "",
tipoSangre: "",
fecha_nacimiento: "",
curp: "",
idCarrera: 0
});
const [tutor, setTutor] = useState({
id: 0,
nombre: "",
apellido: "",
numeroDeTelefono: "",
idUsuario: storage.get('authId')
});
const [carrera, setCarrera] = useState([]);
const [actaN, setActaN] = useState({
id: 0,
titulo: "",
archivo: null,
idUsuario: 0,
valido: null
});
useEffect(() => {
const fetchData = async () => {
try {
const resUsuario = await axios.post("/traerDatosAlumno", user);
if (resUsuario.status === 200) {
setUsuario((prevUsuario) => ({
...prevUsuario,
id: resUsuario.data.id || 0,
nombre: resUsuario.data.nombre || "",
apellido: resUsuario.data.apellido || "",
matricula: resUsuario.data.matricula || "",
correo: resUsuario.data.correo || "",
nacionalidad: resUsuario.data.nacionalidad || "",
tipoSangre: resUsuario.data.tipoSangre || "",
fecha_nacimiento: resUsuario.data.fecha_nacimiento || "",
curp: resUsuario.data.curp || "",
idCarrera: resUsuario.data.idCarrera || 0
}));
} else {
console.log('Error: No hay usuario');
}
} catch (error) {
console.log(error);
}
try {
const resTutor = await axios.post("/traerDatosTutor", user);
if (resTutor.status === 200) {
setTutor({
id: resTutor.data.id,
nombre: resTutor.data.nombre || "",
apellido: resTutor.data.apellido || "",
numeroDeTelefono: resTutor.data.numeroDeTelefono || "",
idUsuario: resTutor.data.idUsuario || 0
});
} else {
console.log('Error: No hay tutor');
}
} catch (error) {
console.error('Error:', error);
}
try {
const resCarrera = await axios.get("/carreras", user);
if (resCarrera.status === 200) {
setCarrera(resCarrera.data);
} else {
console.log('Error: No hay Carrera');
}
} catch (error) {
console.error('Error:', error);
}
};
fetchData();
}, [user]);
const handleInputChange = (e) => {
const { name, value } = e.target;
setUsuario((prevUsuario) => ({
...prevUsuario,
[name]: value
}));
};
const handleTutorInputChange = (e) => {
const { name, value } = e.target;
setTutor((prevTutor) => ({
...prevTutor,
[name]: value
}));
};
const handleFileChange = (e) => {
const file = e.target.files[0];
const fileName = `${usuario.matricula}_ActaN.pdf`;
const modifiedFile = new File([file], fileName, { type: file.type });
setActaN((prevActaN) => ({
...prevActaN,
archivo: modifiedFile
}));
};
const handleCarreraChange = (e) => {
const selectedCarreraId = e.target.value;
setCarreraSeleccionada(selectedCarreraId);
setUsuario((prevUsuario) => ({
...prevUsuario,
idCarrera: parseInt(selectedCarreraId, 10)
}));
};
const subir = async (e) => {
e.preventDefault();
try {
if (tutor.id === 0) {
setTutor({
idUsuario: usuario.id
});
const res = await axios.post(`/agregarTutor`, tutor);
if (res.status === 200) {
console.log('Tutor agregado exitosamente:', res.data);
}
} else {
const res = await axios.put(`/editarTutor`, tutor);
if (res.status === 200) {
console.log('Tutor actualizado exitosamente:', res.data);
}
}
const resUsuario = await axios.put(`/editarUsuario`, usuario);
if (resUsuario.status === 200) {
console.log('Usuario actualizado exitosamente:', resUsuario.data);
}
const formData = new FormData();
formData.append('titulo', `${usuario.matricula}_ActaN`);
formData.append('archivo', actaN.archivo);
formData.append('idUsuario', usuario.id);
fetch('http://localhost:3000/agregarDocumentoAN',{
method: 'POST',
body: formData
}).then(res=>res.text())
.then(res => console.log(res))
.catch(err=>{
console.error(err)
})
setActaN(null)
} catch (error) {
console.error('Error al subir los datos:', error);
//window.location.reload();
}
};
return (
<div className='container'>
<div className='nbn'>
<form>
<form onSubmit={subir}>
<div className="mb-4">
<h5>Datos Personales</h5>
<DivInput
type="text"
name="nombre"
value={usuario.nombre}
className="form-control mb-3"
placeholder="Nombre"
required
handleChange={handleInputChange}
/>
<DivInput
type="text"
name="apellido"
value={usuario.apellido}
className="form-control mb-3"
placeholder="Apellido"
required
handleChange={handleInputChange}
/>
<DivInput
type="email"
name="correo"
value={usuario.correo}
className="form-control mb-3"
placeholder="Correo Electrónico"
required
handleChange={handleInputChange}
/>
<DivInput
type="text"
name="nacionalidad"
value={usuario.nacionalidad}
className="form-control mb-3"
placeholder="Nacionalidad"
required
handleChange={handleInputChange}
/>
<DivInput
type="text"
name="tipoSangre"
value={usuario.tipoSangre}
className="form-control mb-3"
placeholder="Tipo de Sangre"
required
handleChange={handleInputChange}
/>
<h7>Fecha de Nacimiento</h7>
<h6>Fecha de Nacimiento</h6>
<DivInput
type="date"
name="fechaNacimiento"
name="fecha_nacimiento"
value={usuario.fecha_nacimiento}
className="form-control mb-3"
placeholder="Fecha de Nacimiento"
required
handleChange={handleInputChange}
/>
<DivInput
type="text"
name="curp"
value={usuario.curp}
className="form-control mb-3"
placeholder="CURP"
required
handleChange={handleInputChange}
/>
</div>
<div className="mb-4">
<h5>Datos del Tutor</h5>
<DivInput
type="text"
name="nombreTutor"
name="nombre"
value={tutor.nombre}
className="form-control mb-3"
placeholder="Nombre"
required
handleChange={handleTutorInputChange}
/>
<DivInput
type="text"
name="apellidoTutor"
name="apellido"
value={tutor.apellido}
className="form-control mb-3"
placeholder="Apellidos"
required
handleChange={handleTutorInputChange}
/>
<DivInput
type="tel"
name="numeroDeTelefono"
value={tutor.numeroDeTelefono}
className="form-control mb-3"
placeholder="Número de Teléfono"
required
handleChange={handleTutorInputChange}
/>
</div>
<div className="mb-4">
<h5>Carrera</h5>
<select
id="carreraSelect"
className="form-control"
value={carreraSeleccionada}
onChange={handleCarreraChange}
>
<option value="" disabled>Selecciona una carrera</option>
{carrera.map((carrera) => (
<option key={carrera.id} value={carrera.id}>
{carrera.nombre}
</option>
))}
</select>
</div>
<div className="mb-4">
<h5>Documentación</h5>
<h6>Acta De Nacimiento</h6>
<input
type="file"
name="actaDeNacimiento"
name="archivo"
className="form-control mb-3"
accept=".pdf"
placeholder="Acta de Nacimiento"
required
/>
<h6>Constancia De Estudio</h6>
<input
type="file"
name="constanciaDeEstudios"
className="form-control mb-3"
accept=".pdf"
placeholder="Constancia de Estudios"
required
/>
<h6>Fotografia</h6>
<input
type="file"
name="fotografia"
className="form-control mb-3"
accept=".pdf"
placeholder="Fotografía"
required
/>
<h6>Certificado Medico</h6>
<input
type="file"
name="certificadoMedico"
className="form-control mb-3"
accept=".pdf"
placeholder="Certificado Médico"
required
onChange={handleFileChange}
/>
</div>
<button type="submit" className="btn btn-primary">Enviar Inscripción</button>
</form>
</div>
</div>
);
}
};
export default Inscripcion;

View File

@ -13,12 +13,13 @@ const Login = () => {
const form = { ...usuario };
try {
const res = await sendRequest("POST", form, "/alumnoIniciado", "", false);
const res = await sendRequest("POST", usuario, "/alumnoIniciado", "", false);
if (res && res.authToken) {
storage.set("authToken", res.authToken);
storage.set("authUser", res.matricula);
storage.set("authRol", res.authRol);
storage.set("authId", res.authId);
const rol =storage.get("authRol");
go("/home")
} else {

View File

@ -8,7 +8,7 @@ import axios from "axios";
window.axios = axios;
window.axios.defaults.baseURL = "http://localhost:4567";
window.axios.defaults.baseURL = "http://localhost:3000";
window.axios.defaults.headers.common["Accept"] = "application/json";
window.axios.defaults.headers.common["Content-Type"] = "application/json";
window.axios.defaults.headers.common["X-Requested-with"] = "XMLHttpRequest";