import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../models/profile.model.dart'; import '../../providers/profile_provider.dart'; import '../../widgets/app_state_view.dart'; import 'dashboard/programmer_dashboard.dart'; /// Admin-only drill-down screen that shows [ProgrammerDashboard] for a /// specific user in read-only mode. /// /// Route: /programmer-tasks/programmers/:userId class ProgrammerDrillDownScreen extends ConsumerWidget { const ProgrammerDrillDownScreen({ super.key, required this.userId, }); final String userId; @override Widget build(BuildContext context, WidgetRef ref) { final isStrictAdmin = ref.watch(isStrictAdminProvider); final profilesAsync = ref.watch(profilesProvider); if (!isStrictAdmin) { return Scaffold( appBar: AppBar(title: const Text('Programmer')), body: const AppEmptyView( icon: Icons.lock_outline, title: 'Admins only', ), ); } // Resolve the programmer's name for the AppBar title. final profiles = profilesAsync.valueOrNull ?? []; Profile? profile; for (final p in profiles) { if (p.id == userId) { profile = p; break; } } final name = profile?.fullName ?? 'Programmer'; return Scaffold( appBar: AppBar(title: Text(name)), body: ProgrammerDashboard(userId: userId, readOnly: true), ); } }