From 9eee91bdb1c790066e4bb1a73b46a2cfec92c991 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Thu, 7 Aug 2025 12:24:34 +0200 Subject: [PATCH] refine your search message --- .../mih_business_user_search.dart | 99 ++++++++++------- .../package_tools/mih_patient_search.dart | 32 ++++-- .../package_tools/my_patient_list.dart | 100 +++++++++++------- 3 files changed, 146 insertions(+), 85 deletions(-) diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart index 8fef1ace..04a46c1e 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart @@ -25,7 +25,7 @@ class _MihBusinessUserSearchState extends State { final TextEditingController searchController = TextEditingController(); late Future> userSearchResults; final FocusNode _searchFocusNode = FocusNode(); - + bool hasSearchedBefore = false; String userSearch = ""; String errorCode = ""; String errorBody = ""; @@ -50,6 +50,7 @@ class _MihBusinessUserSearchState extends State { if (searchController.text != "") { setState(() { userSearch = searchController.text; + hasSearchedBefore = true; userSearchResults = fetchUsers(userSearch); }); } @@ -62,21 +63,18 @@ class _MihBusinessUserSearchState extends State { arguments: widget.arguments, ); } - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + if (hasSearchedBefore && userSearch.isNotEmpty) { + return Column( children: [ const SizedBox(height: 50), Icon( - MihIcons.personalProfile, + MihIcons.iDontKnow, size: 165, color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), ), const SizedBox(height: 10), Text( - "Search for a Member of Mzansi to add to your team", + "Let's Try Refining Your Search", textAlign: TextAlign.center, overflow: TextOverflow.visible, style: TextStyle( @@ -85,38 +83,65 @@ class _MihBusinessUserSearchState extends State { color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), ), ), - const SizedBox(height: 10), - Center( - child: RichText( + ], + ); + } else { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 50), + Icon( + MihIcons.personalProfile, + size: 165, + color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), + ), + const SizedBox(height: 10), + Text( + "Search for a Member of Mzansi to add to your team", textAlign: TextAlign.center, - text: TextSpan( - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.normal, - color: - MzansiInnovationHub.of(context)!.theme.secondaryColor(), - ), - children: [ - TextSpan( - text: "You can search using their Username or Email"), - // WidgetSpan( - // alignment: PlaceholderAlignment.middle, - // child: Icon( - // Icons.menu, - // size: 20, - // color: MzansiInnovationHub.of(context)! - // .theme - // .secondaryColor(), - // ), - // ), - // TextSpan(text: " to add your first loyalty card"), - ], + overflow: TextOverflow.visible, + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), ), ), - ), - ], - ), - ); + const SizedBox(height: 10), + Center( + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.normal, + color: + MzansiInnovationHub.of(context)!.theme.secondaryColor(), + ), + children: [ + TextSpan( + text: "You can search using their Username or Email"), + // WidgetSpan( + // alignment: PlaceholderAlignment.middle, + // child: Icon( + // Icons.menu, + // size: 20, + // color: MzansiInnovationHub.of(context)! + // .theme + // .secondaryColor(), + // ), + // ), + // TextSpan(text: " to add your first loyalty card"), + ], + ), + ), + ), + ], + ), + ); + } // return Center( // child: Text( // "Enter Username or Email to search", diff --git a/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/mih_patient_search.dart b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/mih_patient_search.dart index 5883e8cd..fa5f9ff3 100644 --- a/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/mih_patient_search.dart +++ b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/mih_patient_search.dart @@ -36,6 +36,7 @@ class _MihPatientSearchState extends State { TextEditingController _mihPatientSearchController = TextEditingController(); final FocusNode _focusNode = FocusNode(); final FocusNode _searchFocusNode = FocusNode(); + bool hasSearchedBefore = false; String _mihPatientSearchString = ""; String baseUrl = AppEnviroment.baseApiUrl; late Future> _mihPatientSearchResults; @@ -126,18 +127,26 @@ class _MihPatientSearchState extends State { personalSelected: widget.personalSelected, ); } else if (patientsList.isEmpty && searchString != "") { - return Padding( - padding: const EdgeInsets.only(top: 35.0), - child: Center( - child: Text( - "No ID or Medical Aid No. matches a Patient", - style: TextStyle( - fontSize: 25, - color: - MzansiInnovationHub.of(context)!.theme.messageTextColor()), - textAlign: TextAlign.center, + return Column( + children: [ + const SizedBox(height: 50), + Icon( + MihIcons.iDontKnow, + size: 165, + color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), ), - ), + const SizedBox(height: 10), + Text( + "Let's Try Refining Your Search", + textAlign: TextAlign.center, + overflow: TextOverflow.visible, + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), + ), + ), + ], ); } else { return Padding( @@ -218,6 +227,7 @@ class _MihPatientSearchState extends State { _mihPatientSearchString = _mihPatientSearchController.text; _mihPatientSearchResults = MIHApiCalls.fetchPatients(_mihPatientSearchString); + hasSearchedBefore = true; }); } } diff --git a/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/my_patient_list.dart b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/my_patient_list.dart index 08ab3295..a908e555 100644 --- a/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/my_patient_list.dart +++ b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/my_patient_list.dart @@ -35,6 +35,7 @@ class _MyPatientListState extends State { late Future> _myPatientList; TextEditingController _myPatientSearchController = TextEditingController(); final FocusNode _searchFocusNode = FocusNode(); + bool hasSearchedBefore = false; String _myPatientIdSearchString = ""; String baseUrl = AppEnviroment.baseApiUrl; @@ -114,21 +115,18 @@ class _MyPatientListState extends State { businessUser: widget.businessUser, ); } - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + if (hasSearchedBefore && _myPatientIdSearchString.isNotEmpty) { + return Column( children: [ const SizedBox(height: 50), Icon( - MihIcons.patientProfile, + MihIcons.iDontKnow, size: 165, color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), ), const SizedBox(height: 10), Text( - "You dont have access to any Patients Profile", + "Let's Try Refining Your Search", textAlign: TextAlign.center, overflow: TextOverflow.visible, style: TextStyle( @@ -137,39 +135,66 @@ class _MyPatientListState extends State { color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), ), ), - const SizedBox(height: 10), - Center( - child: RichText( + ], + ); + } else { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 50), + Icon( + MihIcons.patientProfile, + size: 165, + color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), + ), + const SizedBox(height: 10), + Text( + "You dont have access to any Patients Profile", textAlign: TextAlign.center, - text: TextSpan( - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.normal, - color: - MzansiInnovationHub.of(context)!.theme.secondaryColor(), - ), - children: [ - TextSpan(text: "Press "), - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: Icon( - Icons.search, - size: 20, - color: MzansiInnovationHub.of(context)! - .theme - .secondaryColor(), - ), - ), - TextSpan( - text: - " to use Patient Search to request access to their profile."), - ], + overflow: TextOverflow.visible, + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + color: MzansiInnovationHub.of(context)!.theme.secondaryColor(), ), ), - ), - ], - ), - ); + const SizedBox(height: 10), + Center( + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.normal, + color: + MzansiInnovationHub.of(context)!.theme.secondaryColor(), + ), + children: [ + TextSpan(text: "Press "), + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: Icon( + Icons.search, + size: 20, + color: MzansiInnovationHub.of(context)! + .theme + .secondaryColor(), + ), + ), + TextSpan( + text: + " to use Patient Search to request access to their profile."), + ], + ), + ), + ), + ], + ), + ); + } // return Padding( // padding: const EdgeInsets.only(top: 35.0), // child: Center( @@ -199,6 +224,7 @@ class _MyPatientListState extends State { setState(() { _myPatientList = MIHApiCalls.getPatientAccessListOfBusiness( widget.business!.business_id); + hasSearchedBefore = true; }); }