rename container folders
This commit is contained in:
@@ -0,0 +1,309 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.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_objects/access_request.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class BuildAccessRequestList extends StatefulWidget {
|
||||
final List<AccessRequest> accessRequests;
|
||||
final AppUser signedInUser;
|
||||
|
||||
const BuildAccessRequestList({
|
||||
super.key,
|
||||
required this.accessRequests,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildAccessRequestList> createState() => _BuildPatientsListState();
|
||||
}
|
||||
|
||||
class _BuildPatientsListState extends State<BuildAccessRequestList> {
|
||||
String baseAPI = AppEnviroment.baseApiUrl;
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
late double popUpButtonWidth;
|
||||
late double popUpTitleSize;
|
||||
late double popUpSubtitleSize;
|
||||
late double popUpBodySize;
|
||||
late double popUpIconSize;
|
||||
late double popUpPaddingSize;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
Future<void> updateAccessAPICall(int index, String accessType) async {
|
||||
var response = await http.put(
|
||||
Uri.parse("$baseAPI/access-requests/update/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"business_id": widget.accessRequests[index].business_id,
|
||||
"app_id": widget.accessRequests[index].app_id,
|
||||
"date_time": widget.accessRequests[index].date_time,
|
||||
"access": accessType,
|
||||
}),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
//Navigator.of(context).pushNamed('/home');
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed(
|
||||
'/patient-access-review',
|
||||
arguments: widget.signedInUser,
|
||||
);
|
||||
String message = "";
|
||||
if (accessType == "approved") {
|
||||
message =
|
||||
"You've successfully approved the access request! ${widget.accessRequests[index].Name} now has access to your profile until ${widget.accessRequests[index].revoke_date.substring(0, 16).replaceAll("T", " ")}.";
|
||||
} else {
|
||||
message =
|
||||
"You've declined the access request. ${widget.accessRequests[index].Name} will not have access to your profile.";
|
||||
}
|
||||
MihAlertServices().successBasicAlert(
|
||||
"Success!",
|
||||
message,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayQueue(int index) {
|
||||
String line1 =
|
||||
"Appointment: ${widget.accessRequests[index].date_time.substring(0, 16).replaceAll("T", " ")}";
|
||||
String line2 = "";
|
||||
line2 += "Requestor: ${widget.accessRequests[index].Name}\n";
|
||||
//subtitle += "Business Type: ${widget.accessRequests[index].type}\n";
|
||||
String line3 = "Access: ";
|
||||
String access = "";
|
||||
var nowDate = DateTime.now();
|
||||
var expireyDate = DateTime.parse(widget.accessRequests[index].revoke_date);
|
||||
|
||||
if (expireyDate.isBefore(nowDate)) {
|
||||
access += "EXPIRED";
|
||||
} else {
|
||||
access += "${widget.accessRequests[index].access.toUpperCase()}";
|
||||
}
|
||||
String line4 = "";
|
||||
if (widget.accessRequests[index].revoke_date.contains("9999")) {
|
||||
line4 += "Access Expiration date: NOT SET";
|
||||
} else {
|
||||
line4 +=
|
||||
"Access Expiration date: ${widget.accessRequests[index].revoke_date.substring(0, 10)}";
|
||||
}
|
||||
TextSpan accessWithColour;
|
||||
if (access == "APPROVED") {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
} else if (access == "PENDING") {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
} else {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
line1,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: RichText(
|
||||
text: TextSpan(
|
||||
text: line2,
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
children: <TextSpan>[
|
||||
TextSpan(text: line3),
|
||||
accessWithColour,
|
||||
TextSpan(text: line4),
|
||||
]),
|
||||
),
|
||||
// Text(
|
||||
// subtitle,
|
||||
// style: TextStyle(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
onTap: () {
|
||||
if (access == "CANCELLED") {
|
||||
MihAlertServices().warningAlert(
|
||||
"Access Cancelled",
|
||||
"This appointment has been canceled. As a result, access has been cancelled and the doctor no longer have access to the patient's profile. If you would like them to view the patient's profile again, please book a new appointment through them.",
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
viewApprovalPopUp(index);
|
||||
}
|
||||
},
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward,
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = (width / 4) * 2;
|
||||
popUpheight = null;
|
||||
popUpButtonWidth = 300;
|
||||
popUpTitleSize = 25.0;
|
||||
popUpSubtitleSize = 20.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 25.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = width - (width * 0.1);
|
||||
popUpheight = null;
|
||||
popUpButtonWidth = 300;
|
||||
popUpTitleSize = 20.0;
|
||||
popUpSubtitleSize = 18.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 15.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void viewApprovalPopUp(int index) {
|
||||
String subtitle =
|
||||
"Appointment: ${widget.accessRequests[index].date_time.substring(0, 16).replaceAll("T", " ")}\n";
|
||||
subtitle += "Requestor: ${widget.accessRequests[index].Name}\n";
|
||||
subtitle += "Business Type: ${widget.accessRequests[index].type}\n\n";
|
||||
subtitle +=
|
||||
"You are about to approve an access request to your patient profile.\nPlease be aware that once approved, ${widget.accessRequests[index].Name} will have access to your profile information until ${widget.accessRequests[index].revoke_date.substring(0, 16).replaceAll("T", " ")}.\nIf you are unsure about an upcoming appointment with ${widget.accessRequests[index].Name}, please contact ${widget.accessRequests[index].contact_no} for clarification before approving this request.\n";
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Update Appointment Access",
|
||||
windowBody: Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Text(
|
||||
subtitle,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
//fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
runAlignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
alignment: WrapAlignment.center,
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
updateAccessAPICall(index, "declined");
|
||||
},
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Decline",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
updateAccessAPICall(index, "approved");
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Approve",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
checkScreenSize();
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: widget.accessRequests.length,
|
||||
itemBuilder: (context, index) {
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
//print(index);
|
||||
return displayQueue(index);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,507 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/patient_access.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_access_controlls_provider.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_access_controls_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.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_services/mih_alert_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildBusinessAccessList extends StatefulWidget {
|
||||
final String filterText;
|
||||
final void Function()? onSuccessUpate;
|
||||
|
||||
const BuildBusinessAccessList({
|
||||
super.key,
|
||||
required this.filterText,
|
||||
required this.onSuccessUpate,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildBusinessAccessList> createState() => _BuildPatientsListState();
|
||||
}
|
||||
|
||||
class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
String baseAPI = AppEnviroment.baseApiUrl;
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
late double popUpButtonWidth;
|
||||
late double popUpTitleSize;
|
||||
late double popUpSubtitleSize;
|
||||
late double popUpBodySize;
|
||||
late double popUpIconSize;
|
||||
late double popUpPaddingSize;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
Widget displayQueue(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider,
|
||||
int index,
|
||||
List<PatientAccess> filteredList) {
|
||||
String line1 = "Business Name: ${filteredList[index].requested_by}";
|
||||
String line2 = "";
|
||||
|
||||
line2 +=
|
||||
"Request Date: ${filteredList[index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
||||
line2 += "Profile Type: ${filteredList[index].type.toUpperCase()}\n";
|
||||
//subtitle += "Business Type: ${widget.patientAccessList[index].type}\n";
|
||||
String line3 = "Status: ";
|
||||
String access = filteredList[index].status.toUpperCase();
|
||||
|
||||
TextSpan accessWithColour;
|
||||
if (access == "APPROVED") {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
} else if (access == "PENDING") {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
} else {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
line1,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: RichText(
|
||||
text: TextSpan(
|
||||
text: line2,
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
children: <TextSpan>[
|
||||
TextSpan(text: line3),
|
||||
accessWithColour,
|
||||
]),
|
||||
),
|
||||
// Text(
|
||||
// subtitle,
|
||||
// style: TextStyle(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
onTap: () {
|
||||
viewApprovalPopUp(mzansiProfileProvider, accessProvider, index);
|
||||
},
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward,
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = (width / 4) * 2;
|
||||
popUpheight = null;
|
||||
popUpButtonWidth = 300;
|
||||
popUpTitleSize = 25.0;
|
||||
popUpSubtitleSize = 20.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 25.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = width - (width * 0.1);
|
||||
popUpheight = null;
|
||||
popUpButtonWidth = 300;
|
||||
popUpTitleSize = 20.0;
|
||||
popUpSubtitleSize = 18.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 15.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void viewApprovalPopUp(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider, int index) {
|
||||
String subtitle =
|
||||
"Business Name: ${accessProvider.accessList![index].requested_by}\n";
|
||||
subtitle +=
|
||||
"Requested Date: ${accessProvider.accessList![index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
||||
|
||||
subtitle +=
|
||||
"Profile Type: ${accessProvider.accessList![index].type.toUpperCase()}\n";
|
||||
subtitle +=
|
||||
"Status: ${accessProvider.accessList![index].status.toUpperCase()}";
|
||||
if (accessProvider.accessList![index].status == 'pending') {
|
||||
// "\nYou are about to approve an access request to your patient profile.\nPlease be aware that once approved, ${widget.patientAccessList[index].requested_by} will have access to your profile forever and will be able to contribute to it.\nIf you are unsure about an upcoming appointment with ${widget.patientAccessList[index].requested_by}, please contact *Add Number here* for clarification before approving this request.";
|
||||
} else {
|
||||
subtitle +=
|
||||
"\nActioned By: ${accessProvider.accessList![index].approved_by}\n";
|
||||
subtitle +=
|
||||
"Actioned On: ${accessProvider.accessList![index].approved_on.substring(0, 16).replaceAll("T", " ")}";
|
||||
// subtitle +=
|
||||
// "You have approved this access request to your patient profile.\nPlease be aware that once approved, ${widget.patientAccessList[index].requested_by} will have access to your profile forever and will be able to contribute to it.";
|
||||
}
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Profile Access",
|
||||
windowBody: Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
SizedBox(
|
||||
width: 1000,
|
||||
child: Text(
|
||||
subtitle,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
//fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Visibility(
|
||||
visible: accessProvider.accessList![index].status == 'pending',
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Important Notice: Approving Profile Access",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"You are about to accept access to your patient's profile. Please be aware of the following important points:",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
"1. Permanent Access: Once you accepts this access request, it will become permanent.",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
"2. Shared Information: Any updates make to youe patient profile will be visible to all who have access to the profile.",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
"3. Irreversible Access: Once granted, you cannot revoke access to your patient's profile.",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"By pressing the \"Approve\" button you accept the above terms.",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: accessProvider.accessList![index].status == 'approved',
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Important Notice: Approved Profile Access",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"You have accepted access to your patient's profile. Please be aware of the following important points:",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
"1. Permanent Access: This access is permanent.",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
"2. Shared Information: Any updates make to youe patient profile will be visible to all who have access to the profile.",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
"3. Irreversible Access: You cannot revoke this access to your patient's profile.",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Visibility(
|
||||
visible: accessProvider.accessList![index].status == 'pending',
|
||||
child: Wrap(
|
||||
runAlignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
alignment: WrapAlignment.center,
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () async {
|
||||
print("request declined");
|
||||
int statusCode = await MihAccessControlsServices()
|
||||
.updatePatientAccessAPICall(
|
||||
accessProvider.accessList![index].business_id,
|
||||
accessProvider.accessList![index].requested_by,
|
||||
accessProvider.accessList![index].app_id,
|
||||
"declined",
|
||||
"${mzansiProfileProvider.user!.fname} ${mzansiProfileProvider.user!.lname}",
|
||||
mzansiProfileProvider.user!,
|
||||
context,
|
||||
);
|
||||
if (statusCode == 200) {
|
||||
await MihAccessControlsServices()
|
||||
.getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
context.pop();
|
||||
successPopUp("Successfully Actioned Request",
|
||||
"You have successfully Declined access request");
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Decline",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
onPressed: () async {
|
||||
print("request approved");
|
||||
int statusCode = await MihAccessControlsServices()
|
||||
.updatePatientAccessAPICall(
|
||||
accessProvider.accessList![index].business_id,
|
||||
accessProvider.accessList![index].requested_by,
|
||||
accessProvider.accessList![index].app_id,
|
||||
"approved",
|
||||
"${mzansiProfileProvider.user!.fname} ${mzansiProfileProvider.user!.lname}",
|
||||
mzansiProfileProvider.user!,
|
||||
context,
|
||||
);
|
||||
if (statusCode == 200) {
|
||||
await MihAccessControlsServices()
|
||||
.getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
context.pop();
|
||||
successPopUp("Successfully Actioned Request",
|
||||
"You have successfully Accepted access request");
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Approve",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
MihAlertServices().successAdvancedAlert(
|
||||
title,
|
||||
message,
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
KenLogger.warning("dismissing pop up and refreshing list");
|
||||
if (widget.onSuccessUpate != null) {
|
||||
widget.onSuccessUpate!();
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
List<PatientAccess> filterAccessList(List<PatientAccess> accessList) {
|
||||
if (widget.filterText == "All") {
|
||||
return accessList;
|
||||
}
|
||||
return accessList
|
||||
.where((item) =>
|
||||
item.status.toLowerCase() == widget.filterText.toLowerCase())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
checkScreenSize();
|
||||
return Consumer2<MzansiProfileProvider, MihAccessControllsProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: filterAccessList(accessProvider.accessList!).length,
|
||||
itemBuilder: (context, index) {
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
//print(index);
|
||||
final filteredList = filterAccessList(accessProvider.accessList!);
|
||||
return displayQueue(
|
||||
mzansiProfileProvider, accessProvider, index, filteredList);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
111
mih_ui/lib/mih_packages/access_review/mih_access.dart
Normal file
111
mih_ui/lib/mih_packages/access_review/mih_access.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_access_controlls_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/access_review/package_tools/mih_access_requests.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_data_helper_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihAccess extends StatefulWidget {
|
||||
const MihAccess({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihAccess> createState() => _MihAccessState();
|
||||
}
|
||||
|
||||
class _MihAccessState extends State<MihAccess> {
|
||||
bool _isLoadingInitialData = true;
|
||||
late final MihAccessRequest _accessRequest;
|
||||
|
||||
Future<void> _loadInitialData() async {
|
||||
setState(() {
|
||||
_isLoadingInitialData = true;
|
||||
});
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
if (mzansiProfileProvider.user == null) {
|
||||
await MihDataHelperServices().loadUserDataOnly(
|
||||
mzansiProfileProvider,
|
||||
);
|
||||
}
|
||||
setState(() {
|
||||
_isLoadingInitialData = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_accessRequest = MihAccessRequest();
|
||||
_loadInitialData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<MihAccessControllsProvider>(
|
||||
builder: (BuildContext context, MihAccessControllsProvider accessProvider,
|
||||
Widget? child) {
|
||||
if (_isLoadingInitialData) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Mihloadingcircle(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: accessProvider.toolIndex,
|
||||
onIndexChange: (newValue) {
|
||||
accessProvider.setToolIndex(newValue);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.people)] = () {
|
||||
context.read<MihAccessControllsProvider>().setToolIndex(0);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: context.watch<MihAccessControllsProvider>().toolIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
return [
|
||||
_accessRequest,
|
||||
];
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Access",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihAccessTile extends StatefulWidget {
|
||||
final double packageSize;
|
||||
|
||||
const MihAccessTile({
|
||||
super.key,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihAccessTile> createState() => _MihAccessTileState();
|
||||
}
|
||||
|
||||
class _MihAccessTileState extends State<MihAccessTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
authenticateUser: true,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mihAccess",
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/mih-access',
|
||||
// arguments: widget.signedInUser,
|
||||
// );
|
||||
},
|
||||
appName: "Access Controls",
|
||||
appIcon: Icon(
|
||||
MihIcons.accessControl,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: widget.packageSize,
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
textColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/patient_access.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_access_controlls_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/access_review/builder/build_business_access_list.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_access_controls_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihAccessRequest extends StatefulWidget {
|
||||
const MihAccessRequest({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihAccessRequest> createState() => _MihAccessRequestState();
|
||||
}
|
||||
|
||||
class _MihAccessRequestState extends State<MihAccessRequest> {
|
||||
TextEditingController filterController = TextEditingController();
|
||||
bool isLoading = true;
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
String errorCode = "";
|
||||
String errorBody = "";
|
||||
String datefilter = "";
|
||||
String accessFilter = "";
|
||||
bool forceRefresh = false;
|
||||
late String selectedDropdown;
|
||||
|
||||
List<PatientAccess> filterSearchResults(List<PatientAccess> accessList) {
|
||||
List<PatientAccess> templist = [];
|
||||
for (var item in accessList) {
|
||||
if (filterController.text == "All") {
|
||||
templist.add(item);
|
||||
} else {
|
||||
if (item.status.contains(filterController.text.toLowerCase())) {
|
||||
templist.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return templist;
|
||||
}
|
||||
|
||||
void refreshList() {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MihAccessControllsProvider accessProvider =
|
||||
context.read<MihAccessControllsProvider>();
|
||||
if (forceRefresh == true) {
|
||||
MihAccessControlsServices().getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
setState(() {
|
||||
forceRefresh = false;
|
||||
});
|
||||
} else if (selectedDropdown != filterController.text) {
|
||||
MihAccessControlsServices().getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
setState(() {
|
||||
selectedDropdown = filterController.text;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
return Consumer2<MzansiProfileProvider, MihAccessControllsProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider,
|
||||
Widget? child) {
|
||||
if (isLoading) {
|
||||
return const Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Flexible(
|
||||
child: MihDropdownField(
|
||||
controller: filterController,
|
||||
hintText: "Access Type",
|
||||
dropdownOptions: const [
|
||||
"All",
|
||||
"Approved",
|
||||
"Pending",
|
||||
"Declined",
|
||||
"Cancelled",
|
||||
],
|
||||
requiredText: true,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
iconSize: 35,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
forceRefresh = true;
|
||||
});
|
||||
KenLogger.warning("Refreshing Access List");
|
||||
refreshList();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.refresh,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: BuildBusinessAccessList(
|
||||
filterText: filterController.text,
|
||||
onSuccessUpate: () {
|
||||
setState(() {
|
||||
forceRefresh = true;
|
||||
});
|
||||
refreshList();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> initiasizeAccessList() async {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MihAccessControllsProvider accessProvider =
|
||||
context.read<MihAccessControllsProvider>();
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
await MihAccessControlsServices().getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
filterController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
selectedDropdown = "All";
|
||||
filterController.text = "All";
|
||||
filterController.addListener(refreshList);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await initiasizeAccessList();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem: getBody(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user