import 'package:equatable/equatable.dart';

class Occupacy extends Equatable {
  final DateTime date;
  final String occupancy;
  final String spaceUuid;
  final int occupiedSeconds;

  const Occupacy({
    required this.date,
    required this.occupancy,
    required this.spaceUuid,
    required this.occupiedSeconds,
  });

  factory Occupacy.fromJson(Map<String, dynamic> json) {
    return Occupacy(
      date: DateTime.parse(json['event_date'] as String? ?? '${DateTime.now()}'),
      occupancy: (json['occupancy_percentage'] ?? 0).toString(),
      spaceUuid: json['space_uuid'] as String? ?? '',
      occupiedSeconds: json['occupied_seconds'] as int? ?? 0,
    );
  }

  @override
  List<Object?> get props => [
        date,
        occupancy,
        spaceUuid,
        occupiedSeconds,
      ];
}
