#!/usr/bin/env python3
"""Validation script for TasksPanel refactoring."""

import sys
import os

# Add utils directory to path for imports
sys.path.insert(0, os.path.dirname(__file__))

from utils.validation_common import (
    validate_jsx_component, 
    count_complexity, 
    print_validation_header,
    print_complexity_analysis,
    print_summary_footer
)

def main():
    """Validate TasksPanel refactoring."""
    print_validation_header("TasksPanel Refactoring")
    
    # Components to validate
    components = {
        'TasksViewControls.jsx': ['TasksViewControls'],
        'TasksBoard.jsx': ['TasksBoard'],
        'TasksList.jsx': ['TasksList'],
        'TasksTable.jsx': ['TasksTable'],
        'TasksRecentJobs.jsx': ['TasksRecentJobs'],
        'TasksPanelRefactored.jsx': ['TasksPanelRefactored']
    }
    
    base_path = 'src/proxym/dashboard/components/tasks'
    
    print("1. Component Structure Validation:")
    all_valid = True
    
    for component, expected_exports in components.items():
        file_path = os.path.join(base_path, component)
        is_valid, details = validate_jsx_component(file_path, expected_exports)
        status = "✅" if is_valid else "❌"
        print(f"  {status} {component} - {details}")
        if not is_valid:
            all_valid = False
    
    print_complexity_analysis(list(components.keys()), base_path)
    
    # Compare with original
    original_file = 'src/proxym/dashboard/components/tasks.jsx'
    if os.path.exists(original_file):
        original_complexity = count_complexity(original_file)
        if original_complexity:
            print(f"  📊 Original tasks.jsx: {original_complexity['lines']} lines, complexity: {original_complexity['complexity']}")
    
    print_summary_footer()
    
    print("\n🎯 TasksPanel Refactoring Benefits:")
    print("  ✅ Separated task management into focused components")
    print("  ✅ Improved reusability of task logic")
    print("  ✅ Enhanced testability with isolated components")
    print("  ✅ Better maintainability through modular design")
    
    return all_valid

if __name__ == "__main__":
    main()
