From b34b5bf523b812ebb8e1266a610e853ccf3726b2 Mon Sep 17 00:00:00 2001 From: Sidney Date: Fri, 29 May 2026 20:15:59 -0300 Subject: [PATCH] fix(pre-matricula, types, db): fix pre-enrollment field editor and add max_score db column --- manager/components/PreMatricula.tsx | 41 ++++++++++++++++++----------- manager/components/Sidebar.tsx | 6 ++--- manager/scratch/add_max_score.cjs | 23 ++++++++++++++++ manager/types.ts | 2 +- 4 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 manager/scratch/add_max_score.cjs diff --git a/manager/components/PreMatricula.tsx b/manager/components/PreMatricula.tsx index 08f6357..bf2619f 100644 --- a/manager/components/PreMatricula.tsx +++ b/manager/components/PreMatricula.tsx @@ -94,10 +94,14 @@ const PreMatricula: React.FC = ({ data, onConvert }) => { }; const addField = async () => { - if (!newField.label.trim()) return; + let label = newField.label.trim(); + if (newField.tipo === 'banner' && !label) { + label = 'Folder Promocional'; + } + if (!label) return; const campo = { id: crypto.randomUUID(), - label: newField.label, + label: label, tipo: newField.tipo, placeholder: newField.placeholder, obrigatorio: newField.obrigatorio, @@ -126,12 +130,17 @@ const PreMatricula: React.FC = ({ data, onConvert }) => { }; const updateField = async (campo: PreMatriculaCampo) => { + let label = campo.label.trim(); + if (campo.tipo === 'banner' && !label) { + label = 'Folder Promocional'; + } + const updatedCampo = { ...campo, label }; try { await fetch(`/api/prematricula/campos/${campo.id}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(campo) + body: JSON.stringify(updatedCampo) }); - setCampos(prev => prev.map(c => c.id === campo.id ? campo : c)); + setCampos(prev => prev.map(c => c.id === campo.id ? updatedCampo : c)); setEditingCampo(null); } catch (e) { console.error(e); } }; @@ -468,22 +477,22 @@ const PreMatricula: React.FC = ({ data, onConvert }) => {
{newField.placeholder ? ( -
- Banner -
+
+ Banner +
) : ( -