- {datos.status?.idStatus === 5 && datos.programa?.clavePrograma === `${process.env.NEXT_PUBLIC_CP}` && (
+ {datos.status?.idStatus === 5 && clavesPermitidas.includes(datos?.programa?.clavePrograma || '') && (
setVistoBuenoAcatlan(e.target.checked)}
className="form-checkbox h-5 w-5 text-blue-600"
/>
-
@@ -147,12 +180,7 @@ export default function ConfirmarServicio({
datos.programa?.acatlan &&
!vistoBuenoAcatlan
}
- onClick={() =>
- imprimirWarning(
- "¿Seguro(a) que quieres confirmar este servicio?",
- confirmarServicio
- )
- }
+ onClick={confirma}
className={`px-4 py-2 rounded text-white ${
datos.status?.idStatus === 5 &&
datos.programa?.acatlan &&
diff --git a/src/components/casoEspecial/caso-especial-form.tsx b/src/components/casoEspecial/caso-especial-form.tsx
index 3629a67..ed78268 100644
--- a/src/components/casoEspecial/caso-especial-form.tsx
+++ b/src/components/casoEspecial/caso-especial-form.tsx
@@ -8,10 +8,11 @@ import { Col, FormGroup, FormLabel, InputGroup } from 'react-bootstrap';
import { FaRegCalendarAlt, FaUpload } from 'react-icons/fa';
import DatePicker from 'react-datepicker';
import BotonRegresar from '../boton-regresar';
-import axios from "axios";
+import axios, { AxiosError } from "axios";
import Image from 'next/image';
import { registerLocale } from "react-datepicker";
import { es } from "date-fns/locale/es";
+import Swal from 'sweetalert2';
registerLocale("es", es);
@@ -143,13 +144,20 @@ export default function CasoEspecialForm({
} catch (err: unknown) {
resetear();
setNumeroCuenta('');
- let msg = { message: 'Error al buscar alumno.' };
- if (typeof err === 'object' && err !== null && 'response' in err) {
- const anyErr = err as { response?: { data?: { message?: unknown } } };
- const m = anyErr.response?.data as { message?: unknown } | undefined;
- msg = { message: m?.message ? String(m.message) : msg.message };
- } else if (err instanceof Error) msg = { message: err.message };
- imprimirError(msg);
+ const axiosErr = err as AxiosError
;
+ const mensaje = axiosErr?.response?.data?.message || 'El alumno no cumple con los requisitos para hacer el servicio social.'
+ Swal.fire({
+ icon: 'error',
+ title: 'Error',
+ text: mensaje,
+ })
+ // let msg = { message: 'Error al buscar alumno.' };
+ // if (typeof err === 'object' && err !== null && 'response' in err) {
+ // const anyErr = err as { response?: { data?: { message?: unknown } } };
+ // const m = anyErr.response?.data as { message?: unknown } | undefined;
+ // msg = { message: m?.message ? String(m.message) : msg.message };
+ // } else if (err instanceof Error) msg = { message: err.message };
+ // imprimirError(msg);
} finally {
updateIsLoading(false);
}
@@ -189,6 +197,20 @@ export default function CasoEspecialForm({
...(idStatus === '12' && { institucion: institucion.trim() }),
...(idStatus === '12' && { dependencia: dependencia.trim() }),
...(idStatus === '11' && { motivo }),
+ // idUsuario: Number('19839'),
+ // idCarrera: Number('16'),
+ // idStatus: Number('11'),
+ // numeroCuenta: '422016698',
+ // creditos: '100',
+ // correo: correo.trim(),
+ // fechaInicio: formatDate(fechaInicio),
+ // fechaFin: formatDate(fechaFin),
+ // fechaNacimiento: formatDate(fechaNacimiento),
+ // direccion: direccion.trim(),
+ // telefono: telefono,
+ // ...(idStatus === '12' && { institucion: institucion.trim() }),
+ // ...(idStatus === '12' && { dependencia: dependencia.trim() }),
+ // ...(idStatus === '11' && { motivo }),
};
console.log("Datos a enviar en caso especial:", data);
@@ -196,6 +218,7 @@ export default function CasoEspecialForm({
const formData = new FormData();
// agregar el archivo.
formData.append("archivos", file);
+ formData.append("alumno", JSON.stringify(data));
// armas los datos para el dto
// formData.append("alumno[idUsuario]", alumno.idUsuario.toString());
@@ -211,21 +234,21 @@ export default function CasoEspecialForm({
// formData.append("alumno[direccion]", direccion);
// validaciones extra
- if (institucion) {
- formData.append("alumno[institucion]", institucion);
- }
+ // if (institucion) {
+ // formData.append("alumno[institucion]", institucion);
+ // }
- if (dependencia) {
- formData.append("alumno[dependencia]", dependencia);
- }
+ // if (dependencia) {
+ // formData.append("alumno[dependencia]", dependencia);
+ // }
- if (motivo) {
- formData.append("alumno[motivo]", motivo);
- }
+ // if (motivo) {
+ // formData.append("alumno[motivo]", motivo);
+ // }
- if (!idStatus) {
- console.log('No se envio el idStatus')
- }
+ // if (!idStatus) {
+ // console.log('No se envio el idStatus')
+ // }
//const info = formData.append('alumno', new Blob([JSON.stringify(data)], { type: 'application/json' }));
// formData.append('archivos', file);
@@ -242,6 +265,7 @@ export default function CasoEspecialForm({
// formData.append("alumno[direccion]", alumno.direccion);
console.log("FormData a enviar en caso especial:", formData.getAll);
+ console.log("Esta es la info al registrar el servicio", formData);
try {
updateIsLoading(true);
@@ -255,31 +279,45 @@ export default function CasoEspecialForm({
});
resetear();
setNumeroCuenta('');
+ const mensaje = res?.data?.message || 'Se creo el servicio social con exito.'
+ Swal.fire({
+ icon: 'success',
+ title: 'Exito',
+ text: mensaje,
+ })
imprimirMensaje(res.data.message);
} catch (err: unknown) {
+ const axiosErr = err as AxiosError;
+ const mensaje = axiosErr?.response?.data?.message || 'No se pudo completar el registro del servicio social, por favor intentelo mas tarde.'
+
+ Swal.fire({
+ icon: 'error',
+ title: 'Error',
+ text: mensaje,
+ })
// Quitar esta parte
- if (axios.isAxiosError(err)) {
+ // if (axios.isAxiosError(err)) {
- const backendMessage = err.response?.data?.message;
+ // const backendMessage = err.response?.data?.message;
- if (backendMessage) {
+ // if (backendMessage) {
- // Si el backend manda string
- if (typeof backendMessage === "string") {
- imprimirError({ message: backendMessage });
- return;
- }
+ // // Si el backend manda string
+ // if (typeof backendMessage === "string") {
+ // imprimirError({ message: backendMessage });
+ // return;
+ // }
- // Si el backend manda arreglo (NestJS validation)
- if (Array.isArray(backendMessage)) {
- imprimirError({ message: backendMessage.join("\n") });
- return;
- }
- }
- }
+ // // Si el backend manda arreglo (NestJS validation)
+ // if (Array.isArray(backendMessage)) {
+ // imprimirError({ message: backendMessage.join("\n") });
+ // return;
+ // }
+ // }
+
// Fallback SOLO si no vino nada del backend
- imprimirError({ message: "Error inesperado del servidor" });
+ // imprimirError({ message: "Error inesperado del servidor" });
// let msg: { message: string } = { message: 'Error al enviar formulario.' };
// if (typeof err === 'object' && err !== null && 'response' in err) {
// const anyErr = err as { response?: { data?: unknown } };
diff --git a/src/components/layout/logout.tsx b/src/components/layout/logout.tsx
index b1b185c..ac71261 100644
--- a/src/components/layout/logout.tsx
+++ b/src/components/layout/logout.tsx
@@ -1,3 +1,4 @@
+'use client'
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
diff --git a/src/components/responsable/cuestionario-responsbale2.tsx b/src/components/responsable/cuestionario-responsbale2.tsx
index 5b6f7b7..d822771 100644
--- a/src/components/responsable/cuestionario-responsbale2.tsx
+++ b/src/components/responsable/cuestionario-responsbale2.tsx
@@ -158,12 +158,18 @@ export default function CuestionarioResponsbale2({
else answered = answer !== null && String(answer) !== '';
if (!answered) missing.push(`Pregunta ${p.numeroPregunta}`);
});
- formulario.tablas.forEach((t) => {
+
+ let tablaIndex = 0;
+
+ formulario.tablas.forEach((t, index) => {
const allAnswered = t.renglones.every((r) => {
const tablaResp = respuestas[String(t.idTabla)] as Record | undefined;
return tablaResp && tablaResp[r.idRenglon] !== null;
});
- if (!allAnswered) missing.push(`Tabla ${t.numeroPregunta}`);
+ if (!allAnswered) {
+ const letra = String.fromCharCode(65 + index);
+ missing.push(`Tabla ${t.numeroPregunta}.${letra}`);
+ }
});
return missing;
}, [formulario, respuestas]);