import 'package:hmg_patient_app_new/services/analytics/analytics_service.dart';

class LoginRegistration{
  static int loginMethod = 0;
  static int verificationMethod = 0;

  final GALogger logger;
  LoginRegistration(this.logger);
  // R004.1
  login_register_initiate(){
    logger('login_register_initiate');
  }

  // R005.1
  visited_alhabib_group(bool value){
    // selection_type: yes/no
    logger('visited_alhabib_group', parameters: {
      'selection_type' : value ? 'yes' : 'no'
    });
  }

  // R006.1, R007.1, R008.1, R009.1
  registration_cancel({required String step}){
    // registration_step : enter details
    // registration_step : personal info
    // registration_step : patient info
    // fourth (verification)
    logger('registration_cancel', parameters: {
      'registration_step' : step
    });
  }

  // R006.2
  registration_enter_details(){
    logger('registration_enter_details');
  }

  // R007.2
  registration_personal_info(){
    logger('registration_personal_info');
  }

  // R008.2
  registration_patient_info(){
    logger('registration_patient_info');
  }

  // R009.2
  registration_verification_option(){
    logger('registration_verification_option');
  }

  // R010:registration_confirmation
  registration_confirmation(){
    // verification_method: by
    logger('registration_confirmation');
  }

  registration_fail({required String errorType}){
    // verification_method: by
    logger('registration_fail', parameters: {
      'error_type' : errorType
    });
  }

  // R011.1
  login_start({required String method}){
    logger('login_start', parameters: {
      'login_method' : method
    });
  }

  // R011:login_verify_otp |  R009:registration_verification_option
  verify_otp_method({bool forRegistration = false}){
    if(forRegistration == false)
      logger("login_verify_otp", parameters: {
        'login_method' : _getLoginMethod(),
        'verification_method' : _getVerificationMethod(),
      });
    else
      logger("registration_verification_option", parameters: {
        'verification_method' : _getVerificationMethod()
      });
  }

  // R011:login_verify_otp |  R009:registration_verification_option
  login_verfication({bool forRegistration = false}){
    if(forRegistration == false)
      logger("login_verfication", parameters: {
        'login_method' : _getLoginMethod(),
        'verification_method' : _getVerificationMethod(),
      });
    else
      logger("login_varification_register", parameters: {
        'login_method' : _getLoginMethod(),
        'verification_method' : _getVerificationMethod(),
      });
  }

  // R011.2
  forget_file_number(){
    logger('forget_file_number');
  }

  // R011.3
  register_now(){
    logger('register_now');
  }

  // R012.1, R014.1
  login_successful(){
    logger('login_successful', parameters: {
      'login_method' : _getVerificationMethod()
    });
  }

  // R012.4
  login_unsuccessful({required String method, error}){
    logger('login_unsuccessful', parameters: {
      'login_method' : method
    });
  }

  login_fail({error}){
    logger('login_unsuccessful', parameters: {
      'login_method' : loginMethod,
      'error': error
    });
  }

  // R013
  recover_file_number(){
    logger('recover_file_number');
  }

  // R014.2
  login_with_other_account(){
    logger('login_with_other_account');
  }


  _getLoginMethod(){
    if(loginMethod == 1) return 'national id';
    if(loginMethod == 2) return 'file number';
    return 'otp';
  }

  String _getVerificationMethod(){
    if(verificationMethod == 1) return 'sms';
    if(verificationMethod == 2) return 'fingerprint';
    if(verificationMethod == 3) return 'face id';
    if(verificationMethod == 4) return 'whatsapp';
    return "unknown";
  }
}