import 'package:equatable/equatable.dart';

class OccupancyHeatMapModel extends Equatable {
  final String uuid;

  final DateTime eventDate;

  final int countTotalPresenceDetected;

  const OccupancyHeatMapModel({
    required this.uuid,
    required this.eventDate,
    required this.countTotalPresenceDetected,
  });

  factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
    final eventDate = json['event_date'] as String?;
    final year = eventDate?.split('-')[0];
    final month = eventDate?.split('-')[1];
    final day = eventDate?.split('-')[2];

    return OccupancyHeatMapModel(
      uuid: json['uuid'] as String? ?? '',
      eventDate: DateTime.utc(
        int.parse(year ?? '2025'),
        int.parse(month ?? '1'),
        int.parse(day ?? '1'),
      ),
      countTotalPresenceDetected: num.parse(
        json['count_total_presence_detected']?.toString() ?? '0',
      ).toInt(),
    );
  }

  @override
  List<Object?> get props => [uuid, eventDate, countTotalPresenceDetected];
}
