import 'package:prosapp_web_app/models/schedules_entity.dart';

class Schedules {
  final ScheduleEntity monday;
  final ScheduleEntity tuesday;
  final ScheduleEntity wednesday;
  final ScheduleEntity thursday;
  final ScheduleEntity friday;
  final ScheduleEntity saturday;
  final ScheduleEntity sunday;

  const Schedules({
    required this.monday,
    required this.tuesday,
    required this.wednesday,
    required this.thursday,
    required this.friday,
    required this.saturday,
    required this.sunday,
  });

  static const empty = Schedules(
    monday: ScheduleEntity.empty,
    tuesday: ScheduleEntity.empty,
    wednesday: ScheduleEntity.empty,
    thursday: ScheduleEntity.empty,
    friday: ScheduleEntity.empty,
    saturday: ScheduleEntity.empty,
    sunday: ScheduleEntity.empty,
  );

  // Copy function
  Schedules copyWith({
    ScheduleEntity? monday,
    ScheduleEntity? tuesday,
    ScheduleEntity? wednesday,
    ScheduleEntity? thursday,
    ScheduleEntity? friday,
    ScheduleEntity? saturday,
    ScheduleEntity? sunday,
  }) {
    return Schedules(
      monday: monday ?? this.monday,
      tuesday: tuesday ?? this.tuesday,
      wednesday: wednesday ?? this.wednesday,
      thursday: thursday ?? this.thursday,
      friday: friday ?? this.friday,
      saturday: saturday ?? this.saturday,
      sunday: sunday ?? this.sunday,
    );
  }

  factory Schedules.fromDocument(Map<String, dynamic> doc) {
    return Schedules(
      monday: ScheduleEntity.fromDocument(doc['monday']),
      tuesday: ScheduleEntity.fromDocument(doc['tuesday']),
      wednesday: ScheduleEntity.fromDocument(doc['wednesday']),
      thursday: ScheduleEntity.fromDocument(doc['thursday']),
      friday: ScheduleEntity.fromDocument(doc['friday']),
      saturday: ScheduleEntity.fromDocument(doc['saturday']),
      sunday: ScheduleEntity.fromDocument(doc['sunday']),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'monday': monday.toJson(),
      'tuesday': tuesday.toJson(),
      'wednesday': wednesday.toJson(),
      'thursday': thursday.toJson(),
      'friday': friday.toJson(),
      'saturday': saturday.toJson(),
      'sunday': sunday.toJson(),
    };
  }
}
