class OvertimeDto {
  final String id;
  final DateTime date;
  final double hours;
  final double hourlyRateAtTheTime;
  final String employeeId;
  final bool isDeleted;

  OvertimeDto({
    required this.id,
    required this.employeeId,
    required this.date,
    required this.hours,
    required this.hourlyRateAtTheTime,
    required this.isDeleted,
  });

  factory OvertimeDto.fromJson(Map<String, dynamic> json) {
    return OvertimeDto(
      id: json['id']?.toString() ?? '',
      date: DateTime.parse(json['date']),
      hours: (json['hours'] as num?)?.toDouble() ?? 0.0,
      hourlyRateAtTheTime:
          (json['hourlyRateAtTheTime'] as num?)?.toDouble() ?? 0.0,
      employeeId: json['employeeId']?.toString() ?? '',
      isDeleted: json['isDeleted'] ?? false,
    );
  }
}

class OvertimeListResponseDto {
  final List<OvertimeDto> items;

  OvertimeListResponseDto({required this.items});

  factory OvertimeListResponseDto.fromJson(Map<String, dynamic> json) {
    final data = json['data'];
    if (data == null || data is! Map<String, dynamic>) {
      return OvertimeListResponseDto(items: []);
    }
    final itemsJson = data['items'] as List? ?? [];
    return OvertimeListResponseDto(
      items: itemsJson.map((e) => OvertimeDto.fromJson(e)).toList(),
    );
  }
}
