part of 'personal_info_bloc.dart';

@immutable
class PersonalInfoState {
  const PersonalInfoState({
    this.firstName = '',
    this.lastName = '',
    this.email = '',
    this.phoneNumber = '',
    this.profileImageUrl,
    this.profileImagePath,
    this.isUpdateReceived = false,
    this.status = StateStatus.idle,
    this.emailValidationError = '',
    this.deleted = false
  });

  final String firstName;
  final String lastName;
  final String email;
  final String phoneNumber;
  final String? profileImageUrl;
  final String? profileImagePath;
  final bool isUpdateReceived;
  final StateStatus status;
  final String emailValidationError;
  final bool deleted;

  PersonalInfoState copyWith({
    String? firstName,
    String? lastName,
    String? email,
    String? phoneNumber,
    String? profileImageUrl,
    String? profileImagePath,
    bool? isUpdateReceived,
    StateStatus? status,
    String? emailValidationError,
    bool? deleted,
  }) {
    return PersonalInfoState(
      firstName: firstName ?? this.firstName,
      lastName: lastName ?? this.lastName,
      email: email ?? this.email,
      phoneNumber: phoneNumber ?? this.phoneNumber,
      profileImagePath: profileImagePath ?? this.profileImagePath,
      profileImageUrl: profileImageUrl ?? this.profileImageUrl,
      isUpdateReceived: isUpdateReceived ?? this.isUpdateReceived,
      status: status ?? this.status,
      deleted: deleted ?? this.deleted,
      emailValidationError: emailValidationError ?? this.emailValidationError,
    );
  }

  bool get isFilled {
    return firstName.isNotEmpty && lastName.isNotEmpty && email.isNotEmpty;
    // Phone should not be validated on initial profile setup
    //(!isInEditMode || phoneNumber.isNotEmpty) &&
    //photo is optional
    // (profileImagePath != null || profileImageUrl != null);
  }

  bool get isValid {
    return firstName.isNotEmpty &&
        lastName.isNotEmpty &&
        emailValidationError.isEmpty &&
        // Phone should not be validated on initial profile setup
        //(!isInEditMode || phoneNumber.isNotEmpty) &&
        (profileImagePath != null || profileImageUrl != null);
  }
}
