feat: Implement admin pantry item management with create and update functionality, including category selection and validation
Test Suite / test (24.15.0) (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-11 11:18:13 +02:00
parent 573c12cdc3
commit f132983b75
11 changed files with 683 additions and 38 deletions
@@ -436,6 +436,38 @@ class AdminRepository {
Future<void> removeAdminPantryItem(int pantryItemId) =>
_deleteVoid(PantryApiPaths.adminRemove(pantryItemId));
Future<AdminPantryItem> createAdminPantry({
int? userId,
required int productId,
String? location,
}) {
return _post<AdminPantryItem>(
PantryApiPaths.adminCreate,
body: {
if (userId != null) 'userId': userId,
'productId': productId,
if (location != null && location.trim().isNotEmpty)
'location': location.trim(),
},
parse: (d) => AdminPantryItem.fromJson(Map<String, dynamic>.from(d as Map)),
);
}
Future<AdminPantryItem> updateAdminPantry(
int pantryItemId, {
int? productId,
String? location,
}) {
return _patch(
PantryApiPaths.adminUpdate(pantryItemId),
body: {
if (productId != null) 'productId': productId,
if (location != null) 'location': location,
},
parse: AdminPantryItem.fromJson,
);
}
Future<void> moveAdminPantryToInventory(
int pantryItemId,
Map<String, dynamic> body,