diff --git a/luckychit/lib/interfaces/manager/group_details_page.dart b/luckychit/lib/interfaces/manager/group_details_page.dart index 91fcaf1..356cc32 100644 --- a/luckychit/lib/interfaces/manager/group_details_page.dart +++ b/luckychit/lib/interfaces/manager/group_details_page.dart @@ -93,29 +93,34 @@ class _GroupDetailsPageState extends State with SingleTickerPr elevation: 0, actions: [ // Actions menu - always visible - PopupMenuButton( + PopupMenuButton( icon: Icon(Icons.more_vert, size: 24.w, color: Colors.grey.shade700), tooltip: 'More Options', - onSelected: (value) { - if (value == 'select' && widget.group.isForming) { - _showMemberSelectionDialog(context); - } else if (value == 'add_user' && widget.group.isForming) { - _showAddUserDialog(context); + onSelected: (value) { + if (value == 'select') { + _showMemberSelectionDialog(context); + } else if (value == 'add_user') { + _showAddUserDialog(context); } else if (value == 'add_past_draw') { _showAddPastDrawDialog(context); } else if (value == 'add_past_payments') { _showAddPastPaymentsDialog(context); - } - }, - itemBuilder: (context) => [ - // Add members options (only for forming groups) - if (widget.group.isForming) ...[ + } + }, + itemBuilder: (context) { + final currentMemberCount = widget.group.currentMemberCount; + final maxMembers = widget.group.maxMembers; + final canAddMembers = currentMemberCount < maxMembers; + + return [ + // Add members options (if not full) + if (canAddMembers) ...[ PopupMenuItem( value: 'select', child: Row( children: [ Icon(Icons.people_alt, color: Colors.blue.shade600), - SizedBox(width: 12.w), + SizedBox(width: 12.w), const Text('Select Members'), ], ), @@ -125,36 +130,37 @@ class _GroupDetailsPageState extends State with SingleTickerPr child: Row( children: [ Icon(Icons.person_add, color: Colors.green.shade600), - SizedBox(width: 12.w), + SizedBox(width: 12.w), const Text('Add New User'), ], ), ), - const PopupMenuDivider(), - ], - // Backfill options (always available) - PopupMenuItem( - value: 'add_past_draw', - child: Row( - children: [ - Icon(Icons.history, color: Colors.blue.shade600), - SizedBox(width: 12.w), - const Text('Add Past Draw Result'), - ], + const PopupMenuDivider(), + ], + // Backfill options (always available) + PopupMenuItem( + value: 'add_past_draw', + child: Row( + children: [ + Icon(Icons.history, color: Colors.blue.shade600), + SizedBox(width: 12.w), + const Text('Add Past Draw Result'), + ], + ), ), - ), - PopupMenuItem( - value: 'add_past_payments', - child: Row( - children: [ - Icon(Icons.payment_outlined, color: Colors.green.shade600), - SizedBox(width: 12.w), - const Text('Add Past Payments'), - ], + PopupMenuItem( + value: 'add_past_payments', + child: Row( + children: [ + Icon(Icons.payment_outlined, color: Colors.green.shade600), + SizedBox(width: 12.w), + const Text('Add Past Payments'), + ], + ), ), - ), - ], - ), + ]; + }, + ), ], bottom: PreferredSize( preferredSize: Size.fromHeight(64.h), diff --git a/luckychit/lib/interfaces/manager/manager_dashboard.dart b/luckychit/lib/interfaces/manager/manager_dashboard.dart index 78a9304..f973de4 100644 --- a/luckychit/lib/interfaces/manager/manager_dashboard.dart +++ b/luckychit/lib/interfaces/manager/manager_dashboard.dart @@ -332,50 +332,28 @@ class ManagerDashboard extends StatelessWidget { Widget _buildMobileStatsGrid() { return Obx(() { final groups = ChitGroupService.to.chitGroups; - final activeGroups = groups.where((g) => g.isActive).length; - final formingGroups = groups.where((g) => g.isForming).length; final totalMembers = groups.fold(0, (sum, group) => sum + (group.members?.length ?? 0)); - return Column( + return Row( children: [ - Row( - children: [ - Expanded(child: InteractiveStatsCard( - title: 'Active Chitfunds', - value: activeGroups.toString(), - icon: Icons.group, - color: Colors.blue.shade600, - onTap: () => _navigateToGroups(), - )), - SizedBox(width: 12.w), - Expanded(child: InteractiveStatsCard( - title: 'Forming Chitfunds', - value: formingGroups.toString(), - icon: Icons.group_add, - color: Colors.orange.shade600, - onTap: () => _navigateToGroups(), - )), - ], + Expanded( + child: InteractiveStatsCard( + title: 'Total Chitfunds', + value: groups.length.toString(), + icon: Icons.account_balance_wallet, + color: Colors.green.shade600, + onTap: () => _navigateToGroups(), + ), ), - SizedBox(height: 12.h), - Row( - children: [ - Expanded(child: InteractiveStatsCard( - title: 'Total Members', - value: totalMembers.toString(), - icon: Icons.people, - color: Colors.green.shade600, - onTap: () => _navigateToMembers(), - )), - SizedBox(width: 12.w), - Expanded(child: InteractiveStatsCard( - title: 'Total Chitfunds', - value: groups.length.toString(), - icon: Icons.dashboard, - color: Colors.purple.shade600, - onTap: () => _navigateToGroups(), - )), - ], + SizedBox(width: 12.w), + Expanded( + child: InteractiveStatsCard( + title: 'Total Members', + value: totalMembers.toString(), + icon: Icons.people, + color: Colors.blue.shade600, + onTap: () => _navigateToMembers(), + ), ), ], ); @@ -385,43 +363,29 @@ class ManagerDashboard extends StatelessWidget { Widget _buildDesktopStatsGrid() { return Obx(() { final groups = ChitGroupService.to.chitGroups; - final activeGroups = groups.where((g) => g.isActive).length; - final formingGroups = groups.where((g) => g.isForming).length; final totalMembers = groups.fold(0, (sum, group) => sum + (group.members?.length ?? 0)); return Row( children: [ - Expanded(child: InteractiveStatsCard( - title: 'Active Groups', - value: activeGroups.toString(), - icon: Icons.group, - color: Colors.blue.shade600, - onTap: () => _navigateToGroups(), - )), + Expanded( + child: InteractiveStatsCard( + title: 'Total Chitfunds', + value: groups.length.toString(), + icon: Icons.account_balance_wallet, + color: Colors.green.shade600, + onTap: () => _navigateToGroups(), + ), + ), SizedBox(width: 16.w), - Expanded(child: InteractiveStatsCard( - title: 'Forming Groups', - value: formingGroups.toString(), - icon: Icons.group_add, - color: Colors.orange.shade600, - onTap: () => _navigateToGroups(), - )), - SizedBox(width: 16.w), - Expanded(child: InteractiveStatsCard( - title: 'Total Members', - value: totalMembers.toString(), - icon: Icons.people, - color: Colors.green.shade600, - onTap: () => _navigateToMembers(), - )), - SizedBox(width: 16.w), - Expanded(child: InteractiveStatsCard( - title: 'Total Groups', - value: groups.length.toString(), - icon: Icons.dashboard, - color: Colors.purple.shade600, - onTap: () => _navigateToGroups(), - )), + Expanded( + child: InteractiveStatsCard( + title: 'Total Members', + value: totalMembers.toString(), + icon: Icons.people, + color: Colors.blue.shade600, + onTap: () => _navigateToMembers(), + ), + ), ], ); });