import re import os file_path = r'd:\AI_Contract_Detector\frontend\src\app\dashboard\page.tsx' with open(file_path, 'r', encoding='utf-8') as f: content = f.read() # Pattern to find the end of the results tab motion.div and include the billing tab after it. # We look for the motion.div with key="results" and its closing tags. # {activeTab === "results" && ( ... \n )} pattern = r'(\{activeTab === "results" && \([\s\S]+?\s+?\)\s+?)\}\s+?' billing_tab = r'''\1} {activeTab === "billing" && ( )} ''' if re.search(pattern, content): new_content = re.sub(pattern, billing_tab, content) with open(file_path, 'w', encoding='utf-8') as f: f.write(new_content) print("SUCCESS: Patched page.tsx with Billing Tab") else: print("ERROR: Could not find the injection point in page.tsx") # Debug: show what we found m = re.search(r'activeTab === "results"', content) if m: print("Found activeTab results at index", m.start())