diff --git a/Frontend/patient_manager/lib/components/profileUserUpdate.dart b/Frontend/patient_manager/lib/components/profileUserUpdate.dart index 82e207e7..d3bbe5de 100644 --- a/Frontend/patient_manager/lib/components/profileUserUpdate.dart +++ b/Frontend/patient_manager/lib/components/profileUserUpdate.dart @@ -26,6 +26,7 @@ class _ProfileUserUpdateState extends State { final usernameController = TextEditingController(); final fnameController = TextEditingController(); final lnameController = TextEditingController(); + late bool businessUser; bool isFieldsFilled() { if (fnameController.text.isEmpty || @@ -45,6 +46,13 @@ class _ProfileUserUpdateState extends State { //await getOfficeIdByUser(docOfficeIdApiUrl + userEmail); //print(futureDocOfficeId.toString()); //print("Here3"); + var profileType; + if (businessUser) { + profileType = "business"; + } else { + profileType = "personal"; + } + var response = await http.put( Uri.parse("${AppEnviroment.baseApiUrl}/user/update/"), headers: { @@ -55,6 +63,7 @@ class _ProfileUserUpdateState extends State { "username": usernameController.text, "fnam": fnameController.text, "lname": lnameController.text, + "type": profileType, }), ); //print("Here4"); @@ -70,6 +79,14 @@ class _ProfileUserUpdateState extends State { } } + bool isBusinessUser() { + if (widget.signedInUser.type == "personal") { + return false; + } else { + return true; + } + } + void internetConnectionPopUp() { showDialog( context: context, @@ -93,9 +110,13 @@ class _ProfileUserUpdateState extends State { @override void initState() { - fnameController.text = widget.signedInUser.fname; - lnameController.text = widget.signedInUser.lname; - usernameController.text = widget.signedInUser.username; + setState(() { + fnameController.text = widget.signedInUser.fname; + lnameController.text = widget.signedInUser.lname; + usernameController.text = widget.signedInUser.username; + businessUser = isBusinessUser(); + }); + super.initState(); } @@ -104,7 +125,7 @@ class _ProfileUserUpdateState extends State { return Column( children: [ const Text( - "Update User profile:", + "Personal profile:", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 25, @@ -132,6 +153,31 @@ class _ProfileUserUpdateState extends State { required: true, ), const SizedBox(height: 10.0), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Text( + "Activate Business", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + ), + ), + const SizedBox( + width: 25, + ), + Switch( + value: businessUser, + onChanged: (bool value) { + setState(() { + businessUser = value; + }); + }, + ), + ], + ), + const SizedBox(height: 10.0), SizedBox( width: 500.0, height: 100.0,