funcionabilidad de botones componentes y arreglos
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
NEXT_PUBLIC_API_URL=
|
|
||||||
@@ -2,41 +2,83 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function Areas() {
|
export default function Areas() {
|
||||||
const [tiempo, setTiempo] = useState("");
|
const [area, setArea] = useState(""); // Área seleccionada
|
||||||
|
const [activo, setActivo] = useState(false); // Checkbox Activo
|
||||||
|
const [mantenimiento, setMantenimiento] = useState(false); // Checkbox Mantenimiento
|
||||||
|
const [mensaje, setMensaje] = useState(""); // Mensaje dinámico
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleActualizar = (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("Equipo asignado con tiempo:", tiempo);
|
|
||||||
|
if (!area) {
|
||||||
|
setMensaje("Selecciona un área antes de actualizar");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crear mensaje dinámico
|
||||||
|
const estado = [];
|
||||||
|
if (activo) estado.push("Activo");
|
||||||
|
if (mantenimiento) estado.push("Mantenimiento");
|
||||||
|
const estadosSeleccionados = estado.length
|
||||||
|
? estado.join(" y ")
|
||||||
|
: "Sin estado";
|
||||||
|
|
||||||
|
setMensaje(`Área ${area} actualizada con estado: ${estadosSeleccionados}`);
|
||||||
|
|
||||||
|
// Aquí puedes enviar los datos al backend si quieres
|
||||||
|
console.log({
|
||||||
|
area,
|
||||||
|
activo,
|
||||||
|
mantenimiento,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="containerForm" onSubmit={handleSubmit}>
|
<form className="containerForm" onSubmit={handleActualizar}>
|
||||||
<label className="label">Áreas disponibles</label>
|
<label className="label">Áreas disponibles:</label>
|
||||||
<div className="groupInput">
|
<div className="groupInput">
|
||||||
<select value={tiempo} onChange={(e) => setTiempo(e.target.value)}>
|
{/* Select de áreas */}
|
||||||
|
<select value={area} onChange={(e) => setArea(e.target.value)}>
|
||||||
<option value="">-- Áreas disponibles --</option>
|
<option value="">-- Áreas disponibles --</option>
|
||||||
<option value="15">PECERA</option>
|
<option value="PECERA">PECERA</option>
|
||||||
<option value="30">JAULA</option>
|
<option value="JAULA">JAULA</option>
|
||||||
<option value="45">HUACAL</option>
|
<option value="HUACAL">HUACAL</option>
|
||||||
<option value="60">PCNET1</option>
|
<option value="PCNET1">PCNET1</option>
|
||||||
<option value="90">PCNET2</option>
|
<option value="PCNET2">PCNET2</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<div className="checkbox-grid">
|
{/* Checkboxes */}
|
||||||
<label>
|
<div className="checkbox" style={{ marginTop: "10px" }}>
|
||||||
<input type="checkbox" />
|
<label style={{ marginRight: "10px" }}>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={activo}
|
||||||
|
onChange={(e) => setActivo(e.target.checked)}
|
||||||
|
/>
|
||||||
Activo
|
Activo
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" />
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={mantenimiento}
|
||||||
|
onChange={(e) => setMantenimiento(e.target.checked)}
|
||||||
|
/>
|
||||||
Mantenimiento
|
Mantenimiento
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button className="button buttonSearch" type="submit">
|
{/* Botón Actualizar */}
|
||||||
|
<button
|
||||||
|
className="button buttonSearch"
|
||||||
|
type="submit"
|
||||||
|
style={{ marginTop: "15px" }}
|
||||||
|
>
|
||||||
Actualizar
|
Actualizar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Mensaje dinámico */}
|
||||||
|
{mensaje && <p style={{ marginTop: "20px" }}>{mensaje}</p>}
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,53 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
function Equipos() {
|
function Equipos() {
|
||||||
|
const [cuenta, setCuenta] = useState("");
|
||||||
const [tiempo, setTiempo] = useState("");
|
const [tiempo, setTiempo] = useState("");
|
||||||
|
const [mensaje, setMensaje] = useState("");
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleBuscar = (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("Equipo asignado con tiempo:", tiempo);
|
if (!cuenta) {
|
||||||
|
setMensaje("Ingresa un número de cuenta antes de buscar");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setMensaje(`Buscando información del No. de cuenta: ${cuenta}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAsignar = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!tiempo) {
|
||||||
|
setMensaje("Selecciona un equipo antes de asignar");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setMensaje(`Equipo asignado con tiempo: ${tiempo} minutos`);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="containerForm" onSubmit={handleSubmit}>
|
<div className="containerForm">
|
||||||
<label className="label">Equipos disponibles</label>
|
{/* Formulario Buscar */}
|
||||||
<div className="groupInput">
|
<form onSubmit={handleBuscar} className="groupInput">
|
||||||
|
<label className="label">No. de cuenta:</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={cuenta}
|
||||||
|
onChange={(e) => setCuenta(e.target.value)}
|
||||||
|
placeholder="Ingresa el número de cuenta"
|
||||||
|
/>
|
||||||
|
<button className="button buttonSearch" type="submit">
|
||||||
|
Buscar
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{/* Formulario Asignar */}
|
||||||
|
<form
|
||||||
|
onSubmit={handleAsignar}
|
||||||
|
className="groupInput"
|
||||||
|
style={{ marginTop: "20px" }}
|
||||||
|
>
|
||||||
|
<label className="label">Equipos disponibles:</label>
|
||||||
<select value={tiempo} onChange={(e) => setTiempo(e.target.value)}>
|
<select value={tiempo} onChange={(e) => setTiempo(e.target.value)}>
|
||||||
<option value="">-- Equipos disponibles --</option>
|
<option value="">-- Selecciona un equipo --</option>
|
||||||
<option value="15">1</option>
|
<option value="15">1</option>
|
||||||
<option value="30">2</option>
|
<option value="30">2</option>
|
||||||
<option value="45">3</option>
|
<option value="45">3</option>
|
||||||
@@ -25,8 +59,10 @@ function Equipos() {
|
|||||||
<button className="button buttonSearch" type="submit">
|
<button className="button buttonSearch" type="submit">
|
||||||
Asignar
|
Asignar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</form>
|
||||||
</form>
|
|
||||||
|
{mensaje && <p style={{ marginTop: "20px" }}>{mensaje}</p>}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,36 +2,67 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
function Mesas() {
|
function Mesas() {
|
||||||
const [tiempo, setTiempo] = useState("");
|
const [mesa, setMesa] = useState(""); // Mesa seleccionada
|
||||||
|
const [mantenimiento, setMantenimiento] = useState(false); // Checkbox Mantenimiento
|
||||||
|
const [mensaje, setMensaje] = useState(""); // Mensaje dinámico
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleConfirmar = (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("Equipo asignado con tiempo:", tiempo);
|
|
||||||
|
if (!mesa) {
|
||||||
|
setMensaje("Selecciona una mesa antes de confirmar");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const estado = mantenimiento ? "en mantenimiento" : "disponible";
|
||||||
|
setMensaje(`Mesa ${mesa} confirmada como ${estado}`);
|
||||||
|
|
||||||
|
console.log({
|
||||||
|
mesa,
|
||||||
|
mantenimiento,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="containerForm" onSubmit={handleSubmit}>
|
<form className="containerForm" onSubmit={handleConfirmar}>
|
||||||
<label className="label">Mesas disponibles</label>
|
<label className="label">Mesas disponibles:</label>
|
||||||
<div className="groupInput">
|
<div className="groupInput">
|
||||||
<select value={tiempo} onChange={(e) => setTiempo(e.target.value)}>
|
{/* Select de mesas */}
|
||||||
|
<select value={mesa} onChange={(e) => setMesa(e.target.value)}>
|
||||||
<option value="">-- Mesas disponibles --</option>
|
<option value="">-- Mesas disponibles --</option>
|
||||||
<option value="15">1</option>
|
<option value="1">1</option>
|
||||||
<option value="30">4</option>
|
<option value="4">4</option>
|
||||||
<option value="45">7</option>
|
<option value="7">7</option>
|
||||||
<option value="60">10</option>
|
<option value="10">10</option>
|
||||||
<option value="90">15</option>
|
<option value="15">15</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<div className="checkbox">
|
{/* Checkbox Mantenimiento */}
|
||||||
<input type="checkbox" />
|
<div className="checkbox" style={{ marginTop: "10px" }}>
|
||||||
<label>Mantenimiento</label>
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={mantenimiento}
|
||||||
|
onChange={(e) => setMantenimiento(e.target.checked)}
|
||||||
|
/>
|
||||||
|
Mantenimiento
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button className="button buttonSearch" type="submit">
|
{/* Botón Confirmar */}
|
||||||
|
<button
|
||||||
|
className="button buttonSearch"
|
||||||
|
type="submit"
|
||||||
|
style={{ marginTop: "15px" }}
|
||||||
|
>
|
||||||
Confirmar
|
Confirmar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Mensaje dinámico */}
|
||||||
|
{mensaje && <p style={{ marginTop: "20px" }}>{mensaje}</p>}
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Mesas;
|
export default Mesas;
|
||||||
|
|||||||
@@ -1,108 +1,111 @@
|
|||||||
// 1. Definimos la interfaz que describe las props del componente
|
"use client";
|
||||||
export interface DatosEquipo {
|
import { useState } from "react";
|
||||||
titulo: string; // El título que aparecerá como label
|
|
||||||
opcion: string[]; // Lista de opciones para el select
|
interface DatosEquipo {
|
||||||
|
titulo: string;
|
||||||
|
opcion: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Ya no necesitas tener "DatosOpciones" dentro de este archivo
|
// Lista de programas disponibles
|
||||||
// porque el componente debe ser reutilizable, no fijo.
|
const programas = [
|
||||||
|
"3D MAX STUDIO 2014",
|
||||||
|
"ADOBE CREATIVE SUITE",
|
||||||
|
"ARCHICAD 20",
|
||||||
|
"AUDACITY -win - 2.0",
|
||||||
|
"AUTOCAD",
|
||||||
|
"CODE-BLOCKS",
|
||||||
|
"COREL DRAW",
|
||||||
|
"DEV-C++",
|
||||||
|
"EVIEWS Enterprise",
|
||||||
|
"Google Earth",
|
||||||
|
"INTERNERT",
|
||||||
|
"MAPLE",
|
||||||
|
"MATHEMATICA",
|
||||||
|
"MATLAB",
|
||||||
|
"Maxima",
|
||||||
|
"miktex",
|
||||||
|
"NETBEANS",
|
||||||
|
"OFFICE 2016",
|
||||||
|
"PSeint",
|
||||||
|
"R 3.0.1",
|
||||||
|
"R Studio",
|
||||||
|
"SPPS Statiscs",
|
||||||
|
"STATA 13",
|
||||||
|
"STATGRAOHICS Centurion XVI",
|
||||||
|
];
|
||||||
|
|
||||||
|
// Mapear cada equipo a sus programas (checkboxes que deberían seleccionarse)
|
||||||
|
const caracteristicasPorEquipo: Record<string, string[]> = {
|
||||||
|
"Equipo 1": ["3D MAX STUDIO 2014", "AUTOCAD", "MATLAB"],
|
||||||
|
"Equipo 2": ["ADOBE CREATIVE SUITE", "COREL DRAW", "R Studio"],
|
||||||
|
"Equipo 3": ["ARCHICAD 20", "EVIEWS Enterprise", "SPPS Statiscs"],
|
||||||
|
"Equipo 4": ["MATHEMATICA", "MAPLE", "Maxima"],
|
||||||
|
// Agrega más equipos según necesites
|
||||||
|
};
|
||||||
|
|
||||||
// 3. Recibimos las props como un objeto con estructura DatosEquipo
|
|
||||||
function ProgramSelector({ titulo, opcion }: DatosEquipo) {
|
function ProgramSelector({ titulo, opcion }: DatosEquipo) {
|
||||||
|
// Estado del equipo seleccionado
|
||||||
|
const [equipoSeleccionado, setEquipoSeleccionado] = useState("");
|
||||||
|
// Estado de los checkboxes (programas)
|
||||||
|
const [checkboxes, setCheckboxes] = useState<Record<string, boolean>>(
|
||||||
|
programas.reduce((acc, prog) => ({ ...acc, [prog]: false }), {})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Función al cambiar el select
|
||||||
|
const handleChangeEquipo = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
|
const equipo = e.target.value;
|
||||||
|
setEquipoSeleccionado(equipo);
|
||||||
|
|
||||||
|
// Actualizar checkboxes según características del equipo
|
||||||
|
const nuevosCheckboxes: Record<string, boolean> = {};
|
||||||
|
programas.forEach((prog) => {
|
||||||
|
nuevosCheckboxes[prog] =
|
||||||
|
caracteristicasPorEquipo[equipo]?.includes(prog) || false;
|
||||||
|
});
|
||||||
|
setCheckboxes(nuevosCheckboxes);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Guardar cambios (ejemplo)
|
||||||
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
console.log("Equipo:", equipoSeleccionado);
|
||||||
|
console.log(
|
||||||
|
"Programas seleccionados:",
|
||||||
|
Object.keys(checkboxes).filter((p) => checkboxes[p])
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<form className="form-container" onSubmit={handleSubmit}>
|
||||||
<form className="form-container">
|
<label>{titulo}</label>
|
||||||
{/* Label dinámico con el título que recibimos */}
|
<select value={equipoSeleccionado} onChange={handleChangeEquipo}>
|
||||||
<label>{titulo}</label>
|
<option value="">-- Selecciona un equipo --</option>
|
||||||
|
{opcion.map((eq, i) => (
|
||||||
|
<option key={i} value={eq}>
|
||||||
|
{eq}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
|
||||||
{/* Renderizamos UN solo <select> con varias <option> */}
|
<div className="checkbox-grid">
|
||||||
<select>
|
{programas.map((prog) => (
|
||||||
{opcion.map((op, index) => (
|
<label key={prog}>
|
||||||
<option key={index} value={op}>
|
<input
|
||||||
{op}
|
type="checkbox"
|
||||||
</option>
|
checked={checkboxes[prog]}
|
||||||
))}
|
onChange={() =>
|
||||||
</select>
|
setCheckboxes({ ...checkboxes, [prog]: !checkboxes[prog] })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{prog}
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Lista de checkboxes (esto lo podrías optimizar igual con .map) */}
|
<button className="button buttonSearch" type="submit">
|
||||||
<div className="checkbox-grid">
|
Guardar cambios
|
||||||
<label>
|
</button>
|
||||||
<input type="checkbox" /> 3D MAX STUDIO 2014
|
</form>
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> ADOBE CREATIVE SUITE
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> ARCHICAD 20
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> AUDACITY -win - 2.0
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> AUTOCAD
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> CODE-BLOCKS
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> COREL DRAW
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> DEV-C++
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> EVIEWS Enterprise
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> Google Earth
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> INTERNERT
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> MAPLE
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> MATHEMATICA
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> MATLAB
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> Maxima
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> miktex
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> NETBEANS
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> OFFICE 2016
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> PSeint
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> R 3.0.1
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> R Studio
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> SPPS Statiscs
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> STATA 13
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" /> STATGRAOHICS Centurion XVI
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button className="button buttonSearch">Guardar cambios</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user