import os base_path = 'src/components' # 1. Button.jsx button_path = os.path.join(base_path, 'Button.jsx') button_content = '''import React from 'react'; import { Loader2 } from 'lucide-react'; export default function Button({ children, variant = 'primary', size = 'md', className = '', type = 'button', loading = false, disabled = false, icon, ...props }) { const baseClass = "btn relative inline-flex items-center justify-center transition-all duration-200 active:translate-y-[1px] disabled:opacity-60 disabled:cursor-not-allowed focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--emerald)]"; const variantClass = `btn-${variant}`; const sizeClass = size === 'sm' ? 'btn-sm' : size === 'xs' ? 'btn-xs px-2 py-1 text-xs' : ''; return ( ); } ''' with open(button_path, 'w', encoding='utf-8') as f: f.write(button_content) # 2. StatusChip.jsx status_path = os.path.join(base_path, 'StatusChip.jsx') status_content = '''import React from 'react'; export default function StatusChip({ status, note }) { const s = (status || 'pending').toLowerCase(); let badgeClass = 'badge-yellow'; if (s === 'approved' || s === 'filed' || s === 'verified') badgeClass = 'badge-green'; if (s === 'rejected' || s === 'error') badgeClass = 'badge-red'; if (s === 'sent_for_approval') badgeClass = 'badge-blue'; const statusText = s.replace(/_/g, ' ').toUpperCase(); return (
{statusText} {note && (
Rejection Note: {note}
)}
); } ''' with open(status_path, 'w', encoding='utf-8') as f: f.write(status_content) # 3. ConfirmModal.jsx modal_path = os.path.join(base_path, 'ConfirmModal.jsx') modal_content = '''import React, { useEffect } from "react"; import Button from "./Button"; function ConfirmModal({ isOpen, title, message, confirmText, cancelText, onConfirm, onCancel, isDestructive }) { useEffect(() => { if (!isOpen) return; const handleEsc = (e) => { if (e.key === 'Escape') onCancel(); }; window.addEventListener('keydown', handleEsc); return () => window.removeEventListener('keydown', handleEsc); }, [isOpen, onCancel]); if (!isOpen) return null; return (
e.stopPropagation()}> {title &&

{title}

} {message && (
{message.split('\\n').map((line, i) => ( {line}
))}
)}
); } export default ConfirmModal; ''' with open(modal_path, 'w', encoding='utf-8') as f: f.write(modal_content) # 4. ResponsiveTable.jsx table_path = os.path.join(base_path, 'ResponsiveTable.jsx') table_content = '''import React from 'react'; export default function ResponsiveTable({ columns, data, keyField = 'id', renderCard }) { if (!data || data.length === 0) { return (
inventory_2

No records found

Try adjusting your filters or upload a new document.

); } return ( <>
{columns.map((col, idx) => ( ))} {data.map(row => ( {columns.map((col, idx) => ( ))} ))}
{col.label}
{col.render ? col.render(row) : row[col.key]}
{data.map(row => (
{renderCard ? renderCard(row) : (
{columns.map((col, idx) => (
{col.label}: {col.render ? col.render(row) : row[col.key]}
))}
)}
))}
); } ''' with open(table_path, 'w', encoding='utf-8') as f: f.write(table_content) # 5. Navbar.jsx navbar_path = os.path.join(base_path, 'Navbar.jsx') navbar_content = '''import { Link, useLocation, useNavigate } from 'react-router-dom'; import { useState } from 'react'; export default function Navbar({ solid = false }) { const [isOpen, setIsOpen] = useState(false); const location = useLocation(); const navigate = useNavigate(); const isActive = (path) => { if (path === '/' && location.pathname === '/') return true; if (path !== '/' && location.pathname.startsWith(path)) return true; return false; }; const navLinks = [ { name: 'Home', path: '/' }, { name: 'About Us', path: '/about-us' }, { name: 'Services', path: '/services' }, { name: 'Contact Us', path: '/contact' } ]; return (
BookKeepPro
setIsOpen(!isOpen)}>
); } ''' with open(navbar_path, 'w', encoding='utf-8') as f: f.write(navbar_content) # 6. Footer.jsx footer_path = os.path.join(base_path, 'Footer.jsx') footer_content = '''import { Link } from 'react-router-dom'; export default function Footer() { return ( ); } ''' with open(footer_path, 'w', encoding='utf-8') as f: f.write(footer_content) print('Phase 4 rewritten safely.')