class WorkScheduleModel {
  List<Day> days;
  WorkScheduleModel({
    required this.days,
  });

  factory WorkScheduleModel.fromJson(Map<String, dynamic> json) {
    List<Day> days = [];
    json["work_schedules"].forEach((key, value) {
      days.add(
        Day(
          day: key,
          workTime: workTimeModel.fromJsonList(value),
        ),
      );
    });
    return WorkScheduleModel(days: days);
  }
}

class Day {
  String day;
  List<workTimeModel> workTime;
  Day({
    required this.day,
    required this.workTime,
  });
  factory Day.zero() => Day(
        day: "",
        workTime: [],
      );
}

class workTimeModel {
  String name;
  String startTime;
  String endTime;
  workTimeModel({
    required this.name,
    required this.startTime,
    required this.endTime,
  });

  factory workTimeModel.fromJson(Map<String, dynamic> json) => workTimeModel(
        name: json["name"],
        startTime: json["start"],
        endTime: json["end"],
      );

  static List<workTimeModel> fromJsonList(List<dynamic> json) {
    List<workTimeModel> days = [];
    for (var day in json) {
      days.add(
        workTimeModel.fromJson(day),
      );
    }

    // json[key].forEach(
    //   (element) => days.add(
    //     workTimeModel.fromJson(element),
    //   ),
    // );
    return days;
  }
}
