feat: add pantry management features including repository, providers, and UI integration

This commit is contained in:
Nils-Johan Gynther
2026-04-22 10:45:37 +02:00
parent f11364b73e
commit dd05fed279
9 changed files with 615 additions and 7 deletions
@@ -0,0 +1,28 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/api/api_providers.dart';
import '../../../core/api/guarded_api_call.dart';
import '../../auth/data/auth_providers.dart';
import '../domain/pantry_item.dart';
import '../domain/pantry_product.dart';
import 'pantry_repository.dart';
final pantryRepositoryProvider = Provider<PantryRepository>((ref) {
return PantryRepository(ref.watch(apiClientProvider));
});
final pantryProvider = FutureProvider<List<PantryItem>>((ref) async {
final token = await ref.watch(authStateProvider.future);
return guardedApiCall(
ref,
() => ref.read(pantryRepositoryProvider).fetchPantry(token: token),
);
});
final pantryProductsProvider = FutureProvider<List<PantryProduct>>((ref) async {
final token = await ref.watch(authStateProvider.future);
return guardedApiCall(
ref,
() => ref.read(pantryRepositoryProvider).fetchProducts(token: token),
);
});