const fs = require('fs');
const file = 'app/(onboarding)/onboarding/page.tsx';
let code = fs.readFileSync(file, 'utf8');

// Prepend "use client" and imports
const header = `"use client";\n\nimport React, { useState, useEffect, useMemo, Fragment } from "react";\nimport "./onboarding.css";\n\n`;

// Add export default to the function
code = code.replace('function OnboardingApp() {', 'export default function OnboardingApp() {');

// Remove ReactDOM.createRoot
code = code.replace('ReactDOM.createRoot(document.getElementById("root")).render(<OnboardingApp />);', '');

fs.writeFileSync(file, header + code);
console.log("Reformatted page.tsx");
