From 6e480ef09af84ed5f1ec72e4e6beb415ff62446c Mon Sep 17 00:00:00 2001 From: Deep Koluguri Date: Thu, 6 Nov 2025 15:17:43 -0500 Subject: [PATCH] fixed frontned --- .../manager/group_details_page.dart | 64 +++++++++++++++++-- 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/luckychit/lib/interfaces/manager/group_details_page.dart b/luckychit/lib/interfaces/manager/group_details_page.dart index 0147cf2..8e9e384 100644 --- a/luckychit/lib/interfaces/manager/group_details_page.dart +++ b/luckychit/lib/interfaces/manager/group_details_page.dart @@ -2045,28 +2045,78 @@ class _GroupDetailsPageState extends State with SingleTickerPr 'Group can only be deleted while in "Forming" status', backgroundColor: Colors.orange, colorText: Colors.white, + duration: const Duration(seconds: 3), ); return; } - final memberCount = _service.groupMembers.length; - if (memberCount > 0) { + // Count only ACTIVE members (not removed or inactive) + final activeMemberCount = _service.groupMembers.where((m) => m.status == 'active').length; + + if (activeMemberCount > 0) { Get.snackbar( 'Cannot Delete', - 'Group has $memberCount members. Remove all members first.', + 'Group has $activeMemberCount active member(s). Remove all active members first.', backgroundColor: Colors.orange, colorText: Colors.white, + duration: const Duration(seconds: 4), ); return; } + // Show removed members count if any + final removedMemberCount = _service.groupMembers.where((m) => m.status == 'removed').length; + final totalMembers = _service.groupMembers.length; + showDialog( context: context, builder: (context) => AlertDialog( title: const Text('Delete Group?'), - content: Text( - 'Are you sure you want to delete "${widget.group.name}"?\n\n' - 'This action cannot be undone.', + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Are you sure you want to delete "${widget.group.name}"?', + style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w600), + ), + SizedBox(height: 16.h), + if (removedMemberCount > 0) ...[ + Container( + padding: EdgeInsets.all(12.w), + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: BorderRadius.circular(8.r), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Group Status:', + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 14.sp, + ), + ), + SizedBox(height: 6.h), + Text('• Active members: 0', style: TextStyle(fontSize: 13.sp)), + Text('• Removed members: $removedMemberCount', + style: TextStyle(fontSize: 13.sp, color: Colors.grey.shade600)), + Text('• Total records: $totalMembers', style: TextStyle(fontSize: 13.sp)), + ], + ), + ), + SizedBox(height: 12.h), + ], + Text( + 'This action cannot be undone.', + style: TextStyle( + color: Colors.red.shade700, + fontWeight: FontWeight.w600, + fontSize: 14.sp, + ), + ), + ], ), actions: [ TextButton( @@ -2082,7 +2132,7 @@ class _GroupDetailsPageState extends State with SingleTickerPr backgroundColor: Colors.red, foregroundColor: Colors.white, ), - child: const Text('Delete'), + child: const Text('Delete Group'), ), ], ),