import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../data/referral_repository.dart';
import '../../domain/models/referral_info.dart';

/// My tenant referral info + code
final referralInfoProvider = FutureProvider<ReferralInfo>((ref) async {
  return ref.watch(referralRepositoryProvider).getMyReferralInfo();
});

/// My direct tenant referrals (first page)
final referralListProvider =
    FutureProvider<({List<ReferralItem> items, int total})>((ref) async {
  return ref.watch(referralRepositoryProvider).getMyReferrals();
});

/// Pending tenant rewards
final pendingRewardsProvider =
    FutureProvider<({List<RewardItem> items, int total})>((ref) async {
  return ref.watch(referralRepositoryProvider).getMyRewards(status: 'PENDING');
});

/// All tenant rewards (for history tab)
final allRewardsProvider =
    FutureProvider<({List<RewardItem> items, int total})>((ref) async {
  return ref.watch(referralRepositoryProvider).getMyRewards();
});

// ── User-level / personal circle ─────────────────────────────────────────────

/// Personal user referral info (code, shareUrl, circleSize, pointsBalance …)
final userReferralInfoProvider = FutureProvider<UserReferralInfo>((ref) async {
  return ref.watch(referralRepositoryProvider).getMyUserReferralInfo();
});

/// Personal circle members (level-1 invitees)
final myCircleProvider =
    FutureProvider<({List<CircleMember> items, int total})>((ref) async {
  return ref.watch(referralRepositoryProvider).getMyCircle();
});

/// Points balance + recent transactions
final myPointsProvider = FutureProvider<
    ({
      int balance,
      int totalEarned,
      int totalSpent,
      List<PointTransaction> transactions,
      int total
    })>((ref) async {
  return ref.watch(referralRepositoryProvider).getMyPoints();
});
