add email to add and update business
This commit is contained in:
@@ -44,6 +44,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
final signtureController = TextEditingController();
|
final signtureController = TextEditingController();
|
||||||
final accessController = TextEditingController();
|
final accessController = TextEditingController();
|
||||||
final contactController = TextEditingController();
|
final contactController = TextEditingController();
|
||||||
|
final emailController = TextEditingController();
|
||||||
|
|
||||||
late PlatformFile selectedLogo;
|
late PlatformFile selectedLogo;
|
||||||
late PlatformFile selectedSignature;
|
late PlatformFile selectedSignature;
|
||||||
@@ -115,6 +116,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
"logo_path":
|
"logo_path":
|
||||||
"${widget.signedInUser.app_id}/business_files/${logonameController.text}",
|
"${widget.signedInUser.app_id}/business_files/${logonameController.text}",
|
||||||
"contact_no": contactController.text,
|
"contact_no": contactController.text,
|
||||||
|
"bus_email": emailController.text,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
@@ -157,7 +159,8 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
titleController.text.isEmpty ||
|
titleController.text.isEmpty ||
|
||||||
signtureController.text.isEmpty ||
|
signtureController.text.isEmpty ||
|
||||||
accessController.text.isEmpty ||
|
accessController.text.isEmpty ||
|
||||||
contactController.text.isEmpty) {
|
contactController.text.isEmpty ||
|
||||||
|
emailController.text.isEmpty) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@@ -165,7 +168,9 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void submitForm() {
|
void submitForm() {
|
||||||
if (isFieldsFilled()) {
|
if (!validEmail()) {
|
||||||
|
emailError();
|
||||||
|
} else if (isFieldsFilled()) {
|
||||||
createBusinessProfileAPICall();
|
createBusinessProfileAPICall();
|
||||||
} else {
|
} else {
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -177,6 +182,21 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void emailError() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MIHErrorMessage(errorType: "Invalid Email");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validEmail() {
|
||||||
|
String text = emailController.text;
|
||||||
|
var regex = RegExp(r'^[a-zA-Z0-9]+@[a-zA-Z.-]+\.[a-zA-Z]{2,}$');
|
||||||
|
return regex.hasMatch(text);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -241,6 +261,13 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
required: true,
|
required: true,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
|
MIHTextField(
|
||||||
|
controller: emailController,
|
||||||
|
hintText: "Email",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
MIHFileField(
|
MIHFileField(
|
||||||
controller: logonameController,
|
controller: logonameController,
|
||||||
hintText: "Logo",
|
hintText: "Logo",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
|||||||
final signtureController = TextEditingController();
|
final signtureController = TextEditingController();
|
||||||
final accessController = TextEditingController();
|
final accessController = TextEditingController();
|
||||||
final contactController = TextEditingController();
|
final contactController = TextEditingController();
|
||||||
|
final emailController = TextEditingController();
|
||||||
|
|
||||||
late PlatformFile? selectedLogo = null;
|
late PlatformFile? selectedLogo = null;
|
||||||
late PlatformFile? selectedSignature = null;
|
late PlatformFile? selectedSignature = null;
|
||||||
@@ -179,6 +180,7 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
|||||||
"logo_path":
|
"logo_path":
|
||||||
"${widget.arguments.signedInUser.app_id}/business_files/${logonameController.text}",
|
"${widget.arguments.signedInUser.app_id}/business_files/${logonameController.text}",
|
||||||
"contact_no": contactController.text,
|
"contact_no": contactController.text,
|
||||||
|
"bus_email": emailController.text,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@@ -225,7 +227,8 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
|||||||
titleController.text.isEmpty ||
|
titleController.text.isEmpty ||
|
||||||
signtureController.text.isEmpty ||
|
signtureController.text.isEmpty ||
|
||||||
accessController.text.isEmpty ||
|
accessController.text.isEmpty ||
|
||||||
contactController.text.isEmpty) {
|
contactController.text.isEmpty ||
|
||||||
|
emailController.text.isEmpty) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@@ -233,7 +236,9 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void submitForm(String business_id) {
|
void submitForm(String business_id) {
|
||||||
if (isFieldsFilled()) {
|
if (!validEmail()) {
|
||||||
|
emailError();
|
||||||
|
} else if (isFieldsFilled()) {
|
||||||
updateBusinessProfileAPICall(business_id);
|
updateBusinessProfileAPICall(business_id);
|
||||||
} else {
|
} else {
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -245,6 +250,21 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void emailError() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MIHErrorMessage(errorType: "Invalid Email");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validEmail() {
|
||||||
|
String text = emailController.text;
|
||||||
|
var regex = RegExp(r'^[a-zA-Z0-9]+@[a-zA-Z.-]+\.[a-zA-Z]{2,}$');
|
||||||
|
return regex.hasMatch(text);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -266,6 +286,7 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
|||||||
logonameController.text = widget.arguments.business!.logo_name;
|
logonameController.text = widget.arguments.business!.logo_name;
|
||||||
oldLogoPath = widget.arguments.business!.logo_path;
|
oldLogoPath = widget.arguments.business!.logo_path;
|
||||||
contactController.text = widget.arguments.business!.contact_no;
|
contactController.text = widget.arguments.business!.contact_no;
|
||||||
|
emailController.text = widget.arguments.business!.bus_email;
|
||||||
});
|
});
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -328,6 +349,13 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
|||||||
required: true,
|
required: true,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
|
MIHTextField(
|
||||||
|
controller: emailController,
|
||||||
|
hintText: "Email",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
MIHFileField(
|
MIHFileField(
|
||||||
controller: logonameController,
|
controller: logonameController,
|
||||||
hintText: "Logo",
|
hintText: "Logo",
|
||||||
|
|||||||
Reference in New Issue
Block a user