Files
flux/lib/features/tasks/blocs/task_form_state.dart

78 lines
2.0 KiB
Dart
Raw Permalink Normal View History

2026-05-26 19:31:25 +02:00
part of 'task_form_cubit.dart';
enum TaskFormStatus { initial, loading, submitting, success, failure }
class TaskFormState extends Equatable {
2026-05-29 12:26:41 +02:00
final String? id;
2026-05-26 19:31:25 +02:00
final TaskFormStatus status;
final String title;
final String description;
final DateTime? dueDate;
final bool isGlobal;
final List<String> selectedStaffIds;
2026-05-29 19:24:40 +02:00
final List<TaskReminderConfig> reminders;
2026-06-04 12:34:38 +02:00
final Map<String, List<StaffMemberModel>> groupedAvailableStaff;
2026-05-26 19:31:25 +02:00
final String? errorMessage;
2026-06-04 12:34:38 +02:00
final TaskStatus taskStatus;
2026-05-26 19:31:25 +02:00
const TaskFormState({
this.id,
2026-05-29 12:26:41 +02:00
this.status = TaskFormStatus.initial,
2026-05-26 19:31:25 +02:00
this.title = '',
this.description = '',
this.dueDate,
this.isGlobal = false,
this.selectedStaffIds = const [],
this.reminders = const [],
2026-05-29 19:24:40 +02:00
this.groupedAvailableStaff = const {},
2026-05-26 19:31:25 +02:00
this.errorMessage,
2026-06-04 12:34:38 +02:00
this.taskStatus = TaskStatus.open,
2026-05-26 19:31:25 +02:00
});
bool get isFormValid => title.trim().isNotEmpty;
TaskFormState copyWith({
String? id,
2026-05-29 12:26:41 +02:00
TaskFormStatus? status,
2026-05-26 19:31:25 +02:00
String? title,
String? description,
DateTime? dueDate,
bool? isGlobal,
List<String>? selectedStaffIds,
2026-05-29 12:26:41 +02:00
List<TaskReminderConfig>? reminders,
2026-05-29 19:24:40 +02:00
Map<String, List<StaffMemberModel>>? groupedAvailableStaff,
2026-05-26 19:31:25 +02:00
String? errorMessage,
2026-06-04 12:34:38 +02:00
TaskStatus? taskStatus,
2026-05-26 19:31:25 +02:00
}) {
return TaskFormState(
id: id ?? this.id,
2026-05-29 12:26:41 +02:00
status: status ?? this.status,
2026-05-26 19:31:25 +02:00
title: title ?? this.title,
description: description ?? this.description,
2026-05-29 12:26:41 +02:00
dueDate: dueDate ?? this.dueDate,
2026-05-26 19:31:25 +02:00
isGlobal: isGlobal ?? this.isGlobal,
selectedStaffIds: selectedStaffIds ?? this.selectedStaffIds,
reminders: reminders ?? this.reminders,
2026-05-29 19:24:40 +02:00
groupedAvailableStaff:
groupedAvailableStaff ?? this.groupedAvailableStaff,
2026-05-29 12:26:41 +02:00
errorMessage: errorMessage,
2026-06-04 12:34:38 +02:00
taskStatus: taskStatus ?? this.taskStatus,
2026-05-26 19:31:25 +02:00
);
}
@override
List<Object?> get props => [
id,
2026-05-29 12:26:41 +02:00
status,
2026-05-26 19:31:25 +02:00
title,
description,
dueDate,
isGlobal,
selectedStaffIds,
reminders,
2026-05-29 19:24:40 +02:00
groupedAvailableStaff,
2026-05-26 19:31:25 +02:00
errorMessage,
2026-06-04 12:34:38 +02:00
taskStatus,
2026-05-26 19:31:25 +02:00
];
}