Set Default Value for Audit Type and Fix Language Value on Audit Creation#166
Set Default Value for Audit Type and Fix Language Value on Audit Creation#166caverav merged 4 commits intodevelopmentfrom
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughEste pull request introduce varias modificaciones en el componente Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
frontend/src/routes/audits/audits.tsx (1)
Line range hint
251-267: ¡El manejo de errores necesita mejoras urgentes!El manejo de errores en
handleSubmitNewAudittiene varias deficiencias:
- El mensaje "TODO: Show error" no se ha implementado
- El catch interno solo muestra el error en toast, pero el catch externo lo ignora
- No hay validación del formato de los valores antes de enviarlos
Te propongo esta mejora:
const handleSubmitNewAudit = async () => { if (!currentAuditType || !currentLanguage) { - return; // TODO: Show error + toast.error(t('err.missingRequiredFields')); + return; } try { - await createAudit({ + const response = await createAudit({ name: nameAudit, auditType: currentAuditType.value, language: currentLanguage.value, type: selectedValue, - }).catch(error => { - toast.error(error.message); - }); + }); + + if (response.status === 'success') { setCurrentAuditType(null); setCurrentLanguage(null); setSelectedValue('1'); setNameAudit(''); void fetchAndUpdateData(); setIsOpenNewAuditModal(false); + } } catch (error) { - console.error('Error:', error); + toast.error(t('err.failedCreateAudit')); + console.error('Failed to create audit:', error); } - setIsOpenNewAuditModal(!isOpenNewAuditModal); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
frontend/src/routes/audits/audits.tsx(2 hunks)
🔇 Additional comments (1)
frontend/src/routes/audits/audits.tsx (1)
205-206: ¡Correcto uso de locale como valor interno!
La modificación para usar locale como valor interno y language como etiqueta visual es apropiada. Sin embargo, falta validación de tipos para asegurar que los valores sean correctos.
Ejecutemos una verificación de los tipos:
Descripción
Se realizan dos cambios:
Motivación y Contexto
El primer cambio es más que nada visual, ya que visualmente da la idea de que es opcional el seleccionar uno, cuando en realidad si no se selecciona uno, por defecto es "Default".
El segundo cambio arregla un bug existe en la app, ya que anteriormente se enviaba al backend el campo "language", y este no se reconocia en el dropdown al editar el audit, aunque los campos "auditType" y "language" tuvieran valores (si, pasaba a llevar a auditType). Con este cambio al agregar auditorias y posteriormente editarlas, aparecen los campos correspondientes.
Importante: Este cambio ayuda a las secciones de findings, debido a que anteriormente al agregar un finding se hacia utilizando el campo "language" y no "locale" de los lenguajes.
¿Cómo ha sido probado?
Para probar se debe añadir una auditoria con los campos necesarios y posteriormente ir a la edición de esta, se verá como se rellenan los dropdown correspondientes.
Capturas de pantalla (si es apropiado):
Valor por defecto
Antes:

Ahora:

Tipos de cambios
Lista de verificación:
Summary by CodeRabbit
Nuevas Funciones
Mejoras