Modificaciones
This commit is contained in:
@@ -8,7 +8,7 @@ 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 from "axios";
|
||||
import Image from 'next/image';
|
||||
|
||||
// 🔹 Tipos estrictos
|
||||
@@ -193,19 +193,42 @@ export default function CasoEspecialForm({
|
||||
setNumeroCuenta('');
|
||||
imprimirMensaje(res.data.message);
|
||||
} catch (err: unknown) {
|
||||
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 } };
|
||||
if (anyErr.response && typeof anyErr.response.data === 'object' && anyErr.response.data !== null) {
|
||||
const d = anyErr.response.data as { message?: unknown } | unknown;
|
||||
if (d && typeof d === 'object' && 'message' in d && typeof (d as { message?: unknown }).message === 'string') {
|
||||
msg = { message: (d as { message?: unknown }).message as string };
|
||||
}
|
||||
}
|
||||
} else if (err instanceof Error) {
|
||||
msg = { message: err.message };
|
||||
}
|
||||
imprimirError(msg);
|
||||
// Quitar esta parte
|
||||
if (axios.isAxiosError(err)) {
|
||||
|
||||
const backendMessage = err.response?.data?.message;
|
||||
|
||||
if (backendMessage) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback SOLO si no vino nada del backend
|
||||
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 } };
|
||||
// if (anyErr.response && typeof anyErr.response.data === 'object' && anyErr.response.data !== null) {
|
||||
// const d = anyErr.response.data as { message?: unknown } | unknown;
|
||||
// if (d && typeof d === 'object' && 'message' in d && typeof (d as { message?: unknown }).message === 'string') {
|
||||
// msg = { message: (d as { message?: unknown }).message as string };
|
||||
// }
|
||||
// }
|
||||
// } else if (err instanceof Error) {
|
||||
// msg = { message: err.message };
|
||||
// }
|
||||
// imprimirError(msg);
|
||||
} finally {
|
||||
updateIsLoading(false);
|
||||
}
|
||||
@@ -314,7 +337,7 @@ export default function CasoEspecialForm({
|
||||
</InputGroup.Text>
|
||||
|
||||
<DatePicker
|
||||
selected={fechaNacimiento}
|
||||
// selected={fechaNacimiento}
|
||||
maxDate={new Date()}
|
||||
onChange={handleFechaNacimientoChange}
|
||||
dateFormat="dd-MM-yyyy"
|
||||
|
||||
Reference in New Issue
Block a user