This commit is contained in:
JMARyA 2024-09-15 04:56:09 +02:00
parent 700b620c76
commit 91beacceb6
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 6 additions and 4 deletions

View file

@ -71,9 +71,10 @@ class API {
return ret;
}
Future<List<dynamic>> getLocations() async {
var resp = jsonDecode(await getRequest("$instance/locations"));
return resp as List<dynamic>;
Future<Map<String, Location>> getLocations() async {
var resp = jsonDecode(await getRequest("$instance/locations"))
as Map<String, dynamic>;
return resp.map((key, value) => MapEntry(key, Location(value)));
}
Future<Item> getItem(String item) async {

View file

@ -194,9 +194,10 @@ class _SupplyPageState extends State<SupplyPage> {
}
Future<Map<String, List<dynamic>>> _fetchData() async {
var locations = await API().getLocations();
var locations_map = await API().getLocations();
var origins = await API().getUniqueField(widget.item.id, variant, "origin");
origins.insert(0, "");
var locations = locations_map.keys.toList();
locations.insert(0, "");
return {'locations': locations, 'origins': origins};
}