mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Udpate barcode decoding to match API changes
This commit is contained in:
parent
93630ea910
commit
0f472d448b
@ -51,6 +51,11 @@ Future<void> scanQrCode(BuildContext context) async {
|
|||||||
|
|
||||||
final Map<String, dynamic> body = json.decode(response.body);
|
final Map<String, dynamic> body = json.decode(response.body);
|
||||||
|
|
||||||
|
// TODO - Handle potential error decoding response
|
||||||
|
|
||||||
|
print("Barcode response:");
|
||||||
|
print(body.toString());
|
||||||
|
|
||||||
if (body.containsKey('error')) {
|
if (body.containsKey('error')) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -91,39 +96,45 @@ Future<void> scanQrCode(BuildContext context) async {
|
|||||||
|
|
||||||
void _handleBarcode(BuildContext context, Map<String, dynamic> data) {
|
void _handleBarcode(BuildContext context, Map<String, dynamic> data) {
|
||||||
|
|
||||||
int id;
|
int pk;
|
||||||
|
|
||||||
// A stocklocation has been passed?
|
// A stocklocation has been passed?
|
||||||
if (data.containsKey('stocklocation')) {
|
if (data.containsKey('stocklocation')) {
|
||||||
|
|
||||||
id = data['stocklocation']['id'] ?? null;
|
pk = data['stocklocation']['pk'] as int ?? null;
|
||||||
|
|
||||||
if (id != null) {
|
if (pk != null) {
|
||||||
InvenTreeStockLocation().get(context, id).then((var loc) {
|
InvenTreeStockLocation().get(context, pk).then((var loc) {
|
||||||
if (loc is InvenTreeStockLocation) {
|
if (loc is InvenTreeStockLocation) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// TODO - Show an error here!
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (data.containsKey('stockitem')) {
|
} else if (data.containsKey('stockitem')) {
|
||||||
|
|
||||||
id = data['stockitem']['id'] ?? null;
|
pk = data['stockitem']['pk'] as int ?? null;
|
||||||
|
|
||||||
if (id != null) {
|
if (pk != null) {
|
||||||
InvenTreeStockItem().get(context, id).then((var item) {
|
InvenTreeStockItem().get(context, pk).then((var item) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// TODO - Show an error here!
|
||||||
}
|
}
|
||||||
} else if (data.containsKey('part')) {
|
} else if (data.containsKey('part')) {
|
||||||
|
|
||||||
id = data['part']['id'] ?? null;
|
pk = data['part']['pk'] as int ?? null;
|
||||||
|
|
||||||
if (id != null) {
|
if (pk != null) {
|
||||||
InvenTreePart().get(context, id).then((var part) {
|
InvenTreePart().get(context, pk).then((var part) {
|
||||||
Navigator.push(context,
|
Navigator.push(context,
|
||||||
MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// TODO - Show an error here!
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showDialog(
|
showDialog(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user