import re

with open("resources/js/components/AdminDashboard.tsx.bak", "r", encoding="utf-8") as f:
    content = f.read()

# Find where the product editor starts
match = re.search(r"(\) : activeTab === 'products' \? \([\s\S]+?\) : activeTab === 'reviews' \? \()", content)
if match:
    product_editor_code = match.group(1)
    
    with open("resources/js/components/AdminDashboard.tsx", "r", encoding="utf-8") as f2:
        dest_content = f2.read()
    
    # Replace the simple block I added with the full block from the backup
    dest_content = re.sub(r"\) : activeTab === 'products' \? \([\s\S]+?\) : activeTab === 'reviews' \? \(", product_editor_code, dest_content)
    
    with open("resources/js/components/AdminDashboard.tsx", "w", encoding="utf-8") as f2:
        f2.write(dest_content)
    
    print("Successfully replaced product editor with the one from backup.")
else:
    print("Could not find product editor block in backup file.")

