Refactor respuesta validation in submitRespuestas method for improved clarity

This commit is contained in:
miguel
2026-03-09 19:13:26 -06:00
parent aa2a0f1073
commit f4bd054aa1
@@ -87,7 +87,9 @@ export class CuestionarioRespondidoService {
if (cuestionario.evento?.id_evento) { if (cuestionario.evento?.id_evento) {
const id_evento = cuestionario.evento.id_evento; const id_evento = cuestionario.evento.id_evento;
const tieneLista = const tieneLista =
await this.eventoUsuarioService.eventoTieneListaRestringida(id_evento); await this.eventoUsuarioService.eventoTieneListaRestringida(
id_evento,
);
if (tieneLista) { if (tieneLista) {
const preguntaIds = submitDto.respuestas.map((r) => r.id_pregunta); const preguntaIds = submitDto.respuestas.map((r) => r.id_pregunta);
@@ -109,13 +111,17 @@ export class CuestionarioRespondidoService {
const respuesta = submitDto.respuestas.find( const respuesta = submitDto.respuestas.find(
(r) => r.id_pregunta === pregunta.id_pregunta, (r) => r.id_pregunta === pregunta.id_pregunta,
); );
if ( if (
respuesta && respuesta &&
typeof respuesta.valor === 'string' && respuesta.valor !== null &&
respuesta.valor.trim() respuesta.valor !== undefined
) { ) {
identificador = respuesta.valor.trim().toUpperCase(); const valorStr = String(respuesta.valor).trim();
break; if (valorStr) {
identificador = valorStr.toUpperCase();
break;
}
} }
} }