Add activate business toggle on profile update
This commit is contained in:
@@ -26,6 +26,7 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
final usernameController = TextEditingController();
|
final usernameController = TextEditingController();
|
||||||
final fnameController = TextEditingController();
|
final fnameController = TextEditingController();
|
||||||
final lnameController = TextEditingController();
|
final lnameController = TextEditingController();
|
||||||
|
late bool businessUser;
|
||||||
|
|
||||||
bool isFieldsFilled() {
|
bool isFieldsFilled() {
|
||||||
if (fnameController.text.isEmpty ||
|
if (fnameController.text.isEmpty ||
|
||||||
@@ -45,6 +46,13 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
//await getOfficeIdByUser(docOfficeIdApiUrl + userEmail);
|
//await getOfficeIdByUser(docOfficeIdApiUrl + userEmail);
|
||||||
//print(futureDocOfficeId.toString());
|
//print(futureDocOfficeId.toString());
|
||||||
//print("Here3");
|
//print("Here3");
|
||||||
|
var profileType;
|
||||||
|
if (businessUser) {
|
||||||
|
profileType = "business";
|
||||||
|
} else {
|
||||||
|
profileType = "personal";
|
||||||
|
}
|
||||||
|
|
||||||
var response = await http.put(
|
var response = await http.put(
|
||||||
Uri.parse("${AppEnviroment.baseApiUrl}/user/update/"),
|
Uri.parse("${AppEnviroment.baseApiUrl}/user/update/"),
|
||||||
headers: <String, String>{
|
headers: <String, String>{
|
||||||
@@ -55,6 +63,7 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
"username": usernameController.text,
|
"username": usernameController.text,
|
||||||
"fnam": fnameController.text,
|
"fnam": fnameController.text,
|
||||||
"lname": lnameController.text,
|
"lname": lnameController.text,
|
||||||
|
"type": profileType,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
//print("Here4");
|
//print("Here4");
|
||||||
@@ -70,6 +79,14 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBusinessUser() {
|
||||||
|
if (widget.signedInUser.type == "personal") {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void internetConnectionPopUp() {
|
void internetConnectionPopUp() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -93,9 +110,13 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
fnameController.text = widget.signedInUser.fname;
|
setState(() {
|
||||||
lnameController.text = widget.signedInUser.lname;
|
fnameController.text = widget.signedInUser.fname;
|
||||||
usernameController.text = widget.signedInUser.username;
|
lnameController.text = widget.signedInUser.lname;
|
||||||
|
usernameController.text = widget.signedInUser.username;
|
||||||
|
businessUser = isBusinessUser();
|
||||||
|
});
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +125,7 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
"Update User profile:",
|
"Personal profile:",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
@@ -132,6 +153,31 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
required: true,
|
required: true,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
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(
|
SizedBox(
|
||||||
width: 500.0,
|
width: 500.0,
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user