import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_model.dart';
import 'package:syncrow_web/utils/string_utils.dart';

class SendBookableSpacesToApiParams {
  List<String> spaceUuids;
  List<String> daysAvailable;
  String startTime;
  String endTime;
  int points;
  SendBookableSpacesToApiParams({
    required this.spaceUuids,
    required this.daysAvailable,
    required this.startTime,
    required this.endTime,
    required this.points,
  });

  static SendBookableSpacesToApiParams fromBookableSpacesModel(
      List<BookableSpacemodel> bookableSpaces) {
    return SendBookableSpacesToApiParams(
      spaceUuids: bookableSpaces.map((space) => space.spaceUuid).toList(),
      daysAvailable: bookableSpaces
          .expand((space) => space.spaceConfig!.bookableDays)
          .toSet()
          .toList(),
      startTime: formatTimeOfDayTo24HourString(
          bookableSpaces.first.spaceConfig!.bookingStartTime!),
      endTime: formatTimeOfDayTo24HourString(
          bookableSpaces.first.spaceConfig!.bookingEndTime!),
      points: bookableSpaces.first.spaceConfig!.cost,
    );
  }

  Map<String, dynamic> toJson() => {
        'spaceUuids': spaceUuids,
        'daysAvailable': daysAvailable,
        'startTime': startTime,
        'endTime': endTime,
        'points': points
      };
}
