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