From fce539abc20d44c56538778e911589d13d1b1d57 Mon Sep 17 00:00:00 2001 From: AI Studio Date: Wed, 12 Aug 2026 20:39:17 +0000 Subject: [PATCH] style(HistoriaClinica): Agrupar tabs en menu select unificado y mostrar botones de accion en linea --- auto_portal.cjs | 137 +++++++++++++++ fix_atb.cjs | 24 +++ fix_buttons.cjs | 21 +++ fix_estudios.cjs | 46 +++++ fix_ic_atb.cjs | 26 +++ fix_pendientes.cjs | 38 +++++ fix_props.cjs | 22 +++ patch.cjs | 58 +++++++ patch.js | 39 +++++ patch2.cjs | 45 +++++ src/sections/HistoriaClinica.tsx | 240 ++++++++++++++++----------- src/sections/SeccionIndicaciones.tsx | 32 +++- update_buttons.cjs | 92 ++++++++++ update_glucemias.cjs | 37 +++++ 14 files changed, 747 insertions(+), 110 deletions(-) create mode 100644 auto_portal.cjs create mode 100644 fix_atb.cjs create mode 100644 fix_buttons.cjs create mode 100644 fix_estudios.cjs create mode 100644 fix_ic_atb.cjs create mode 100644 fix_pendientes.cjs create mode 100644 fix_props.cjs create mode 100644 patch.cjs create mode 100644 patch.js create mode 100644 patch2.cjs create mode 100644 update_buttons.cjs create mode 100644 update_glucemias.cjs diff --git a/auto_portal.cjs b/auto_portal.cjs new file mode 100644 index 0000000..f1277d6 --- /dev/null +++ b/auto_portal.cjs @@ -0,0 +1,137 @@ +const fs = require('fs'); + +const patterns = [ + { + // Glucemias + find: `
\n
\n {canEdit && (\n \n )}\n \n
\n
`, + replace: `{portalNode ? createPortal(\n <>\n {canEdit && (\n \n )}\n \n ,\n portalNode\n ) : (\n
\n
\n {canEdit && (\n \n )}\n \n
\n
\n )}` + }, + { + // Laboratorios + find: `
\n {canEdit && }\n setSearchTerm(e.target.value)} className="max-w-xs" />\n
`, + replace: ` + {portalNode ? createPortal( + <> + {canEdit && } + setSearchTerm(e.target.value)} className="max-w-[150px] h-9" /> + , + portalNode + ) : ( +
+ {canEdit && } + setSearchTerm(e.target.value)} className="max-w-xs" /> +
+ )} + `.trim() + }, + { + // Evoluciones + find: `
\n {canEdit && }\n
`, + replace: ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} + `.trim() + }, + { + // EAB + find: `
\n {canEdit && }\n
`, + replace: ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} + `.trim() + }, + { + // Cultivos + find: `
\n {canEdit && }\n
`, + replace: ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} + `.trim() + }, + { + // Estudios + find: `
\n {canEdit && }\n
`, + replace: ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} + `.trim() + }, + { + // Interconsultas + find: `
\n {canEdit && }\n
`, + replace: ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} + `.trim() + }, + { + // ATB + find: `
\n {canEdit && }\n
`, + replace: ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} + `.trim() + }, + { + // Pendientes + find: `
\n {canEdit && }\n
`, + replace: ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} + `.trim() + } +]; + +let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); + +for (let p of patterns) { + if (code.includes(p.find)) { + code = code.replace(p.find, p.replace); + } else { + console.log("NOT FOUND:", p.find.substring(0, 50)); + } +} + +fs.writeFileSync('src/sections/HistoriaClinica.tsx', code); diff --git a/fix_atb.cjs b/fix_atb.cjs new file mode 100644 index 0000000..efd89ac --- /dev/null +++ b/fix_atb.cjs @@ -0,0 +1,24 @@ +const fs = require('fs'); +let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); + +const repl = ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} +`.trim(); + +code = code.replace( + /
\s*\{canEdit && ` and `` + + // A more robust approach: + // Instead of replacing the JSX, let's just create a string replacement loop for known patterns. + code = code.replace( + /
\s*(\{canEdit && } +
+ +
+ )} +`.trim(); + +code = code.replace(regex, repl); +fs.writeFileSync('src/sections/HistoriaClinica.tsx', code); diff --git a/fix_ic_atb.cjs b/fix_ic_atb.cjs new file mode 100644 index 0000000..b16f31d --- /dev/null +++ b/fix_ic_atb.cjs @@ -0,0 +1,26 @@ +const fs = require('fs'); +let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); + +const replIC = ` + {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} +`.trim(); + +code = code.replace( + /
\s*\{canEdit && + {canEdit && ( + + )} + , + portalNode + ) : ( +
+ + {canEdit && ( + + )} +
+ )} +`.trim(); + +code = code.replace(regex, repl); +fs.writeFileSync('src/sections/HistoriaClinica.tsx', code); diff --git a/fix_props.cjs b/fix_props.cjs new file mode 100644 index 0000000..8527426 --- /dev/null +++ b/fix_props.cjs @@ -0,0 +1,22 @@ +const fs = require('fs'); + +function fix(filename) { + let code = fs.readFileSync(filename, 'utf8'); + + // Fix duplicate portalNode + code = code.replace(/portalNode , portalNode/g, 'portalNode'); + + // Add type definition: replace `canEdit?: boolean;` with `canEdit?: boolean; portalNode?: HTMLDivElement | null;` + code = code.replace(/canEdit\?: boolean;/g, 'canEdit?: boolean;\n portalNode?: HTMLDivElement | null;'); + + // For SeccionPendientes which has `canEdit: boolean })` + code = code.replace(/canEdit: boolean \}\)/g, 'canEdit: boolean; portalNode?: HTMLDivElement | null; })'); + + // For SeccionIndicaciones (if it uses `canEdit?: boolean`) + + fs.writeFileSync(filename, code); +} + +fix('src/sections/HistoriaClinica.tsx'); +try { fix('src/sections/SeccionIndicaciones.tsx'); } catch(e){} + diff --git a/patch.cjs b/patch.cjs new file mode 100644 index 0000000..f523d1f --- /dev/null +++ b/patch.cjs @@ -0,0 +1,58 @@ +const fs = require('fs'); +let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); + +code = code.replace("import { useState } from 'react';", "import { useState } from 'react';\nimport { createPortal } from 'react-dom';"); + +const portalState = "const [tabActivo, setTabActivo] = useState('evoluciones');\n const [portalNode, setPortalNode] = useState(null);"; +code = code.replace("const [tabActivo, setTabActivo] = useState('evoluciones');", portalState); + +const tabsListRegex = /([\s\S]*?)<\/ScrollArea>/; +const newTabsList = ` +
+ + + +
+`; + +code = code.replace(tabsListRegex, newTabsList.trim()); + +// We also need to add portalNode={portalNode} to all SeccionXXX components +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); +code = code.replace(//g, ''); + +// Update signatures +function updateSignature(name) { + const regex = new RegExp(`function ${name}\\(\\{ (.*?)canEdit \\}: \\{([\\s\\S]*?)canEdit\\?: boolean;([\\s\\S]*?)\\}\\) \\{`, 'g'); + // Wait, some might not have canEdit?: boolean optional. +} +// Actually, it's easier to do this individually or just with a regex + +fs.writeFileSync('src/sections/HistoriaClinica.tsx', code); diff --git a/patch.js b/patch.js new file mode 100644 index 0000000..44ab953 --- /dev/null +++ b/patch.js @@ -0,0 +1,39 @@ +const fs = require('fs'); +let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); + +code = code.replace("import { useState } from 'react';", "import { useState } from 'react';\nimport { createPortal } from 'react-dom';"); + +const portalState = "const [tabActivo, setTabActivo] = useState('evoluciones');\n const [portalNode, setPortalNode] = useState(null);"; +code = code.replace("const [tabActivo, setTabActivo] = useState('evoluciones');", portalState); + +const tabsListRegex = /([\s\S]*?)<\/ScrollArea>/; +const newTabsList = ` +
+ + + +
+`.trim(); + +code = code.replace(tabsListRegex, newTabsList); + +fs.writeFileSync('src/sections/HistoriaClinica.tsx', code); diff --git a/patch2.cjs b/patch2.cjs new file mode 100644 index 0000000..86949f8 --- /dev/null +++ b/patch2.cjs @@ -0,0 +1,45 @@ +const fs = require('fs'); + +function processFile(filename) { + let code = fs.readFileSync(filename, 'utf8'); + + // Add import if not present + if (!code.includes("import { createPortal }")) { + code = code.replace("import { useState }", "import { useState } from 'react';\nimport { createPortal }"); + if (!code.includes("import { createPortal }")) { + code = "import { createPortal } from 'react-dom';\n" + code; + } + } + + // Update component signatures + const components = [ + 'SeccionGlucemias', 'SeccionLaboratorios', 'SeccionEvoluciones', + 'SeccionAcidosBase', 'SeccionCultivos', 'SeccionATB', + 'SeccionEstudiosComplementarios', 'SeccionInterconsultas', 'SeccionPendientes', + 'SeccionIndicaciones' + ]; + + components.forEach(name => { + // 1. Add portalNode to the destructured props + const regex1 = new RegExp(`function ${name}\\(\\{ (.*?) \\}: \\{`, 'g'); + code = code.replace(regex1, `function ${name}({ $1, portalNode }: {`); + + // Some don't have spaces around the brackets + const regex1b = new RegExp(`function ${name}\\(\\{(.*?)\\}: \\{`, 'g'); + code = code.replace(regex1b, `function ${name}({$1, portalNode}: {`); + + // 2. Add portalNode?: HTMLDivElement | null; to the type definition + // Usually ends with canEdit?: boolean; }) or canEdit: boolean }) + const regex2 = new RegExp(`(canEdit\\??: boolean;?\\s*)\\}\\)`, 'g'); + // Actually we can just find the end of the props type definition for that component. + // It's safer to just replace `canEdit` or something similar, but let's do a more robust approach. + }); + + fs.writeFileSync(filename, code); +} + +processFile('src/sections/HistoriaClinica.tsx'); +try { + processFile('src/sections/SeccionIndicaciones.tsx'); +} catch (e) {} + diff --git a/src/sections/HistoriaClinica.tsx b/src/sections/HistoriaClinica.tsx index 1380869..d7339f4 100644 --- a/src/sections/HistoriaClinica.tsx +++ b/src/sections/HistoriaClinica.tsx @@ -1,4 +1,5 @@ import { useState } from 'react'; +import { createPortal } from 'react-dom'; import { toast } from 'sonner'; import { User } from 'lucide-react'; import { useHospitalStore } from '@/hooks/useHospitalStore'; @@ -249,6 +250,7 @@ export function HistoriaClinica({ canEdit, }: HistoriaClinicaProps) { const [tabActivo, setTabActivo] = useState('evoluciones'); + const [portalNode, setPortalNode] = useState(null); const { pendientes } = useHospitalStore(); const indicacionesActivas = (indicadores || []).filter(i => i.estado === 'Activa'); const pendientesActivos = (pendientes || []).filter(p => p.pacienteId === paciente.id && p.estado === 'pendiente'); @@ -536,81 +538,49 @@ export function HistoriaClinica({
- - - - - Evoluciones - ({evoluciones.length}) - - - - - Indicaciones - ({indicacionesActivas.length}) - - - - Glucemias - ({glucemias.length}) - - - - Laboratorio - ({laboratorios.length}) - - - - EAB - ({acidosBase.length}) - - - - Cultivos - ({cultivos.length}) - - - - ATB - ({atb.length}) - - - - Estudios - ({estudiosComplementarios.length}) - - - - Interconsultas - ({interconsultas.length}) - - - - Pendientes - ({pendientesActivos.length}) - - - - +
+ + + +
- + - + - + - + - + @@ -680,7 +650,7 @@ export function HistoriaClinica({ ); } -function SeccionGlucemias({ glucemias, patientId, internacionId, add, update, del, canEdit }: { +function SeccionGlucemias({ glucemias, patientId, internacionId, add, update, del, canEdit, portalNode}: { glucemias: Glucemia[]; patientId: string; internacionId: string; @@ -688,6 +658,7 @@ function SeccionGlucemias({ glucemias, patientId, internacionId, add, update, de update: (id: string, data: Partial) => void; del: (id: string) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const [dialog, setDialog] = useState(false); const [evolDialog, setEvolDialog] = useState(false); @@ -768,8 +739,8 @@ function SeccionGlucemias({ glucemias, patientId, internacionId, add, update, de return (
-
-
+ {portalNode ? createPortal( + <> {canEdit && ( + , + portalNode + ) : ( +
+
+ {canEdit && ( + + )} + +
-
+ )} @@ -940,7 +925,7 @@ function SeccionGlucemias({ glucemias, patientId, internacionId, add, update, de ); } -function SeccionLaboratorios({ lab, patientId, internacionId, add, update, del, addAcidoBase, canEdit }: { +function SeccionLaboratorios({ lab, patientId, internacionId, add, update, del, addAcidoBase, canEdit, portalNode}: { lab: Laboratorio[]; patientId: string; internacionId: string; @@ -949,6 +934,7 @@ function SeccionLaboratorios({ lab, patientId, internacionId, add, update, del, del: (id: string) => void; addAcidoBase?: (a: Omit) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const [dialog, setDialog] = useState(false); const [obsDialog, setObsDialog] = useState(false); @@ -1864,13 +1850,14 @@ function SeccionLaboratorios({ lab, patientId, internacionId, add, update, del, ); } -function SeccionEvoluciones({ evos, internacionId, add, update, del, canEdit }: { +function SeccionEvoluciones({ evos, internacionId, add, update, del, canEdit, portalNode}: { evos: Evolucion[]; internacionId: string; add: (e: Omit) => void; update: (id: string, data: Partial) => void; del: (id: string) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const { currentUser } = useHospitalStore(); const [dialog, setDialog] = useState(false); @@ -1974,9 +1961,14 @@ function SeccionEvoluciones({ evos, internacionId, add, update, del, canEdit }: return (
-
- {canEdit && } -
+ {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} {edit ? 'Editar' : 'Nueva'} Evolución @@ -2181,7 +2173,7 @@ function SeccionEvoluciones({ evos, internacionId, add, update, del, canEdit }: ); } -function SeccionAcidosBase({ ab, patientId, internacionId, add, update, del, canEdit }: { +function SeccionAcidosBase({ ab, patientId, internacionId, add, update, del, canEdit, portalNode}: { ab: AcidoBase[]; patientId: string; internacionId: string; @@ -2189,6 +2181,7 @@ function SeccionAcidosBase({ ab, patientId, internacionId, add, update, del, can update: (id: string, datos: Partial) => void; del: (id: string) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const [dialog, setDialog] = useState(false); const [editDialog, setEditDialog] = useState(false); @@ -2260,9 +2253,14 @@ function SeccionAcidosBase({ ab, patientId, internacionId, add, update, del, can return (
-
- {canEdit && } -
+ {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} Nueva Gasometría Arterial @@ -2400,7 +2398,7 @@ function SeccionAcidosBase({ ab, patientId, internacionId, add, update, del, can ); } -function SeccionCultivos({ cults, patient, internacionId, add, update, del, canEdit }: { +function SeccionCultivos({ cults, patient, internacionId, add, update, del, canEdit, portalNode}: { cults: Cultivo[]; patient: Paciente; internacionId: string; @@ -2408,6 +2406,7 @@ function SeccionCultivos({ cults, patient, internacionId, add, update, del, canE update: (id: string, data: Partial) => void; del: (id: string) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const [dialog, setDialog] = useState(false); const [resDialog, setResDialog] = useState(false); @@ -2505,9 +2504,14 @@ function SeccionCultivos({ cults, patient, internacionId, add, update, del, canE return (
-
- {canEdit && } -
+ {portalNode ? createPortal( + canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )} Nuevo Cultivo @@ -2698,7 +2702,7 @@ function SeccionCultivos({ cults, patient, internacionId, add, update, del, canE ); } -function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, add, update, del, canEdit }: { +function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, add, update, del, canEdit, portalNode}: { estudios: EstudioComplementario[]; internacionId: string; pacienteId: string; @@ -2706,6 +2710,7 @@ function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, a update: (id: string, datos: Partial) => void; del: (id: string) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const [dialog, setDialog] = useState(false); const [filtro, setFiltro] = useState<'todos' | 'internacion'>('internacion'); @@ -2847,7 +2852,7 @@ function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, a ); } -function SeccionInterconsultas({ interconsultas, pacienteId, internacionId, add, update, del, canEdit }: { +function SeccionInterconsultas({ interconsultas, pacienteId, internacionId, add, update, del, canEdit, portalNode}: { interconsultas: Interconsulta[]; pacienteId: string; internacionId: string; @@ -2855,6 +2860,7 @@ function SeccionInterconsultas({ interconsultas, pacienteId, internacionId, add, update: (id: string, datos: Partial) => void; del: (id: string) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const [dialog, setDialog] = useState(false); const [fecha, setFecha] = useState(getLocalToday()); @@ -2902,12 +2908,20 @@ function SeccionInterconsultas({ interconsultas, pacienteId, internacionId, add, return (
-
- {canEdit && } -
+ , + portalNode + ) : ( +
+ {canEdit && } +
+ )} @@ -3020,7 +3034,7 @@ function SeccionInterconsultas({ interconsultas, pacienteId, internacionId, add, ); } -function SeccionATB({ atb, internacionId, pacienteId, add, update, del, canEdit }: { +function SeccionATB({ atb, internacionId, pacienteId, add, update, del, canEdit, portalNode}: { atb: ATB[]; internacionId: string; pacienteId: string; @@ -3028,6 +3042,7 @@ function SeccionATB({ atb, internacionId, pacienteId, add, update, del, canEdit update: (id: string, data: Partial) => void; del: (id: string) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; }) { const [dialog, setDialog] = useState(false); const [edit, setEdit] = useState(null); @@ -3085,11 +3100,18 @@ function SeccionATB({ atb, internacionId, pacienteId, add, update, del, canEdit return (
-
- {canEdit && } -
+ , + portalNode + ) : ( +
+ {canEdit && } +
+ )} @@ -3159,7 +3181,7 @@ function SeccionATB({ atb, internacionId, pacienteId, add, update, del, canEdit ); } -function SeccionPendientes({ pacienteId, internacionId, canEdit }: { pacienteId: string; internacionId: string; canEdit: boolean }) { +function SeccionPendientes({ pacienteId, internacionId, canEdit, portalNode}: { pacienteId: string; internacionId: string; canEdit: boolean; portalNode?: HTMLDivElement | null; }) { const { pendientes, agregarPendiente, actualizarPendiente, eliminarPendiente, currentUser } = useHospitalStore(); const [modalAbierto, setModalAbierto] = useState(false); const [pendienteEditar, setPendienteEditar] = useState(null); @@ -3368,18 +3390,34 @@ function SeccionPendientes({ pacienteId, internacionId, canEdit }: { pacienteId:
-
- - {canEdit && ( - - )} -
+ {canEdit && ( + + )} + , + portalNode + ) : ( +
+ + {canEdit && ( + + )} +
+ )}
{/* List of Pendientes */} diff --git a/src/sections/SeccionIndicaciones.tsx b/src/sections/SeccionIndicaciones.tsx index 82e535a..961b0a1 100644 --- a/src/sections/SeccionIndicaciones.tsx +++ b/src/sections/SeccionIndicaciones.tsx @@ -1,4 +1,5 @@ import { useState } from 'react'; +import { createPortal } from 'react'; import { toast } from 'sonner'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; @@ -13,7 +14,7 @@ import type { Indicacion, IndicacionTipo, ViaAdministracion, TipoPlanHidratacion import { useHospitalStore } from '@/hooks/useHospitalStore'; import { getNombreProfesional, getLocalToday } from '@/lib/utils'; -export function SeccionIndicaciones({ recomendaciones, internacionId, pacienteId, add, update, del, movimientos, onAgregarMovimiento, canEdit, atbList = [], addATB, updateATB }: { +export function SeccionIndicaciones({ recomendaciones, internacionId, pacienteId, add, update, del, movimientos, onAgregarMovimiento, canEdit, atbList = [], addATB, updateATB, portalNode}: { recomendaciones: Indicacion[]; internacionId: string; pacienteId?: string; @@ -23,6 +24,7 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, pacienteId movimientos?: unknown[]; onAgregarMovimiento?: (m: unknown) => void; canEdit?: boolean; + portalNode?: HTMLDivElement | null; atbList?: ATB[]; addATB?: (a: Omit) => Promise; updateATB?: (id: string, datos: Partial) => void; @@ -283,14 +285,26 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, pacienteId return (
-
- {canEdit && } - -
+ {portalNode ? createPortal( + <> + {canEdit && } + + , + portalNode + ) : ( +
+ {canEdit && } + +
+ )} diff --git a/update_buttons.cjs b/update_buttons.cjs new file mode 100644 index 0000000..8b33c2f --- /dev/null +++ b/update_buttons.cjs @@ -0,0 +1,92 @@ +const fs = require('fs'); + +let hc = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); + +// Laboratorios +hc = hc.replace( + /
\s*\{canEdit && } + setSearchTerm(e.target.value)} className="max-w-xs" /> + , + portalNode + ) : ( +
+ {canEdit && } + setSearchTerm(e.target.value)} className="max-w-xs" /> +
+ )}` +); + +// General pattern for those inside `
` +const blocks = [ + 'Nueva Evolución', + 'Nueva Gasometría', + 'Nuevo Cultivo', + 'Nuevo Estudio', + 'Nueva Interconsulta', + 'Nuevo ATB' +]; + +blocks.forEach(text => { + const regex = new RegExp(`
\\s*\\{canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )}`); +}); + +// Pendientes +hc = hc.replace( + /
\s*\{canEdit && , + portalNode + ) : ( +
+ {canEdit && } +
+ )}` +); + +fs.writeFileSync('src/sections/HistoriaClinica.tsx', hc); + + +let si = fs.readFileSync('src/sections/SeccionIndicaciones.tsx', 'utf8'); + +// Also import createPortal +if (!si.includes("createPortal")) { + si = si.replace("import { useState }", "import { useState } from 'react';\nimport { createPortal }"); +} + +si = si.replace( + /
\s*\{canEdit && } + + , + portalNode + ) : ( +
+ {canEdit && } + +
+ )}` +); + +fs.writeFileSync('src/sections/SeccionIndicaciones.tsx', si); diff --git a/update_glucemias.cjs b/update_glucemias.cjs new file mode 100644 index 0000000..c70ed81 --- /dev/null +++ b/update_glucemias.cjs @@ -0,0 +1,37 @@ +const fs = require('fs'); + +let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); + +const regex = /
\s*
\s*\{canEdit && \(\s* + )} + + , + portalNode + ) : ( +
+
+ {canEdit && ( + + )} + +
+
+ )} +`.trim(); + +code = code.replace(regex, replacement); +fs.writeFileSync('src/sections/HistoriaClinica.tsx', code);