NEW: MIH Calendar Provider Setup
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_providers/about_mih_pro
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_authentication_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calculator_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_mine_sweeper_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_ai_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
@@ -95,6 +96,9 @@ class _MzansiInnovationHubState extends State<MzansiInnovationHub> {
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MihCalculatorProvider(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MihCalendarProvider(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => AboutMihProvider(),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
||||
class MIHCalendar extends StatefulWidget {
|
||||
@@ -19,16 +22,29 @@ class MIHCalendar extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MIHCalendarState extends State<MIHCalendar> {
|
||||
DateTime selectedDay = DateTime.now();
|
||||
late DateTime selectedDay;
|
||||
CalendarFormat _calendarFormat = CalendarFormat.week;
|
||||
|
||||
void onDaySelected(DateTime day, DateTime focusedDay) {
|
||||
KenLogger.success("Selected Day: $day");
|
||||
setState(() {
|
||||
selectedDay = day;
|
||||
});
|
||||
widget.setDate(selectedDay.toString().split(" ")[0]);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
MihCalendarProvider mihCalendarProvider =
|
||||
context.read<MihCalendarProvider>();
|
||||
if (mihCalendarProvider.selectedDay.isNotEmpty) {
|
||||
selectedDay = DateTime.parse(mihCalendarProvider.selectedDay);
|
||||
} else {
|
||||
selectedDay = DateTime.now();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/appointment.dart';
|
||||
|
||||
class MihCalendarProvider extends ChangeNotifier {
|
||||
int toolIndex;
|
||||
String selectedDay = DateTime.now().toString().split(" ")[0];
|
||||
List<Appointment>? personalAppointments;
|
||||
List<Appointment>? businessAppointments;
|
||||
|
||||
MihCalendarProvider({
|
||||
this.toolIndex = 0,
|
||||
@@ -11,4 +15,66 @@ class MihCalendarProvider extends ChangeNotifier {
|
||||
toolIndex = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setSelectedDay(String day) {
|
||||
selectedDay = day;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetSelectedDay() {
|
||||
selectedDay = DateTime.now().toString().split(" ")[0];
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setPersonalAppointments({required List<Appointment> appointments}) {
|
||||
personalAppointments = appointments;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setBusinessAppointments({required List<Appointment> appointments}) {
|
||||
businessAppointments = appointments;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void addPersonalAppointment({required Appointment newAppointment}) {
|
||||
personalAppointments?.add(newAppointment);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void addBusinessAppointment({required Appointment newAppointment}) {
|
||||
businessAppointments?.add(newAppointment);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void editPersonalAppointment({required Appointment updatedAppointment}) {
|
||||
int index = personalAppointments?.indexWhere((appointment) =>
|
||||
appointment.idappointments == updatedAppointment.idappointments) ??
|
||||
-1;
|
||||
if (index != -1) {
|
||||
personalAppointments?[index] = updatedAppointment;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void editBusinessAppointment({required Appointment updatedAppointment}) {
|
||||
int index = businessAppointments?.indexWhere((appointment) =>
|
||||
appointment.idappointments == updatedAppointment.idappointments) ??
|
||||
-1;
|
||||
if (index != -1) {
|
||||
businessAppointments?[index] = updatedAppointment;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void deletePersonalAppointment({required int appointmentId}) {
|
||||
personalAppointments?.removeWhere(
|
||||
(appointment) => appointment.idappointments == appointmentId);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void deleteBusinessAppointment({required int appointmentId}) {
|
||||
businessAppointments?.removeWhere(
|
||||
(appointment) => appointment.idappointments == appointmentId);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +241,7 @@ class MihGoRouter {
|
||||
path: MihGoRouterPaths.calendar,
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
KenLogger.success("MihGoRouter: mihCalendar");
|
||||
final CalendarArguments? args = state.extra as CalendarArguments?;
|
||||
if (args == null) {
|
||||
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go(MihGoRouterPaths.mihHome);
|
||||
});
|
||||
@@ -250,7 +249,6 @@ class MihGoRouter {
|
||||
}
|
||||
return MzansiCalendar(
|
||||
key: UniqueKey(),
|
||||
arguments: args,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -260,7 +258,7 @@ class MihGoRouter {
|
||||
path: MihGoRouterPaths.mzansiAi,
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
KenLogger.success("MihGoRouter: mzansiAi");
|
||||
if (context.watch<MzansiProfileProvider>().business == null) {
|
||||
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go(MihGoRouterPaths.mihHome);
|
||||
});
|
||||
|
||||
@@ -2,8 +2,11 @@ import 'package:flutter_speed_dial/flutter_speed_dial.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_components/mih_objects/appointment.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/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_mzansi_calendar_services.dart';
|
||||
@@ -17,18 +20,10 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
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_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/appointment.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildAppointmentList extends StatefulWidget {
|
||||
final List<Appointment> appointmentList;
|
||||
final AppUser signedInUser;
|
||||
final Business? business;
|
||||
final BusinessUser? businessUser;
|
||||
final bool personalSelected;
|
||||
final bool inWaitingRoom;
|
||||
final TextEditingController titleController;
|
||||
final TextEditingController descriptionIDController;
|
||||
@@ -38,11 +33,6 @@ class BuildAppointmentList extends StatefulWidget {
|
||||
|
||||
const BuildAppointmentList({
|
||||
super.key,
|
||||
required this.appointmentList,
|
||||
required this.signedInUser,
|
||||
required this.business,
|
||||
required this.businessUser,
|
||||
required this.personalSelected,
|
||||
required this.inWaitingRoom,
|
||||
required this.titleController,
|
||||
required this.descriptionIDController,
|
||||
@@ -77,22 +67,39 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayAppointment(int index, double bodyWidth) {
|
||||
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");
|
||||
Widget displayAppointment(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider, int index, double bodyWidth) {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
String heading = "";
|
||||
String description = "";
|
||||
DateTime now;
|
||||
int hourNow = 0;
|
||||
String date = "";
|
||||
int appointHour = 0;
|
||||
String appointDate = "";
|
||||
if (appointmentList[index].date_time.contains("T")) {
|
||||
heading =
|
||||
"${appointmentList[index].date_time.split('T')[1].substring(0, 5)} - ${appointmentList[index].title.toUpperCase()}";
|
||||
description = appointmentList[index].description;
|
||||
now = DateTime.now();
|
||||
hourNow = int.parse(now.toString().split(' ')[1].substring(0, 2));
|
||||
date = DateTime(now.year, now.month, now.day).toString().split(' ')[0];
|
||||
appointDate = appointmentList[index].date_time.split('T')[0];
|
||||
appointHour = int.parse(
|
||||
appointmentList[index].date_time.split('T')[1].substring(0, 2));
|
||||
} else {
|
||||
heading =
|
||||
"${appointmentList[index].date_time.split(' ')[1].substring(0, 5)} - ${appointmentList[index].title.toUpperCase()}";
|
||||
description = appointmentList[index].description;
|
||||
now = DateTime.now();
|
||||
hourNow = int.parse(now.toString().split(' ')[1].substring(0, 2));
|
||||
date = DateTime(now.year, now.month, now.day).toString().split(' ')[0];
|
||||
appointDate = appointmentList[index].date_time.split(' ')[0];
|
||||
appointHour = int.parse(
|
||||
appointmentList[index].date_time.split(' ')[1].substring(0, 2));
|
||||
}
|
||||
Color appointmentColor = MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
if (date == appointDate) {
|
||||
@@ -132,26 +139,28 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
widget.titleController.text = widget.appointmentList[index].title;
|
||||
widget.titleController.text = appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
widget.appointmentList[index].description;
|
||||
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);
|
||||
appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text =
|
||||
appointmentList[index].date_time.split('T')[1].substring(0, 5);
|
||||
});
|
||||
if (widget.inWaitingRoom == false) {
|
||||
appointmentDetailsWindow(index, bodyWidth);
|
||||
appointmentDetailsWindow(
|
||||
mzansiProfileProvider, mihCalendarProvider, index, bodyWidth);
|
||||
} else {
|
||||
waitingRiinAppointmentDetailsWindow(index, bodyWidth);
|
||||
waitingRoomAppointmentDetailsWindow(
|
||||
mzansiProfileProvider, mihCalendarProvider, index, bodyWidth);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentDetailsWindow(int index, double bodyWidth) {
|
||||
void appointmentDetailsWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider, int index, double bodyWidth) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -177,7 +186,8 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
appointmentUpdateWindow(index, bodyWidth);
|
||||
appointmentUpdateWindow(mzansiProfileProvider,
|
||||
mihCalendarProvider, index, bodyWidth);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
@@ -197,7 +207,8 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
deleteAppointmentConfirmationWindow(index);
|
||||
deleteAppointmentConfirmationWindow(
|
||||
mzansiProfileProvider, mihCalendarProvider, index);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -273,7 +284,11 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
);
|
||||
}
|
||||
|
||||
void waitingRiinAppointmentDetailsWindow(int index, double bodyWidth) {
|
||||
void waitingRoomAppointmentDetailsWindow(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
int index,
|
||||
double bodyWidth) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -299,7 +314,8 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
appointmentUpdateWindow(index, bodyWidth);
|
||||
appointmentUpdateWindow(mzansiProfileProvider,
|
||||
mihCalendarProvider, index, bodyWidth);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
@@ -319,7 +335,8 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
deleteAppointmentConfirmationWindow(index);
|
||||
deleteAppointmentConfirmationWindow(
|
||||
mzansiProfileProvider, mihCalendarProvider, index);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -405,7 +422,11 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentUpdateWindow(int index, double bodyWidth) {
|
||||
void appointmentUpdateWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider, int index, double bodyWidth) {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -415,13 +436,13 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
windowTitle: "Update Appointment",
|
||||
onWindowTapClose: () {
|
||||
setState(() {
|
||||
widget.titleController.text = widget.appointmentList[index].title;
|
||||
widget.titleController.text = appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
widget.appointmentList[index].description;
|
||||
appointmentList[index].description;
|
||||
widget.dateController.text =
|
||||
widget.appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text = widget
|
||||
.appointmentList[index].date_time
|
||||
appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text = appointmentList[index]
|
||||
.date_time
|
||||
.split('T')[1]
|
||||
.substring(0, 5);
|
||||
});
|
||||
@@ -497,7 +518,8 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
updateAppointmentCall(index);
|
||||
updateAppointmentCall(mzansiProfileProvider,
|
||||
mihCalendarProvider, index);
|
||||
} else {
|
||||
MihAlertServices()
|
||||
.formNotFilledCompletely(context);
|
||||
@@ -542,7 +564,10 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
}
|
||||
}
|
||||
|
||||
void deleteAppointmentConfirmationWindow(int index) {
|
||||
void deleteAppointmentConfirmationWindow(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -550,46 +575,55 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
return MIHDeleteMessage(
|
||||
deleteType: "Appointment",
|
||||
onTap: () {
|
||||
deleteAppointmentCall(index);
|
||||
deleteAppointmentCall(
|
||||
mzansiProfileProvider, mihCalendarProvider, index);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateAppointmentCall(int index) async {
|
||||
Future<void> updateAppointmentCall(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
int index) async {
|
||||
int statusCode;
|
||||
if (isAppointmentInputValid()) {
|
||||
if (widget.personalSelected == true) {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
if (mzansiProfileProvider.personalHome == true) {
|
||||
statusCode = await MihMzansiCalendarApis.updatePersonalAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
mzansiProfileProvider.user!,
|
||||
mzansiProfileProvider.business,
|
||||
null,
|
||||
widget.appointmentList[index].idappointments,
|
||||
appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
widget.dateController.text,
|
||||
widget.timeController.text,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
} else if (widget.personalSelected == false &&
|
||||
} else if (mzansiProfileProvider.personalHome == false &&
|
||||
widget.inWaitingRoom == false) {
|
||||
statusCode = await MihMzansiCalendarApis.updateBusinessAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
widget.appointmentList[index].idappointments,
|
||||
mzansiProfileProvider.user!,
|
||||
mzansiProfileProvider.business,
|
||||
mzansiProfileProvider.businessUser,
|
||||
appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
widget.dateController.text,
|
||||
widget.timeController.text,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
statusCode = await MihMzansiCalendarApis.updatePatientAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
widget.appointmentList[index].idappointments,
|
||||
mzansiProfileProvider.user!,
|
||||
mzansiProfileProvider.business,
|
||||
mzansiProfileProvider.businessUser,
|
||||
appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
widget.dateController.text,
|
||||
@@ -604,27 +638,20 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
KenLogger.warning("calendar route");
|
||||
context.goNamed(
|
||||
"mihCalendar",
|
||||
extra: CalendarArguments(
|
||||
widget.signedInUser,
|
||||
widget.personalSelected,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
KenLogger.warning("waiting room route");
|
||||
// GoRouter.of(context).refresh();
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: false,
|
||||
);
|
||||
context.goNamed(
|
||||
'patientManager',
|
||||
extra: PatManagerArguments(
|
||||
widget.signedInUser,
|
||||
mzansiProfileProvider.user!,
|
||||
false,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
mzansiProfileProvider.business,
|
||||
mzansiProfileProvider.businessUser,
|
||||
),
|
||||
);
|
||||
// context.pop();
|
||||
@@ -642,22 +669,26 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteAppointmentCall(int index) async {
|
||||
Future<void> deleteAppointmentCall(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
int index) async {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
int statucCode = await MihMzansiCalendarApis.deleteAppointmentAPICall(
|
||||
widget.signedInUser,
|
||||
widget.personalSelected,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
mzansiProfileProvider.user!,
|
||||
mzansiProfileProvider.personalHome,
|
||||
mzansiProfileProvider.business,
|
||||
mzansiProfileProvider.businessUser,
|
||||
widget.inWaitingRoom,
|
||||
widget.appointmentList[index].idappointments,
|
||||
appointmentList[index].idappointments,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
if (statucCode == 200) {
|
||||
context.pop();
|
||||
context.pop();
|
||||
setState(() {
|
||||
widget.appointmentList.removeAt(index);
|
||||
});
|
||||
successPopUp("Successfully Deleted Appointment",
|
||||
"You appointment has been successfully deleted from your calendar.");
|
||||
} else {
|
||||
@@ -730,20 +761,24 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
);
|
||||
}
|
||||
|
||||
bool canEditAppointment(int index) {
|
||||
if (widget.personalSelected == true &&
|
||||
widget.appointmentList[index].app_id == widget.signedInUser.app_id &&
|
||||
widget.appointmentList[index].business_id == "") {
|
||||
bool canEditAppointment(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider, int index) {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
if (mzansiProfileProvider.personalHome == true &&
|
||||
appointmentList[index].app_id == mzansiProfileProvider.user!.app_id &&
|
||||
appointmentList[index].business_id == "") {
|
||||
return true;
|
||||
} else if (widget.personalSelected == false &&
|
||||
widget.appointmentList[index].business_id ==
|
||||
widget.business!.business_id &&
|
||||
widget.appointmentList[index].app_id.isEmpty) {
|
||||
} else if (mzansiProfileProvider.personalHome == false &&
|
||||
appointmentList[index].business_id ==
|
||||
mzansiProfileProvider.business!.business_id &&
|
||||
appointmentList[index].app_id.isEmpty) {
|
||||
return true;
|
||||
} else if (widget.personalSelected == false &&
|
||||
widget.appointmentList[index].business_id ==
|
||||
widget.business!.business_id &&
|
||||
widget.appointmentList[index].app_id.isNotEmpty) {
|
||||
} else if (mzansiProfileProvider.personalHome == false &&
|
||||
appointmentList[index].business_id ==
|
||||
mzansiProfileProvider.business!.business_id &&
|
||||
appointmentList[index].app_id.isNotEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -765,16 +800,27 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
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, width);
|
||||
},
|
||||
),
|
||||
return Consumer2<MzansiProfileProvider, MihCalendarProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
Widget? child) {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: getPaddingSize()),
|
||||
child: ListView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: appointmentList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return displayAppointment(
|
||||
mzansiProfileProvider, mihCalendarProvider, index, width);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,15 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tools/appointments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MzansiCalendar extends StatefulWidget {
|
||||
final CalendarArguments arguments;
|
||||
const MzansiCalendar({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -40,9 +38,9 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
// Navigator.of(context).pop();
|
||||
context.read<MihCalendarProvider>().resetSelectedDay();
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: widget.arguments.personalSelected,
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
@@ -64,19 +62,16 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
//appointment here
|
||||
Appointments(
|
||||
signedInUser: widget.arguments.signedInUser,
|
||||
business: widget.arguments.business,
|
||||
businessUser: widget.arguments.businessUser,
|
||||
personalSelected: widget.arguments.personalSelected,
|
||||
),
|
||||
Appointments(),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
List<String> toolTitles = [
|
||||
widget.arguments.personalSelected == true ? "Personal" : "Business",
|
||||
mzansiProfileProvider.personalHome == true ? "Personal" : "Business",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MzansiCalendarTile extends StatefulWidget {
|
||||
final CalendarArguments arguments;
|
||||
final double packageSize;
|
||||
|
||||
const MzansiCalendarTile({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@@ -27,7 +24,6 @@ class _MzansiCalendarTileState extends State<MzansiCalendarTile> {
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mihCalendar",
|
||||
extra: widget.arguments,
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/calendar',
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_calendar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/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_mzansi_calendar_services.dart';
|
||||
@@ -17,29 +23,12 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_time_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/appointment.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/builder/build_appointment_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../main.dart';
|
||||
|
||||
import '../../../mih_components/mih_package_components/mih_calendar.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import '../../../mih_config/mih_env.dart';
|
||||
import '../../../mih_components/mih_objects/app_user.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class Appointments extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final Business? business;
|
||||
final BusinessUser? businessUser;
|
||||
final bool personalSelected;
|
||||
|
||||
const Appointments({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.business,
|
||||
required this.businessUser,
|
||||
required this.personalSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -57,25 +46,18 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentTimeController =
|
||||
TextEditingController();
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
String selectedDay = DateTime.now().toString().split(" ")[0];
|
||||
|
||||
late Future<List<Appointment>> personalAppointmentResults;
|
||||
late Future<List<Appointment>> businessAppointmentResults;
|
||||
late Future<List<Appointment>> appointmentResults;
|
||||
|
||||
bool isLoading = true;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
Widget displayAppointmentList(List<Appointment> appointmentList) {
|
||||
Widget displayAppointmentList(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider) {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
if (appointmentList.isNotEmpty) {
|
||||
return Expanded(
|
||||
child: BuildAppointmentList(
|
||||
appointmentList: appointmentList,
|
||||
signedInUser: widget.signedInUser,
|
||||
business: widget.business,
|
||||
businessUser: widget.businessUser,
|
||||
personalSelected: widget.personalSelected,
|
||||
inWaitingRoom: false,
|
||||
titleController: _appointmentTitleController,
|
||||
descriptionIDController: _appointmentDescriptionIDController,
|
||||
@@ -101,7 +83,7 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No appointments for $selectedDay",
|
||||
"No appointments for ${mihCalendarProvider.selectedDay}",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
@@ -147,7 +129,8 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
);
|
||||
}
|
||||
|
||||
void addAppointmentWindow(double width) {
|
||||
void addAppointmentWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider, double width) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -227,7 +210,8 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
addAppointmentCall();
|
||||
addAppointmentCall(
|
||||
mzansiProfileProvider, mihCalendarProvider);
|
||||
} else {
|
||||
MihAlertServices().formNotFilledCompletely(context);
|
||||
}
|
||||
@@ -269,28 +253,33 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addAppointmentCall() async {
|
||||
Future<void> addAppointmentCall(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
) async {
|
||||
if (isAppointmentInputValid()) {
|
||||
int statusCode;
|
||||
if (widget.personalSelected == false) {
|
||||
if (mzansiProfileProvider.personalHome == false) {
|
||||
statusCode = await MihMzansiCalendarApis.addBusinessAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business!,
|
||||
widget.businessUser!,
|
||||
mzansiProfileProvider.user!,
|
||||
mzansiProfileProvider.business!,
|
||||
mzansiProfileProvider.businessUser!,
|
||||
false,
|
||||
_appointmentTitleController.text,
|
||||
_appointmentDescriptionIDController.text,
|
||||
_appointmentDateController.text,
|
||||
_appointmentTimeController.text,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
statusCode = await MihMzansiCalendarApis.addPersonalAppointment(
|
||||
widget.signedInUser,
|
||||
mzansiProfileProvider.user!,
|
||||
_appointmentTitleController.text,
|
||||
_appointmentDescriptionIDController.text,
|
||||
_appointmentDateController.text,
|
||||
_appointmentTimeController.text,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
}
|
||||
@@ -298,20 +287,20 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
context.pop();
|
||||
successPopUp("Successfully Added Appointment",
|
||||
"You appointment has been successfully added to your calendar.");
|
||||
setState(() {
|
||||
if (widget.personalSelected) {
|
||||
appointmentResults = MihMzansiCalendarApis.getPersonalAppointments(
|
||||
widget.signedInUser.app_id,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
}
|
||||
});
|
||||
if (mzansiProfileProvider.personalHome == true) {
|
||||
await MihMzansiCalendarApis.getPersonalAppointments(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
mihCalendarProvider.selectedDay,
|
||||
mihCalendarProvider,
|
||||
);
|
||||
} else {
|
||||
await MihMzansiCalendarApis.getBusinessAppointments(
|
||||
mzansiProfileProvider.business!.business_id,
|
||||
false,
|
||||
mihCalendarProvider.selectedDay,
|
||||
mihCalendarProvider,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
@@ -397,8 +386,8 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
);
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
if (widget.personalSelected == false) {
|
||||
String getTitle(MzansiProfileProvider mzansiProfileProvider) {
|
||||
if (mzansiProfileProvider.personalHome == false) {
|
||||
return "Business Appointments";
|
||||
} else {
|
||||
return "Personal Appointments";
|
||||
@@ -407,108 +396,114 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
|
||||
void checkforchange() {
|
||||
setState(() {
|
||||
if (widget.personalSelected == false) {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
appointmentResults = MihMzansiCalendarApis.getPersonalAppointments(
|
||||
widget.signedInUser.app_id,
|
||||
selectedDay,
|
||||
);
|
||||
}
|
||||
isLoading = true;
|
||||
});
|
||||
_loadInitialAppointments();
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
MIHCalendar(
|
||||
calendarWidth: 500,
|
||||
rowHeight: 35,
|
||||
setDate: (value) {
|
||||
setState(() {
|
||||
selectedDay = value;
|
||||
selectedAppointmentDateController.text = selectedDay;
|
||||
});
|
||||
}),
|
||||
// Divider(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
if (isLoading) {
|
||||
return const Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
return Consumer2<MzansiProfileProvider, MihCalendarProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
Widget? child) {
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: appointmentResults,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
return const Expanded(
|
||||
child: Center(child: Mihloadingcircle()));
|
||||
} else if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
return displayAppointmentList(snapshot.requireData);
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling appointments",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
MIHCalendar(
|
||||
calendarWidth: 500,
|
||||
rowHeight: 35,
|
||||
setDate: (value) {
|
||||
mihCalendarProvider.setSelectedDay(value);
|
||||
setState(() {
|
||||
selectedAppointmentDateController.text = value;
|
||||
});
|
||||
}),
|
||||
// Divider(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
displayAppointmentList(
|
||||
mzansiProfileProvider,
|
||||
mihCalendarProvider,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Add Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
addAppointmentWindow(width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Add Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
addAppointmentWindow(
|
||||
mzansiProfileProvider, mihCalendarProvider, width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _loadInitialAppointments() async {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MihCalendarProvider mihCalendarProvider =
|
||||
context.read<MihCalendarProvider>();
|
||||
if (mzansiProfileProvider.personalHome == false) {
|
||||
await MihMzansiCalendarApis.getBusinessAppointments(
|
||||
mzansiProfileProvider.business!.business_id,
|
||||
false,
|
||||
mihCalendarProvider.selectedDay,
|
||||
mihCalendarProvider,
|
||||
);
|
||||
} else {
|
||||
await MihMzansiCalendarApis.getPersonalAppointments(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
mihCalendarProvider.selectedDay,
|
||||
mihCalendarProvider,
|
||||
);
|
||||
}
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
selectedAppointmentDateController.dispose();
|
||||
@@ -522,19 +517,8 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
@override
|
||||
void initState() {
|
||||
selectedAppointmentDateController.addListener(checkforchange);
|
||||
setState(() {
|
||||
if (widget.personalSelected == false) {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
appointmentResults = MihMzansiCalendarApis.getPersonalAppointments(
|
||||
widget.signedInUser.app_id,
|
||||
selectedDay,
|
||||
);
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
_loadInitialAppointments();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -98,12 +98,6 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||
//=============== Calendar ===============
|
||||
temp.add({
|
||||
"Calendar": MzansiCalendarTile(
|
||||
arguments: CalendarArguments(
|
||||
mzansiProfileProvider.user!,
|
||||
false,
|
||||
mzansiProfileProvider.business!,
|
||||
mzansiProfileProvider.businessUser!,
|
||||
),
|
||||
packageSize: packageSize,
|
||||
)
|
||||
});
|
||||
|
||||
@@ -125,12 +125,6 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
||||
//=============== Calendar ===============
|
||||
temp.add({
|
||||
"Calendar": MzansiCalendarTile(
|
||||
arguments: CalendarArguments(
|
||||
widget.signedInUser,
|
||||
true,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
),
|
||||
packageSize: packageSize,
|
||||
)
|
||||
});
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/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_mzansi_calendar_services.dart';
|
||||
@@ -26,6 +28,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/builder/build_appointment_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class WaitingRoom extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
@@ -60,113 +63,91 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
final TextEditingController _patientController = TextEditingController();
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
String selectedDay = DateTime.now().toString().split(" ")[0];
|
||||
|
||||
late Future<List<Appointment>> businessAppointmentResults;
|
||||
late Future<List<Appointment>> appointmentResults;
|
||||
bool inWaitingRoom = true;
|
||||
bool isLoading = true;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
// Business Appointment Tool
|
||||
Widget getBusinessAppointmentsTool(double width) {
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
MIHCalendar(
|
||||
calendarWidth: 500,
|
||||
rowHeight: 35,
|
||||
setDate: (value) {
|
||||
setState(() {
|
||||
selectedDay = value;
|
||||
selectedAppointmentDateController.text = selectedDay;
|
||||
});
|
||||
}),
|
||||
// Divider(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
return Consumer<MihCalendarProvider>(
|
||||
builder: (BuildContext context, MihCalendarProvider mihCalendarProvider,
|
||||
Widget? child) {
|
||||
if (isLoading) {
|
||||
return const Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: appointmentResults,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
return const Expanded(
|
||||
child: Center(child: Mihloadingcircle()));
|
||||
} else if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
return
|
||||
// Container(child: const Placeholder());
|
||||
displayAppointmentList(snapshot.requireData);
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling appointments",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
MIHCalendar(
|
||||
calendarWidth: 500,
|
||||
rowHeight: 35,
|
||||
setDate: (value) {
|
||||
mihCalendarProvider.setSelectedDay(value);
|
||||
setState(() {
|
||||
selectedAppointmentDateController.text = value;
|
||||
});
|
||||
}),
|
||||
// Divider(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
displayAppointmentList(mihCalendarProvider),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Add Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
// addAppointmentWindow();
|
||||
appointmentTypeSelection(width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Add Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
// addAppointmentWindow();
|
||||
appointmentTypeSelection(mihCalendarProvider, width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayAppointmentList(List<Appointment> appointmentList) {
|
||||
if (appointmentList.isNotEmpty) {
|
||||
Widget displayAppointmentList(MihCalendarProvider mihCalendarProvider) {
|
||||
if (mihCalendarProvider.businessAppointments!.isNotEmpty) {
|
||||
return Expanded(
|
||||
child: BuildAppointmentList(
|
||||
appointmentList: appointmentList,
|
||||
signedInUser: widget.signedInUser,
|
||||
business: widget.business,
|
||||
businessUser: widget.businessUser,
|
||||
personalSelected: widget.personalSelected,
|
||||
inWaitingRoom: true,
|
||||
titleController: _appointmentTitleController,
|
||||
descriptionIDController: _appointmentDescriptionIDController,
|
||||
@@ -192,7 +173,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No Appointments for $selectedDay",
|
||||
"No Appointments for ${mihCalendarProvider.selectedDay}",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
@@ -255,7 +236,8 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
// );
|
||||
}
|
||||
|
||||
void appointmentTypeSelection(double width) {
|
||||
void appointmentTypeSelection(
|
||||
MihCalendarProvider mihCalendarProvider, double width) {
|
||||
String question = "What type of appointment would you like to add?";
|
||||
question +=
|
||||
"\n\nExisting Patient: Add an appointment for an patient your practice has access to.";
|
||||
@@ -325,7 +307,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
addAppointmentWindow(width);
|
||||
addAppointmentWindow(mihCalendarProvider, width);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
@@ -347,7 +329,8 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
);
|
||||
}
|
||||
|
||||
void addAppointmentWindow(double width) {
|
||||
void addAppointmentWindow(
|
||||
MihCalendarProvider mihCalendarProvider, double width) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -428,7 +411,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
addAppointmentCall();
|
||||
addAppointmentCall(mihCalendarProvider);
|
||||
} else {
|
||||
MihAlertServices().formNotFilledCompletely(context);
|
||||
}
|
||||
@@ -459,7 +442,8 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> addAppointmentCall() async {
|
||||
Future<void> addAppointmentCall(
|
||||
MihCalendarProvider mihCalendarProvider) async {
|
||||
if (isAppointmentInputValid()) {
|
||||
int statusCode;
|
||||
if (widget.personalSelected == false) {
|
||||
@@ -472,6 +456,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
_appointmentDescriptionIDController.text,
|
||||
_appointmentDateController.text,
|
||||
_appointmentTimeController.text,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
@@ -481,6 +466,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
_appointmentDescriptionIDController.text,
|
||||
_appointmentDateController.text,
|
||||
_appointmentTimeController.text,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
}
|
||||
@@ -488,6 +474,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
context.pop();
|
||||
successPopUp("Successfully Added Appointment",
|
||||
"You appointment has been successfully added to your calendar.");
|
||||
_loadInitialAppointments();
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
@@ -585,11 +572,24 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
|
||||
void checkforchange() {
|
||||
setState(() {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
true,
|
||||
selectedDay,
|
||||
);
|
||||
isLoading = true;
|
||||
});
|
||||
_loadInitialAppointments();
|
||||
}
|
||||
|
||||
Future<void> _loadInitialAppointments() async {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MihCalendarProvider mihCalendarProvider =
|
||||
context.read<MihCalendarProvider>();
|
||||
await MihMzansiCalendarApis.getBusinessAppointments(
|
||||
mzansiProfileProvider.business!.business_id,
|
||||
false,
|
||||
mihCalendarProvider.selectedDay,
|
||||
mihCalendarProvider,
|
||||
);
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -606,12 +606,8 @@ class _WaitingRoomState extends State<WaitingRoom> {
|
||||
@override
|
||||
void initState() {
|
||||
selectedAppointmentDateController.addListener(checkforchange);
|
||||
setState(() {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
true,
|
||||
selectedDay,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadInitialAppointments();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart'
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import '../mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
@@ -23,9 +24,10 @@ class MihMzansiCalendarApis {
|
||||
/// date (yyyy-mm-dd),
|
||||
///
|
||||
/// Returns Future<List<Appointment>>.
|
||||
static Future<List<Appointment>> getPersonalAppointments(
|
||||
static Future<int> getPersonalAppointments(
|
||||
String app_id,
|
||||
String date,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
) async {
|
||||
final response = await http.get(Uri.parse(
|
||||
"${AppEnviroment.baseApiUrl}/appointments/personal/$app_id?date=$date"));
|
||||
@@ -33,7 +35,9 @@ class MihMzansiCalendarApis {
|
||||
Iterable l = jsonDecode(response.body);
|
||||
List<Appointment> personalAppointments =
|
||||
List<Appointment>.from(l.map((model) => Appointment.fromJson(model)));
|
||||
return personalAppointments;
|
||||
mihCalendarProvider.setPersonalAppointments(
|
||||
appointments: personalAppointments);
|
||||
return response.statusCode;
|
||||
} else {
|
||||
throw Exception('failed to fatch personal appointments');
|
||||
}
|
||||
@@ -46,38 +50,21 @@ class MihMzansiCalendarApis {
|
||||
/// date (yyyy-mm-dd),
|
||||
///
|
||||
/// Returns Future<List<Appointment>>.
|
||||
static Future<List<Appointment>> getBusinessAppointments(
|
||||
static Future<int> getBusinessAppointments(
|
||||
String business_id,
|
||||
bool waitingRoom,
|
||||
String date,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
) async {
|
||||
//print("Patien manager page: $endpoint");
|
||||
final response = await http.get(Uri.parse(
|
||||
"${AppEnviroment.baseApiUrl}/appointments/business/$business_id?date=$date"));
|
||||
// print("Here");
|
||||
// print("Body: ${response.body}");
|
||||
// print("Code: ${response.statusCode}");
|
||||
// errorCode = response.statusCode.toString();
|
||||
// errorBody = response.body;
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
//print("Here1");
|
||||
Iterable l = jsonDecode(response.body);
|
||||
//print("Here2");
|
||||
List<Appointment> businessAppointments =
|
||||
List<Appointment>.from(l.map((model) => Appointment.fromJson(model)));
|
||||
//print("Here3");
|
||||
//print(patientQueue);
|
||||
// if (waitingRoom == true) {
|
||||
// businessAppointments = businessAppointments
|
||||
// .where((element) => element.app_id != "")
|
||||
// .toList();
|
||||
// } else {
|
||||
// businessAppointments = businessAppointments
|
||||
// .where((element) => element.app_id == "")
|
||||
// .toList();
|
||||
// }
|
||||
return businessAppointments;
|
||||
mihCalendarProvider.setBusinessAppointments(
|
||||
appointments: businessAppointments);
|
||||
return response.statusCode;
|
||||
} else {
|
||||
throw Exception('failed to fatch business appointments');
|
||||
}
|
||||
@@ -98,6 +85,7 @@ class MihMzansiCalendarApis {
|
||||
BusinessUser? businessUser,
|
||||
bool inWaitingRoom,
|
||||
int idappointments,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
BuildContext context,
|
||||
) async {
|
||||
loadingPopUp(context);
|
||||
@@ -109,6 +97,19 @@ class MihMzansiCalendarApis {
|
||||
body: jsonEncode(<String, dynamic>{"idappointments": idappointments}),
|
||||
);
|
||||
context.pop();
|
||||
if (response.statusCode == 200) {
|
||||
if (personalSelected == true) {
|
||||
mihCalendarProvider.deletePersonalAppointment(
|
||||
appointmentId: idappointments);
|
||||
getPersonalAppointments(signedInUser.app_id,
|
||||
mihCalendarProvider.selectedDay, mihCalendarProvider);
|
||||
} else {
|
||||
mihCalendarProvider.deleteBusinessAppointment(
|
||||
appointmentId: idappointments);
|
||||
getBusinessAppointments(business!.business_id, inWaitingRoom,
|
||||
mihCalendarProvider.selectedDay, mihCalendarProvider);
|
||||
}
|
||||
}
|
||||
return response.statusCode;
|
||||
//print("Here4");
|
||||
//print(response.statusCode);
|
||||
@@ -163,6 +164,7 @@ class MihMzansiCalendarApis {
|
||||
String description,
|
||||
String date,
|
||||
String time,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
BuildContext context,
|
||||
) async {
|
||||
loadingPopUp(context);
|
||||
@@ -181,6 +183,18 @@ class MihMzansiCalendarApis {
|
||||
}),
|
||||
);
|
||||
context.pop();
|
||||
if (response.statusCode == 201) {
|
||||
mihCalendarProvider.addPersonalAppointment(
|
||||
newAppointment: Appointment(
|
||||
idappointments: 0,
|
||||
app_id: signedInUser.app_id,
|
||||
business_id: "",
|
||||
date_time: "$date $time",
|
||||
title: title,
|
||||
description: description,
|
||||
),
|
||||
);
|
||||
}
|
||||
return response.statusCode;
|
||||
// if (response.statusCode == 201) {
|
||||
// Navigator.pop(context);
|
||||
@@ -227,6 +241,7 @@ class MihMzansiCalendarApis {
|
||||
String description,
|
||||
String date,
|
||||
String time,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
BuildContext context,
|
||||
) async {
|
||||
loadingPopUp(context);
|
||||
@@ -245,43 +260,19 @@ class MihMzansiCalendarApis {
|
||||
}),
|
||||
);
|
||||
context.pop();
|
||||
if (response.statusCode == 201) {
|
||||
mihCalendarProvider.addBusinessAppointment(
|
||||
newAppointment: Appointment(
|
||||
idappointments: 0,
|
||||
app_id: "",
|
||||
business_id: business.business_id,
|
||||
date_time: "$date $time",
|
||||
title: title,
|
||||
description: description,
|
||||
),
|
||||
);
|
||||
}
|
||||
return response.statusCode;
|
||||
// if (response.statusCode == 201) {
|
||||
// // Navigator.pop(context);
|
||||
// Navigator.pop(context);
|
||||
// Navigator.pop(context);
|
||||
// Navigator.pop(context);
|
||||
// String message =
|
||||
// "Your appointment \"$title\" for the $date $title has been deleted.";
|
||||
|
||||
// // Navigator.pop(context);
|
||||
// if (inWaitingRoom) {
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/patient-manager',
|
||||
// arguments: PatManagerArguments(
|
||||
// signedInUser,
|
||||
// false,
|
||||
// business,
|
||||
// businessUser,
|
||||
// ),
|
||||
// );
|
||||
// } else {
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/calendar',
|
||||
// arguments: CalendarArguments(
|
||||
// signedInUser,
|
||||
// false,
|
||||
// business,
|
||||
// businessUser,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
// successPopUp(message, context);
|
||||
// } else {
|
||||
// Navigator.pop(context);
|
||||
// internetConnectionPopUp(context);
|
||||
// }
|
||||
}
|
||||
|
||||
/// This function is used to add an appointment to users mzansi Calendar.
|
||||
@@ -324,20 +315,6 @@ class MihMzansiCalendarApis {
|
||||
);
|
||||
context.pop();
|
||||
return response.statusCode;
|
||||
// if (response.statusCode == 201) {
|
||||
// MihNotificationApis.addNewAppointmentNotificationAPICall(
|
||||
// patientAppId,
|
||||
// personalSelected,
|
||||
// date,
|
||||
// time,
|
||||
// businessArgs,
|
||||
// context,
|
||||
// );
|
||||
// // Navigator.pop(context);
|
||||
// } else {
|
||||
// Navigator.pop(context);
|
||||
// internetConnectionPopUp(context);
|
||||
// }
|
||||
}
|
||||
|
||||
/// This function is used to update an appointment to users mzansi Calendar.
|
||||
@@ -362,6 +339,7 @@ class MihMzansiCalendarApis {
|
||||
String description,
|
||||
String date,
|
||||
String time,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
BuildContext context,
|
||||
) async {
|
||||
loadingPopUp(context);
|
||||
@@ -379,6 +357,18 @@ class MihMzansiCalendarApis {
|
||||
}),
|
||||
);
|
||||
context.pop();
|
||||
if (response.statusCode == 200) {
|
||||
mihCalendarProvider.editPersonalAppointment(
|
||||
updatedAppointment: Appointment(
|
||||
idappointments: idappointments,
|
||||
app_id: signedInUser.app_id,
|
||||
business_id: "",
|
||||
date_time: "$date $time",
|
||||
title: title,
|
||||
description: description,
|
||||
),
|
||||
);
|
||||
}
|
||||
return response.statusCode;
|
||||
// if (response.statusCode == 200) {
|
||||
// Navigator.pop(context);
|
||||
@@ -426,6 +416,7 @@ class MihMzansiCalendarApis {
|
||||
String description,
|
||||
String date,
|
||||
String time,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
BuildContext context,
|
||||
) async {
|
||||
loadingPopUp(context);
|
||||
@@ -443,6 +434,18 @@ class MihMzansiCalendarApis {
|
||||
}),
|
||||
);
|
||||
context.pop();
|
||||
if (response.statusCode == 200) {
|
||||
mihCalendarProvider.editBusinessAppointment(
|
||||
updatedAppointment: Appointment(
|
||||
idappointments: idappointments,
|
||||
app_id: "",
|
||||
business_id: business!.business_id,
|
||||
date_time: "$date $time",
|
||||
title: title,
|
||||
description: description,
|
||||
),
|
||||
);
|
||||
}
|
||||
return response.statusCode;
|
||||
// if (response.statusCode == 200) {
|
||||
// Navigator.pop(context);
|
||||
|
||||
Reference in New Issue
Block a user