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
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user