diff --git a/app/(private)/AgregarTiempo/Addtime.tsx b/app/(private)/AgregarTiempo/Addtime.tsx index 0960e01..b819528 100644 --- a/app/(private)/AgregarTiempo/Addtime.tsx +++ b/app/(private)/AgregarTiempo/Addtime.tsx @@ -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, + }); } }; diff --git a/app/(private)/AgregarTiempo/page.tsx b/app/(private)/AgregarTiempo/page.tsx index c8204d3..45ddd9c 100644 --- a/app/(private)/AgregarTiempo/page.tsx +++ b/app/(private)/AgregarTiempo/page.tsx @@ -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 (
- {errorMessage && } + {errorMessage && }

AGREGAR TIEMPO

diff --git a/app/(private)/AsignacionMesas/page.tsx b/app/(private)/AsignacionMesas/page.tsx index 69bfe52..edf42f8 100644 --- a/app/(private)/AsignacionMesas/page.tsx +++ b/app/(private)/AsignacionMesas/page.tsx @@ -65,7 +65,7 @@ export default async function Page(props: { return (
- {errorMessage && } + {errorMessage && }

ASIGNACIÓN DE MESAS

diff --git a/app/(private)/Inscripcion/page.tsx b/app/(private)/Inscripcion/page.tsx index 2384a42..098d8f4 100644 --- a/app/(private)/Inscripcion/page.tsx +++ b/app/(private)/Inscripcion/page.tsx @@ -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 && ( ); } diff --git a/app/Components/Global/ShowError.tsx b/app/Components/Global/ShowError.tsx index ef7140b..1041bf7 100644 --- a/app/Components/Global/ShowError.tsx +++ b/app/Components/Global/ShowError.tsx @@ -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]); diff --git a/app/Components/Impressions/impressions.tsx b/app/Components/Impressions/impressions.tsx index b16dab1..5cc455e 100644 --- a/app/Components/Impressions/impressions.tsx +++ b/app/Components/Impressions/impressions.tsx @@ -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; } diff --git a/app/Components/Receipt/Inscripcion.tsx b/app/Components/Receipt/Inscripcion.tsx index e813703..342f0d3 100644 --- a/app/Components/Receipt/Inscripcion.tsx +++ b/app/Components/Receipt/Inscripcion.tsx @@ -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", diff --git a/app/Components/Receipt/Receipt.tsx b/app/Components/Receipt/Receipt.tsx index ef6b470..0f50d5c 100644 --- a/app/Components/Receipt/Receipt.tsx +++ b/app/Components/Receipt/Receipt.tsx @@ -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", diff --git a/app/Components/auth/ChangePassword/changePassword.tsx b/app/Components/auth/ChangePassword/changePassword.tsx index 8c96f96..4215ac7 100644 --- a/app/Components/auth/ChangePassword/changePassword.tsx +++ b/app/Components/auth/ChangePassword/changePassword.tsx @@ -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 ( diff --git a/app/Components/auth/Login/Login.tsx b/app/Components/auth/Login/Login.tsx index d340987..2042843 100644 --- a/app/Components/auth/Login/Login.tsx +++ b/app/Components/auth/Login/Login.tsx @@ -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(); } diff --git a/app/globals.css b/app/globals.css index 70b7fe4..3efcefd 100644 --- a/app/globals.css +++ b/app/globals.css @@ -359,7 +359,7 @@ a { text-align: start; color: #bd8c01; border-bottom: 1px solid #cfcfcf; - margin-bottom: 10px; + margin-bottom: 0.5rem; } form { diff --git a/app/lib/getStudent.ts b/app/lib/getStudent.ts index 2f9cee3..419bc86 100644 --- a/app/lib/getStudent.ts +++ b/app/lib/getStudent.ts @@ -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