feat: Add bulk delete and merge functionality for inventory items with DTOs and API endpoints
Test Suite / test (24.15.0) (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-11 09:36:15 +02:00
parent 8e6e0e96b8
commit d4a7983afb
9 changed files with 591 additions and 19 deletions
@@ -52,6 +52,31 @@ class InventoryRepository {
await _api.deleteJson(InventoryApiPaths.remove(id), token: token);
}
Future<void> bulkDeleteInventoryItems(List<int> ids, {String? token}) async {
await _api.postJson(
InventoryApiPaths.bulkDelete,
body: {'ids': ids},
token: token,
);
}
Future<InventoryItem> mergeInventoryItems(
List<int> ids, {
String? targetUnit,
String? token,
}) async {
final body = <String, dynamic>{'ids': ids};
if (targetUnit != null && targetUnit.trim().isNotEmpty) {
body['targetUnit'] = targetUnit.trim();
}
final data = await _api.postJson(
InventoryApiPaths.mergeMany,
body: body,
token: token,
);
return InventoryItem.fromJson(data as Map<String, dynamic>);
}
Future<void> moveInventoryItemToPantry(int id, {String? token}) async {
await _api.postJson(InventoryApiPaths.moveToPantry(id), body: null, token: token);
}