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) {
const id_evento = cuestionario.evento.id_evento;
const tieneLista =
await this.eventoUsuarioService.eventoTieneListaRestringida(id_evento);
await this.eventoUsuarioService.eventoTieneListaRestringida(
id_evento,
);
if (tieneLista) {
const preguntaIds = submitDto.respuestas.map((r) => r.id_pregunta);
@@ -109,13 +111,17 @@ export class CuestionarioRespondidoService {
const respuesta = submitDto.respuestas.find(
(r) => r.id_pregunta === pregunta.id_pregunta,
);
if (
respuesta &&
typeof respuesta.valor === 'string' &&
respuesta.valor.trim()
respuesta.valor !== null &&
respuesta.valor !== undefined
) {
identificador = respuesta.valor.trim().toUpperCase();
break;
const valorStr = String(respuesta.valor).trim();
if (valorStr) {
identificador = valorStr.toUpperCase();
break;
}
}
}