From 3d6dc742d4c75415a8cfcee00c58addbeb33462f Mon Sep 17 00:00:00 2001 From: alzalia1 Date: Thu, 14 Aug 2025 12:10:37 +0200 Subject: [PATCH] fix: display owner shortid on add --- .../add_page/widgets/confirmation_popup.dart | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/lib/ui/add_page/widgets/confirmation_popup.dart b/lib/ui/add_page/widgets/confirmation_popup.dart index 84041d2..b365959 100644 --- a/lib/ui/add_page/widgets/confirmation_popup.dart +++ b/lib/ui/add_page/widgets/confirmation_popup.dart @@ -113,45 +113,42 @@ class _ConfirmationPopupState extends State { ), TextButton( onPressed: () async { + if (widget.viewModel.askPrice && + _formKey.currentState!.validate()) { + _formKey.currentState!.save(); + } + var result = await widget.viewModel.sendBook( widget.book, widget.viewModel.currentOwner!, widget.viewModel.currentBal!, price, ); + switch (result) { case Ok(): - switch (widget.viewModel.askPrice) { - case true: - if (_formKey.currentState!.validate()) { - _formKey.currentState!.save(); - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - "\"${widget.book.title}\" ($price€) a bien été enregistré", - ), - behavior: SnackBarBehavior.floating, - ), - ); - widget.exitPopup(context); - } - } - break; - case false: - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - "\"${widget.book.title}\" (PL) a bien été enregistré", - ), - behavior: SnackBarBehavior.floating, - ), - ); - widget.exitPopup(context); - } + if (context.mounted) { + Navigator.of(context).pop(); } - + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text( + "ID : ${widget.viewModel.currentOwner!.firstName[0]}${widget.viewModel.currentOwner!.lastName[0]}${(price == 0) ? "PL" : price.toString()}", + ), + content: Text( + "Identifiant propriétaire de ce livre. Pensez à l'écrire pour retrouver lae propriétaire du livre lors de la vente ou du retour !", + ), + actions: [ + TextButton( + onPressed: () { + widget.exitPopup(context); + }, + child: Text("Ok"), + ), + ], + ), + ); break; case Error(): if (context.mounted) {