// lib/data/models/working_hours.dart

import 'package:equatable/equatable.dart';

class Shift extends Equatable {
  final String openAt;
  final String closeAt;

  const Shift({required this.openAt, required this.closeAt});

  @override
  List<Object?> get props => [openAt, closeAt];

  factory Shift.fromJson(Map<String, dynamic> json) {
    return Shift(
      openAt: json['openAt'],
      closeAt: json['closeAt'],
    );
  }
}

class WorkingHours extends Equatable {
  final String day;
  final List<Shift> shifts;

  const WorkingHours({required this.day, required this.shifts});

  bool get isOpen => shifts.isNotEmpty;

  @override
  List<Object?> get props => [day, shifts];

  factory WorkingHours.fromJson(Map<String, dynamic> json) {
    var shiftsFromJson = json['shifts'] as List;
    List<Shift> shiftList = shiftsFromJson.map((s) => Shift.fromJson(s)).toList();

    return WorkingHours(
      day: json['day'],
      shifts: shiftList,
    );
  }
}