NEW: Hide sensitive data on my business user
This commit is contained in:
@@ -77,9 +77,13 @@ class _BusinesProfileState extends State<BusinesProfile> {
|
|||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
iconSize: 35,
|
iconSize: 35,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
MzansiProfileProvider mzansiProfileProvider =
|
||||||
|
context.read<MzansiProfileProvider>();
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
);
|
);
|
||||||
|
mzansiProfileProvider.setHideBusinessUserDetails(true);
|
||||||
|
mzansiProfileProvider.setBusinessIndex(0);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,372 @@
|
|||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_image_display.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_my_business_user_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class MihUpdateMyBusinessUserDetails extends StatefulWidget {
|
||||||
|
const MihUpdateMyBusinessUserDetails({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihUpdateMyBusinessUserDetails> createState() =>
|
||||||
|
_MihUpdateMyBusinessUserDetailsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihUpdateMyBusinessUserDetailsState
|
||||||
|
extends State<MihUpdateMyBusinessUserDetails> {
|
||||||
|
final fileNameController = TextEditingController();
|
||||||
|
final titleTextController = TextEditingController();
|
||||||
|
final fnameController = TextEditingController();
|
||||||
|
final lnameController = TextEditingController();
|
||||||
|
final accessController = TextEditingController();
|
||||||
|
final signtureController = TextEditingController();
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
PlatformFile? userPicFile;
|
||||||
|
PlatformFile? newSelectedSignaturePic;
|
||||||
|
late String env;
|
||||||
|
|
||||||
|
bool isFormFilled() {
|
||||||
|
if (titleTextController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> uploadFile(MzansiProfileProvider mzansiProfileProvider) async {
|
||||||
|
if (newSelectedSignaturePic != null) {
|
||||||
|
int uploadStatusCode = 0;
|
||||||
|
uploadStatusCode = await MihFileApi.uploadFile(
|
||||||
|
mzansiProfileProvider.user!.app_id,
|
||||||
|
env,
|
||||||
|
"business_files",
|
||||||
|
newSelectedSignaturePic!,
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
if (uploadStatusCode == 200) {
|
||||||
|
signtureController.text = newSelectedSignaturePic!.name;
|
||||||
|
int deleteStatusCode = 0;
|
||||||
|
deleteStatusCode = await MihFileApi.deleteFile(
|
||||||
|
mzansiProfileProvider.user!.app_id,
|
||||||
|
env,
|
||||||
|
"business_files",
|
||||||
|
mzansiProfileProvider.businessUser!.sig_path.split("/").last,
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
if (deleteStatusCode == 200) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true; // No file selected, so no upload needed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> submitForm(MzansiProfileProvider mzansiProfileProvider) async {
|
||||||
|
if (isFormFilled()) {
|
||||||
|
bool successfullyUploadedFile = await uploadFile(mzansiProfileProvider);
|
||||||
|
if (!mounted) return;
|
||||||
|
if (successfullyUploadedFile) {
|
||||||
|
int statusCode = await MihMyBusinessUserServices().updateBusinessUser(
|
||||||
|
mzansiProfileProvider.user!.app_id,
|
||||||
|
mzansiProfileProvider.businessUser!.business_id,
|
||||||
|
titleTextController.text,
|
||||||
|
accessController.text,
|
||||||
|
signtureController.text,
|
||||||
|
mzansiProfileProvider,
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
if (!mounted) return;
|
||||||
|
if (statusCode == 200) {
|
||||||
|
String message = "Business details updated successfully";
|
||||||
|
context.pop();
|
||||||
|
successPopUp(message, false);
|
||||||
|
} else {
|
||||||
|
MihAlertServices().errorBasicAlert(
|
||||||
|
"Error Updating Business User Details",
|
||||||
|
"An error occurred while updating the business User details. Please check internet connection and try again.",
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MihAlertServices().internetConnectionAlert(context);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MihAlertServices().inputErrorAlert(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void successPopUp(String message, bool stayOnPersonalSide) {
|
||||||
|
MihAlertServices().successBasicAlert(
|
||||||
|
"Success!",
|
||||||
|
message,
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getWindowBody(double width) {
|
||||||
|
return Consumer<MzansiProfileProvider>(
|
||||||
|
builder: (BuildContext context,
|
||||||
|
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
||||||
|
return MihSingleChildScroll(
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
MihForm(
|
||||||
|
formKey: _formKey,
|
||||||
|
formFields: [
|
||||||
|
Center(
|
||||||
|
child: MihCircleAvatar(
|
||||||
|
imageFile: mzansiProfileProvider.userProfilePicture,
|
||||||
|
width: 150,
|
||||||
|
editable: false,
|
||||||
|
fileNameController: fileNameController,
|
||||||
|
userSelectedfile: userPicFile,
|
||||||
|
frameColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
backgroundColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
onChange: (_) {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: false,
|
||||||
|
child: MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: fileNameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "Selected File Name",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: titleTextController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: false,
|
||||||
|
hintText: "Title",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: fnameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "First Name",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: lnameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "Surname",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: accessController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Access Level",
|
||||||
|
readOnly: true,
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Container(
|
||||||
|
width: 300,
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: const Text(
|
||||||
|
"Signature:",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: MihImageDisplay(
|
||||||
|
imageFile: newSelectedSignaturePic != null
|
||||||
|
? MemoryImage(newSelectedSignaturePic!.bytes!)
|
||||||
|
: mzansiProfileProvider.businessUserSignature,
|
||||||
|
width: 300,
|
||||||
|
height: 200,
|
||||||
|
editable: true,
|
||||||
|
fileNameController: signtureController,
|
||||||
|
userSelectedfile: newSelectedSignaturePic,
|
||||||
|
onChange: (selectedFile) {
|
||||||
|
setState(() {
|
||||||
|
newSelectedSignaturePic = selectedFile;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Visibility(
|
||||||
|
visible: false,
|
||||||
|
child: MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: fileNameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "Selected Signature File",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
Center(
|
||||||
|
child: MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
submitForm(mzansiProfileProvider);
|
||||||
|
} else {
|
||||||
|
MihAlertServices().inputErrorAlert(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Update",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setControllers() {
|
||||||
|
MzansiProfileProvider mzansiProfileProvider =
|
||||||
|
context.read<MzansiProfileProvider>();
|
||||||
|
fileNameController.text =
|
||||||
|
mzansiProfileProvider.user!.pro_pic_path.split("/").last;
|
||||||
|
signtureController.text =
|
||||||
|
mzansiProfileProvider.businessUser!.sig_path.split("/").last;
|
||||||
|
titleTextController.text = mzansiProfileProvider.businessUser!.title;
|
||||||
|
fnameController.text = mzansiProfileProvider.user!.fname;
|
||||||
|
lnameController.text = mzansiProfileProvider.user!.lname;
|
||||||
|
accessController.text = mzansiProfileProvider.businessUser!.access;
|
||||||
|
if (AppEnviroment.getEnv() == "Prod") {
|
||||||
|
env = "Prod";
|
||||||
|
} else {
|
||||||
|
env = "Dev";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
fileNameController.dispose();
|
||||||
|
titleTextController.dispose();
|
||||||
|
fnameController.dispose();
|
||||||
|
lnameController.dispose();
|
||||||
|
accessController.dispose();
|
||||||
|
signtureController.dispose();
|
||||||
|
userPicFile = null;
|
||||||
|
newSelectedSignaturePic = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
setControllers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
return MihPackageWindow(
|
||||||
|
fullscreen: false,
|
||||||
|
windowTitle: "Edit Profile",
|
||||||
|
onWindowTapClose: () {
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
windowBody: getWindowBody(screenWidth),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,17 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:ken_logger/ken_logger.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_my_business_user_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_image_display.dart';
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_image_display.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_update_my_business_user_details.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MihMyBusinessUser extends StatefulWidget {
|
class MihMyBusinessUser extends StatefulWidget {
|
||||||
@@ -28,105 +24,113 @@ class MihMyBusinessUser extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||||
|
final fileNameController = TextEditingController();
|
||||||
|
final signtureController = TextEditingController();
|
||||||
PlatformFile? userPicFile;
|
PlatformFile? userPicFile;
|
||||||
PlatformFile? newSelectedSignaturePic;
|
PlatformFile? newSelectedSignaturePic;
|
||||||
final fileNameController = TextEditingController();
|
|
||||||
final titleTextController = TextEditingController();
|
|
||||||
final fnameController = TextEditingController();
|
|
||||||
final lnameController = TextEditingController();
|
|
||||||
final accessController = TextEditingController();
|
|
||||||
final signtureController = TextEditingController();
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
|
||||||
late String env;
|
|
||||||
|
|
||||||
bool isFormFilled() {
|
void editBizUserProfileWindow(
|
||||||
if (titleTextController.text.isEmpty) {
|
MzansiProfileProvider mzansiProfileProvider, double width) {
|
||||||
return false;
|
showDialog(
|
||||||
} else {
|
barrierDismissible: false,
|
||||||
return true;
|
context: context,
|
||||||
}
|
builder: (context) => MihUpdateMyBusinessUserDetails(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> uploadFile(MzansiProfileProvider mzansiProfileProvider) async {
|
String getDisplayText(
|
||||||
if (newSelectedSignaturePic != null) {
|
MzansiProfileProvider profileProvider, String originalText) {
|
||||||
int uploadStatusCode = 0;
|
int textLength = originalText.length >= 13 ? 13 : 6;
|
||||||
uploadStatusCode = await MihFileApi.uploadFile(
|
String displayText = "";
|
||||||
mzansiProfileProvider.user!.app_id,
|
if (profileProvider.hideBusinessUserDetails) {
|
||||||
env,
|
for (int i = 0; i < textLength; i++) {
|
||||||
"business_files",
|
displayText += "●";
|
||||||
newSelectedSignaturePic!,
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
if (uploadStatusCode == 200) {
|
|
||||||
signtureController.text = newSelectedSignaturePic!.name;
|
|
||||||
int deleteStatusCode = 0;
|
|
||||||
deleteStatusCode = await MihFileApi.deleteFile(
|
|
||||||
mzansiProfileProvider.user!.app_id,
|
|
||||||
env,
|
|
||||||
"business_files",
|
|
||||||
mzansiProfileProvider.businessUser!.sig_path.split("/").last,
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
if (deleteStatusCode == 200) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return true; // No file selected, so no upload needed
|
displayText = originalText;
|
||||||
}
|
}
|
||||||
|
return displayText;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> submitForm(MzansiProfileProvider mzansiProfileProvider) async {
|
Widget buildEmployeeInfoCard(MzansiProfileProvider profileProvider) {
|
||||||
KenLogger.success("Start Submit Form");
|
TextStyle titleStyle = TextStyle(
|
||||||
if (isFormFilled()) {
|
fontSize: 30,
|
||||||
KenLogger.success("Form Filled");
|
fontWeight: FontWeight.bold,
|
||||||
KenLogger.success("Start File Upload");
|
color: MihColors.getPrimaryColor(
|
||||||
bool successfullyUploadedFile = await uploadFile(mzansiProfileProvider);
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
KenLogger.success(
|
);
|
||||||
"File Upload Complete: outcome $successfullyUploadedFile");
|
TextStyle subtitleStyle = TextStyle(
|
||||||
if (!mounted) return;
|
fontSize: 20,
|
||||||
KenLogger.success("is mounted");
|
fontWeight: FontWeight.normal,
|
||||||
if (successfullyUploadedFile) {
|
color: MihColors.getPrimaryColor(
|
||||||
int statusCode = await MihMyBusinessUserServices().updateBusinessUser(
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
mzansiProfileProvider.user!.app_id,
|
);
|
||||||
mzansiProfileProvider.businessUser!.business_id,
|
TextStyle subtitleHeadingStyle = TextStyle(
|
||||||
titleTextController.text,
|
fontSize: 20,
|
||||||
accessController.text,
|
fontWeight: FontWeight.bold,
|
||||||
signtureController.text,
|
color: MihColors.getPrimaryColor(
|
||||||
mzansiProfileProvider,
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
context,
|
);
|
||||||
);
|
return MihPackageWindow(
|
||||||
KenLogger.success("Details Update Complete: status code $statusCode");
|
fullscreen: false,
|
||||||
if (!mounted) return;
|
windowTitle: "Employee Info Card",
|
||||||
KenLogger.success("is mounted");
|
onWindowTapClose: null,
|
||||||
if (statusCode == 200) {
|
backgroundColor: MihColors.getSecondaryColor(
|
||||||
KenLogger.success("Start Success Message");
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
String message = "Business details updated successfully";
|
foregroundColor: MihColors.getPrimaryColor(
|
||||||
successPopUp(message, false);
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
} else {
|
windowBody: Column(
|
||||||
MihAlertServices().errorBasicAlert(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
"Error Updating Business User Details",
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
"An error occurred while updating the business User details. Please check internet connection and try again.",
|
children: [
|
||||||
context,
|
Row(
|
||||||
);
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
}
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
} else {
|
children: [
|
||||||
MihAlertServices().internetConnectionAlert(context);
|
Expanded(
|
||||||
}
|
child: Column(
|
||||||
} else {
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
MihAlertServices().inputErrorAlert(context);
|
children: [
|
||||||
}
|
Text(
|
||||||
}
|
"${profileProvider.user!.fname} ${profileProvider.user!.lname}",
|
||||||
|
style: titleStyle,
|
||||||
void successPopUp(String message, bool stayOnPersonalSide) {
|
),
|
||||||
MihAlertServices().successBasicAlert(
|
RichText(
|
||||||
"Success!",
|
text: TextSpan(
|
||||||
message,
|
children: <TextSpan>[
|
||||||
context,
|
TextSpan(
|
||||||
|
text: "Title: ",
|
||||||
|
style: subtitleHeadingStyle,
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: profileProvider.businessUser!.title,
|
||||||
|
style: subtitleStyle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: <TextSpan>[
|
||||||
|
TextSpan(
|
||||||
|
text: "Access: ",
|
||||||
|
style: subtitleHeadingStyle,
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: getDisplayText(profileProvider,
|
||||||
|
profileProvider.businessUser!.access),
|
||||||
|
style: subtitleStyle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,28 +141,12 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
|||||||
mzansiProfileProvider.user!.pro_pic_path.split("/").last;
|
mzansiProfileProvider.user!.pro_pic_path.split("/").last;
|
||||||
signtureController.text =
|
signtureController.text =
|
||||||
mzansiProfileProvider.businessUser!.sig_path.split("/").last;
|
mzansiProfileProvider.businessUser!.sig_path.split("/").last;
|
||||||
KenLogger.success("title: ${mzansiProfileProvider.businessUser!.title}");
|
|
||||||
KenLogger.success(
|
|
||||||
"sig url: ${mzansiProfileProvider.businessUser!.sig_path}");
|
|
||||||
titleTextController.text = mzansiProfileProvider.businessUser!.title;
|
|
||||||
fnameController.text = mzansiProfileProvider.user!.fname;
|
|
||||||
lnameController.text = mzansiProfileProvider.user!.lname;
|
|
||||||
accessController.text = mzansiProfileProvider.businessUser!.access;
|
|
||||||
if (AppEnviroment.getEnv() == "Prod") {
|
|
||||||
env = "Prod";
|
|
||||||
} else {
|
|
||||||
env = "Dev";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
fileNameController.dispose();
|
fileNameController.dispose();
|
||||||
titleTextController.dispose();
|
|
||||||
fnameController.dispose();
|
|
||||||
lnameController.dispose();
|
|
||||||
accessController.dispose();
|
|
||||||
signtureController.dispose();
|
signtureController.dispose();
|
||||||
userPicFile = null;
|
userPicFile = null;
|
||||||
newSelectedSignaturePic = null;
|
newSelectedSignaturePic = null;
|
||||||
@@ -184,17 +172,16 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
|||||||
return Consumer<MzansiProfileProvider>(
|
return Consumer<MzansiProfileProvider>(
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
||||||
return MihSingleChildScroll(
|
return Stack(
|
||||||
child: Padding(
|
children: [
|
||||||
padding:
|
MihSingleChildScroll(
|
||||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
child: Padding(
|
||||||
|
padding: MzansiInnovationHub.of(context)!.theme.screenType ==
|
||||||
|
"desktop"
|
||||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
MihForm(
|
|
||||||
formKey: _formKey,
|
|
||||||
formFields: [
|
|
||||||
Center(
|
Center(
|
||||||
child: MihCircleAvatar(
|
child: MihCircleAvatar(
|
||||||
imageFile: mzansiProfileProvider.userProfilePicture,
|
imageFile: mzansiProfileProvider.userProfilePicture,
|
||||||
@@ -211,90 +198,8 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
|||||||
onChange: (_) {},
|
onChange: (_) {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Visibility(
|
|
||||||
visible: false,
|
|
||||||
child: MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: fileNameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "Selected File Name",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
MihTextFormField(
|
buildEmployeeInfoCard(mzansiProfileProvider),
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: titleTextController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: false,
|
|
||||||
hintText: "Title",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: fnameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "First Name",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: lnameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "Surname",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: accessController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Access Level",
|
|
||||||
readOnly: true,
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Container(
|
Container(
|
||||||
width: 300,
|
width: 300,
|
||||||
@@ -308,55 +213,50 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Center(
|
Center(
|
||||||
child: MihImageDisplay(
|
child: mzansiProfileProvider.hideBusinessUserDetails
|
||||||
imageFile: newSelectedSignaturePic != null
|
? ClipRRect(
|
||||||
? MemoryImage(newSelectedSignaturePic!.bytes!)
|
borderRadius: BorderRadius.circular(300 * 0.1),
|
||||||
: mzansiProfileProvider.businessUserSignature,
|
child: ImageFiltered(
|
||||||
width: 300,
|
imageFilter: ImageFilter.blur(
|
||||||
height: 200,
|
sigmaX: 15.0, sigmaY: 15.0),
|
||||||
editable: true,
|
child: MihImageDisplay(
|
||||||
fileNameController: signtureController,
|
key: UniqueKey(),
|
||||||
userSelectedfile: newSelectedSignaturePic,
|
imageFile: mzansiProfileProvider
|
||||||
onChange: (selectedFile) {
|
.businessUserSignature,
|
||||||
setState(() {
|
width: 300,
|
||||||
newSelectedSignaturePic = selectedFile;
|
height: 200,
|
||||||
});
|
editable: false,
|
||||||
},
|
fileNameController: signtureController,
|
||||||
),
|
userSelectedfile: newSelectedSignaturePic,
|
||||||
|
onChange: (selectedFile) {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: MihImageDisplay(
|
||||||
|
key: UniqueKey(),
|
||||||
|
imageFile:
|
||||||
|
mzansiProfileProvider.businessUserSignature,
|
||||||
|
width: 300,
|
||||||
|
height: 200,
|
||||||
|
editable: false,
|
||||||
|
fileNameController: signtureController,
|
||||||
|
userSelectedfile: newSelectedSignaturePic,
|
||||||
|
onChange: (selectedFile) {},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
Visibility(
|
|
||||||
visible: false,
|
|
||||||
child: MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: fileNameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "Selected Signature File",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!.validate()) {
|
editBizUserProfileWindow(
|
||||||
submitForm(mzansiProfileProvider);
|
mzansiProfileProvider, width);
|
||||||
} else {
|
|
||||||
MihAlertServices().inputErrorAlert(context);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
width: 300,
|
width: 300,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Update",
|
"Edit Profile",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MihColors.getPrimaryColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
@@ -367,12 +267,35 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
Positioned(
|
||||||
|
right: 5,
|
||||||
|
top: 5,
|
||||||
|
child: MihButton(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
onPressed: () {
|
||||||
|
mzansiProfileProvider.setHideBusinessUserDetails(
|
||||||
|
!mzansiProfileProvider.hideBusinessUserDetails);
|
||||||
|
},
|
||||||
|
buttonColor: mzansiProfileProvider.hideBusinessUserDetails
|
||||||
|
? MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||||
|
: MihColors.getRedColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
child: Icon(
|
||||||
|
mzansiProfileProvider.hideBusinessUserDetails
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off,
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class _PatientInfoState extends State<PatientInfo> {
|
|||||||
|
|
||||||
String getDisplayText(
|
String getDisplayText(
|
||||||
PatientManagerProvider patientManagerProvider, String originalText) {
|
PatientManagerProvider patientManagerProvider, String originalText) {
|
||||||
int textLength = originalText.length >= 13 ? 13 : originalText.length;
|
int textLength = originalText.length >= 13 ? 13 : 6;
|
||||||
String displayText = "";
|
String displayText = "";
|
||||||
if (patientManagerProvider.hidePatientDetails) {
|
if (patientManagerProvider.hidePatientDetails) {
|
||||||
for (int i = 0; i < textLength; i++) {
|
for (int i = 0; i < textLength; i++) {
|
||||||
@@ -42,7 +42,7 @@ class _PatientInfoState extends State<PatientInfo> {
|
|||||||
|
|
||||||
Widget buildPatientInfoCard(PatientManagerProvider patientManagerProvider) {
|
Widget buildPatientInfoCard(PatientManagerProvider patientManagerProvider) {
|
||||||
TextStyle titleStyle = TextStyle(
|
TextStyle titleStyle = TextStyle(
|
||||||
fontSize: 25,
|
fontSize: 30,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: MihColors.getPrimaryColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
@@ -157,7 +157,7 @@ class _PatientInfoState extends State<PatientInfo> {
|
|||||||
|
|
||||||
Widget buildMedAidInfoCard(PatientManagerProvider patientManagerProvider) {
|
Widget buildMedAidInfoCard(PatientManagerProvider patientManagerProvider) {
|
||||||
TextStyle titleStyle = TextStyle(
|
TextStyle titleStyle = TextStyle(
|
||||||
fontSize: 25,
|
fontSize: 30,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: MihColors.getPrimaryColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
|||||||
@@ -21,11 +21,13 @@ class MzansiProfileProvider extends ChangeNotifier {
|
|||||||
UserConsent? userConsent;
|
UserConsent? userConsent;
|
||||||
List<BusinessEmployee>? employeeList;
|
List<BusinessEmployee>? employeeList;
|
||||||
List<AppUser> userSearchResults = [];
|
List<AppUser> userSearchResults = [];
|
||||||
|
bool hideBusinessUserDetails;
|
||||||
|
|
||||||
MzansiProfileProvider({
|
MzansiProfileProvider({
|
||||||
this.personalHome = true,
|
this.personalHome = true,
|
||||||
this.personalIndex = 0,
|
this.personalIndex = 0,
|
||||||
this.businessIndex = 0,
|
this.businessIndex = 0,
|
||||||
|
this.hideBusinessUserDetails = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
@@ -67,6 +69,11 @@ class MzansiProfileProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setHideBusinessUserDetails(bool hideBusinessUserDetails) {
|
||||||
|
this.hideBusinessUserDetails = hideBusinessUserDetails;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void setUserProfilePicUrl(String url) {
|
void setUserProfilePicUrl(String url) {
|
||||||
userProfilePicUrl = url;
|
userProfilePicUrl = url;
|
||||||
userProfilePicture = url.isNotEmpty ? NetworkImage(url) : null;
|
userProfilePicture = url.isNotEmpty ? NetworkImage(url) : null;
|
||||||
|
|||||||
Reference in New Issue
Block a user