import 'dart:async';

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/src/data/models/entities/user_entity.dart';
import 'package:legacy_shared/src/data/repositories/legacy_shared_repository.dart';

import 'legacy_shared_repository_provider.dart';

final loggedUserProvider = AsyncNotifierProvider<LoggedUserNotifier, UserEntity>(
    LoggedUserNotifier.new,
  );

class LoggedUserNotifier extends AsyncNotifier<UserEntity> {
  late final LegacySharedRepository _legacySharedRepository;

  @override
  Future<UserEntity> build() {
    _legacySharedRepository = ref.read(legacySharedRepositoryProvider);
    return _legacySharedRepository.getLoggedUser(token: '');
  }
}
