feat: implement admin product management panel with bulk categorization and premium user toggle
This commit is contained in:
@@ -3,6 +3,8 @@ import '../../../core/api/api_client.dart';
|
||||
import '../../../core/api/api_paths.dart';
|
||||
import '../../../core/api/guarded_api_call.dart';
|
||||
import '../../auth/data/auth_providers.dart';
|
||||
import '../domain/admin_category_node.dart';
|
||||
import '../domain/admin_product.dart';
|
||||
import '../domain/ai_model_info.dart';
|
||||
import '../domain/pending_product.dart';
|
||||
import '../domain/user_admin.dart';
|
||||
@@ -115,4 +117,36 @@ class AdminRepository {
|
||||
.map((e) => AiModelInfo.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<List<AdminProduct>> listProducts() async {
|
||||
final data = await guardedApiCall(
|
||||
_ref,
|
||||
() => _apiClient.getJson(ProductApiPaths.list),
|
||||
);
|
||||
return (data as List<dynamic>)
|
||||
.map((e) => AdminProduct.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<List<AdminCategoryNode>> listCategoryTree() async {
|
||||
final data = await guardedApiCall(
|
||||
_ref,
|
||||
() => _apiClient.getJson(CategoryApiPaths.tree),
|
||||
);
|
||||
return (data as List<dynamic>)
|
||||
.map((e) => AdminCategoryNode.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<void> bulkSetCategory(List<int> ids, {required int? categoryId}) async {
|
||||
final token = await _token();
|
||||
await guardedApiCall(
|
||||
_ref,
|
||||
() => _apiClient.postJson(
|
||||
ProductApiPaths.bulkUpdate,
|
||||
body: {'ids': ids, 'categoryId': categoryId},
|
||||
token: token,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user