import 'package:flutter/material.dart';
import '../widgets/education_ui.dart';

class EducationProgramsPage extends StatelessWidget {
  const EducationProgramsPage({super.key, required this.programs, required this.onAdd});
  final List<Map<String, dynamic>> programs;
  final VoidCallback onAdd;

  @override
  Widget build(BuildContext context) => Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
    EducationPageHeading(title: 'Program Directory', subtitle: 'Programs organized under their schools', icon: Icons.menu_book_outlined, actionText: 'ADD PROGRAM', onAction: onAdd),
    const SizedBox(height: 16),
    Container(color: educationGreen, padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12), child: const Row(children: [
      Expanded(child: Text('PROGRAM', style: TextStyle(color: Colors.white, fontWeight: FontWeight.w800))),
      Text('SCHOOL', style: TextStyle(color: Colors.white, fontWeight: FontWeight.w800)),
    ])),
    const SizedBox(height: 3),
    Expanded(child: programs.isEmpty
      ? const EducationEmptyState(text: 'There are no programs yet. Create a school first, then add its programs.')
      : ListView.separated(
          itemCount: programs.length,
          separatorBuilder: (_, __) => const SizedBox(height: 3),
          itemBuilder: (_, index) {
            final program = programs[index];
            return EducationRecordTile(
              icon: Icons.menu_book_outlined,
              title: educationText(program['program_name']),
              detail: 'Program code: ${educationText(program['program_code'], 'Not set')}',
              trailing: educationText(program['school_name']),
            );
          },
        )),
  ]);
}
