From 6622d0340dc0dcfdc7fab4c83b2fc0c8031da553 Mon Sep 17 00:00:00 2001 From: Moe Poi ~ Date: Mon, 13 Nov 2023 12:24:10 +0700 Subject: [PATCH] Add limitation to checkout --- lib/components/checkout_form.dart | 36 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/components/checkout_form.dart b/lib/components/checkout_form.dart index 94305a6..bc23fc1 100644 --- a/lib/components/checkout_form.dart +++ b/lib/components/checkout_form.dart @@ -74,11 +74,8 @@ class _CheckoutFormState extends State { onPressed: () { checkSessionExist().then((isLoggedIn) { if (isLoggedIn) { - submitForm(context).then((statusCode) { - Navigator.pop(context); - Navigator.pushReplacementNamed( - context, '/transactions'); - }); + clearCart() + .then((value) => showAlertDialog(context)); } else { Navigator.pushNamed(context, '/login'); } @@ -107,3 +104,32 @@ class _CheckoutFormState extends State { ); } } + +showAlertDialog(BuildContext context) { + Widget okButton = TextButton( + child: const Text("OK", style: TextStyle(color: Colors.white)), + onPressed: () { + Navigator.pop(context); + Navigator.pushReplacementNamed(context, '/products'); + }, + ); + AlertDialog alert = AlertDialog( + backgroundColor: const Color(0xff1b1c1e), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + content: const Text( + "Coming Soon", + style: TextStyle(color: Colors.white70), + ), + actions: [ + okButton, + ], + ); + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); +}