import 'package:e_porter/domain/models/user_entity.dart';
import 'package:e_porter/domain/repositories/auth_repository.dart';

class LoginUseCase {
  final AuthRepository authRepository;

  LoginUseCase(this.authRepository);

  Future<UserEntity> call(String email, String password) async {
    return await authRepository.signInWithEmailPassword(email, password);
  }
}

class GetUserRoleUseCase {
  final AuthRepository authRepository;
  GetUserRoleUseCase(this.authRepository);

  Future<String?> call(String uid) async {
    return await authRepository.getUserRole(uid);
  }
}

class GetUserDataUseCase {
  final AuthRepository authRepository;
  GetUserDataUseCase(this.authRepository);

  Future<UserData?> call(String uid) async {
    return await authRepository.getUserData(uid);
  }
}

class RegisterUseCase {
  final AuthRepository authRepository;

  RegisterUseCase(this.authRepository);

  Future<UserEntity> call(String email, String password) async {
    return await authRepository.registerWithEmailPassword(email, password);
  }
}

class SaveUserDataUseCase {
  final AuthRepository authRepository;

  SaveUserDataUseCase(this.authRepository);

  Future<void> call(UserData userData) async {
    return await authRepository.saveUserData(userData);
  }
}

class SendResetEmailUseCase {
  final AuthRepository repo;
  SendResetEmailUseCase(this.repo);
  Future<void> call(String email) => repo.sendPasswordResetEmail(email);
}

class ConfirmResetPasswordUseCase {
  final AuthRepository repo;
  ConfirmResetPasswordUseCase(this.repo);
  Future<void> call(String code, String newPassword) => repo.confirmPasswordReset(code, newPassword);
}
