diff --git a/app/(private)/InformacionEquipo/InformacionEquipo.tsx b/app/(private)/InformacionEquipo/InformacionEquipo.tsx index f8cf187..e6c3bd0 100644 --- a/app/(private)/InformacionEquipo/InformacionEquipo.tsx +++ b/app/(private)/InformacionEquipo/InformacionEquipo.tsx @@ -9,7 +9,7 @@ import SelectorEquipo from "@/app/Components/InformacionEquipos/SelectorEquipo"; import { useState } from "react"; import "./informacionequipo.css"; - + export default function InformacionEquipo({ defaultKey, }: { diff --git a/app/(private)/Mensajes/page.tsx b/app/(private)/Mensajes/page.tsx index 7b9eeba..96a96df 100644 --- a/app/(private)/Mensajes/page.tsx +++ b/app/(private)/Mensajes/page.tsx @@ -1,4 +1,5 @@ import EnviarMensaje from "@/app/Components/EviarMensaje/EnviarMensaje"; +import EnviarMensajeSala from "@/app/Components/EviarMensaje/EnviarMensajeSala"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; export default async function Page(props: { @@ -32,7 +33,7 @@ export default async function Page(props: { key: "Sala", label: "Sala", content: ( - { +/* MISMA interfaz que tu SelectorEquipo */ +interface Equipos { + id_equipo: number; + id_plataforma: number; + id_area_ubicacion: number; + nombre_equipo: string; + ubicacion: string; + activo: boolean; + ip: string; + areaUbicacion: { area: string }; + plataforma: { nombre: string }; +} + +const EnviarMensaje = ({ titulo }: EnviarMensajeProps) => { + + const [equipos, setEquipos] = useState([]); const [seleccion, setSeleccion] = useState(""); const [mensaje, setMensaje] = useState(""); const [customMsg, setCustomMsg] = useState(""); + + useEffect(() => { + const fetchEquipos = async () => { + try { + const response = await axios.get(`${envConfig.apiUrl}/equipo`); + setEquipos(response.data); + } catch (error) { + console.error("Error cargando equipos:", error); + } + }; + + fetchEquipos(); + }, []); + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - // Aquí puedes manejar el envío (guardar en estado global, enviar a backend, etc.) + + console.log({ + equipo: seleccion, + mensaje, + customMsg, + }); }; return (
- {/* Selección principal */} + +
@@ -37,25 +76,22 @@ const EnviarMensaje = ({ titulo, opciones }: EnviarMensajeProps) => { {/* Selección de mensaje */} +
- + +
{/* Mensaje personalizado */} +
{ onChange={(e) => setCustomMsg(e.target.value)} placeholder="Escribe tu mensaje..." /> - + +
- - {/* Botón de enviar */} - diff --git a/app/Components/EviarMensaje/EnviarMensajeSala.tsx b/app/Components/EviarMensaje/EnviarMensajeSala.tsx new file mode 100644 index 0000000..cd8926b --- /dev/null +++ b/app/Components/EviarMensaje/EnviarMensajeSala.tsx @@ -0,0 +1,109 @@ +"use client"; + +import { useEffect, useState } from "react"; +import axios from "axios"; +import { envConfig } from "@/app/lib/config"; + +interface EnviarMensajeProps { + titulo: string; + opciones: string[]; +} + +/* 🔵 INTERFAZ SALAS */ +interface AreaUbicacion { + id_area_ubicacion: number; + area: string; +} + +const EnviarMensajeSala = ({ titulo }: EnviarMensajeProps) => { + const [salas, setSalas] = useState([]); + const [seleccion, setSeleccion] = useState(""); + const [mensaje, setMensaje] = useState(""); + const [customMsg, setCustomMsg] = useState(""); + + /* 🔵 FETCH SOLO SALAS */ + useEffect(() => { + const fetchSalas = async () => { + try { + const response = await axios.get(`${envConfig.apiUrl}/area-ubicacion`); + setSalas(response.data); + } catch (error) { + console.error("Error cargando salas:", error); + } + }; + + fetchSalas(); + }, []); + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + + console.log({ + sala: seleccion, + mensaje, + customMsg, + }); + }; + + return ( +
+ {/* 🔵 SELECT SALAS */} + + +
+ +
+ + {/* Selección de mensaje */} + + +
+ + + +
+ + {/* Mensaje personalizado */} + + +
+ setCustomMsg(e.target.value)} + placeholder="Escribe tu mensaje..." + /> + + +
+ + {/* Botón */} + +
+ ); +}; + +export default EnviarMensajeSala;