Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Kiosk/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Kiosk/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Kiosk/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Kiosk/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Kiosk/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 24 additions & 17 deletions Kiosk/lib/screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,31 +250,38 @@ class _MainScreenState extends State<MainScreen> {
}
}

void _processPayment() {
Future<void> _processPayment() async {
if (_cartItems.isEmpty) return;
final order = model.Order(
id: DateTime.now().millisecondsSinceEpoch.toString(),
items: _cartItems.values
.map((item) => model.OrderItem(
barcode: item.product.barcode,
name: item.product.name,
price: item.product.price,
quantity: item.quantity,
))
.toList(),
totalAmount: _totalAmount,
timestamp: DateTime.now().millisecondsSinceEpoch,
);

try {
await _db.insertOrder(order);
Comment on lines +269 to +270

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Save order only after payment confirmation

The order is inserted into the database before the payment flow completes. Because PaymentScreen only calls onPaymentConfirmed after the admin PIN succeeds, any user who backs out of the screen or fails the PIN will still have an order recorded, inflating order history and revenue metrics while the cart remains uncleared. Consider deferring insertOrder until the confirmation callback or explicitly persisting it as a pending order.

Useful? React with 👍 / 👎.

} catch (e) {
debugPrint('Failed to save order: $e');
}

if (!mounted) return;
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => PaymentScreen(
totalAmount: _totalAmount,
onPaymentConfirmed: () async {
onPaymentConfirmed: () {
final l10n = AppLocalizations.of(context)!;
final navigator = Navigator.of(context);
final messenger = ScaffoldMessenger.of(context);
// Create and save order
final order = model.Order(
id: DateTime.now().millisecondsSinceEpoch.toString(), // Simple ID
items: _cartItems.values.map((item) => model.OrderItem(
barcode: item.product.barcode,
name: item.product.name,
price: item.product.price,
quantity: item.quantity,
)).toList(),
totalAmount: _totalAmount,
timestamp: DateTime.now().millisecondsSinceEpoch,
);

await _db.insertOrder(order);
if (!mounted) return;

_clearCart();
navigator.pop();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Kiosk/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: kiosk
description: "Vending Machine Kiosk App"
publish_to: 'none'
version: 0.3.0+1
version: 0.4.0+6

environment:
sdk: ^3.9.2
Expand Down
Binary file modified Kiosk/web/favicon.png
Binary file modified Kiosk/web/icons/Icon-192.png
Binary file modified Kiosk/web/icons/Icon-512.png
Binary file modified Kiosk/web/icons/Icon-maskable-192.png
Binary file modified Kiosk/web/icons/Icon-maskable-512.png
Binary file modified Manager/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file modified Manager/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file modified Manager/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary file modified Manager/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary file modified Manager/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
2 changes: 1 addition & 1 deletion Manager/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: manager
description: "Vending Machine Manager App"
publish_to: 'none'
version: 0.3.0+1
version: 0.4.0+6

environment:
sdk: ^3.9.2
Expand Down
Binary file modified Manager/web/favicon.png
Binary file modified Manager/web/icons/Icon-192.png
Binary file modified Manager/web/icons/Icon-512.png
Binary file modified Manager/web/icons/Icon-maskable-192.png
Binary file modified Manager/web/icons/Icon-maskable-512.png