import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:dartz/dartz.dart';

import '../../common/api/api_failure.dart';

part 'auth.freezed.dart';

part 'entities/check_phone_entity.dart';
part 'entities/register_entity.dart';
part 'entities/verify_entity.dart';
part 'entities/login_entity.dart';
part 'entities/resend_entity.dart';
part 'failures/auth_failure.dart';
part 'repositories/i_auth_repository.dart';

enum CheckPhoneStatus { notRegistered, passwordRequired, unknown }

extension CheckPhoneStatusX on CheckPhoneStatus {
  String toStringType() => switch (this) {
    CheckPhoneStatus.notRegistered => 'NOT_REGISTERED',
    CheckPhoneStatus.passwordRequired => 'PASSWORD_REQUIRED',
    CheckPhoneStatus.unknown => '',
  };

  bool get isNotRegistered => this == CheckPhoneStatus.notRegistered;
  bool get isPasswordRequired => this == CheckPhoneStatus.passwordRequired;
}

enum ResendStatus { resendNotAllowed, success, unknown }

extension ResendStatusX on ResendStatus {
  String toStringType() => switch (this) {
    ResendStatus.resendNotAllowed => 'RESEND_NOT_ALLOWED',
    ResendStatus.success => 'SUCCESS',
    ResendStatus.unknown => '',
  };

  bool get isResendNotAllowed => this == ResendStatus.resendNotAllowed;
  bool get isSuccess => this == ResendStatus.success;
}
