|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import 'package:car_customer_app/repositories/provider_repo.dart';
|
|
|
|
|
import 'package:car_customer_app/repositories/appointment_repo.dart';
|
|
|
|
|
import 'package:car_customer_app/view_models/dashboard_view_model.dart';
|
|
|
|
|
import 'package:car_customer_app/views/appointments/book_appointment_schedules_view.dart';
|
|
|
|
|
import 'package:car_customer_app/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
@ -127,6 +128,11 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onConfirmAppointmentPressed({required BuildContext context, required appointmentId}) async {
|
|
|
|
|
context.read<PaymentVM>().updateAppointmentIdsForPayment(ids: [appointmentId]);
|
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.appointment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onCancelAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
@ -209,6 +215,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
resetAfterBookingAppointment() {
|
|
|
|
|
servicesInCurrentAppointment.clear();
|
|
|
|
|
allSelectedItemsInAppointments.clear();
|
|
|
|
|
serviceAppointmentScheduleList.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
populateAppointmentsFilterList() {
|
|
|
|
|
@ -597,8 +604,70 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.bookAppointmenSchedulesView);
|
|
|
|
|
navigateWithName(context, AppRoutes.bookAppointmenSchedulesView, arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 1, appointmentId: 0)); // 1 For Creating an Appointment
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onRescheduleAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
|
|
|
|
|
List<String> serviceItemIdsForHome = [];
|
|
|
|
|
List<String> serviceItemIdsForWorkshop = [];
|
|
|
|
|
appointmentListModel.appointmentServicesList!.forEach((service) {
|
|
|
|
|
service.serviceItems!.forEach((serviceItem) {
|
|
|
|
|
serviceItemIdsForWorkshop.add(serviceItem.id!.toString());
|
|
|
|
|
|
|
|
|
|
// if (serviceItem.isHomeSelected ?? false) {
|
|
|
|
|
// serviceItemIdsForHome.add(serviceItem.id!.toString());
|
|
|
|
|
// } else {
|
|
|
|
|
// serviceItemIdsForWorkshop.add(serviceItem.id!.toString());
|
|
|
|
|
// }
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList = await scheduleRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
|
serviceItemIdsForHome: serviceItemIdsForHome,
|
|
|
|
|
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (serviceAppointmentScheduleList.isEmpty) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast("There are no available appointments for selected Items.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.bookAppointmenSchedulesView,
|
|
|
|
|
arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 2, appointmentId: appointmentListModel.id ?? 0)); // 2 For Rescheduling an Appointment
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onRescheduleAppointmentConfirmPressed({required BuildContext context, required int appointmentId, required int selectedSlotId}) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
GenericRespModel genericRespModel = await scheduleRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
|
serviceAppointmentID: appointmentId,
|
|
|
|
|
serviceSlotID: selectedSlotId,
|
|
|
|
|
appointmentScheduleAction: 1, // 1 for Reschedule and 2 for Cancel
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 2 || genericRespModel.data == null) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (genericRespModel.data == 1) {
|
|
|
|
|
context.read<DashboardVM>().onNavbarTapped(1);
|
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.cancelled);
|
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
|
getMyAppointments();
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
Utils.showToast("${e.toString()}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|