import 'package:equatable/equatable.dart';

enum FormI9Status { initial, submitting, success, failure }

class FormI9State extends Equatable {
  final int currentStep;
  // Personal Info
  final String firstName;
  final String lastName;
  final String middleInitial;
  final String otherLastNames;
  final String dob;
  final String ssn;
  final String email;
  final String phone;
  
  // Address
  final String address;
  final String aptNumber;
  final String city;
  final String state;
  final String zipCode;

  // Citizenship
  final String citizenshipStatus; // citizen, noncitizen_national, permanent_resident, alien_authorized
  final String uscisNumber;
  final String admissionNumber;
  final String passportNumber;
  final String countryIssuance;

  // Signature
  final bool preparerUsed;
  final String signature;

  final FormI9Status status;
  final String? errorMessage;

  const FormI9State({
    this.currentStep = 0,
    this.firstName = '',
    this.lastName = '',
    this.middleInitial = '',
    this.otherLastNames = '',
    this.dob = '',
    this.ssn = '',
    this.email = '',
    this.phone = '',
    this.address = '',
    this.aptNumber = '',
    this.city = '',
    this.state = '',
    this.zipCode = '',
    this.citizenshipStatus = '',
    this.uscisNumber = '',
    this.admissionNumber = '',
    this.passportNumber = '',
    this.countryIssuance = '',
    this.preparerUsed = false,
    this.signature = '',
    this.status = FormI9Status.initial,
    this.errorMessage,
  });

  FormI9State copyWith({
    int? currentStep,
    String? firstName,
    String? lastName,
    String? middleInitial,
    String? otherLastNames,
    String? dob,
    String? ssn,
    String? email,
    String? phone,
    String? address,
    String? aptNumber,
    String? city,
    String? state,
    String? zipCode,
    String? citizenshipStatus,
    String? uscisNumber,
    String? admissionNumber,
    String? passportNumber,
    String? countryIssuance,
    bool? preparerUsed,
    String? signature,
    FormI9Status? status,
    String? errorMessage,
  }) {
    return FormI9State(
      currentStep: currentStep ?? this.currentStep,
      firstName: firstName ?? this.firstName,
      lastName: lastName ?? this.lastName,
      middleInitial: middleInitial ?? this.middleInitial,
      otherLastNames: otherLastNames ?? this.otherLastNames,
      dob: dob ?? this.dob,
      ssn: ssn ?? this.ssn,
      email: email ?? this.email,
      phone: phone ?? this.phone,
      address: address ?? this.address,
      aptNumber: aptNumber ?? this.aptNumber,
      city: city ?? this.city,
      state: state ?? this.state,
      zipCode: zipCode ?? this.zipCode,
      citizenshipStatus: citizenshipStatus ?? this.citizenshipStatus,
      uscisNumber: uscisNumber ?? this.uscisNumber,
      admissionNumber: admissionNumber ?? this.admissionNumber,
      passportNumber: passportNumber ?? this.passportNumber,
      countryIssuance: countryIssuance ?? this.countryIssuance,
      preparerUsed: preparerUsed ?? this.preparerUsed,
      signature: signature ?? this.signature,
      status: status ?? this.status,
      errorMessage: errorMessage ?? this.errorMessage,
    );
  }

  @override
  List<Object?> get props => [
        currentStep,
        firstName,
        lastName,
        middleInitial,
        otherLastNames,
        dob,
        ssn,
        email,
        phone,
        address,
        aptNumber,
        city,
        state,
        zipCode,
        citizenshipStatus,
        uscisNumber,
        admissionNumber,
        passportNumber,
        countryIssuance,
        preparerUsed,
        signature,
        status,
        errorMessage,
      ];
}
