fixed informacionDeEquipo.equipos
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import SearchUser from "@/app/Components/Global/SearchUser/searchUser";
|
||||
import Information from "@/app/Components/Global/Information/information";
|
||||
import Receipt from "@/app/Components/Receipt/Receipt";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import { GetStudent } from "@/app/lib/getStudent";
|
||||
|
||||
import "./addTime.css";
|
||||
import Selection from "@/app/Components/Selection/Selection";
|
||||
import ShowError from "@/app/Components/Global/ShowError";
|
||||
import { GetRegisterStudent } from "@/app/lib/getRegisterStudent";
|
||||
|
||||
export default async function Page(props: {
|
||||
searchParams?: Promise<{
|
||||
@@ -15,13 +14,14 @@ export default async function Page(props: {
|
||||
}) {
|
||||
const params = await props.searchParams;
|
||||
const numAcount = params?.numAcount ? params.numAcount : null;
|
||||
let errorMessage = "";
|
||||
|
||||
let student: any = null;
|
||||
if (numAcount) {
|
||||
const result = await GetStudent(parseInt(numAcount));
|
||||
const result = await GetRegisterStudent(parseInt(numAcount));
|
||||
|
||||
if (result.error) {
|
||||
toast.error("Alumno no encontrado");
|
||||
errorMessage = `${result.error}`;
|
||||
return;
|
||||
} else {
|
||||
student = result;
|
||||
@@ -30,6 +30,8 @@ export default async function Page(props: {
|
||||
|
||||
return (
|
||||
<section className="containerSection">
|
||||
{errorMessage && <ShowError key={Date.now()} message={errorMessage} />}
|
||||
|
||||
<h2 className="title"> AGREGAR TIEMPO </h2>
|
||||
|
||||
<SearchUser value={numAcount} />
|
||||
|
||||
@@ -4,10 +4,12 @@ import Receipt from "@/app/Components/Receipt/Receipt";
|
||||
import Selection from "@/app/Components/Selection/Selection";
|
||||
import ShowError from "@/app/Components/Global/ShowError";
|
||||
import { GetStudent } from "@/app/lib/getStudent";
|
||||
import "./inscripcion.css";
|
||||
import Table from "@/app/Components/Global/table";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
|
||||
import "./inscripcion.css";
|
||||
import Inscripcion from "@/app/Components/Receipt/Inscripcion";
|
||||
|
||||
if (!envConfig.apiUrl) {
|
||||
console.error("API URL is not defined in envConfig");
|
||||
}
|
||||
@@ -123,20 +125,8 @@ export default async function Page(props: {
|
||||
{student && (
|
||||
<>
|
||||
<section className="inscripcion">
|
||||
<Selection />
|
||||
|
||||
<select
|
||||
style={{
|
||||
marginBottom: "1rem",
|
||||
maxWidth: "100px",
|
||||
minWidth: "100px",
|
||||
}}
|
||||
>
|
||||
<option value="0">con pago</option>
|
||||
<option value="1">sin pago</option>
|
||||
</select>
|
||||
|
||||
<Receipt numAcount={student.id_cuenta} />
|
||||
<Inscripcion numAcount={student.id_cuenta} />
|
||||
</section>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
"use client";
|
||||
import { SetStateAction, useState } from "react";
|
||||
import axios from "axios";
|
||||
import { SetStateAction, useEffect, useState } from "react";
|
||||
import { envConfig } from "../lib/config";
|
||||
|
||||
interface mesas {
|
||||
idMesa: number;
|
||||
active: number;
|
||||
}
|
||||
export default function AsignacionMesas() {
|
||||
const [tiempo, setTiempo] = useState("");
|
||||
const [mesa, setMesa] = useState<mesas[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const getMesa = async() => {
|
||||
const response = await axios.get(`${envConfig.apiUrl}/mesa/activo`);
|
||||
setMesa(response.data);
|
||||
};
|
||||
getMesa()
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<form className="containerForm">
|
||||
<label className="label">Mesas disponibles</label>
|
||||
<div className="groupInput">
|
||||
<select value={tiempo} onChange={(e) => setTiempo(e.target.value)}>
|
||||
<option value="">-- Mesas disponibles --</option>
|
||||
<option value="15">1 </option>
|
||||
<option value="30">3 </option>
|
||||
<option value="45">4 </option>
|
||||
<option value="60">22 </option>
|
||||
<option value="90">15 </option>
|
||||
<option value="120">20 </option>
|
||||
|
||||
{mesa.map((mesa, key) => (
|
||||
<option key={key} value={mesa.idMesa}>{mesa.idMesa}</option>
|
||||
))}
|
||||
</select>
|
||||
<button className="button buttonSearch" type="submit">
|
||||
Actualizar
|
||||
|
||||
@@ -8,75 +8,118 @@ interface Data {
|
||||
id_equipo: number;
|
||||
id_plataforma: number;
|
||||
id_area_ubicacion: number;
|
||||
ubicacion: string;
|
||||
}
|
||||
|
||||
interface Plataforma {
|
||||
id_plataforma: number;
|
||||
nombre: string;
|
||||
}
|
||||
|
||||
interface Area {
|
||||
id_area_ubicacion: number;
|
||||
area: string;
|
||||
extra: string;
|
||||
}
|
||||
|
||||
export default function Equipos() {
|
||||
const [Equipo, setEquipo] = useState("");
|
||||
const [Data, setData] = useState<Data | any>();
|
||||
const [id, setId] = useState("");
|
||||
const [data, setData] = useState<Data | null>(null);
|
||||
|
||||
const handleSubmit = async (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const [plataforma, setPlataforma] = useState<Plataforma[]>([]);
|
||||
const [area, setArea] = useState<Area[]>([]);
|
||||
|
||||
const [ubicacion, setUbicacion] = useState("");
|
||||
const [nombre, setNombre] = useState("");
|
||||
|
||||
const [idPlataforma, setIdPlataforma] = useState<number | "">("");
|
||||
const [idArea, setIdArea] = useState<number | "">("");
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
// const response = await axios.get(
|
||||
// `${envConfig.apiUrl}/equipo/${Equipo}`
|
||||
// );
|
||||
|
||||
// if (!response) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
setData("response");
|
||||
const [equipoRes, plataformaRes, areaRes] = await Promise.all([
|
||||
axios.get(`${envConfig.apiUrl}/equipo/${id}`),
|
||||
axios.get(`${envConfig.apiUrl}/alumno-inscrito/plataforma`),
|
||||
axios.get(`${envConfig.apiUrl}/area-ubicacion`)
|
||||
]);
|
||||
|
||||
const equipo = equipoRes.data as Data;
|
||||
|
||||
setData(equipo);
|
||||
setNombre(equipo.nombre_equipo);
|
||||
setUbicacion(equipo.ubicacion);
|
||||
setIdPlataforma(equipo.id_plataforma);
|
||||
setIdArea(equipo.id_area_ubicacion);
|
||||
|
||||
setPlataforma(plataformaRes.data);
|
||||
setArea(areaRes.data);
|
||||
};
|
||||
|
||||
return (
|
||||
<form className="containerForm">
|
||||
<form className="containerForm" onSubmit={handleSubmit}>
|
||||
<div className="groupInput">
|
||||
<input
|
||||
placeholder="Numero de Equipo a buscar..."
|
||||
value={Equipo}
|
||||
onChange={(e) => {
|
||||
setEquipo(e.target.value);
|
||||
}}
|
||||
placeholder="Número de Equipo a buscar..."
|
||||
value={id}
|
||||
onChange={(e) => setId(e.target.value)}
|
||||
/>
|
||||
|
||||
<button type="button" className="button buttonSearch" onClick={handleSubmit}>
|
||||
<button type="submit" className="button buttonSearch">
|
||||
Buscar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{Data && (
|
||||
{data && (
|
||||
<div>
|
||||
<label className="label">Ubicacion</label>
|
||||
<label className="label">Ubicación</label>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Coloca"
|
||||
value={Data.id_area_ubicacion}
|
||||
value={ubicacion}
|
||||
onChange={(e) => setUbicacion(e.target.value)}
|
||||
/>
|
||||
|
||||
<label className="label">Nombre</label>
|
||||
<input type="text" placeholder="Coloca " value={Data.nombre_equipo} />
|
||||
<input
|
||||
type="text"
|
||||
value={nombre}
|
||||
onChange={(e) => setNombre(e.target.value)}
|
||||
/>
|
||||
|
||||
<label className="label">Plataforma</label>
|
||||
<select>
|
||||
<option value="0">Elige</option>
|
||||
<option value="1">2</option>
|
||||
<option value="2">3</option>
|
||||
<option value="3">4</option>
|
||||
<option value="4">5</option>
|
||||
<option value="5">6</option>
|
||||
<select
|
||||
value={idPlataforma}
|
||||
onChange={(e) => setIdPlataforma(Number(e.target.value))}
|
||||
>
|
||||
<option value="">Elige</option>
|
||||
{plataforma.map((plat) => (
|
||||
<option key={plat.id_plataforma} value={plat.id_plataforma}>
|
||||
{plat.nombre}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
<label className="label">Area Ubicacion</label>
|
||||
<select>
|
||||
<option value="0">Elige</option>
|
||||
<option value="1">mmmmm</option>
|
||||
<option value="2">mmmmm</option>
|
||||
<option value="3">mmmmm</option>
|
||||
<option value="4">mmmmm</option>
|
||||
<option value="5">mmmmm</option>
|
||||
<label className="label">Área Ubicación</label>
|
||||
<select
|
||||
value={idArea}
|
||||
onChange={(e) => setIdArea(Number(e.target.value))}
|
||||
>
|
||||
<option value="">Elige</option>
|
||||
{area.map((a) => (
|
||||
<option key={a.id_area_ubicacion} value={a.id_area_ubicacion}>
|
||||
{a.area}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="containerButton" style={{marginTop:"1rem"}}>
|
||||
<button className="button buttonSearch">Nuevo</button>
|
||||
<button className="button buttonSearch">Editar</button>
|
||||
|
||||
<div className="containerButton" style={{ marginTop: "1rem" }}>
|
||||
<button type="button" className="button buttonSearch">
|
||||
Nuevo
|
||||
</button>
|
||||
<button type="button" className="button buttonSearch">
|
||||
Editar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -101,7 +101,7 @@ function Impressions({ costs, numAcount }: ImpressionsProps) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="groupInput">
|
||||
<div className="groupInput" style={{height:"35px", flexWrap:"nowrap"}}>
|
||||
<label className="label">Total:</label>
|
||||
<label
|
||||
style={{ width: "100%", minWidth: "200px", maxWidth: "500px" }}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
"use client";
|
||||
|
||||
import toast from "react-hot-toast";
|
||||
import { useState } from "react";
|
||||
import { PostReceipt } from "@/app/lib/postReceipt";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import "./Receipt.css";
|
||||
import Selection from "../Selection/Selection";
|
||||
|
||||
interface ReceiptsProps {
|
||||
numAcount: number | null;
|
||||
}
|
||||
|
||||
export default function Inscripcion({ numAcount }: ReceiptsProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const [folio, setFolio] = useState("");
|
||||
const [amount, setAmount] = useState("");
|
||||
const [date, setDate] = useState("");
|
||||
|
||||
//restrict this month//
|
||||
const day = new Date();
|
||||
const year = day.getFullYear();
|
||||
const month = day.getMonth();
|
||||
const today = day.getDate();
|
||||
|
||||
const minFecha = new Date(year, month, 1).toISOString().split("T")[0];
|
||||
const maxFecha = new Date(year, month, today).toISOString().split("T")[0];
|
||||
//restrict this month//
|
||||
|
||||
const handleSaveReceipt = async () => {
|
||||
if (!numAcount) {
|
||||
toast.error("busca de nuevo al estudiante");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!folio) {
|
||||
toast.error("Ingresa el folio del ticket");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!amount) {
|
||||
toast.error("Coloca el monto a depositar");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!date) {
|
||||
toast.error("Coloca la fecha");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await PostReceipt({
|
||||
id_cuenta: numAcount,
|
||||
folio_recibo: folio,
|
||||
monto: Number(amount),
|
||||
fecha_recibo: date,
|
||||
});
|
||||
|
||||
setFolio("");
|
||||
setAmount("");
|
||||
setDate("");
|
||||
|
||||
toast.success("Recibo guardado");
|
||||
router.refresh();
|
||||
} catch (err: any) {
|
||||
toast.error(String(err));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<section>
|
||||
<Selection />
|
||||
|
||||
<select
|
||||
style={{
|
||||
marginBottom: "1rem",
|
||||
maxWidth: "100px",
|
||||
minWidth: "100px",
|
||||
}}
|
||||
>
|
||||
<option value="0">con pago</option>
|
||||
<option value="1">sin pago</option>
|
||||
</select>
|
||||
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleSaveReceipt();
|
||||
}}
|
||||
>
|
||||
<div className="gap">
|
||||
<div className="groupInput">
|
||||
<label className="label">Ticket:</label>
|
||||
<input
|
||||
type="text"
|
||||
value={folio}
|
||||
onChange={(error) => {
|
||||
const value = error.target.value;
|
||||
if (/^\d*$/.test(value) && value.length <= 7) {
|
||||
setFolio(value);
|
||||
}
|
||||
}}
|
||||
placeholder="Numero de tiket..."
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="groupInput">
|
||||
<label className="label">Monto:</label>
|
||||
<input
|
||||
type="text"
|
||||
value={amount}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
|
||||
if (/^\d*\.?\d*$/.test(value)) {
|
||||
const numericValue = parseFloat(value);
|
||||
|
||||
if (value === "" || numericValue <= 1000) {
|
||||
setAmount(value);
|
||||
} else {
|
||||
toast.error("El monto no puede superar $1000.00");
|
||||
}
|
||||
}
|
||||
}}
|
||||
placeholder="Monto recibido..."
|
||||
inputMode="numeric"
|
||||
pattern="^\d*\.?\d+$"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="groupInput">
|
||||
<label className="label">Fecha de Pago:</label>
|
||||
<input
|
||||
type="date"
|
||||
value={date}
|
||||
onChange={(e) => setDate(e.target.value)}
|
||||
min={minFecha}
|
||||
max={maxFecha}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="containerButton">
|
||||
<button className="button buttonSearch">Inscribir</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
//IO
|
||||
@@ -129,7 +129,7 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
</div>
|
||||
|
||||
<div className="containerButton">
|
||||
<button className="button buttonSearch">Agregar tiempo</button>
|
||||
<button className="button buttonSearch" type="submit">Guardar</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.barNavigation li {
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
color: #585858;
|
||||
width: 100%;
|
||||
transition: background-color 0.3s ease, border 0.3s ease;
|
||||
font-size: 1.5rem;
|
||||
@@ -28,6 +28,8 @@
|
||||
.barNavigation li:hover {
|
||||
background-color: #f3f4f6;
|
||||
color: black !important;
|
||||
border-radius: 8px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.menuToggle {
|
||||
@@ -64,7 +66,10 @@
|
||||
flex-direction: column;
|
||||
top: 100%;
|
||||
width: 100%;
|
||||
background-color: #003e79;
|
||||
min-width: 200px;
|
||||
border: 1px solid #cfcfcf;
|
||||
border-radius: 8px;
|
||||
background-color: #ffffff;
|
||||
transition: color 0.3s ease;
|
||||
transition: opacity 0.4s ease, max-height 0.4s ease;
|
||||
}
|
||||
@@ -102,7 +107,7 @@
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #383838;
|
||||
color: #545454;
|
||||
font-size: 1.5rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
@@ -224,4 +229,4 @@ tbody {
|
||||
tbody {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,11 +79,11 @@
|
||||
|
||||
.containerBarNav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-left: 110px;
|
||||
max-height: 60%;
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
|
||||
+1
-2
@@ -327,7 +327,7 @@ form {
|
||||
border-radius: 4px;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
height: 100%;
|
||||
height: fit-content;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,6 @@ form {
|
||||
|
||||
.toggleContent {
|
||||
overflow-y: auto;
|
||||
height: 450px;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import axios from "axios";
|
||||
import { envConfig } from "./config";
|
||||
import { redirect } from "next/navigation";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
if (!envConfig.apiUrl) {
|
||||
console.error("API URL is not defined in envConfig");
|
||||
}
|
||||
|
||||
export async function GetRegisterStudent(numAcount: number) {
|
||||
const cookieStore = cookies();
|
||||
const token = (await cookieStore).get("token")?.value;
|
||||
|
||||
if (!token) redirect("/");
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${envConfig.apiUrl}/alumno-inscrito/${numAcount}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
const msg =
|
||||
error.response?.data?.message ||
|
||||
error.message ||
|
||||
"Error desconocido al obtener estudiante";
|
||||
return { error: msg };
|
||||
}
|
||||
}
|
||||
//IO
|
||||
Reference in New Issue
Block a user