import '../enums/priority.dart';

class TaskEntity {
  final String id;
  final String title;
  final String? description;
  final DateTime date;
  final String? time;
  final Priority priority;
  final bool isDone;
  final DateTime? createdAt;
  final DateTime? updatedAt;

  const TaskEntity({
    required this.id,
    required this.title,
    this.description,
    required this.date,
    this.time,
    this.priority = Priority.medium,
    this.isDone = false,
    this.createdAt,
    this.updatedAt,
  });

  TaskEntity copyWith({
    String? id,
    String? title,
    String? description,
    DateTime? date,
    String? time,
    Priority? priority,
    bool? isDone,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return TaskEntity(
      id: id ?? this.id,
      title: title ?? this.title,
      description: description ?? this.description,
      date: date ?? this.date,
      time: time ?? this.time,
      priority: priority ?? this.priority,
      isDone: isDone ?? this.isDone,
      createdAt: createdAt ?? this.createdAt,
      updatedAt: updatedAt ?? this.updatedAt,
    );
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is TaskEntity && other.id == id;
  }

  @override
  int get hashCode => id.hashCode;
}
