forked from yaso_meth/mih-project
set up business
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_env/env.dart';
|
||||
@@ -7,6 +8,47 @@ import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class MihBusinessDetailsApi {
|
||||
Future<Response> createBusinessDetails(
|
||||
String appId,
|
||||
String busineName,
|
||||
String businessType,
|
||||
String businessRegistrationNo,
|
||||
String businessPracticeNo,
|
||||
String businessVatNo,
|
||||
String businessEmail,
|
||||
String businessPhoneNumber,
|
||||
String businessLocation,
|
||||
String businessLogoFilename,
|
||||
BuildContext context,
|
||||
) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
var response = await http.post(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/business/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"Name": busineName,
|
||||
"type": businessType,
|
||||
"registration_no": businessRegistrationNo,
|
||||
"logo_name": businessLogoFilename,
|
||||
"logo_path": "$appId/business_files/$businessLogoFilename",
|
||||
"contact_no": businessPhoneNumber,
|
||||
"bus_email": businessEmail,
|
||||
"gps_location": businessLocation,
|
||||
"practice_no": businessPracticeNo,
|
||||
"vat_no": businessVatNo,
|
||||
}),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<int> updateBusinessDetails(
|
||||
String business_id,
|
||||
String business_name,
|
||||
|
||||
@@ -42,10 +42,13 @@ class MihFileApi {
|
||||
var decodedData = jsonDecode(response.body);
|
||||
fileUrl = decodedData['minioURL'];
|
||||
} else {
|
||||
internetConnectionPopUp(context);
|
||||
// internetConnectionPopUp(context);
|
||||
print("Error: ${response.statusCode}");
|
||||
print("Error: ${response.body}");
|
||||
}
|
||||
} catch (e) {
|
||||
internetConnectionPopUp(context);
|
||||
// internetConnectionPopUp(context);
|
||||
print("Error getting url");
|
||||
} finally {
|
||||
// Navigator.of(context).pop(); // Always pop loading dialog
|
||||
}
|
||||
|
||||
@@ -7,8 +7,45 @@ import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class MihMyBusinessUserApi {
|
||||
Future<int> createBusinessUser(
|
||||
String business_id,
|
||||
String app_id,
|
||||
String signatureFilename,
|
||||
String title,
|
||||
String access,
|
||||
BuildContext context,
|
||||
) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
var response = await http.post(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/business-user/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"business_id": business_id,
|
||||
"app_id": app_id,
|
||||
"signature": signatureFilename,
|
||||
"sig_path": "$business_id/business_files/$signatureFilename",
|
||||
"title": title,
|
||||
"access": access,
|
||||
}),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
if (response.statusCode == 201) {
|
||||
return 201;
|
||||
} else {
|
||||
internetConnectionPopUp(context);
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
|
||||
/// This function updates the business user details.
|
||||
Future<int> updateBusinessDetails(
|
||||
Future<int> updateBusinessUser(
|
||||
String app_id,
|
||||
String business_id,
|
||||
String bUserTitle,
|
||||
|
||||
@@ -144,6 +144,7 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
||||
MihImageDisplay(
|
||||
imageFile: imagePreview,
|
||||
width: 300,
|
||||
height: 200,
|
||||
editable: true,
|
||||
fileNameController: _imagefileController,
|
||||
userSelectedfile: imageFile,
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:mzansi_innovation_hub/main.dart';
|
||||
class MihImageDisplay extends StatefulWidget {
|
||||
final ImageProvider<Object>? imageFile;
|
||||
final double width;
|
||||
final double height;
|
||||
final bool editable;
|
||||
final TextEditingController fileNameController;
|
||||
final onChange;
|
||||
@@ -15,6 +16,7 @@ class MihImageDisplay extends StatefulWidget {
|
||||
super.key,
|
||||
required this.imageFile,
|
||||
required this.width,
|
||||
required this.height,
|
||||
required this.editable,
|
||||
required this.fileNameController,
|
||||
required this.userSelectedfile,
|
||||
@@ -28,11 +30,28 @@ class MihImageDisplay extends StatefulWidget {
|
||||
class _MihImageDisplayState extends State<MihImageDisplay> {
|
||||
late ImageProvider<Object>? imagePreview;
|
||||
|
||||
ImageProvider<Object>? getImage() {
|
||||
Color dark = const Color(0XFF3A4454);
|
||||
if (widget.imageFile == null) {
|
||||
if (MzanziInnovationHub.of(context)!.theme.secondaryColor() == dark) {
|
||||
print("here in light icon");
|
||||
return const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png');
|
||||
} else {
|
||||
print("here in dark icon");
|
||||
return const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png');
|
||||
}
|
||||
} else {
|
||||
return widget.imageFile;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
setState(() {
|
||||
imagePreview = widget.imageFile;
|
||||
imagePreview = getImage();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,6 +61,7 @@ class _MihImageDisplayState extends State<MihImageDisplay> {
|
||||
// color: Colors.white,
|
||||
alignment: Alignment.center,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
|
||||
@@ -277,6 +277,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
userSelectedfile: imageFile,
|
||||
frameColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
backgroundColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
onChange: (selectedfile) {
|
||||
setState(() {
|
||||
imageFile = selectedfile;
|
||||
@@ -286,7 +288,23 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
} else if (snapshot.hasError) {
|
||||
return Text("Error: ${snapshot.error}");
|
||||
} else {
|
||||
return const Text("Error loading image");
|
||||
return MihCircleAvatar(
|
||||
imageFile: null,
|
||||
width: 150,
|
||||
editable: true,
|
||||
fileNameController: fileNameController,
|
||||
userSelectedfile: imageFile,
|
||||
frameColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
backgroundColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
onChange: (selectedfile) {
|
||||
setState(() {
|
||||
imageFile = selectedfile;
|
||||
});
|
||||
},
|
||||
);
|
||||
// return const Text("Error loading image");
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -257,20 +257,6 @@ class _MihBusinessProfileState extends State<MihBusinessProfile> {
|
||||
);
|
||||
}
|
||||
|
||||
ImageProvider<Object>? isPictureAvailable(String url) {
|
||||
print("logo Url: $url");
|
||||
if (url == "") {
|
||||
return const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/i-dont-know-2.png');
|
||||
} else if (url != "") {
|
||||
return NetworkImage(url);
|
||||
} else {
|
||||
return const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/i-dont-know-2.png');
|
||||
// return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
nameController.dispose();
|
||||
@@ -321,7 +307,7 @@ class _MihBusinessProfileState extends State<MihBusinessProfile> {
|
||||
setState(() {
|
||||
logoUri = value;
|
||||
});
|
||||
logoPreview = isPictureAvailable(logoUri);
|
||||
logoPreview = NetworkImage(logoUri);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -55,8 +55,6 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
|
||||
Future<bool> uploadFile() async {
|
||||
if (userSignatureFile != null) {
|
||||
print(userSignatureFile!.name);
|
||||
print(userSignatureFile!.bytes);
|
||||
int uploadStatusCode = 0;
|
||||
uploadStatusCode = await MihFileApi.uploadFile(
|
||||
widget.arguments.signedInUser.app_id,
|
||||
@@ -86,10 +84,8 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
}
|
||||
|
||||
Future<void> submitForm() async {
|
||||
print("Here 1");
|
||||
if (isFormFilled()) {
|
||||
print("Here 1");
|
||||
int statusCode = await MihMyBusinessUserApi().updateBusinessDetails(
|
||||
int statusCode = await MihMyBusinessUserApi().updateBusinessUser(
|
||||
widget.arguments.signedInUser.app_id,
|
||||
widget.arguments.businessUser!.business_id,
|
||||
titleDropdownController.text,
|
||||
@@ -98,9 +94,7 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
context,
|
||||
);
|
||||
if (statusCode == 200) {
|
||||
print("Here 1");
|
||||
bool successfullyUploadedFile = await uploadFile();
|
||||
print("Here 4");
|
||||
if (successfullyUploadedFile) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
@@ -259,12 +253,26 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
userSelectedfile: userPicFile,
|
||||
frameColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
backgroundColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
onChange: (_) {},
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text("Error: ${snapshot.error}");
|
||||
} else {
|
||||
return const Text("Error loading image");
|
||||
return MihCircleAvatar(
|
||||
imageFile: null,
|
||||
width: 150,
|
||||
editable: false,
|
||||
fileNameController: fileNameController,
|
||||
userSelectedfile: userPicFile,
|
||||
frameColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
backgroundColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
onChange: (_) {},
|
||||
);
|
||||
// return const Text("Error loading image");
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -319,7 +327,7 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
width: 300,
|
||||
alignment: Alignment.topLeft,
|
||||
child: const Text(
|
||||
"Signature",
|
||||
"Signature:",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -352,6 +360,7 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
return MihImageDisplay(
|
||||
imageFile: NetworkImage(snapshot.data.toString()),
|
||||
width: 300,
|
||||
height: 200,
|
||||
editable: true,
|
||||
fileNameController: signtureController,
|
||||
userSelectedfile: userSignatureFile,
|
||||
@@ -364,7 +373,20 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
} else if (snapshot.hasError) {
|
||||
return Text("Error: ${snapshot.error}");
|
||||
} else {
|
||||
return const Text("Error loading image");
|
||||
return MihImageDisplay(
|
||||
imageFile: null,
|
||||
width: 300,
|
||||
height: 200,
|
||||
editable: true,
|
||||
fileNameController: signtureController,
|
||||
userSelectedfile: userSignatureFile,
|
||||
onChange: (selectedFile) {
|
||||
setState(() {
|
||||
userSignatureFile = selectedFile;
|
||||
});
|
||||
},
|
||||
);
|
||||
// return const Text("Error loading image");
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_apis/mih_business_details_apis.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_apis/mih_file_api.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_apis/mih_location_api.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_apis/mih_my_business_user_apis.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_text_input.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_header.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_layout_builder.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_env/env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../../../main.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:http/http.dart' as http2;
|
||||
|
||||
import '../../../mih_apis/mih_location_api.dart';
|
||||
import '../../../mih_components/mih_inputs_and_buttons/mih_button.dart';
|
||||
import '../../../mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart';
|
||||
import '../../../mih_components/mih_inputs_and_buttons/mih_file_input.dart';
|
||||
import '../../../mih_components/mih_inputs_and_buttons/mih_text_input.dart';
|
||||
import '../../../mih_components/mih_layout/mih_action.dart';
|
||||
import '../../../mih_components/mih_layout/mih_body.dart';
|
||||
import '../../../mih_components/mih_layout/mih_header.dart';
|
||||
import '../../../mih_components/mih_layout/mih_layout_builder.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import '../../../mih_env/env.dart';
|
||||
import '../../../mih_objects/app_user.dart';
|
||||
|
||||
class ProfileBusinessAdd extends StatefulWidget {
|
||||
//final BusinessUserScreenArguments arguments;
|
||||
@@ -56,48 +54,80 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
final practiceNoController = TextEditingController();
|
||||
final vatNoController = TextEditingController();
|
||||
|
||||
late PlatformFile selectedLogo;
|
||||
late PlatformFile selectedSignature;
|
||||
ImageProvider<Object>? logoPreview;
|
||||
ImageProvider<Object>? signaturePreview;
|
||||
PlatformFile? selectedLogo;
|
||||
PlatformFile? selectedSignature;
|
||||
|
||||
final ValueNotifier<String> busType = ValueNotifier("");
|
||||
|
||||
Future<void> uploadSelectedFile(
|
||||
PlatformFile file, TextEditingController controller) async {
|
||||
var token = await SuperTokens.getAccessToken();
|
||||
var request = http2.MultipartRequest(
|
||||
'POST', Uri.parse("${AppEnviroment.baseApiUrl}/minio/upload/file/"));
|
||||
request.headers['accept'] = 'application/json';
|
||||
request.headers['Authorization'] = 'Bearer $token';
|
||||
request.headers['Content-Type'] = 'multipart/form-data';
|
||||
request.fields['app_id'] = widget.signedInUser.app_id;
|
||||
request.fields['folder'] = "business_files";
|
||||
request.files.add(await http2.MultipartFile.fromBytes('file', file.bytes!,
|
||||
filename: file.name.replaceAll(RegExp(r' '), '-')));
|
||||
var response1 = await request.send();
|
||||
if (response1.statusCode == 200) {
|
||||
// Future<void> uploadSelectedFile(
|
||||
// PlatformFile file, TextEditingController controller) async {
|
||||
// var token = await supertokens.getaccesstoken();
|
||||
// var request = http2.multipartrequest(
|
||||
// 'post', uri.parse("${appenviroment.baseapiurl}/minio/upload/file/"));
|
||||
// request.headers['accept'] = 'application/json';
|
||||
// request.headers['authorization'] = 'bearer $token';
|
||||
// request.headers['content-type'] = 'multipart/form-data';
|
||||
// request.fields['app_id'] = widget.signedinuser.app_id;
|
||||
// request.fields['folder'] = "business_files";
|
||||
// request.files.add(await http2.multipartfile.frombytes('file', file.bytes!,
|
||||
// filename: file.name.replaceall(regexp(r' '), '-')));
|
||||
// var response1 = await request.send();
|
||||
// if (response1.statuscode == 200) {
|
||||
// } else {
|
||||
// internetconnectionpopup();
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<bool> uploadFile(String id, PlatformFile? selectedFile) async {
|
||||
print("Inside uploud file method");
|
||||
int uploadStatusCode = 0;
|
||||
uploadStatusCode = await MihFileApi.uploadFile(
|
||||
id,
|
||||
"business_files",
|
||||
selectedFile,
|
||||
context,
|
||||
);
|
||||
print("Status code: $uploadStatusCode");
|
||||
if (uploadStatusCode == 200) {
|
||||
return true;
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createBusinessUserAPICall(String business_id) async {
|
||||
var response = await http.post(
|
||||
Uri.parse("$baseAPI/business-user/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"business_id": business_id,
|
||||
"app_id": widget.signedInUser.app_id,
|
||||
"signature": signtureController.text,
|
||||
"sig_path":
|
||||
"${widget.signedInUser.app_id}/business_files/${signtureController.text}",
|
||||
"title": titleController.text,
|
||||
"access": accessController.text,
|
||||
}),
|
||||
print("Inside create bus user method");
|
||||
int statusCode = await MihMyBusinessUserApi().createBusinessUser(
|
||||
business_id,
|
||||
widget.signedInUser.app_id,
|
||||
signtureController.text,
|
||||
titleController.text,
|
||||
accessController.text,
|
||||
context,
|
||||
);
|
||||
if (response.statusCode == 201) {
|
||||
uploadSelectedFile(selectedSignature, signtureController);
|
||||
// var response = await http.post(
|
||||
// Uri.parse("$baseAPI/business-user/insert/"),
|
||||
// headers: <String, String>{
|
||||
// "Content-Type": "application/json; charset=UTF-8"
|
||||
// },
|
||||
// body: jsonEncode(<String, dynamic>{
|
||||
// "business_id": business_id,
|
||||
// "app_id": widget.signedInUser.app_id,
|
||||
// "signature": signtureController.text,
|
||||
// "sig_path":
|
||||
// "${widget.signedInUser.app_id}/business_files/${signtureController.text}",
|
||||
// "title": titleController.text,
|
||||
// "access": accessController.text,
|
||||
// }),
|
||||
// );
|
||||
print("Status code: $statusCode");
|
||||
if (statusCode == 201) {
|
||||
// uploadSelectedFile(selectedSignature, signtureController);
|
||||
// bool successfullyUploadedFile =
|
||||
// await uploadFile(business_id, selectedSignature);
|
||||
// if (successfullyUploadedFile) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
'/',
|
||||
@@ -106,44 +136,58 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
String message =
|
||||
"Your business profile is now live! You can now start connecting with customers and growing your business.";
|
||||
successPopUp(message);
|
||||
// } else {
|
||||
// internetConnectionPopUp();
|
||||
// }
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createBusinessProfileAPICall() async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
|
||||
var response = await http.post(
|
||||
Uri.parse("$baseAPI/business/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"Name": nameController.text,
|
||||
"type": typeController.text,
|
||||
"registration_no": regController.text,
|
||||
"logo_name": logonameController.text,
|
||||
"logo_path":
|
||||
"${widget.signedInUser.app_id}/business_files/${logonameController.text}",
|
||||
"contact_no": contactController.text,
|
||||
"bus_email": emailController.text,
|
||||
"gps_location": locationController.text,
|
||||
"practice_no": practiceNoController.text,
|
||||
"vat_no": vatNoController.text,
|
||||
}),
|
||||
print("Inside create business profile method");
|
||||
Response response = await MihBusinessDetailsApi().createBusinessDetails(
|
||||
widget.signedInUser.app_id,
|
||||
nameController.text,
|
||||
typeController.text,
|
||||
regController.text,
|
||||
practiceNoController.text,
|
||||
vatNoController.text,
|
||||
emailController.text,
|
||||
contactController.text,
|
||||
locationController.text,
|
||||
logonameController.text,
|
||||
context,
|
||||
);
|
||||
// var response = await http.post(
|
||||
// Uri.parse("$baseAPI/business/insert/"),
|
||||
// headers: <String, String>{
|
||||
// "Content-Type": "application/json; charset=UTF-8"
|
||||
// },
|
||||
// body: jsonEncode(<String, dynamic>{
|
||||
// "Name": nameController.text,
|
||||
// "type": typeController.text,
|
||||
// "registration_no": regController.text,
|
||||
// "logo_name": logonameController.text,
|
||||
// "logo_path":
|
||||
// "${widget.signedInUser.app_id}/business_files/${logonameController.text}",
|
||||
// "contact_no": contactController.text,
|
||||
// "bus_email": emailController.text,
|
||||
// "gps_location": locationController.text,
|
||||
// "practice_no": practiceNoController.text,
|
||||
// "vat_no": vatNoController.text,
|
||||
// }),
|
||||
// );
|
||||
print(response.body);
|
||||
if (response.statusCode == 201) {
|
||||
var businessResponse = jsonDecode(response.body);
|
||||
// bool successfullyUploadedFile =
|
||||
// await uploadFile(widget.signedInUser.app_id, selectedSignature);
|
||||
// if (successfullyUploadedFile) {
|
||||
createBusinessUserAPICall(businessResponse['business_id']);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
// uploadSelectedFile(selectedLogo, logonameController);
|
||||
// } else {
|
||||
// internetConnectionPopUp();
|
||||
// }
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
@@ -174,11 +218,11 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
if (nameController.text.isEmpty ||
|
||||
typeController.text.isEmpty ||
|
||||
regController.text.isEmpty ||
|
||||
logonameController.text.isEmpty ||
|
||||
// logonameController.text.isEmpty ||
|
||||
fnameController.text.isEmpty ||
|
||||
lnameController.text.isEmpty ||
|
||||
titleController.text.isEmpty ||
|
||||
signtureController.text.isEmpty ||
|
||||
// signtureController.text.isEmpty ||
|
||||
accessController.text.isEmpty ||
|
||||
contactController.text.isEmpty ||
|
||||
emailController.text.isEmpty) {
|
||||
@@ -189,9 +233,10 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
}
|
||||
|
||||
void submitForm() {
|
||||
if (!validEmail()) {
|
||||
if (!isEmailValid()) {
|
||||
emailError();
|
||||
} else if (isFieldsFilled()) {
|
||||
print("Inside submit method");
|
||||
createBusinessProfileAPICall();
|
||||
} else {
|
||||
showDialog(
|
||||
@@ -212,12 +257,18 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
);
|
||||
}
|
||||
|
||||
bool validEmail() {
|
||||
bool isEmailValid() {
|
||||
String text = emailController.text;
|
||||
var regex = RegExp(r'^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$');
|
||||
return regex.hasMatch(text);
|
||||
}
|
||||
|
||||
// bool validEmail() {
|
||||
// String text = emailController.text;
|
||||
// var regex = RegExp(r'^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$');
|
||||
// return regex.hasMatch(text);
|
||||
// }
|
||||
|
||||
void typeSelected() {
|
||||
if (typeController.text.isNotEmpty) {
|
||||
busType.value = typeController.text;
|
||||
@@ -280,6 +331,33 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
.theme
|
||||
.secondaryColor()),
|
||||
const SizedBox(height: 10.0),
|
||||
// MihCircleAvatar(
|
||||
// imageFile: logoPreview,
|
||||
// width: 150,
|
||||
// editable: true,
|
||||
// fileNameController: logonameController,
|
||||
// userSelectedfile: selectedLogo,
|
||||
// frameColor:
|
||||
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
// backgroundColor:
|
||||
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
// onChange: (selectedfile) {
|
||||
// setState(() {
|
||||
// selectedLogo = selectedfile;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 10.0),
|
||||
// Visibility(
|
||||
// visible: true,
|
||||
// child: MIHTextField(
|
||||
// controller: logonameController,
|
||||
// hintText: "Selected Logo File Name",
|
||||
// editable: false,
|
||||
// required: true,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 10.0),
|
||||
MIHTextField(
|
||||
controller: regController,
|
||||
hintText: "Registration No.",
|
||||
@@ -339,27 +417,27 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
required: true,
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MIHFileField(
|
||||
controller: logonameController,
|
||||
hintText: "Logo",
|
||||
editable: false,
|
||||
required: true,
|
||||
onPressed: () async {
|
||||
FilePickerResult? result =
|
||||
await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['jpg', 'png', 'pdf'],
|
||||
);
|
||||
if (result == null) return;
|
||||
final selectedFile = result.files.first;
|
||||
setState(() {
|
||||
selectedLogo = selectedFile;
|
||||
});
|
||||
setState(() {
|
||||
logonameController.text = selectedFile.name;
|
||||
});
|
||||
},
|
||||
),
|
||||
// MIHFileField(
|
||||
// controller: logonameController,
|
||||
// hintText: "Logo",
|
||||
// editable: false,
|
||||
// required: true,
|
||||
// onPressed: () async {
|
||||
// FilePickerResult? result =
|
||||
// await FilePicker.platform.pickFiles(
|
||||
// type: FileType.custom,
|
||||
// allowedExtensions: ['jpg', 'png', 'pdf'],
|
||||
// );
|
||||
// if (result == null) return;
|
||||
// final selectedFile = result.files.first;
|
||||
// setState(() {
|
||||
// selectedLogo = selectedFile;
|
||||
// });
|
||||
// setState(() {
|
||||
// logonameController.text = selectedFile.name;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 10.0),
|
||||
Row(
|
||||
children: [
|
||||
@@ -441,27 +519,59 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
required: true,
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MIHFileField(
|
||||
controller: signtureController,
|
||||
hintText: "Signature",
|
||||
editable: false,
|
||||
required: true,
|
||||
onPressed: () async {
|
||||
FilePickerResult? result =
|
||||
await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['jpg', 'png', 'pdf'],
|
||||
);
|
||||
if (result == null) return;
|
||||
final selectedFile = result.files.first;
|
||||
setState(() {
|
||||
selectedSignature = selectedFile;
|
||||
});
|
||||
setState(() {
|
||||
signtureController.text = selectedFile.name;
|
||||
});
|
||||
},
|
||||
),
|
||||
// const SizedBox(height: 10),
|
||||
// Container(
|
||||
// width: 300,
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: const Text(
|
||||
// "Signature:",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// MihImageDisplay(
|
||||
// imageFile: signaturePreview,
|
||||
// width: 300,
|
||||
// editable: true,
|
||||
// fileNameController: signtureController,
|
||||
// userSelectedfile: selectedSignature,
|
||||
// onChange: (selectedFile) {
|
||||
// setState(() {
|
||||
// selectedSignature = selectedFile;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 10.0),
|
||||
// MIHTextField(
|
||||
// controller: signtureController,
|
||||
// hintText: "Selected Signature File Name",
|
||||
// editable: false,
|
||||
// required: true,
|
||||
// ),
|
||||
const SizedBox(height: 10.0),
|
||||
// MIHFileField(
|
||||
// controller: signtureController,
|
||||
// hintText: "Signature",
|
||||
// editable: false,
|
||||
// required: true,
|
||||
// onPressed: () async {
|
||||
// FilePickerResult? result =
|
||||
// await FilePicker.platform.pickFiles(
|
||||
// type: FileType.custom,
|
||||
// allowedExtensions: ['jpg', 'png', 'pdf'],
|
||||
// );
|
||||
// if (result == null) return;
|
||||
// final selectedFile = result.files.first;
|
||||
// setState(() {
|
||||
// selectedSignature = selectedFile;
|
||||
// });
|
||||
// setState(() {
|
||||
// signtureController.text = selectedFile.name;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 15.0),
|
||||
MIHDropdownField(
|
||||
controller: accessController,
|
||||
@@ -232,6 +232,8 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
||||
fileNameController: proPicController,
|
||||
userSelectedfile: proPic,
|
||||
frameColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
backgroundColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
onChange: (selectedImage) {
|
||||
setState(() {
|
||||
proPic = selectedImage;
|
||||
|
||||
@@ -24,7 +24,7 @@ import '../mih_objects/arguments.dart';
|
||||
import '../mih_packages/authentication/forgot_password.dart';
|
||||
import '../mih_packages/authentication/reset_password.dart';
|
||||
import '../mih_packages/patient_profile/pat_profile/components/full_screen_file.dart';
|
||||
import '../mih_packages/mzansi_profile/manage_business/profile_business_add.dart';
|
||||
import '../mih_packages/mzansi_profile/business_profile/profile_business_add.dart';
|
||||
|
||||
class RouteGenerator {
|
||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||
|
||||
Reference in New Issue
Block a user