Prevent task starting and completion without assigned it staff

This commit is contained in:
2026-03-02 20:22:42 +08:00
parent 43d2bd4f95
commit eb49329b16
2 changed files with 42 additions and 6 deletions
+12 -6
View File
@@ -3503,12 +3503,8 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
return chip;
}
final statusOptions = _statusOptions.where((status) {
if (status == 'in_progress' && !hasAssignedItStaff) {
return false;
}
return true;
}).toList();
// Show all status options - validation happens on selection
final statusOptions = _statusOptions;
return PopupMenuButton<String>(
onSelected: (value) async {
@@ -3606,6 +3602,16 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
return;
}
// Validate IT staff assignment before starting or completing
if ((value == 'in_progress' || value == 'completed') &&
!hasAssignedItStaff) {
showWarningSnackBar(
context,
'Please assign at least one IT Staff member before ${value == 'in_progress' ? 'starting' : 'completing'} this task.',
);
return;
}
// Update DB only — Supabase realtime stream will emit the
// updated task list, so explicit invalidation here causes a
// visible loading/refresh and is unnecessary.