update business details profile udpate
This commit is contained in:
@@ -47,13 +47,17 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
final contactController = TextEditingController();
|
final contactController = TextEditingController();
|
||||||
final emailController = TextEditingController();
|
final emailController = TextEditingController();
|
||||||
final locationController = TextEditingController();
|
final locationController = TextEditingController();
|
||||||
|
final websiteController = TextEditingController();
|
||||||
|
final ratingController = TextEditingController();
|
||||||
|
final missionVisionController = TextEditingController();
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
||||||
late String env;
|
late String env;
|
||||||
|
|
||||||
Future<void> submitForm() async {
|
Future<void> submitForm() async {
|
||||||
if (isFormFilled()) {
|
if (isFormFilled()) {
|
||||||
int statusCode = 0;
|
int statusCode = 0;
|
||||||
statusCode = await MihBusinessDetailsServices().updateBusinessDetails(
|
statusCode = await MihBusinessDetailsServices().updateBusinessDetailsV2(
|
||||||
widget.arguments.business!.business_id,
|
widget.arguments.business!.business_id,
|
||||||
nameController.text,
|
nameController.text,
|
||||||
typeController.text,
|
typeController.text,
|
||||||
@@ -64,6 +68,9 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
contactController.text,
|
contactController.text,
|
||||||
locationController.text,
|
locationController.text,
|
||||||
fileNameController.text,
|
fileNameController.text,
|
||||||
|
websiteController.text,
|
||||||
|
ratingController.text.isEmpty ? "0" : ratingController.text,
|
||||||
|
missionVisionController.text,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
@@ -253,10 +260,55 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
inputColor: MzanziInnovationHub.of(context)!
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
controller: regController,
|
controller: nameController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText: true,
|
requiredText: true,
|
||||||
hintText: "Registration No.",
|
hintText: "Business Name",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihDropdownField(
|
||||||
|
controller: typeController,
|
||||||
|
hintText: "Business Type",
|
||||||
|
dropdownOptions: const ["Doctors Office", "Other"],
|
||||||
|
editable: true,
|
||||||
|
enableSearch: true,
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
requiredText: true,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: emailController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Business Email",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.validateEmail(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: contactController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Contact Number",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().isEmpty(value);
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
@@ -269,25 +321,78 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
inputColor: MzanziInnovationHub.of(context)!
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
controller: nameController,
|
controller: websiteController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText: true,
|
requiredText: false,
|
||||||
hintText: "Business Name",
|
hintText: "Business Website",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().isEmpty(value);
|
return MihValidationServices()
|
||||||
|
.validateWebsite(value, false);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 10),
|
||||||
MihDropdownField(
|
MihTextFormField(
|
||||||
controller: typeController,
|
height: 250,
|
||||||
hintText: "Business Type",
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
dropdownOptions: const ["Doctors Office", "Other"],
|
.theme
|
||||||
editable: true,
|
.secondaryColor(),
|
||||||
enableSearch: true,
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: missionVisionController,
|
||||||
|
multiLineInput: true,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Business Mission & Vision",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().validateLength(
|
||||||
|
missionVisionController.text, 256);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
child: ValueListenableBuilder(
|
||||||
|
valueListenable: _counter,
|
||||||
|
builder: (BuildContext context, int value,
|
||||||
|
Widget? child) {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"$value",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getMissionVisionLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Text(
|
||||||
|
"/256",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getMissionVisionLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: regController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Registration No.",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().isEmpty(value);
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
requiredText: true,
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
@@ -324,39 +429,6 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor(),
|
|
||||||
inputColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.primaryColor(),
|
|
||||||
controller: contactController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Contact Number",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor(),
|
|
||||||
inputColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.primaryColor(),
|
|
||||||
controller: emailController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Business Email",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices()
|
|
||||||
.validateEmail(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
@@ -442,6 +514,14 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color getMissionVisionLimitColor(int limit) {
|
||||||
|
if (_counter.value <= limit) {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.secondaryColor();
|
||||||
|
} else {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.errorColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -471,12 +551,20 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
contactController.text = widget.arguments.business!.contact_no;
|
contactController.text = widget.arguments.business!.contact_no;
|
||||||
emailController.text = widget.arguments.business!.bus_email;
|
emailController.text = widget.arguments.business!.bus_email;
|
||||||
locationController.text = widget.arguments.business!.gps_location;
|
locationController.text = widget.arguments.business!.gps_location;
|
||||||
|
websiteController.text = widget.arguments.business!.website;
|
||||||
|
ratingController.text = widget.arguments.business!.rating;
|
||||||
|
missionVisionController.text = widget.arguments.business!.mission_vision;
|
||||||
});
|
});
|
||||||
if (AppEnviroment.getEnv() == "Prod") {
|
if (AppEnviroment.getEnv() == "Prod") {
|
||||||
env = "Prod";
|
env = "Prod";
|
||||||
} else {
|
} else {
|
||||||
env = "Dev";
|
env = "Dev";
|
||||||
}
|
}
|
||||||
|
missionVisionController.addListener(() {
|
||||||
|
setState(() {
|
||||||
|
_counter.value = missionVisionController.text.characters.length;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user