import 'package:auth/src/features/sign_up/domain/entities/address_entity.dart';
import 'package:auth/src/features/sign_up/presentation/state/address_view_state.dart';

extension AddressViewStateMapper on AddressViewState {
  bool get isValid =>
      street.trim().isNotEmpty &&
      city.trim().isNotEmpty &&
      province.trim().isNotEmpty &&
      state.trim().isNotEmpty &&
      country.trim().isNotEmpty &&
      (postCode != null);

  AddressEntity toEntity() {
    return AddressEntity(
      street: street.trim(),
      city: city.trim(),
      province: province.trim(),
      state: state.trim(),
      country: country.trim(),
      postCode: postCode ?? 0,
    );
  }
}
