Commit 67fce730 authored by Stefano Antonio Valdez Peña's avatar Stefano Antonio Valdez Peña
Browse files

Corrccion en rechazo de horario

parent 524073bd
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -13,8 +13,9 @@ function InicioDocente() {
  const [searchTerm, setSearchTerm] = useState(""); // Estado para el filtro de búsqueda
  const navigate = useNavigate();
  
  const nombreDocente = localStorage.getItem("matricula");

  const { nombre, matricula: matriculaDocente } = location.state || {};
  const nombreDocente = location.state?.nombre;

    // Guardar la matrícula del tutor en localStorage
    useEffect(() => {
@@ -25,7 +26,7 @@ function InicioDocente() {
  
    // Obtener la matrícula y nombre del docente desde localStorage si no está en location.state
    const storedMatriculaDocente = localStorage.getItem("matriculaDocente");
    // 🔒 Evitar que el usuario regrese a la pantalla anterior con el botón de retroceso
    // Evitar que el usuario regrese a la pantalla anterior con el botón de retroceso
    useEffect(() => {
      const bloquearAtras = () => {
        window.history.pushState(null, null, window.location.href);
@@ -39,7 +40,7 @@ function InicioDocente() {
      };
    }, []);

  console.log("Estado recibido:", location.state);
  console.log("Estado recibido:", location.state, matriculaDocente, storedMatriculaDocente);

    useEffect(() => {
      const fetchAlumnos = async () => {
@@ -94,8 +95,15 @@ function InicioDocente() {
        }
      };

      // Recarga si location.state.reload es true, igual que en InicioTutor
      if (location.state && location.state.reload) {
        fetchAlumnos();
        // Limpiar la bandera para evitar recargas infinitas
        navigate(location.pathname, { replace: true, state: { ...location.state, reload: false } });
      } else {
        fetchAlumnos();
    }, [matriculaDocente, storedMatriculaDocente]);
      }
    }, [matriculaDocente, storedMatriculaDocente, location.state]);


    useEffect(() => {
@@ -113,8 +121,8 @@ function InicioDocente() {
    }, []);

  const handleRevisarHorario = (alumno) => {
    console.log("Navegando a: ", `/revisar-horario/${alumno.matricula}`);
    navigate(`/docente/revisar-horario/${alumno.matricula}`, { state: { nombre: alumno.nombre, matricula: alumno.matricula, matriculaDocente, id_carrera: alumno.id_carrera} });
    console.log("Navegando a: ", `/revisar-horario/${alumno.matricula}, ${matriculaDocente}`);
    navigate(`/docente/revisar-horario/${alumno.matricula}`, { state: { nombre: alumno.nombre, matricula: alumno.matricula, matriculaTutor: matriculaDocente, id_carrera: alumno.id_carrera} });
  };

  const handleDownloadCSV = async () => {
+9 −2
Original line number Diff line number Diff line
@@ -105,8 +105,15 @@ function InicioTutor() {
      }
    };

    // Si location.state.reload es true, recargar los datos
    if (location.state && location.state.reload) {
      fetchAlumnos();
  }, [matriculaTutor, storedMatriculaTutor]);
      // Limpiar la bandera para evitar recargas infinitas
      navigate(location.pathname, { replace: true, state: { ...location.state, reload: false } });
    } else {
      fetchAlumnos();
    }
  }, [matriculaTutor, storedMatriculaTutor, location.state]);

  const handleRevisarHorario = (alumno) => {
    console.log("alumno:", alumno);
+17 −4
Original line number Diff line number Diff line
@@ -13,9 +13,10 @@ function RevisionHorarioTutor() {
  // Recuperar el estado (nombre y matricula) desde la navegación
  const location = useLocation();
  const id_carrera = localStorage.getItem("id_carrera");
  const { nombre, matricula, matriculaTutor, matriculaDocente, origen } = location.state || {};
  const { nombre, matricula, matriculaTutor, origen } = location.state || {};
  const carrerasPermitidasSemiescolarizadas = ['ISftwS', 'IDsrS', 'IEIndS', 'ICmpS', 'IRMcaS', 'IElecS'];
  console.log("Nombre y matrícula del tutor:", nombre, matricula, matriculaTutor, id_carrera);

  useEffect(() => {
    fetch(`http://localhost:5000/api/tutores/horario/${matricula}`)
      .then(response => response.json())
@@ -72,16 +73,28 @@ function RevisionHorarioTutor() {
      if (!response.ok) {
        throw new Error("Error al actualizar el estatus");
      }
      //esperar 1 segundo antes de navegar
      navigate(-1); // Regresar a la página anterior
  
      // Usar matriculaTutor de props o de localStorage como fallback
      const tutorMatricula = matriculaTutor || localStorage.getItem("matriculaTutor") || "";

      
      // Filtrar por la matrícula para determinar el tipo de usuario
      if (tutorMatricula.startsWith("T")) {
        navigate("/tutor", { state: { reload: true } });
      } else if (tutorMatricula.startsWith("P")) {
        // Regresar a la vista principal de docente (no a /docente/alumnos)
        navigate("/docente/alumnos", { state: { reload: true } });
      } else {
        navigate(-1);
      }

      if (nuevoEstatus === 0) { // Si está rechazado
        await eliminarHorario(); // Esperar a que se complete
  
        //await enviarComentarioCorreo(); // Esperar a que se complete
      }
    } catch (error) {
      alert("Hubo un error al actualizar el estatus.");
      console.error("Error al actualizar el estatus:", error);
    }
  };

+20 −15
Original line number Diff line number Diff line
@@ -135,25 +135,30 @@
  .top-right {
    position: absolute;
    top: 10px;
    right: 10px;
    right: 0;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    pointer-events: none; /* Para evitar que el contenedor capture eventos */
  }

  .logout-button {
    background-color: #f44336; /* Color de fondo del botón */
    color: white; /* Color del texto */
    border: none; /* Sin borde */
    padding: 10px 20px; /* Espaciado interno */
    text-align: center; /* Alineación del texto */
    text-decoration: none; /* Sin subrayado */
    display: inline-block; /* Mostrar en línea */
    font-size: 16px; /* Tamaño de la fuente */
    margin: 4px 2px; /* Margen */
    cursor: pointer; /* Cambiar el cursor al pasar sobre el botón */
    border-radius: 12px; /* Bordes redondeados */
    background-color: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 20px 4px 2px; /* margen derecho mayor */
    cursor: pointer;
    border-radius: 12px;
    pointer-events: auto; /* Permite que el botón capture eventos */
  }

  .logout-button:hover {
    background-color: #d32f2f; /* Color de fondo al pasar el cursor */
    background-color: #d32f2f;
  }

  
+4 −4
Original line number Diff line number Diff line
@@ -128,14 +128,14 @@ function Validacion2() {
    <div className="validacion-layout">
      <ToastContainer />
      <div className="validacion-container">
        <h2>Validación de horario</h2>
        <h4><strong>{nombreAlumno || "Cargando..."}</strong></h4>
        <h4>Matricula: <strong>{matricula || "Cargando..."}</strong></h4>
        <div className="top-right">
        <div style={{ display: "flex", justifyContent: "flex-end", width: "100%" }}>
          <button className="logout-button" onClick={handleLogout}>
            Cerrar sesión
          </button>
        </div>
        <h2>Validación de horario</h2>
        <h4><strong>{nombreAlumno || "Cargando..."}</strong></h4>
        <h4>Matricula: <strong>{matricula || "Cargando..."}</strong></h4>

        {estatusHorario === 0 ? (
          <>