tring to fix sanciones

This commit is contained in:
2025-09-26 17:42:52 -06:00
parent 3bd6d6b7c2
commit d13ceed45e
4 changed files with 128 additions and 88 deletions
-2
View File
@@ -1,5 +1,3 @@
"use client";
import BitacoraAlumno from "@/app/Components/Reportes/BitacoraSanciones/BitacoraAlumno";
import BitacoraEquipo from "@/app/Components/Reportes/BitacoraSanciones/BitacoraEquipo";
import BitacoraMesas from "@/app/Components/Reportes/BitacoraSanciones/BitacoraMesas";
+2 -4
View File
@@ -3,10 +3,10 @@ import Receipt from "../../Components/Receipt/Receipt";
import Toggle from "../../Components/Global/Toggle/Toggle";
import Information from "../../Components/Global/Information/information";
import AlertBox from "@/app/Components/Global/AlertBox/AlertBox";
import Impressions from "@/app/Components/Servicios/Impressions/impressions";
import { GetStudent } from "@/app/lib/getStudent";
import "@/app/globals.css";
import Impressions from "@/app/Components/Servicios/Impressions/impressions";
export default async function Page(props: {
searchParams?: Promise<{
@@ -46,7 +46,7 @@ export default async function Page(props: {
<h2 className="title">IMPRESIONES Y PLOTEO</h2>
<SearchUser urlBase="Impresiones" value={numAcount} />
{student ? (
{student && (
<>
<Information
NoCuenta={student.id_cuenta}
@@ -138,8 +138,6 @@ export default async function Page(props: {
]}
/>
</>
) : (
<></>
)}
</section>
);
@@ -1,97 +1,49 @@
"use client";
import { useEffect, useState } from "react";
import styles from "./Page.module.css";
import SearchUser from "../../Global/SearchUser/searchUser";
import Information from "../../Global/Information/information";
import AlertBox from "../../Global/AlertBox/AlertBox";
import { GetStudent } from "@/app/lib/getStudent";
import { envConfig } from "@/app/lib/config";
interface sancion {
no_cuenta: number;
nombre: string;
motivo: string;
duracion: number;
fecha_sancion: string;
utilizar_hasta: number;
}
export default async function Sanciones(props: {
searchParams?: Promise<{
numAcount: string;
success?: string;
error?: string;
}>;
}) {
const params = await props.searchParams;
const numAcount = params?.numAcount ? params.numAcount : null;
const showSuccess = params?.success ? params.success : null;
let showError = params?.error ? params.error : null;
export default function Sanciones() {
const [sanciones, setSanciones] = useState<sancion[]>([]);
const [ubicacion_equipo, setUbicacionEquipo] = useState("");
const [no_cuenta, setNo_cuenta] = useState("");
let student: any = null;
useEffect(() => {
fetch(`${envConfig.apiUrl}/student/${no_cuenta}`).then(
(
response // Revisar
) => response.json().then((data) => setNo_cuenta(data[0].sancion))
);
}, [no_cuenta]);
if (numAcount) {
const result = await GetStudent(parseInt(numAcount));
if (result.error) {
showError = "alumno no encontrado";
} else {
student = result;
}
}
return (
<>
<SearchUser urlBase="BitacoraSanciones" value="3" />
{showError && (
<>
<AlertBox key={Date.now()} message={showError} type="error" />
</>
)}
{/* <Information NoCuenta={sancion.id_cuenta} Nombre={student.nombre} /> */}
{showSuccess && (
<AlertBox key={Date.now()} message={showSuccess} type="success" />
)}
<form className="containerForm">
<label className="label">Ubicacion de equipo</label>
<SearchUser urlBase="BitacoraSanciones" value={numAcount} />
<div
className="groupInput"
style={{ display: "flex", gap: "1rem", flexDirection: "row" }}
>
<select
value={ubicacion_equipo}
onChange={(e) => setUbicacionEquipo(e.target.value)}
>
<option value="">-- Selecciona un equipo --</option>
<option value="255">Equipo 255</option>
</select>
<button className="button buttonSearch" type="submit">
Asignar
</button>
</div>
</form>
<div className={styles.tableContainer}>
<table className={styles.machineTable}>
<thead>
<tr>
<th>Cuenta</th>
<th>Motivo de la sancion</th>
<th>Duracion (Semanas) </th>
<th>Fecha Sancion</th>
<th>Podra utilizar el servicio hasta</th>
</tr>
</thead>
<tbody>
{sanciones.map((sancion, index) => (
<tr key={index}>
<td>{sancion.no_cuenta}</td>
<td>{sancion.motivo}</td>
<td>{sancion.fecha_sancion}</td>
<td>{sancion.duracion}</td>
<td>{sancion.utilizar_hasta}</td>
</tr>
))}
</tbody>
</table>
</div>
<form className="containerForm">
<div className="groupInput">
<select
value={ubicacion_equipo}
onChange={(e) => setUbicacionEquipo(e.target.value)}
>
<option value="">-- Selecciona una sancion --</option>
<option value="sancion 1">No cerrar sesion (Una semana)</option>
</select>
<button className="button buttonSearch" type="submit">
Aplicar sancion
</button>
</div>
</form>
{student && (
<Information NoCuenta={student.id_cuenta} Nombre={student.nombre} />
)}
</>
);
}
@@ -0,0 +1,92 @@
import { useState } from "react";
import styles from "./Page.module.css";
interface alumno_sancion {
id_alumno_sancion: number;
fecha_inicio: string;
alumno: alumno;
sancion: sancion;
}
interface alumno {
id_cuenta: number;
nombre: string;
credito: number;
}
interface sancion {
id_sancion: number;
sancion: string;
duracion: number;
}
export default function UbicacionEquipo() {
const [ubicacionEquipo, setUbicacionEquipo] = useState("");
const [sanciones, setSanciones] = useState<>([]);
return (
<>
<form className="containerForm">
<label className="label">Ubicacion de equipo</label>
<div
className="groupInput"
style={{ display: "flex", gap: "1rem", flexDirection: "row" }}
>
<select
value={ubicacionEquipo}
onChange={(e) => setUbicacionEquipo(e.target.value)}
>
<option value="">-- Selecciona un equipo --</option>
<option value="255">Equipo 255</option>
</select>
<button className="button buttonSearch" type="submit">
Asignar
</button>
</div>
</form>
<div className={styles.tableContainer}>
<table className={styles.machineTable}>
<thead>
<tr>
<th>Cuenta</th>
<th>Motivo de la sancion</th>
<th>Duracion (Semanas) </th>
<th>Fecha Sancion</th>
<th>Podra utilizar el servicio hasta</th>
</tr>
</thead>
<tbody>
{sanciones &&
sanciones.map((sancion, index) => (
<tr key={index}>
<td>{sancion.id_sancion}</td>
<td>{sancion.sancion}</td>
<td>{sancion.fecha_sancion}</td>
<td>{sancion.duracion}</td>
<td>{sancion.utilizar_hasta}</td>
</tr>
))}
</tbody>
</table>
</div>
<form className="containerForm">
<div className="groupInput">
<select
value={ubicacionEquipo}
onChange={(e) => setUbicacionEquipo(e.target.value)}
>
<option value="">-- Selecciona una sancion --</option>
<option value="sancion 1">No cerrar sesion (Una semana)</option>
</select>
<button className="button buttonSearch" type="submit">
Aplicar sancion
</button>
</div>
</form>
</>
);
}
//IO