feat: implement user-scoped receipt aliases with global fallback; enhance alias management in admin panel
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -9,6 +9,7 @@ import '../domain/admin_category_node.dart';
|
||||
import '../domain/admin_product.dart';
|
||||
import '../domain/ai_model_info.dart';
|
||||
import '../domain/pending_product.dart';
|
||||
import '../domain/receipt_alias.dart';
|
||||
import '../domain/user_admin.dart';
|
||||
|
||||
final adminRepositoryProvider = Provider<AdminRepository>((ref) {
|
||||
@@ -213,6 +214,21 @@ class AdminRepository {
|
||||
'targetProductId': targetProductId,
|
||||
});
|
||||
|
||||
Future<Map<String, dynamic>> previewMerge({
|
||||
required int sourceProductId,
|
||||
required int targetProductId,
|
||||
}) async {
|
||||
final token = await _token();
|
||||
final data = await guardedApiCall(
|
||||
_ref,
|
||||
() => _apiClient.getJson(
|
||||
ProductApiPaths.mergePreview(sourceProductId, targetProductId),
|
||||
token: token,
|
||||
),
|
||||
);
|
||||
return Map<String, dynamic>.from(data as Map);
|
||||
}
|
||||
|
||||
Future<List<AdminAiCategorizeResult>> aiCategorizeBulk({
|
||||
List<int>? productIds,
|
||||
}) async {
|
||||
@@ -246,4 +262,23 @@ class AdminRepository {
|
||||
/// OBS: endpointen /ai/models kräver autentisering.
|
||||
Future<List<AiModelInfo>> listAiModels() =>
|
||||
_getList(AiApiPaths.models, AiModelInfo.fromJson);
|
||||
|
||||
// ── Kvittoalias (admin/global fallback) ───────────────────────────────────
|
||||
|
||||
Future<List<ReceiptAlias>> listReceiptAliases() =>
|
||||
_getList(ReceiptAliasApiPaths.list, ReceiptAlias.fromJson);
|
||||
|
||||
Future<void> upsertReceiptAlias({
|
||||
required String receiptName,
|
||||
required int productId,
|
||||
bool isGlobal = false,
|
||||
}) =>
|
||||
_postVoid(ReceiptAliasApiPaths.list, {
|
||||
'receiptName': receiptName,
|
||||
'productId': productId,
|
||||
'isGlobal': isGlobal,
|
||||
});
|
||||
|
||||
Future<void> removeReceiptAlias(int id) =>
|
||||
_deleteVoid(ReceiptAliasApiPaths.remove(id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user