delete all toast and modified botton add equipo
This commit is contained in:
@@ -131,7 +131,11 @@ export default function AddTime({
|
||||
error.response?.data?.message ||
|
||||
error.message ||
|
||||
"Error desconocido al crear recibo";
|
||||
toast.error(msg);
|
||||
Swal.fire({
|
||||
title: msg,
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ import ShowError from "@/app/Components/Global/ShowError";
|
||||
|
||||
import { GetRegisterStudent } from "@/app/lib/getRegisterStudent";
|
||||
|
||||
import "./addTime.css";
|
||||
import AddTime from "./Addtime";
|
||||
import Table from "@/app/Components/Global/table";
|
||||
|
||||
import "./addTime.css";
|
||||
|
||||
const headers = ["Inscrito", "Tiempo", "Confirmó"];
|
||||
|
||||
export default async function Page(props: {
|
||||
@@ -46,7 +47,7 @@ export default async function Page(props: {
|
||||
|
||||
return (
|
||||
<section className="containerSection">
|
||||
{errorMessage && <ShowError message={errorMessage} />}
|
||||
{errorMessage && <ShowError key={Date.now()} message={errorMessage} />}
|
||||
|
||||
<h2 className="title">AGREGAR TIEMPO</h2>
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ export default async function Page(props: {
|
||||
|
||||
return (
|
||||
<section className="containerSection">
|
||||
{errorMessage && <ShowError message={errorMessage} />}
|
||||
{errorMessage && <ShowError key={Date.now()} message={errorMessage} />}
|
||||
|
||||
<h2 className="title"> ASIGNACIÓN DE MESAS </h2>
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ export default async function Page(props: {
|
||||
let student: any = null;
|
||||
let inscripcion: any = null;
|
||||
let errorMessage = "";
|
||||
let isSancionado = false;
|
||||
|
||||
if (numAcount) {
|
||||
const idCuenta = parseInt(numAcount);
|
||||
@@ -53,6 +54,11 @@ export default async function Page(props: {
|
||||
const studentResult = await GetStudent(idCuenta);
|
||||
if (studentResult.error) {
|
||||
errorMessage = `${studentResult.error}`;
|
||||
|
||||
if (studentResult.status === 403) {
|
||||
isSancionado = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
student = studentResult;
|
||||
}
|
||||
@@ -67,12 +73,12 @@ export default async function Page(props: {
|
||||
|
||||
const tableData = Array.isArray(inscripcion)
|
||||
? inscripcion.map((ins) => ({
|
||||
Inscrito: ins.plataforma?.nombre || "—",
|
||||
Tiempo: ins.tiempo_disponible
|
||||
? `${ins.tiempo_disponible} minutos`
|
||||
: "—",
|
||||
Confirmó: ins.platica.data?.[0] === 1 ? "sí" : "no",
|
||||
}))
|
||||
Inscrito: ins.plataforma?.nombre || "—",
|
||||
Tiempo: ins.tiempo_disponible
|
||||
? `${ins.tiempo_disponible} minutos`
|
||||
: "—",
|
||||
Confirmó: ins.platica.data?.[0] === 1 ? "sí" : "no",
|
||||
}))
|
||||
: [];
|
||||
|
||||
const plataformasInscritas = Array.isArray(inscripcion)
|
||||
@@ -99,7 +105,7 @@ export default async function Page(props: {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{!student && numAcount && (
|
||||
{!student && numAcount && !isSancionado && (
|
||||
<Link href={`/Alta?numAcount=${numAcount}`}>
|
||||
<button
|
||||
className="button buttonSearch"
|
||||
|
||||
@@ -44,22 +44,34 @@ export default function Equipos() {
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
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`),
|
||||
]);
|
||||
try {
|
||||
|
||||
const equipo = equipoRes.data as Data;
|
||||
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);
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
title: "Equipo no encontrado",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
}
|
||||
|
||||
setData(equipo);
|
||||
setNombre(equipo.nombre_equipo);
|
||||
setUbicacion(equipo.ubicacion);
|
||||
setIdPlataforma(equipo.id_plataforma);
|
||||
setIdArea(equipo.id_area_ubicacion);
|
||||
|
||||
setPlataforma(plataformaRes.data);
|
||||
setArea(areaRes.data);
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
@@ -129,7 +141,6 @@ export default function Equipos() {
|
||||
setIsCreating(true);
|
||||
setIsEditing(true);
|
||||
} catch (error) {
|
||||
|
||||
Swal.fire({
|
||||
title: "Error al preparar formulario!",
|
||||
icon: "error",
|
||||
@@ -161,7 +172,11 @@ export default function Equipos() {
|
||||
} catch (error: any) {
|
||||
const message =
|
||||
error?.response?.data?.message || "Error al crear el equipo";
|
||||
toast.error(message);
|
||||
Swal.fire({
|
||||
title: message,
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -251,13 +266,6 @@ export default function Equipos() {
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="button buttonCharge"
|
||||
onClick={handleNuevo}
|
||||
>
|
||||
Nuevo
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="button buttonSearch"
|
||||
@@ -270,6 +278,13 @@ export default function Equipos() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="button buttonCharge"
|
||||
onClick={handleNuevo}
|
||||
>
|
||||
Nuevo
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import Swal from "sweetalert2";
|
||||
|
||||
export default function ShowError({ message }: { message: string }) {
|
||||
useEffect(() => {
|
||||
if (message) {
|
||||
toast.error(message);
|
||||
Swal.fire({
|
||||
title: message,
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
}, [message]);
|
||||
|
||||
|
||||
@@ -71,7 +71,11 @@ function Impressions({ costs, numAcount, id_servicio }: ImpressionsProps) {
|
||||
if (result.message === "Token inválido") {
|
||||
handleLogout();
|
||||
} else {
|
||||
toast.error(result.message);
|
||||
Swal.fire({
|
||||
title: result.message,
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export default function Inscripcion({
|
||||
}
|
||||
|
||||
if (!folio) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Ingresa el folio del ticket!",
|
||||
icon: "error",
|
||||
@@ -72,7 +72,7 @@ export default function Inscripcion({
|
||||
}
|
||||
|
||||
if (!amount) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Coloca el monto a depositar!",
|
||||
icon: "error",
|
||||
@@ -82,7 +82,7 @@ export default function Inscripcion({
|
||||
}
|
||||
|
||||
if (!date) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Coloca la fecha!",
|
||||
icon: "error",
|
||||
@@ -92,7 +92,7 @@ export default function Inscripcion({
|
||||
}
|
||||
|
||||
if (!plataformaSeleccionada) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Selecciona una plataforma!",
|
||||
icon: "error",
|
||||
@@ -132,13 +132,17 @@ export default function Inscripcion({
|
||||
error.response?.data?.message ||
|
||||
error.message ||
|
||||
"Error desconocido al crear recibo";
|
||||
toast.error(String(msg));
|
||||
Swal.fire({
|
||||
title: msg,
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleInscripcionSinPago = async () => {
|
||||
if (!numAcount) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "busca de nuevo al estudiante!",
|
||||
icon: "error",
|
||||
@@ -148,7 +152,7 @@ export default function Inscripcion({
|
||||
}
|
||||
|
||||
if (!plataformaSeleccionada) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Selecciona una plataforma!",
|
||||
icon: "error",
|
||||
@@ -177,7 +181,7 @@ export default function Inscripcion({
|
||||
throw new Error(data.message || "Error al inscribir");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Alumno inscrito sin pago!",
|
||||
icon: "success",
|
||||
@@ -185,7 +189,11 @@ export default function Inscripcion({
|
||||
});
|
||||
router.refresh();
|
||||
} catch (err: any) {
|
||||
toast.error(err.message);
|
||||
Swal.fire({
|
||||
title: err.message,
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -200,7 +208,6 @@ export default function Inscripcion({
|
||||
value={conPago}
|
||||
onChange={(e) => setConPago(e.target.value as "con" | "sin")}
|
||||
style={{
|
||||
marginBottom: "1rem",
|
||||
maxWidth: "120px",
|
||||
minWidth: "120px",
|
||||
}}
|
||||
@@ -245,7 +252,7 @@ export default function Inscripcion({
|
||||
const numericValue = parseFloat(value);
|
||||
|
||||
if (lock && numericValue > 1000) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title:
|
||||
"El monto no puede superar $1000.00 Desbloquea el candado !",
|
||||
@@ -257,7 +264,7 @@ export default function Inscripcion({
|
||||
|
||||
|
||||
if (numericValue > 10000) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title:
|
||||
"El monto no puede superar $10000.00 pesos",
|
||||
|
||||
@@ -33,42 +33,42 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
|
||||
const handleSaveReceipt = async () => {
|
||||
if (!numAcount) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "busca de nuevo al estudiante!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
title: "busca de nuevo al estudiante!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!folio) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Ingresa el folio del ticket!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
title: "Ingresa el folio del ticket!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!amount) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Coloca el monto a depositar!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
title: "Coloca el monto a depositar!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!date) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Coloca la fecha!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
title: "Coloca la fecha!",
|
||||
icon: "error",
|
||||
draggable: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
setAmount("");
|
||||
setDate(todayISO);
|
||||
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Recibo Guardado Correctamente!",
|
||||
icon: "success",
|
||||
@@ -93,9 +93,8 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
|
||||
router.refresh();
|
||||
} catch (err: any) {
|
||||
toast.error(String(err));
|
||||
Swal.fire({
|
||||
title: "Tiket ya existente!",
|
||||
title: err,
|
||||
icon: "error",
|
||||
draggable: false
|
||||
});
|
||||
@@ -139,7 +138,7 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
const numericValue = parseFloat(value);
|
||||
|
||||
if (lock && numericValue > 1000) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title:
|
||||
"El monto no puede superar $1000.00 Desbloquea el candado !",
|
||||
@@ -150,7 +149,7 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
}
|
||||
|
||||
if (numericValue > 10000) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title:
|
||||
"El monto no puede superar $10000.00 pesos",
|
||||
|
||||
@@ -13,22 +13,26 @@ export default function ChangePassword() {
|
||||
e.preventDefault();
|
||||
const data = { password, newPassword };
|
||||
|
||||
try{
|
||||
try {
|
||||
const response = await apiClient.post("/user/changePassword", data);
|
||||
toast.success( `${response.data.message}`)
|
||||
Swal.fire({
|
||||
title: response.data.message,
|
||||
icon: "success",
|
||||
draggable: true,
|
||||
});
|
||||
setPass('');
|
||||
setNewPass('');
|
||||
setconfirmNewPass('');
|
||||
}catch{
|
||||
|
||||
Swal.fire({
|
||||
title: "No es la contraseña actual!",
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
} catch {
|
||||
|
||||
Swal.fire({
|
||||
title: "No es tu contraseña actual!",
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,29 +17,33 @@ function Login() {
|
||||
e.preventDefault();
|
||||
|
||||
if (!user) {
|
||||
|
||||
Swal.fire({
|
||||
title: "Coloca un usuario!",
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
Swal.fire({
|
||||
title: "Coloca un usuario!",
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Coloca una contraseña!",
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
title: "Coloca una contraseña!",
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await loginUser(user, password);
|
||||
|
||||
if ("error" in data) {
|
||||
toast.error(data.error);
|
||||
Swal.fire({
|
||||
title: data.error,
|
||||
icon: "error",
|
||||
draggable: true,
|
||||
});
|
||||
} else {
|
||||
const token = data.access_token;
|
||||
const payload = JSON.parse(atob(token.split(".")[1]));
|
||||
@@ -50,12 +54,12 @@ function Login() {
|
||||
document.cookie = `user=${usuario}; path=/; SameSite=Strict`;
|
||||
document.cookie = `role=${role}; path=/; SameSite=Strict`;
|
||||
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Inicio de sesión exitoso!",
|
||||
icon: "success",
|
||||
draggable: true,
|
||||
});
|
||||
title: "Inicio de sesión exitoso!",
|
||||
icon: "success",
|
||||
draggable: true,
|
||||
});
|
||||
router.push("/Impresiones");
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
+1
-1
@@ -359,7 +359,7 @@ a {
|
||||
text-align: start;
|
||||
color: #bd8c01;
|
||||
border-bottom: 1px solid #cfcfcf;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
form {
|
||||
|
||||
@@ -12,6 +12,7 @@ export async function GetStudent(numAcount: number) {
|
||||
const token = (await cookieStore).get("token")?.value;
|
||||
|
||||
if (!token) redirect("/");
|
||||
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${envConfig.apiUrl}/student/${numAcount}`,
|
||||
@@ -23,12 +24,14 @@ export async function GetStudent(numAcount: number) {
|
||||
);
|
||||
|
||||
return response.data;
|
||||
|
||||
} catch (error: any) {
|
||||
const msg =
|
||||
error.response?.data?.message ||
|
||||
error.message ||
|
||||
"Error desconocido al obtener estudiante";
|
||||
return { error: msg };
|
||||
return {
|
||||
error:
|
||||
error.response?.data?.message ||
|
||||
"Error al obtener estudiante",
|
||||
status: error.response?.status,
|
||||
};
|
||||
}
|
||||
}
|
||||
//IO
|
||||
|
||||
Reference in New Issue
Block a user