update
This commit is contained in:
parent
d21554cddc
commit
b13b385cb7
10 changed files with 84 additions and 70 deletions
|
@ -1,5 +1,3 @@
|
|||
import 'dart:js_interop_unsafe';
|
||||
|
||||
import 'package:cdb_ui/api.dart' as API;
|
||||
import 'package:cdb_ui/api.dart';
|
||||
import 'package:cdb_ui/pages/supply.dart';
|
||||
|
|
|
@ -24,6 +24,7 @@ class StatsPage extends StatelessWidget {
|
|||
// global origin / destinations
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Home"),),
|
||||
body: FutureBuilder(
|
||||
future: _fetchData(),
|
||||
builder: (context, snapshot) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class _SupplyPageState extends State<SupplyPage> {
|
|||
var t = SupplyForm(
|
||||
itemID: widget.item.id,
|
||||
variant: variant,
|
||||
price: "${_priceController.text} €",
|
||||
price: double.parse(_priceController.text),
|
||||
origin: _selectedOrigin,
|
||||
location: _selectedLocation,
|
||||
note: _noteController.text);
|
||||
|
@ -66,8 +66,13 @@ class _SupplyPageState extends State<SupplyPage> {
|
|||
}
|
||||
|
||||
API()
|
||||
.supplyItem(widget.item.id, variant, "${_priceController.text} €",
|
||||
_selectedOrigin, _selectedLocation, _noteController.text)
|
||||
.supplyItem(
|
||||
widget.item.id,
|
||||
variant,
|
||||
double.parse(_priceController.text),
|
||||
_selectedOrigin,
|
||||
_selectedLocation,
|
||||
_noteController.text)
|
||||
.then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Item added successfully!')),
|
||||
|
@ -138,7 +143,7 @@ class _SupplyPageState extends State<SupplyPage> {
|
|||
? await API()
|
||||
.getLatestPrice(widget.item.id, variant,
|
||||
origin: selection)
|
||||
.then((x) => x.value.toStringAsFixed(2))
|
||||
.then((x) => x.toStringAsFixed(2))
|
||||
: _priceController.text;
|
||||
setState(() {
|
||||
_priceController.text = price;
|
||||
|
@ -293,7 +298,7 @@ class AutocompletedTextField extends StatelessWidget {
|
|||
class SupplyForm {
|
||||
final String itemID;
|
||||
final String variant;
|
||||
final String price;
|
||||
final double price;
|
||||
final String? origin;
|
||||
final String? location;
|
||||
final String note;
|
||||
|
|
|
@ -165,7 +165,7 @@ class _TransactionPageState extends State<TransactionPage> {
|
|||
|
||||
if (transaction.expired) const Text("Transaction is Expired!"),
|
||||
|
||||
IconText(Icons.money, transaction.price.format(),
|
||||
IconText(Icons.money, transaction.price.toStringAsFixed(2),
|
||||
color: Colors.green),
|
||||
|
||||
if (transaction.origin != null)
|
||||
|
@ -181,7 +181,8 @@ class _TransactionPageState extends State<TransactionPage> {
|
|||
Text("Consumed on: ${tsFormat(transaction.consumed!.timestamp)}"),
|
||||
IconText(Icons.store, transaction.consumed!.destination,
|
||||
color: Colors.blue),
|
||||
IconText(Icons.money, transaction.consumed!.price.format(),
|
||||
IconText(
|
||||
Icons.money, transaction.consumed!.price.toStringAsFixed(2),
|
||||
color: Colors.green),
|
||||
]
|
||||
|
||||
|
@ -286,8 +287,7 @@ class TransactionCard extends StatelessWidget {
|
|||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
IconText(Icons.money,
|
||||
"${t.price.value.toStringAsFixed(2)} ${t.price.currency}",
|
||||
IconText(Icons.money, "${t.price.toStringAsFixed(2)} €",
|
||||
color: Colors.green),
|
||||
if (t.origin != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
|
@ -328,6 +328,7 @@ class IconText extends StatelessWidget {
|
|||
Text(
|
||||
text,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue