49 lines
1.9 KiB
Dart
49 lines
1.9 KiB
Dart
// ============================================================
|
||
// CouponProvider — 券功能 Riverpod Providers
|
||
// ============================================================
|
||
|
||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
import '../../../../core/services/coupon_service.dart';
|
||
|
||
/// CouponApiService Provider(DI 入口)
|
||
final couponServiceProvider = Provider<CouponApiService>((ref) {
|
||
return CouponApiService();
|
||
});
|
||
|
||
// ── Featured Coupons ──────────────────────────────────────────
|
||
|
||
final featuredCouponsProvider = FutureProvider.autoDispose((ref) async {
|
||
return ref.read(couponServiceProvider).getFeaturedCoupons();
|
||
});
|
||
|
||
// ── My Holdings ───────────────────────────────────────────────
|
||
|
||
class HoldingsParams {
|
||
final String? status;
|
||
final int page;
|
||
final int limit;
|
||
const HoldingsParams({this.status, this.page = 1, this.limit = 20});
|
||
}
|
||
|
||
final myHoldingsProvider =
|
||
FutureProvider.autoDispose.family<dynamic, HoldingsParams>((ref, params) async {
|
||
return ref.read(couponServiceProvider).getMyHoldings(
|
||
status: params.status,
|
||
page: params.page,
|
||
limit: params.limit,
|
||
);
|
||
});
|
||
|
||
// ── Holdings Summary ──────────────────────────────────────────
|
||
|
||
final holdingsSummaryProvider = FutureProvider.autoDispose((ref) async {
|
||
return ref.read(couponServiceProvider).getHoldingsSummary();
|
||
});
|
||
|
||
// ── Coupon Detail ─────────────────────────────────────────────
|
||
|
||
final couponDetailProvider =
|
||
FutureProvider.autoDispose.family<dynamic, String>((ref, couponId) async {
|
||
return ref.read(couponServiceProvider).getCouponDetail(couponId);
|
||
});
|