fix product page
This commit is contained in:
@@ -14,9 +14,14 @@ import 'package:worker/features/products/domain/entities/product.dart';
|
||||
abstract class ProductsRepository {
|
||||
/// Get all products
|
||||
///
|
||||
/// Returns a list of all available products.
|
||||
/// Returns a list of all available products with pagination support.
|
||||
/// [limitStart] - Starting index for pagination (default: 0)
|
||||
/// [limitPageLength] - Number of items per page (default: 12)
|
||||
/// Throws an exception if the operation fails.
|
||||
Future<List<Product>> getAllProducts();
|
||||
Future<List<Product>> getAllProducts({
|
||||
int limitStart = 0,
|
||||
int limitPageLength = 12,
|
||||
});
|
||||
|
||||
/// Search products by query
|
||||
///
|
||||
@@ -27,8 +32,14 @@ abstract class ProductsRepository {
|
||||
/// Get products by category
|
||||
///
|
||||
/// [categoryId] - Category ID to filter by
|
||||
/// [limitStart] - Starting index for pagination (default: 0)
|
||||
/// [limitPageLength] - Number of items per page (default: 12)
|
||||
/// Returns list of products in the specified category.
|
||||
Future<List<Product>> getProductsByCategory(String categoryId);
|
||||
Future<List<Product>> getProductsByCategory(
|
||||
String categoryId, {
|
||||
int limitStart = 0,
|
||||
int limitPageLength = 12,
|
||||
});
|
||||
|
||||
/// Get product by ID
|
||||
///
|
||||
|
||||
@@ -17,12 +17,25 @@ class GetProducts {
|
||||
/// Execute the use case
|
||||
///
|
||||
/// [categoryId] - Optional category ID to filter products
|
||||
/// [limitStart] - Starting index for pagination (default: 0)
|
||||
/// [limitPageLength] - Number of items per page (default: 12)
|
||||
/// Returns list of products (all or filtered by category)
|
||||
Future<List<Product>> call({String? categoryId}) async {
|
||||
Future<List<Product>> call({
|
||||
String? categoryId,
|
||||
int limitStart = 0,
|
||||
int limitPageLength = 12,
|
||||
}) async {
|
||||
if (categoryId == null || categoryId == 'all') {
|
||||
return await repository.getAllProducts();
|
||||
return await repository.getAllProducts(
|
||||
limitStart: limitStart,
|
||||
limitPageLength: limitPageLength,
|
||||
);
|
||||
} else {
|
||||
return await repository.getProductsByCategory(categoryId);
|
||||
return await repository.getProductsByCategory(
|
||||
categoryId,
|
||||
limitStart: limitStart,
|
||||
limitPageLength: limitPageLength,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user