import 'package:boilerplate/core/utils/shared_preferences_util.dart';
import 'package:boilerplate/data/repositories/auth_repository.dart';
import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';

import '../../../core/utils/print_utils.dart';
import '../../../data/models/app/failure.dart';

@injectable
class LoginUseCase {
  @factoryParam
  final SharedPreferencesUtil _pref;
  final AuthRepository _authRepo;

  LoginUseCase(this._authRepo, this._pref);

  Future<void> execute() async {
    try {
      final data = await _authRepo.login({
        "email": "customer1@gmail.com",
        "password": "P@ssw0rd",
      });

      _pref.putString(SharedPreferencesUtil.keyAccessToken, data);

      // return const Left(true);
    } catch (err) {
      print('LoginUseCase Error : $err');
      // return Right(Failure(
      //   errMessage: '$err',
      // ));
    }
  }
}
