part of 'create_shift_details_bloc.dart';

@immutable
class CreateShiftDetailsState {
  final bool inLoading;
  final bool isExpanded;
  final ShiftEntity shift;
  final List<MapPlace> suggestions;
  final List<RoleViewModel> roles;

  final ShiftValidationState? validationState;

  const CreateShiftDetailsState({
    required this.shift,
    this.inLoading = false,
    required this.suggestions,
    required this.roles,
    this.isExpanded = true,
    this.validationState
  });

  CreateShiftDetailsState copyWith({
    bool? inLoading,
    List<MapPlace>? suggestions,
    ShiftEntity? shift,
    String? department,
    List<RoleViewModel>? roles,
    bool? isExpanded,
    ShiftValidationState? validationState,
  }) {
    return CreateShiftDetailsState(
      shift: shift ?? this.shift,
      inLoading: inLoading ?? false,
      suggestions: suggestions ?? this.suggestions,
      roles: roles ?? this.roles,
      isExpanded: isExpanded ?? this.isExpanded,
      validationState: validationState,

    );
  }
}

class RoleViewModel {
  final String id;
  final CreateRoleBloc bloc;


  RoleViewModel({required this.id, required this.bloc});
}

class ShiftValidationState {

  final String? addressError;
  final String? contactsError;
  bool showed;

  bool get hasError =>
      addressError != null ||
          contactsError != null;

  String? get message {
    return addressError ?? contactsError ?? '';
  }

   ShiftValidationState({
    this.addressError,
    this.contactsError,this.showed = false});

  ShiftValidationState copyWith({
    String? addressError,
    String? contactsError,
  }) {
    return ShiftValidationState(
      addressError: addressError ?? this.addressError,
      contactsError: contactsError ?? this.contactsError,
      showed: showed
    );
  }
}
