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;
|
|
|
|
|
final Map<String, List<StaffMemberModel>>
|
|
|
|
|
groupedAvailableStaff; // <-- RIPRISTINATO
|
2026-05-26 19:31:25 +02:00
|
|
|
final String? errorMessage;
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
}) {
|
|
|
|
|
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-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,
|
|
|
|
|
];
|
|
|
|
|
}
|