From 824bb75f0d2bdc054990c23371a3f15fb89e2b1f Mon Sep 17 00:00:00 2001 From: yaso-meth Date: Fri, 16 Aug 2024 10:40:22 +0200 Subject: [PATCH] check if form is completely filled --- .../lib/pages/profileBusinessAdd.dart | 28 +++++++++++++++++- .../lib/pages/profileBusinessUpdate.dart | 29 +++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart b/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart index 197414f6..ad04253c 100644 --- a/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart +++ b/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart @@ -147,8 +147,34 @@ class _ProfileBusinessAddState extends State { ); } + bool isFieldsFilled() { + if (nameController.text.isEmpty || + typeController.text.isEmpty || + regController.text.isEmpty || + logonameController.text.isEmpty || + fnameController.text.isEmpty || + lnameController.text.isEmpty || + titleController.text.isEmpty || + signtureController.text.isEmpty || + accessController.text.isEmpty || + contactController.text.isEmpty) { + return false; + } else { + return true; + } + } + void submitForm() { - createBusinessProfileAPICall(); + if (isFieldsFilled()) { + createBusinessProfileAPICall(); + } else { + showDialog( + context: context, + builder: (context) { + return const MIHErrorMessage(errorType: "Input Error"); + }, + ); + } } @override diff --git a/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart b/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart index 4a6df30b..1ca6bcbe 100644 --- a/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart +++ b/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart @@ -215,9 +215,34 @@ class _ProfileBusinessUpdateState extends State { ); } + bool isFieldsFilled() { + if (nameController.text.isEmpty || + typeController.text.isEmpty || + regController.text.isEmpty || + logonameController.text.isEmpty || + fnameController.text.isEmpty || + lnameController.text.isEmpty || + titleController.text.isEmpty || + signtureController.text.isEmpty || + accessController.text.isEmpty || + contactController.text.isEmpty) { + return false; + } else { + return true; + } + } + void submitForm(String business_id) { - //to-do late - updateBusinessProfileAPICall(business_id); + if (isFieldsFilled()) { + updateBusinessProfileAPICall(business_id); + } else { + showDialog( + context: context, + builder: (context) { + return const MIHErrorMessage(errorType: "Input Error"); + }, + ); + } } @override