const fs = require('fs'); let content = fs.readFileSync('src/App.jsx', 'utf8'); // 1. State content = content.replace( /const \[isPrivate, setIsPrivate\] = useState\(false\);/, `const [isPrivate, setIsPrivate] = useState(false);\n const [shortcutsEnabled, setShortcutsEnabled] = useState(false);` ); // 2. Toggle and Nav handle const toggleInsert = ` const handlePrivacyToggle = (newVal) => { setIsPrivate(newVal); saveUserSetting('isPrivate', newVal); }; const handleShortcutsToggle = (newVal) => { setShortcutsEnabled(newVal); saveUserSetting('shortcutsEnabled', newVal); }; const handleNavShortcut = (direction) => { const navItems = ['dashboard', 'closet', 'wishlist', 'laundry', 'outfits', 'planner', 'community', 'settings']; const currentIndex = navItems.indexOf(view); if (currentIndex === -1) return; let nextIndex; if (direction === 'up') { nextIndex = currentIndex === 0 ? navItems.length - 1 : currentIndex - 1; } else { nextIndex = currentIndex === navItems.length - 1 ? 0 : currentIndex + 1; } setView(navItems[nextIndex]); if (window.innerWidth < 768) setSidebarOpen(false); }; `; content = content.replace( /const handlePrivacyToggle = \(newVal\) => \{[\s\S]*?saveUserSetting\('isPrivate', newVal\);\n \};/, toggleInsert.trim() ); // 3. Load from Firebase content = content.replace( /if \(data\.settings\.isPrivate !== undefined\) setIsPrivate\(data\.settings\.isPrivate\);/, `if (data.settings.isPrivate !== undefined) setIsPrivate(data.settings.isPrivate);\n if (data.settings.shortcutsEnabled !== undefined) setShortcutsEnabled(data.settings.shortcutsEnabled);` ); // 4. UseEffect const useEffectInsert = ` useEffect(() => { if (!shortcutsEnabled) return; const handleKeyDown = (e) => { if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return; if (e.key.toLowerCase() === 'q') { handleNavShortcut('up'); } else if (e.key.toLowerCase() === 'e') { handleNavShortcut('down'); } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [shortcutsEnabled, view]); useEffect(() => { if (editingItem && editingItem.color) {`; content = content.replace( /useEffect\(\(\) => \{\n if \(editingItem && editingItem\.color\) \{/, useEffectInsert.trim() ); // 5. Settings UI const settingsUI = `
Atalhos de Teclado
Ativar navegação com Q e E