diff --git a/lib/api.dart b/lib/api.dart index af93ada..e77f68a 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -251,10 +251,8 @@ class API { // /flow//end Future?> endFlow(String id, {List? produced}) async { -// todo : update api for supplyform - - var resp = jsonDecode( - await postRequest("$instance/$id/end", {"produced": produced})); + var resp = jsonDecode(await postRequest("$instance/$id/end", + {"produced": produced?.map((x) => x.json()).toList()})); if (produced != null) { return resp["produced"] as List; @@ -384,12 +382,12 @@ class Transaction { late String item; late String variant; late Price price; - late String? origin; + String? origin; late int timestamp; - late ConsumeInfo? consumed; + ConsumeInfo? consumed; late bool expired; - late String? note; - late Location? location; + String? note; + Location? location; Transaction(Map json) { uuid = json["uuid"]; @@ -404,11 +402,11 @@ class Transaction { location = json["location"] != null ? Location(json["location"]) : null; } - Transaction.inMemory(String itemID, String variant, String price, + Transaction.inMemory(String itemID, String variantID, String price, String? origin, Location? location, String? note) { uuid = ""; item = itemID; - variant = variant; + variant = variantID; this.price = Price.fromString(price); origin = origin; timestamp = 0; diff --git a/lib/pages/supply.dart b/lib/pages/supply.dart index 1b214e8..985a72d 100644 --- a/lib/pages/supply.dart +++ b/lib/pages/supply.dart @@ -38,7 +38,7 @@ class _SupplyPageState extends State { availableVariants = widget.onlyVariants ?? widget.item.variants.keys.toList(); - variant = widget.item.variants.keys.first; + variant = availableVariants.first; _selectedOrigin = widget.forceOrigin ?? ""; _priceController = TextEditingController(text: widget.forcePrice ?? ""); @@ -310,6 +310,17 @@ class SupplyForm { ); } + Map json() { + return { + "item": itemID, + "variant": variant, + "price": price, + "origin": origin, + "location": location, + "note": note + }; + } + SupplyForm({ required this.itemID, required this.variant,