import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:niogu_app/core/providers/app_provider.dart';
import 'package:niogu_app/core/enums/member_level.dart';
import 'package:niogu_app/features/profile/data/repositories/profile_repository_impl.dart';
import 'package:niogu_app/features/profile/domain/repositories/i_profile_repository.dart';
import 'package:niogu_app/features/profile/presentation/controllers/profile_controller.dart';

final profileRepositoryProvider = Provider.autoDispose<IProfileRepository>((
  ref,
) {
  final appDatabase = ref.watch(appDatabaseProvider);
  return ProfileRepositoryImpl(appDatabase);
});

final profileCompletenessStreamProvider = StreamProvider.autoDispose<double>((
  ref,
) {
  final profileRepository = ref.watch(profileRepositoryProvider);
  return profileRepository.watchProfileCompleteness();
});

final businessCompletenessStreamProvider = StreamProvider.autoDispose<double>((
  ref,
) {
  final profileRepository = ref.watch(profileRepositoryProvider);
  return profileRepository.watchBusinessCompleteness();
});

final outletCompletenessStreamProvider = StreamProvider.autoDispose<double>((ref) {
  final profileRepository = ref.watch(profileRepositoryProvider);
  return profileRepository.watchOutletCompleteness();
});

final memberLevelStreamProvider = StreamProvider.autoDispose<MemberLevel>((ref) {
  final profileRepository = ref.watch(profileRepositoryProvider);
  return profileRepository.watchMemberLevel();
});

final profileControllerProvider =
    AsyncNotifierProvider.autoDispose<ProfileController, void>(
      ProfileController.new,
    );
