import 'package:equatable/equatable.dart';

/// Entité de domaine représentant une réservation.
///
/// Cette entité est pure et indépendante de la couche de données.
/// Elle représente une réservation d'événement ou d'établissement.
class Reservation extends Equatable {
  const Reservation({
    required this.id,
    required this.userId,
    required this.userFullName,
    required this.eventId,
    required this.eventTitle,
    required this.reservationDate,
    required this.numberOfPeople,
    required this.status,
    this.establishmentId,
    this.establishmentName,
    this.notes,
    this.createdAt,
  });

  final String id;
  final String userId;
  final String userFullName;
  final String eventId;
  final String eventTitle;
  final DateTime reservationDate;
  final int numberOfPeople;
  final ReservationStatus status;
  final String? establishmentId;
  final String? establishmentName;
  final String? notes;
  final DateTime? createdAt;

  @override
  List<Object?> get props => [
        id,
        userId,
        userFullName,
        eventId,
        eventTitle,
        reservationDate,
        numberOfPeople,
        status,
        establishmentId,
        establishmentName,
        notes,
        createdAt,
      ];

  /// Crée une copie de cette réservation avec des valeurs modifiées.
  Reservation copyWith({
    String? id,
    String? userId,
    String? userFullName,
    String? eventId,
    String? eventTitle,
    DateTime? reservationDate,
    int? numberOfPeople,
    ReservationStatus? status,
    String? establishmentId,
    String? establishmentName,
    String? notes,
    DateTime? createdAt,
  }) {
    return Reservation(
      id: id ?? this.id,
      userId: userId ?? this.userId,
      userFullName: userFullName ?? this.userFullName,
      eventId: eventId ?? this.eventId,
      eventTitle: eventTitle ?? this.eventTitle,
      reservationDate: reservationDate ?? this.reservationDate,
      numberOfPeople: numberOfPeople ?? this.numberOfPeople,
      status: status ?? this.status,
      establishmentId: establishmentId ?? this.establishmentId,
      establishmentName: establishmentName ?? this.establishmentName,
      notes: notes ?? this.notes,
      createdAt: createdAt ?? this.createdAt,
    );
  }
}

/// Statut d'une réservation.
enum ReservationStatus {
  pending, // En attente de confirmation
  confirmed, // Confirmée
  cancelled, // Annulée
  completed, // Terminée
}
