import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:niogu_ecommerce_v1/core/providers/app_provider.dart';
import 'package:niogu_ecommerce_v1/features/favorite/domain/entities/favorite.dart';
import 'package:niogu_ecommerce_v1/features/favorite/presentation/controllers/favorite_controller.dart';

final favoriteControllerProvider =
    StateNotifierProvider<FavoriteController, Map<String, SelectedFavorite>>((
      ref,
    ) {
      return FavoriteController();
    });

final favoriteProvider = Provider<List<SelectedFavorite>>((ref) {
  final currentOutletId = ref.watch(currentOutletIdProvider);

  final favoriteController = ref.watch(favoriteControllerProvider);

  return favoriteController.values
      .where((f) => f.outletId == currentOutletId)
      .toList();
});
