import 'package:location/resource/string.gen.dart';

class ErrorCode {
  /// 登录相关错误码
  static const int verificationCodeError = 1005; //验证码错误
  static const int noLoginError = 1006; //未登录
  static const int noMember = 1007; //没有会员

  /// 好友关系相关错误码
  static const int friendNotRegistered = 1100; //好友未注册本应用
  static const int friendRequestSent = 1101; //好友申请已发出，请等待对方通过
  static const int alreadyInFriendList = 1102; //该好友已在好友列表
  static const int cannotAddSelf = 1103; //不能添加自己为好友

  /// 紧急联系人相关错误码
  static const int maxContactsReached = 1200; // 最多添加5人，请移除后再添加
  static const int contactAlreadyAdded = 1201; //对方已是您的紧急联系人
  static const int smsSendFailed = 1202; //短信发送失败，请核实手机号码

  /// 会员服务相关错误码
  static const int getMemberFree = 1300; //每位用户只能领取一次试用
  static const int isMember = 1301; //您已经是会员了
  static const int payOrderError = 1004;
}

/// 错误码扩展方法
extension ErrorDescription on int {
  String? get description {
    switch (this) {
      case ErrorCode.verificationCodeError:
        return StringName.loginVerificationCodeErrorToast;
      case ErrorCode.noLoginError:
        return StringName.accountNoLogin;
      case ErrorCode.noMember:
        return StringName.memberExpired;
      case ErrorCode.maxContactsReached:
        return StringName.urgentContactAddMaxTip;
      case ErrorCode.smsSendFailed:
        return StringName.urgentContactEmsSendFail;
    }
    return null;
  }
}
