fixed select in active and the lock now can register ticket 1 month later
This commit is contained in:
@@ -80,7 +80,7 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) {
|
|||||||
}, [inscripcion]);
|
}, [inscripcion]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!puedeContinuar || !numAcount || error === "Equipo" || error === "Mesa") return;
|
if (!puedeContinuar || !numAcount || !(error === "Equipo" || error === "Mesa")) return;
|
||||||
|
|
||||||
const fetchEquipos = async () => {
|
const fetchEquipos = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export default function MesasDisponibles() {
|
|||||||
|
|
||||||
await axios.patch(
|
await axios.patch(
|
||||||
`${envConfig.apiUrl}/mesa/${id_mesa}/activo`,
|
`${envConfig.apiUrl}/mesa/${id_mesa}/activo`,
|
||||||
|
{},
|
||||||
{ headers },
|
{ headers },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) {
|
|||||||
const minutosRestantes = Math.floor(restante / 60000);
|
const minutosRestantes = Math.floor(restante / 60000);
|
||||||
const segundos = Math.floor((restante % 60000) / 1000);
|
const segundos = Math.floor((restante % 60000) / 1000);
|
||||||
|
|
||||||
setMinutos(minutosRestantes+1);
|
setMinutos(minutosRestantes + 1);
|
||||||
setTiempoRestante(
|
setTiempoRestante(
|
||||||
`${minutosRestantes} minuto(s) con ${segundos} segundo(s)`
|
`${minutosRestantes} minuto(s) con ${segundos} segundo(s)`
|
||||||
);
|
);
|
||||||
@@ -151,10 +151,13 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) {
|
|||||||
|
|
||||||
if (modo === "Cuenta" && numAcount) {
|
if (modo === "Cuenta" && numAcount) {
|
||||||
fetchByCuenta(parseInt(numAcount));
|
fetchByCuenta(parseInt(numAcount));
|
||||||
|
setBitacoraEquipo(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modo === "Equipo" && machine) {
|
if (modo === "Equipo" && machine) {
|
||||||
fetchByEquipo(parseInt(machine));
|
fetchByEquipo(parseInt(machine));
|
||||||
|
setBitacoraCuenta(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
|
|||||||
|
|
||||||
await axios.patch(
|
await axios.patch(
|
||||||
`${envConfig.apiUrl}/bitacora-mesa/cancelar/${bitacora.id_bitacora_mesa}`,
|
`${envConfig.apiUrl}/bitacora-mesa/cancelar/${bitacora.id_bitacora_mesa}`,
|
||||||
{ tiempo_asignado: minutos?? 0 },
|
{ tiempo_asignado: minutos ?? 0 },
|
||||||
{ headers }
|
{ headers }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -137,6 +137,8 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
setBitacoraMesa(null);
|
||||||
|
setBitacoraCuenta(null);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: "Error al cancelar tiempo",
|
title: "Error al cancelar tiempo",
|
||||||
|
|||||||
@@ -8,8 +8,30 @@ import Cookies from "js-cookie";
|
|||||||
|
|
||||||
import "./tableEquipos.css";
|
import "./tableEquipos.css";
|
||||||
|
|
||||||
|
type AreaUbicacion = {
|
||||||
|
id_area_ubicacion: number;
|
||||||
|
area: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Equipo = {
|
||||||
|
id_equipo: number;
|
||||||
|
nombre_equipo: string;
|
||||||
|
ubicacion: string;
|
||||||
|
plataforma: {
|
||||||
|
nombre: string
|
||||||
|
};
|
||||||
|
areaUbicacion: {area:string};
|
||||||
|
ocupado: boolean;
|
||||||
|
activo: {
|
||||||
|
data: number[]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default function TableEquipos() {
|
export default function TableEquipos() {
|
||||||
const [equipos, setEquipos] = useState<any[]>([]);
|
const [machines, setMachines] = useState<Equipo[]>([]);
|
||||||
|
const [areas, setAreas] = useState<AreaUbicacion[]>([]);
|
||||||
|
const [selectedArea, setSelectedArea] = useState("Todo");
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
const token = Cookies.get("token");
|
const token = Cookies.get("token");
|
||||||
@@ -22,7 +44,7 @@ export default function TableEquipos() {
|
|||||||
const response = await axios.get(`${envConfig.apiUrl}/equipo`,
|
const response = await axios.get(`${envConfig.apiUrl}/equipo`,
|
||||||
{ headers },
|
{ headers },
|
||||||
);
|
);
|
||||||
setEquipos(response.data);
|
setMachines(response.data);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("ERROR API:", error.response?.data || error.message);
|
console.error("ERROR API:", error.response?.data || error.message);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -31,16 +53,33 @@ export default function TableEquipos() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchEquipos();
|
fetchEquipos();
|
||||||
|
fetchAreas();
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const fetchAreas = async () => {
|
||||||
|
try {
|
||||||
|
const res = await axios.get(
|
||||||
|
`${process.env.NEXT_PUBLIC_API_URL}/area-ubicacion`,
|
||||||
|
{ headers },
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
setAreas(res.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error cargando áreas:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const toggleEquipo = async (id_equipo: number) => {
|
const toggleEquipo = async (id_equipo: number) => {
|
||||||
try {
|
try {
|
||||||
await axios.patch(
|
await axios.patch(
|
||||||
`${envConfig.apiUrl}/equipo/${id_equipo}/activo`,
|
`${envConfig.apiUrl}/equipo/${id_equipo}/activo`,
|
||||||
|
{},
|
||||||
{ headers },
|
{ headers },
|
||||||
);
|
);
|
||||||
|
|
||||||
setEquipos((prev) =>
|
setMachines((prev) =>
|
||||||
prev.map((e) =>
|
prev.map((e) =>
|
||||||
e.id_equipo === id_equipo
|
e.id_equipo === id_equipo
|
||||||
? {
|
? {
|
||||||
@@ -64,6 +103,14 @@ export default function TableEquipos() {
|
|||||||
return <p>Cargando equipos...</p>;
|
return <p>Cargando equipos...</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filteredMachines =
|
||||||
|
selectedArea === "Todo"
|
||||||
|
? machines
|
||||||
|
: machines.filter(
|
||||||
|
(machine) => machine.areaUbicacion.area === selectedArea,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -81,9 +128,29 @@ export default function TableEquipos() {
|
|||||||
<th>Área</th>
|
<th>Área</th>
|
||||||
<th>Activo</th>
|
<th>Activo</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr style={{ position: "relative", zIndex: "0" }}>
|
||||||
|
<th />
|
||||||
|
<th />
|
||||||
|
<th />
|
||||||
|
<th>
|
||||||
|
<select
|
||||||
|
style={{ minWidth: "50px" }}
|
||||||
|
value={selectedArea}
|
||||||
|
onChange={(e) => setSelectedArea(e.target.value)}
|
||||||
|
>
|
||||||
|
<option value="Todo">Todo</option>
|
||||||
|
{areas.map((area) => (
|
||||||
|
<option key={area.id_area_ubicacion} value={area.area}>
|
||||||
|
{area.area}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</th>
|
||||||
|
<th />
|
||||||
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{equipos.map((eq) => {
|
{filteredMachines.map((eq) => {
|
||||||
const isActivo = eq.activo?.data?.[0] === 1;
|
const isActivo = eq.activo?.data?.[0] === 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -93,7 +160,7 @@ export default function TableEquipos() {
|
|||||||
<td className={eq.plataforma?.nombre}>
|
<td className={eq.plataforma?.nombre}>
|
||||||
{eq.plataforma?.nombre}
|
{eq.plataforma?.nombre}
|
||||||
</td>
|
</td>
|
||||||
<td>{eq.areaUbicacion?.area || eq.id_area_ubicacion}</td>
|
<td>{eq.areaUbicacion.area}</td>
|
||||||
|
|
||||||
<td
|
<td
|
||||||
style={{ display: "flex", alignItems: "center", gap: "5px" }}
|
style={{ display: "flex", alignItems: "center", gap: "5px" }}
|
||||||
|
|||||||
Reference in New Issue
Block a user