38 lines
1.6 KiB
JavaScript
38 lines
1.6 KiB
JavaScript
const fs = require('fs');
|
|
|
|
let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8');
|
|
|
|
const regex = /<div className="flex justify-between">\s*<div className="flex gap-2">\s*\{canEdit && \(\s*<Button variant="outline" onClick=\{.*?>\s*<Plus className="h-4 w-4 mr-2" \/>Nueva\s*<\/Button>\s*\)\}\s*<Button variant="outline" onClick=\{.*?\} disabled=\{listGlucemias.length === 0\}>\s*<TrendingUp className="h-4 w-4 mr-2" \/>Evolución\s*<\/Button>\s*<\/div>\s*<\/div>/g;
|
|
|
|
const replacement = `
|
|
{portalNode ? createPortal(
|
|
<>
|
|
{canEdit && (
|
|
<Button variant="outline" onClick={() => { reset(); setDialog(true); }}>
|
|
<Plus className="h-4 w-4 mr-2" />Nueva
|
|
</Button>
|
|
)}
|
|
<Button variant="outline" onClick={() => setEvolDialog(true)} disabled={listGlucemias.length === 0}>
|
|
<TrendingUp className="h-4 w-4 mr-2" />Evolución
|
|
</Button>
|
|
</>,
|
|
portalNode
|
|
) : (
|
|
<div className="flex justify-between mb-4">
|
|
<div className="flex gap-2">
|
|
{canEdit && (
|
|
<Button variant="outline" onClick={() => { reset(); setDialog(true); }}>
|
|
<Plus className="h-4 w-4 mr-2" />Nueva
|
|
</Button>
|
|
)}
|
|
<Button variant="outline" onClick={() => setEvolDialog(true)} disabled={listGlucemias.length === 0}>
|
|
<TrendingUp className="h-4 w-4 mr-2" />Evolución
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
)}
|
|
`.trim();
|
|
|
|
code = code.replace(regex, replacement);
|
|
fs.writeFileSync('src/sections/HistoriaClinica.tsx', code);
|