update package folder name
This commit is contained in:
@@ -0,0 +1,429 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
import '../../../main.dart';
|
||||
import '../../../mih_components/mih_inputs_and_buttons/mih_button.dart';
|
||||
import '../../../mih_components/mih_layout/mih_window.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_warning_message.dart';
|
||||
import '../../../mih_env/env.dart';
|
||||
import '../../../mih_objects/access_request.dart';
|
||||
import '../../../mih_objects/app_user.dart';
|
||||
|
||||
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.";
|
||||
}
|
||||
successPopUp(message);
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
}
|
||||
|
||||
void internetConnectionPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Internet Connection");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void successPopUp(String message) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MIHSuccessMessage(
|
||||
successType: "Success",
|
||||
successMessage: message,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void accessCancelledWarning() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHWarningMessage(warningType: "Access Cancelled");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
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: MzanziInnovationHub.of(context)!.theme.successColor()));
|
||||
} else if (access == "PENDING") {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color:
|
||||
MzanziInnovationHub.of(context)!.theme.messageTextColor()));
|
||||
} else {
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MzanziInnovationHub.of(context)!.theme.errorColor()));
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
line1,
|
||||
style: TextStyle(
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
),
|
||||
),
|
||||
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: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
onTap: () {
|
||||
if (access == "CANCELLED") {
|
||||
accessCancelledWarning();
|
||||
} else {
|
||||
viewApprovalPopUp(index);
|
||||
}
|
||||
},
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward,
|
||||
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzanziInnovationHub.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) => MIHWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Update Appointment Access",
|
||||
windowBody: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Text(
|
||||
subtitle,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
fontSize: popUpBodySize,
|
||||
//fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: popUpButtonWidth,
|
||||
height: 50,
|
||||
child: MIHButton(
|
||||
onTap: () {
|
||||
updateAccessAPICall(index, "declined");
|
||||
},
|
||||
buttonText: "Decline",
|
||||
buttonColor:
|
||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||
textColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: popUpButtonWidth,
|
||||
height: 50,
|
||||
child: MIHButton(
|
||||
onTap: () {
|
||||
updateAccessAPICall(index, "approved");
|
||||
},
|
||||
buttonText: "Approve",
|
||||
buttonColor:
|
||||
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||
textColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
windowTools: const [],
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
);
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// barrierDismissible: false,
|
||||
// builder: (context) => Dialog(
|
||||
// child: Stack(
|
||||
// children: [
|
||||
// Container(
|
||||
// //padding: const EdgeInsets.all(15.0),
|
||||
// width: popUpWidth,
|
||||
// height: popUpheight,
|
||||
// decoration: BoxDecoration(
|
||||
// color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
// borderRadius: BorderRadius.circular(25.0),
|
||||
// border: Border.all(
|
||||
// color:
|
||||
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
// width: 5.0),
|
||||
// ),
|
||||
// child: SingleChildScrollView(
|
||||
// padding: EdgeInsets.all(popUpPaddingSize),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Update Appointment Access",
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// color: MzanziInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// fontSize: popUpTitleSize,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 15.0),
|
||||
// Text(
|
||||
// subtitle,
|
||||
// textAlign: TextAlign.left,
|
||||
// style: TextStyle(
|
||||
// color: MzanziInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// fontSize: popUpBodySize,
|
||||
// //fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 10.0),
|
||||
// Wrap(
|
||||
// runSpacing: 10,
|
||||
// spacing: 10,
|
||||
// children: [
|
||||
// SizedBox(
|
||||
// width: popUpButtonWidth,
|
||||
// height: 50,
|
||||
// child: MIHButton(
|
||||
// onTap: () {
|
||||
// updateAccessAPICall(index, "declined");
|
||||
// },
|
||||
// buttonText: "Decline",
|
||||
// buttonColor: MzanziInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .errorColor(),
|
||||
// textColor: MzanziInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .primaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: popUpButtonWidth,
|
||||
// height: 50,
|
||||
// child: MIHButton(
|
||||
// onTap: () {
|
||||
// updateAccessAPICall(index, "approved");
|
||||
// },
|
||||
// buttonText: "Approve",
|
||||
// buttonColor: MzanziInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .successColor(),
|
||||
// textColor: MzanziInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .primaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Positioned(
|
||||
// top: 5,
|
||||
// right: 5,
|
||||
// width: 50,
|
||||
// height: 50,
|
||||
// child: IconButton(
|
||||
// onPressed: () {
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// icon: Icon(
|
||||
// Icons.close,
|
||||
// color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||
// size: 35,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
@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: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
);
|
||||
},
|
||||
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,442 @@
|
||||
import 'package:Mzansi_Innovation_Hub/main.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_apis/mih_mzansi_calendar_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_date_input.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_multiline_text_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_inputs_and_buttons/mih_time_input.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_window.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_delete_message.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_error_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/appointment.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BuildAppointmentList extends StatefulWidget {
|
||||
final List<Appointment> appointmentList;
|
||||
final AppUser signedInUser;
|
||||
final TextEditingController titleController;
|
||||
final TextEditingController descriptionIDController;
|
||||
final TextEditingController dateController;
|
||||
final TextEditingController timeController;
|
||||
|
||||
const BuildAppointmentList({
|
||||
super.key,
|
||||
required this.appointmentList,
|
||||
required this.signedInUser,
|
||||
required this.titleController,
|
||||
required this.descriptionIDController,
|
||||
required this.dateController,
|
||||
required this.timeController,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildAppointmentList> createState() => _BuildAppointmentListState();
|
||||
}
|
||||
|
||||
class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
String baseAPI = AppEnviroment.baseApiUrl;
|
||||
TextEditingController dateController = TextEditingController();
|
||||
TextEditingController timeController = TextEditingController();
|
||||
TextEditingController idController = TextEditingController();
|
||||
TextEditingController fnameController = TextEditingController();
|
||||
TextEditingController lnameController = TextEditingController();
|
||||
TextEditingController daysExtensionController = TextEditingController();
|
||||
int counter = 0;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
double getPaddingSize() {
|
||||
if (MzanziInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
return (width / 10);
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayAppointment(int index) {
|
||||
String heading =
|
||||
"${widget.appointmentList[index].date_time.split('T')[1].substring(0, 5)} - ${widget.appointmentList[index].title.toUpperCase()}";
|
||||
String description = widget.appointmentList[index].description;
|
||||
DateTime now = new DateTime.now();
|
||||
int hourNow = int.parse(now.toString().split(' ')[1].substring(0, 2));
|
||||
String date =
|
||||
new DateTime(now.year, now.month, now.day).toString().split(' ')[0];
|
||||
String appointDate = widget.appointmentList[index].date_time.split('T')[0];
|
||||
int appointHour = int.parse(
|
||||
widget.appointmentList[index].date_time.split('T')[1].substring(0, 2));
|
||||
// print("Date Time Now: $now");
|
||||
// print("Hour Now: $hourNow");
|
||||
// print("Date: $date");
|
||||
// print("Appointment Date: $appointDate");
|
||||
// print("Appointment Hour: $appointHour");
|
||||
Color appointmentColor =
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor();
|
||||
if (date == appointDate) {
|
||||
if (appointHour < hourNow) {
|
||||
appointmentColor =
|
||||
MzanziInnovationHub.of(context)!.theme.messageTextColor();
|
||||
} else if (appointHour == hourNow) {
|
||||
appointmentColor =
|
||||
MzanziInnovationHub.of(context)!.theme.successColor();
|
||||
}
|
||||
} else if (DateTime.parse(appointDate).isBefore(DateTime.parse(date))) {
|
||||
appointmentColor =
|
||||
MzanziInnovationHub.of(context)!.theme.messageTextColor();
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 3.0,
|
||||
color: appointmentColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
heading,
|
||||
style: TextStyle(
|
||||
color: appointmentColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
description,
|
||||
style: TextStyle(
|
||||
color: appointmentColor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
widget.titleController.text = widget.appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
widget.appointmentList[index].description;
|
||||
widget.dateController.text =
|
||||
widget.appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text = widget
|
||||
.appointmentList[index].date_time
|
||||
.split('T')[1]
|
||||
.substring(0, 5);
|
||||
});
|
||||
appointmentDetailsWindow(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentDetailsWindow(int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MIHWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Appointment Details",
|
||||
windowTools: [
|
||||
Visibility(
|
||||
visible: canEditAppointment(index),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
deleteAppointmentConfirmationWindow(index);
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
),
|
||||
],
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
widget.dateController.clear();
|
||||
widget.timeController.clear();
|
||||
widget.titleController.clear();
|
||||
widget.descriptionIDController.clear();
|
||||
},
|
||||
windowBody: [
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.titleController,
|
||||
hintText: "Title",
|
||||
editable: false,
|
||||
required: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.dateController,
|
||||
hintText: "Date",
|
||||
editable: false,
|
||||
required: false,
|
||||
)),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.timeController,
|
||||
hintText: "Time",
|
||||
editable: false,
|
||||
required: false,
|
||||
)),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
height: 250,
|
||||
child: MIHMLTextField(
|
||||
controller: widget.descriptionIDController,
|
||||
hintText: "Description",
|
||||
editable: false,
|
||||
required: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Visibility(
|
||||
visible: canEditAppointment(index),
|
||||
child: SizedBox(
|
||||
width: 500,
|
||||
height: 50,
|
||||
child: MIHButton(
|
||||
onTap: () {
|
||||
appointmentUpdateWindow(index);
|
||||
},
|
||||
buttonText: "Edit",
|
||||
buttonColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
textColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
),
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: 500,
|
||||
// height: 50,
|
||||
// child: MIHButton(
|
||||
// onTap: () {
|
||||
// addAppointmentCall();
|
||||
// checkforchange();
|
||||
// },
|
||||
// buttonText: "Add",
|
||||
// buttonColor:
|
||||
// MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||
// textColor:
|
||||
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentUpdateWindow(int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MIHWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Update Appointment",
|
||||
windowTools: [],
|
||||
onWindowTapClose: () {
|
||||
setState(() {
|
||||
widget.titleController.text = widget.appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
widget.appointmentList[index].description;
|
||||
widget.dateController.text =
|
||||
widget.appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text = widget
|
||||
.appointmentList[index].date_time
|
||||
.split('T')[1]
|
||||
.substring(0, 5);
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
windowBody: [
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.titleController,
|
||||
hintText: "Title",
|
||||
editable: true,
|
||||
required: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHDateField(
|
||||
controller: widget.dateController,
|
||||
lableText: "Date",
|
||||
required: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTimeField(
|
||||
controller: widget.timeController,
|
||||
lableText: "Time",
|
||||
required: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
height: 250,
|
||||
child: MIHMLTextField(
|
||||
controller: widget.descriptionIDController,
|
||||
hintText: "Description",
|
||||
editable: true,
|
||||
required: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 500,
|
||||
height: 50,
|
||||
child: MIHButton(
|
||||
onTap: () {
|
||||
updateAppointmentCall(index);
|
||||
},
|
||||
buttonText: "Update",
|
||||
buttonColor:
|
||||
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||
textColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 500,
|
||||
height: 50,
|
||||
child: MIHButton(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
widget.titleController.text =
|
||||
widget.appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
widget.appointmentList[index].description;
|
||||
widget.dateController.text = widget
|
||||
.appointmentList[index].date_time
|
||||
.split('T')[0];
|
||||
widget.timeController.text = widget
|
||||
.appointmentList[index].date_time
|
||||
.split('T')[1]
|
||||
.substring(0, 5);
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
buttonText: "Cancel",
|
||||
buttonColor:
|
||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||
textColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
bool isAppointmentInputValid() {
|
||||
if (widget.titleController.text.isEmpty ||
|
||||
widget.descriptionIDController.text.isEmpty ||
|
||||
widget.dateController.text.isEmpty ||
|
||||
widget.timeController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void deleteAppointmentConfirmationWindow(int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MIHDeleteMessage(
|
||||
deleteType: "Appointment",
|
||||
onTap: () {
|
||||
deleteAppointmentCall(index);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void updateAppointmentCall(int index) {
|
||||
if (isAppointmentInputValid()) {
|
||||
MihMzansiCalendarApis.updatePersonalAppointment(
|
||||
widget.signedInUser,
|
||||
widget.appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
widget.dateController.text,
|
||||
widget.timeController.text,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Input Error");
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void deleteAppointmentCall(int index) {
|
||||
MihMzansiCalendarApis.deleteLoyaltyCardAPICall(
|
||||
widget.signedInUser,
|
||||
widget.appointmentList[index].idappointments,
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
bool canEditAppointment(int index) {
|
||||
if (widget.appointmentList[index].business_id == "") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
daysExtensionController.dispose();
|
||||
dateController.dispose();
|
||||
timeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: getPaddingSize()),
|
||||
child: ListView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: widget.appointmentList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return displayAppointment(index);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
136
Frontend/lib/mih_packages/calendar/builder/build_queue_list.dart
Normal file
136
Frontend/lib/mih_packages/calendar/builder/build_queue_list.dart
Normal file
@@ -0,0 +1,136 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../main.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_warning_message.dart';
|
||||
import '../../../mih_env/env.dart';
|
||||
import '../../../mih_objects/app_user.dart';
|
||||
import '../../../mih_objects/patient_queue.dart';
|
||||
|
||||
class BuildQueueList extends StatefulWidget {
|
||||
final List<PatientQueue> patientQueue;
|
||||
final AppUser signedInUser;
|
||||
|
||||
const BuildQueueList({
|
||||
super.key,
|
||||
required this.patientQueue,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildQueueList> createState() => _BuildQueueListState();
|
||||
}
|
||||
|
||||
class _BuildQueueListState extends State<BuildQueueList> {
|
||||
String baseAPI = AppEnviroment.baseApiUrl;
|
||||
TextEditingController dateController = TextEditingController();
|
||||
TextEditingController timeController = TextEditingController();
|
||||
TextEditingController idController = TextEditingController();
|
||||
TextEditingController fnameController = TextEditingController();
|
||||
TextEditingController lnameController = TextEditingController();
|
||||
TextEditingController daysExtensionController = TextEditingController();
|
||||
int counter = 0;
|
||||
|
||||
Widget displayQueue(int index) {
|
||||
String title = widget.patientQueue[index].business_name.toUpperCase();
|
||||
// widget.patientQueue[index].date_time.split('T')[1].substring(0, 5);
|
||||
String line234 = "";
|
||||
// var nowDate = DateTime.now();
|
||||
// var expireyDate = DateTime.parse(widget.patientQueue[index].revoke_date);
|
||||
|
||||
line234 +=
|
||||
widget.patientQueue[index].date_time.split('T')[1].substring(0, 5);
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
),
|
||||
),
|
||||
subtitle: RichText(
|
||||
text: TextSpan(
|
||||
text: "Time: $line234",
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
// children: [
|
||||
// TextSpan(text: line5),
|
||||
// accessWithColour,
|
||||
// TextSpan(text: line6),
|
||||
// ]
|
||||
),
|
||||
),
|
||||
onTap: () {},
|
||||
);
|
||||
}
|
||||
|
||||
bool isAccessExpired(String accessType) {
|
||||
if (accessType == "EXPIRED") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void noAccessWarning() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHWarningMessage(warningType: "No Access");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void accessDeclinedWarning() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHWarningMessage(warningType: "Access Declined");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentCancelledWarning() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHWarningMessage(warningType: "Appointment Canelled");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void expiredAccessWarning() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHWarningMessage(warningType: "Expired Access");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
daysExtensionController.dispose();
|
||||
dateController.dispose();
|
||||
timeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
);
|
||||
},
|
||||
itemCount: widget.patientQueue.length,
|
||||
itemBuilder: (context, index) {
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
//print(index);
|
||||
|
||||
return displayQueue(index);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user