add favorite

This commit is contained in:
Phuoc Nguyen
2025-11-18 11:23:07 +07:00
parent 192c322816
commit a5eb95fa64
25 changed files with 2506 additions and 978 deletions

View File

@@ -0,0 +1,29 @@
import 'package:worker/features/products/domain/entities/product.dart';
/// Favorites Repository Interface
///
/// Defines the contract for favorites data operations.
/// Implementations should follow the online-first approach:
/// 1. Try to fetch/update data from API
/// 2. Update local cache with API response
/// 3. On network failure, fall back to local cache
abstract class FavoritesRepository {
/// Get favorite products with full product data
///
/// Online-first: Fetches from wishlist API, caches locally.
/// Falls back to local cache on network failure.
/// Returns `List<Product>` with complete product information.
Future<List<Product>> getFavoriteProducts();
/// Add a product to favorites
///
/// Online-first: Adds to API, then caches locally.
/// On network failure, queues for later sync.
Future<void> addFavorite(String productId);
/// Remove a product from favorites
///
/// Online-first: Removes from API, then updates local cache.
/// On network failure, queues for later sync.
Future<bool> removeFavorite(String productId);
}