Files
fin-tracker/app/lib/features/pending/providers.dart
T
Dmitry b69bb4a0c9 feat(app): экраны импорта отчётов, целей, доходов, ребалансировки, налогов и бенчмарков
Импорт (/imports, /instruments/pending) и фаза 4 (/goals, /income,
/rebalance, /tax, аналитика-хаб с benchmarks_card) — по
docs/ai/import-contract.md и docs/ai/phase4-contract.md. file_picker для
загрузки отчёта.
2026-09-19 10:44:38 +03:00

35 lines
1.4 KiB
Dart

import 'package:fintracker_api/fintracker_api.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/api/api_client.dart';
import 'data/pending_api.dart';
final pendingApiProvider = Provider<PendingApi>((ref) => PendingApi(ref.watch(apiProvider).dio));
/// `pending | resolved | ignored | all` — the filter of the resolve screen.
final pendingStatusFilterProvider = StateProvider<String>((ref) => 'pending');
final pendingInstrumentsProvider =
FutureProvider.autoDispose<List<PendingInstrument>>((ref) async {
final status = ref.watch(pendingStatusFilterProvider);
return ref.watch(pendingApiProvider).list(status: status);
});
/// How many rows still await a decision — shown as a badge next to the import screen's link.
final pendingCountProvider = FutureProvider.autoDispose<int>((ref) async {
final rows = await ref.watch(pendingApiProvider).list(status: 'pending');
return rows.length;
});
/// Instrument search for the "link to an existing instrument" dialog. This one endpoint is
/// already in the generated client, so it goes through it rather than raw Dio.
final instrumentSearchProvider =
FutureProvider.autoDispose.family<List<InstrumentOut>, String>((ref, query) async {
if (query.trim().length < 2) return const [];
final r = await ref
.watch(apiProvider)
.getInstrumentsApi()
.instrumentsList(q: query.trim(), limit: 25);
return r.data ?? const [];
});