|
|
|
@ -45,10 +45,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
final BranchRepo branchRepo;
|
|
|
|
final BranchRepo branchRepo;
|
|
|
|
final AppointmentRepo appointmentRepo;
|
|
|
|
final AppointmentRepo appointmentRepo;
|
|
|
|
|
|
|
|
|
|
|
|
AppointmentsVM({required this.commonServices,
|
|
|
|
AppointmentsVM({required this.commonServices, required this.appointmentRepo, required this.commonRepo, required this.branchRepo});
|
|
|
|
required this.appointmentRepo,
|
|
|
|
|
|
|
|
required this.commonRepo,
|
|
|
|
|
|
|
|
required this.branchRepo});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isUpcommingEnabled = true;
|
|
|
|
bool isUpcommingEnabled = true;
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
@ -76,8 +73,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleList = [];
|
|
|
|
List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleList = [];
|
|
|
|
|
|
|
|
|
|
|
|
bool ifItemAlreadySelected(int id) {
|
|
|
|
bool ifItemAlreadySelected(int id) {
|
|
|
|
int indexFound = allSelectedItemsInAppointments
|
|
|
|
int indexFound = allSelectedItemsInAppointments.indexWhere((element) => element.id == id);
|
|
|
|
.indexWhere((element) => element.id == id);
|
|
|
|
|
|
|
|
if (indexFound != -1) {
|
|
|
|
if (indexFound != -1) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -98,8 +94,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onItemsSelectedInService() async {
|
|
|
|
Future<void> onItemsSelectedInService() async {
|
|
|
|
if (currentServiceSelection != null) {
|
|
|
|
if (currentServiceSelection != null) {
|
|
|
|
int index = servicesInCurrentAppointment.indexWhere((element) =>
|
|
|
|
int index = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (index == -1) {
|
|
|
|
if (index == -1) {
|
|
|
|
double totalPrice = 0.0;
|
|
|
|
double totalPrice = 0.0;
|
|
|
|
@ -116,11 +111,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onPayNowPressedForAppointment({required BuildContext context, required int appointmentID}) async {
|
|
|
|
Future<void> onPayNowPressedForAppointment({required BuildContext context, required int appointmentID}) async {
|
|
|
|
context
|
|
|
|
context.read<PaymentVM>().updateAppointmentIdsForPayment(ids: [appointmentID]);
|
|
|
|
.read<PaymentVM>()
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.partialAppointment);
|
|
|
|
.updateAppointmentIdsForPayment(ids: [appointmentID]);
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView,
|
|
|
|
|
|
|
|
arguments: PaymentTypes.partialAppointment);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onBookAppointmentPressed(BuildContext context) async {
|
|
|
|
Future<void> onBookAppointmentPressed(BuildContext context) async {
|
|
|
|
@ -128,8 +120,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
bool isSuccess = false;
|
|
|
|
bool isSuccess = false;
|
|
|
|
List<int> appointmentIdsList = [];
|
|
|
|
List<int> appointmentIdsList = [];
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GenericRespModel genericRespModel =
|
|
|
|
GenericRespModel genericRespModel = await appointmentRepo.createServiceAppointment(
|
|
|
|
await appointmentRepo.createServiceAppointment(
|
|
|
|
|
|
|
|
schedules: serviceAppointmentScheduleList,
|
|
|
|
schedules: serviceAppointmentScheduleList,
|
|
|
|
serviceProviderID: selectedBranchModel!.serviceProviderId ?? 0,
|
|
|
|
serviceProviderID: selectedBranchModel!.serviceProviderId ?? 0,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -155,17 +146,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
context.read<DashboardVmCustomer>().onNavbarTapped(1);
|
|
|
|
context.read<DashboardVmCustomer>().onNavbarTapped(1);
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.booked);
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.booked);
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
resetAfterBookingAppointment();
|
|
|
|
resetAfterBookingAppointment();
|
|
|
|
if (isSuccess) {
|
|
|
|
if (isSuccess) {
|
|
|
|
if (amountToPayForAppointment > 0) {
|
|
|
|
if (amountToPayForAppointment > 0) {
|
|
|
|
context
|
|
|
|
context.read<PaymentVM>().updateAppointmentIdsForPayment(ids: appointmentIdsList);
|
|
|
|
.read<PaymentVM>()
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.appointment);
|
|
|
|
.updateAppointmentIdsForPayment(ids: appointmentIdsList);
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView,
|
|
|
|
|
|
|
|
arguments: PaymentTypes.appointment);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(LocaleKeys.appointmentBookedSuccessfully.tr());
|
|
|
|
Utils.showToast(LocaleKeys.appointmentBookedSuccessfully.tr());
|
|
|
|
getMyAppointments();
|
|
|
|
getMyAppointments();
|
|
|
|
@ -178,34 +165,27 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onConfirmAppointmentPressed({required BuildContext context, required appointmentId}) async {
|
|
|
|
Future<void> onConfirmAppointmentPressed({required BuildContext context, required appointmentId}) async {
|
|
|
|
context
|
|
|
|
context.read<PaymentVM>().updateAppointmentIdsForPayment(ids: [appointmentId]);
|
|
|
|
.read<PaymentVM>()
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.appointment);
|
|
|
|
.updateAppointmentIdsForPayment(ids: [appointmentId]);
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.paymentMethodsView,
|
|
|
|
|
|
|
|
arguments: PaymentTypes.appointment);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onCancelAppointmentPressed({required BuildContext context,
|
|
|
|
Future<void> onCancelAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async {
|
|
|
|
required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GenericRespModel genericRespModel =
|
|
|
|
GenericRespModel genericRespModel = await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
|
|
|
|
serviceAppointmentID: appointmentListModel.id ?? 0,
|
|
|
|
serviceAppointmentID: appointmentListModel.id ?? 0,
|
|
|
|
serviceSlotID: appointmentListModel.serviceSlotID ?? 0,
|
|
|
|
serviceSlotID: appointmentListModel.serviceSlotID ?? 0,
|
|
|
|
appointmentScheduleAction: 2, // 1 for Reschedule and 2 for Cancel
|
|
|
|
appointmentScheduleAction: 2, // 1 for Reschedule and 2 for Cancel
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 2 ||
|
|
|
|
if (genericRespModel.messageStatus == 2 || genericRespModel.data == null) {
|
|
|
|
genericRespModel.data == null) {
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
context.read<DashboardVmCustomer>().onNavbarTapped(1);
|
|
|
|
context.read<DashboardVmCustomer>().onNavbarTapped(1);
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.cancelled);
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.cancelled);
|
|
|
|
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
await getMyAppointments();
|
|
|
|
await getMyAppointments();
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
@ -236,8 +216,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel branchSelectedCategoryId =
|
|
|
|
SelectionModel branchSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateProviderCategoryId(SelectionModel id) {
|
|
|
|
void updateProviderCategoryId(SelectionModel id) {
|
|
|
|
branchSelectedCategoryId = id;
|
|
|
|
branchSelectedCategoryId = id;
|
|
|
|
@ -252,30 +231,23 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
|
|
void updateBranchServiceId(SelectionModel id) async {
|
|
|
|
void updateBranchServiceId(SelectionModel id) async {
|
|
|
|
branchSelectedServiceId = id;
|
|
|
|
branchSelectedServiceId = id;
|
|
|
|
currentServiceSelection = branchServices.firstWhere(
|
|
|
|
currentServiceSelection = branchServices.firstWhere((element) => element.serviceProviderServiceId == id.selectedId);
|
|
|
|
(element) => element.serviceProviderServiceId == id.selectedId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void removeServiceInCurrentAppointment(int index) {
|
|
|
|
void removeServiceInCurrentAppointment(int index) {
|
|
|
|
int serviceId = servicesInCurrentAppointment
|
|
|
|
int serviceId = servicesInCurrentAppointment.elementAt(index).serviceProviderServiceId ?? -1;
|
|
|
|
.elementAt(index)
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.serviceProviderServiceId == serviceId);
|
|
|
|
.serviceProviderServiceId ??
|
|
|
|
|
|
|
|
-1;
|
|
|
|
|
|
|
|
allSelectedItemsInAppointments.removeWhere(
|
|
|
|
|
|
|
|
(element) => element.serviceProviderServiceId == serviceId);
|
|
|
|
|
|
|
|
servicesInCurrentAppointment.removeAt(index);
|
|
|
|
servicesInCurrentAppointment.removeAt(index);
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resetCategorySelectionBottomSheet() {
|
|
|
|
resetCategorySelectionBottomSheet() {
|
|
|
|
selectedSubServicesCounter = 0;
|
|
|
|
selectedSubServicesCounter = 0;
|
|
|
|
branchSelectedCategoryId =
|
|
|
|
branchSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
isHomeTapped = false;
|
|
|
|
isHomeTapped = false;
|
|
|
|
branchSelectedServiceId =
|
|
|
|
branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
currentServiceSelection = null;
|
|
|
|
currentServiceSelection = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -290,29 +262,21 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Future<void> populateAppointmentsFilterList() async {
|
|
|
|
Future<void> populateAppointmentsFilterList() async {
|
|
|
|
if (appointmentsFilterOptions.isNotEmpty) return;
|
|
|
|
if (appointmentsFilterOptions.isNotEmpty) return;
|
|
|
|
|
|
|
|
|
|
|
|
myAppointmentsEnum = await commonRepo.getEnumTypeValues(
|
|
|
|
myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: 13); // 13 is to get Appointments Filter Enums
|
|
|
|
enumTypeID: 13); // 13 is to get Appointments Filter Enums
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < myAppointmentsEnum.length; i++) {
|
|
|
|
for (int i = 0; i < myAppointmentsEnum.length; i++) {
|
|
|
|
appointmentsFilterOptions.add(FilterListModel(
|
|
|
|
appointmentsFilterOptions.add(FilterListModel(title: myAppointmentsEnum[i].enumValueStr, isSelected: false, id: myAppointmentsEnum[i].enumValue));
|
|
|
|
title: myAppointmentsEnum[i].enumValueStr,
|
|
|
|
|
|
|
|
isSelected: false,
|
|
|
|
|
|
|
|
id: myAppointmentsEnum[i].enumValue));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
appointmentsFilterOptions.insert(
|
|
|
|
appointmentsFilterOptions.insert(0, FilterListModel(title: "All Appointments", isSelected: true, id: 0));
|
|
|
|
0, FilterListModel(title: "All Appointments", isSelected: true, id: 0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: THIS SHOULD REMOVED AND ADDED IN THE ENUMS API
|
|
|
|
// TODO: THIS SHOULD REMOVED AND ADDED IN THE ENUMS API
|
|
|
|
appointmentsFilterOptions.add(
|
|
|
|
appointmentsFilterOptions.add(FilterListModel(title: "Work In Progress", isSelected: false, id: 7));
|
|
|
|
FilterListModel(title: "Work In Progress", isSelected: false, id: 7));
|
|
|
|
appointmentsFilterOptions.add(FilterListModel(title: "Visit Completed", isSelected: false, id: 8));
|
|
|
|
appointmentsFilterOptions.add(
|
|
|
|
|
|
|
|
FilterListModel(title: "Visit Completed", isSelected: false, id: 8));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
applyFilterOnAppointmentsVM({required AppointmentStatusEnum appointmentStatusEnum,
|
|
|
|
applyFilterOnAppointmentsVM({required AppointmentStatusEnum appointmentStatusEnum, bool isNeedCustomerFilter = false}) {
|
|
|
|
bool isNeedCustomerFilter = false}) {
|
|
|
|
|
|
|
|
// isNeedCustomerFilter IS ONLY FOR THE PROVIDER APP
|
|
|
|
// isNeedCustomerFilter IS ONLY FOR THE PROVIDER APP
|
|
|
|
if (appointmentsFilterOptions.isEmpty) return;
|
|
|
|
if (appointmentsFilterOptions.isEmpty) return;
|
|
|
|
for (var value in appointmentsFilterOptions) {
|
|
|
|
for (var value in appointmentsFilterOptions) {
|
|
|
|
@ -320,8 +284,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (var element in appointmentsFilterOptions) {
|
|
|
|
for (var element in appointmentsFilterOptions) {
|
|
|
|
if (element.id ==
|
|
|
|
if (element.id == appointmentStatusEnum.getIdFromAppointmentStatusEnum()) {
|
|
|
|
appointmentStatusEnum.getIdFromAppointmentStatusEnum()) {
|
|
|
|
|
|
|
|
element.isSelected = true;
|
|
|
|
element.isSelected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -332,15 +295,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
if (appointmentStatusEnum.getIdFromAppointmentStatusEnum() == 0) {
|
|
|
|
if (appointmentStatusEnum.getIdFromAppointmentStatusEnum() == 0) {
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers();
|
|
|
|
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers();
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
myFilteredAppointments = myAppointments
|
|
|
|
myFilteredAppointments = myAppointments.where((element) => element.appointmentStatusID! == appointmentStatusEnum.getIdFromAppointmentStatusEnum()).toList();
|
|
|
|
.where((element) =>
|
|
|
|
|
|
|
|
element.appointmentStatusID! ==
|
|
|
|
|
|
|
|
appointmentStatusEnum.getIdFromAppointmentStatusEnum())
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers();
|
|
|
|
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers();
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
findAppointmentsBasedOnCustomers() {
|
|
|
|
findAppointmentsBasedOnCustomers() {
|
|
|
|
@ -354,9 +315,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
|
|
// Create a list of CustomerData instances
|
|
|
|
// Create a list of CustomerData instances
|
|
|
|
myFilteredAppointments2 = uniqueCustomerIDs.map((id) {
|
|
|
|
myFilteredAppointments2 = uniqueCustomerIDs.map((id) {
|
|
|
|
List<AppointmentListModel> list = myFilteredAppointments
|
|
|
|
List<AppointmentListModel> list = myFilteredAppointments.where((item) => item.customerID == id).toList();
|
|
|
|
.where((item) => item.customerID == id)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
AppointmentListModel model = list.first;
|
|
|
|
AppointmentListModel model = list.first;
|
|
|
|
model.customerAppointmentList = list;
|
|
|
|
model.customerAppointmentList = list;
|
|
|
|
return model;
|
|
|
|
return model;
|
|
|
|
@ -376,35 +335,42 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
// }).toList();
|
|
|
|
// }).toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getMyAppointments() async {
|
|
|
|
// Future<void> getMyAppointments() async {
|
|
|
|
setState(ViewState.busy);
|
|
|
|
// setState(ViewState.busy);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// myAppointments =
|
|
|
|
|
|
|
|
// await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
|
|
|
|
// myFilteredAppointments = myAppointments;
|
|
|
|
|
|
|
|
// myUpComingAppointments = myAppointments
|
|
|
|
|
|
|
|
// .where((element) =>
|
|
|
|
|
|
|
|
// element.appointmentStatusEnum == AppointmentStatusEnum.booked)
|
|
|
|
|
|
|
|
// .toList();
|
|
|
|
|
|
|
|
// applyFilterOnAppointmentsVM(
|
|
|
|
|
|
|
|
// appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
|
|
|
|
// if (myUpComingAppointments.isEmpty) {
|
|
|
|
|
|
|
|
// isShowEmptyMessage = true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// setState(ViewState.idle);
|
|
|
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
myAppointments =
|
|
|
|
Future<void> getMyAppointments({bool isNeedToRebuild = false}) async {
|
|
|
|
await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
|
|
|
|
myUpComingAppointments = myAppointments
|
|
|
|
|
|
|
|
.where((element) =>
|
|
|
|
|
|
|
|
element.appointmentStatusEnum == AppointmentStatusEnum.confirmed)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
// myFilteredAppointments = myAppointments;
|
|
|
|
if (myUpComingAppointments.isEmpty) {
|
|
|
|
myUpComingAppointments = myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked).toList();
|
|
|
|
isShowEmptyMessage = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AppointmentSlots? appointmentSlots;
|
|
|
|
AppointmentSlots? appointmentSlots;
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getAppointmentSlotsInfo({required Map<String, dynamic> map,
|
|
|
|
Future<void> getAppointmentSlotsInfo({required Map<String, dynamic> map, required BuildContext context, bool isNeedToRebuild = false}) async {
|
|
|
|
required BuildContext context,
|
|
|
|
|
|
|
|
bool isNeedToRebuild = false}) async {
|
|
|
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
MResponse genericRespModel =
|
|
|
|
MResponse genericRespModel = await appointmentRepo.getAppointmentSlots(map);
|
|
|
|
await appointmentRepo.getAppointmentSlots(map);
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
appointmentSlots = AppointmentSlots.fromJson(genericRespModel.data);
|
|
|
|
appointmentSlots = AppointmentSlots.fromJson(genericRespModel.data);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -415,26 +381,21 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getMyAppointmentsForProvider(Map<String, dynamic> map,) async {
|
|
|
|
Future<void> getMyAppointmentsForProvider(
|
|
|
|
|
|
|
|
Map<String, dynamic> map,
|
|
|
|
|
|
|
|
) async {
|
|
|
|
setState(ViewState.busy);
|
|
|
|
setState(ViewState.busy);
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForProvider(map);
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForProvider(map);
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
myUpComingAppointments = await myAppointments
|
|
|
|
myUpComingAppointments = await myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList();
|
|
|
|
.where((element) =>
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true);
|
|
|
|
element.appointmentStatusEnum == AppointmentStatusEnum.confirmed)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.allAppointments,
|
|
|
|
|
|
|
|
isNeedCustomerFilter: true);
|
|
|
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateAppointmentStatus(Map<String, dynamic> map,
|
|
|
|
updateAppointmentStatus(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
|
|
|
|
{bool isNeedToRebuild = false}) async {
|
|
|
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
MResponse genericRespModel =
|
|
|
|
MResponse genericRespModel = await appointmentRepo.updateAppointmentStatus(map);
|
|
|
|
await appointmentRepo.updateAppointmentStatus(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
Utils.showToast(LocaleKeys.appointmentStatusUpdated.tr());
|
|
|
|
Utils.showToast(LocaleKeys.appointmentStatusUpdated.tr());
|
|
|
|
@ -446,12 +407,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateAppointmentPaymentStatus(Map<String, dynamic> map,
|
|
|
|
updateAppointmentPaymentStatus(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
|
|
|
|
{bool isNeedToRebuild = false}) async {
|
|
|
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
MResponse genericRespModel =
|
|
|
|
MResponse genericRespModel = await appointmentRepo.updateAppointmentPaymentStatus(map);
|
|
|
|
await appointmentRepo.updateAppointmentPaymentStatus(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
Utils.showToast(LocaleKeys.paymentStatusUpdated.tr());
|
|
|
|
Utils.showToast(LocaleKeys.paymentStatusUpdated.tr());
|
|
|
|
@ -463,11 +422,9 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<MResponse> createMergeAppointment(Map<String, dynamic> map,
|
|
|
|
Future<MResponse> createMergeAppointment(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
|
|
|
|
{bool isNeedToRebuild = false}) async {
|
|
|
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
MResponse genericRespModel =
|
|
|
|
MResponse genericRespModel = await appointmentRepo.createMergeAppointment(map);
|
|
|
|
await appointmentRepo.createMergeAppointment(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return genericRespModel;
|
|
|
|
return genericRespModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -475,16 +432,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
bool inNeedToEnableMergeButton = false;
|
|
|
|
bool inNeedToEnableMergeButton = false;
|
|
|
|
|
|
|
|
|
|
|
|
updateCheckBoxInMergeRequest(int currentIndex) {
|
|
|
|
updateCheckBoxInMergeRequest(int currentIndex) {
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected =
|
|
|
|
.customerAppointmentList![currentIndex]
|
|
|
|
!(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
|
|
|
|
.isSelected = !(myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
|
|
|
.customerAppointmentList?[currentIndex]
|
|
|
|
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []);
|
|
|
|
.isSelected ??
|
|
|
|
|
|
|
|
false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
|
|
|
.customerAppointmentList ??
|
|
|
|
|
|
|
|
[]);
|
|
|
|
|
|
|
|
if (count > 1)
|
|
|
|
if (count > 1)
|
|
|
|
inNeedToEnableMergeButton = true;
|
|
|
|
inNeedToEnableMergeButton = true;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@ -493,59 +444,35 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int countSelected(List<AppointmentListModel> appointments) {
|
|
|
|
int countSelected(List<AppointmentListModel> appointments) {
|
|
|
|
return appointments
|
|
|
|
return appointments.where((appointment) => appointment.isSelected == true).toList().length;
|
|
|
|
.where((appointment) => appointment.isSelected == true)
|
|
|
|
|
|
|
|
.toList()
|
|
|
|
|
|
|
|
.length;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) {
|
|
|
|
updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) {
|
|
|
|
for (var element in serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
for (var element in serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList!) {
|
|
|
|
.customTimeDateSlotList!) {
|
|
|
|
|
|
|
|
element.date!.isSelected = false;
|
|
|
|
element.date!.isSelected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.isSelected = true;
|
|
|
|
.customTimeDateSlotList![dateIndex]
|
|
|
|
|
|
|
|
.date!
|
|
|
|
|
|
|
|
.isSelected = true;
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex = dateIndex;
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex = dateIndex;
|
|
|
|
final date = TimeSlotModel(
|
|
|
|
final date = TimeSlotModel(
|
|
|
|
date: serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
date: serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.date,
|
|
|
|
.customTimeDateSlotList![dateIndex]
|
|
|
|
slotId: serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.slotId,
|
|
|
|
.date!
|
|
|
|
|
|
|
|
.date,
|
|
|
|
|
|
|
|
slotId: serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
|
|
|
.customTimeDateSlotList![dateIndex]
|
|
|
|
|
|
|
|
.date!
|
|
|
|
|
|
|
|
.slotId,
|
|
|
|
|
|
|
|
isSelected: true,
|
|
|
|
isSelected: true,
|
|
|
|
slot: "",
|
|
|
|
slot: "",
|
|
|
|
);
|
|
|
|
);
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].selectedCustomTimeDateSlotModel = CustomTimeDateSlotModel(date: date);
|
|
|
|
.selectedCustomTimeDateSlotModel = CustomTimeDateSlotModel(date: date);
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateSelectedAppointmentSlotByDate({required int scheduleIndex, required int slotIndex}) {
|
|
|
|
updateSelectedAppointmentSlotByDate({required int scheduleIndex, required int slotIndex}) {
|
|
|
|
for (var element in serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
for (var element in serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList!) {
|
|
|
|
.customTimeDateSlotList!) {
|
|
|
|
|
|
|
|
for (var element in element.availableSlots!) {
|
|
|
|
for (var element in element.availableSlots!) {
|
|
|
|
element.isSelected = false;
|
|
|
|
element.isSelected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int index =
|
|
|
|
int index = serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex!;
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex!;
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![index].availableSlots![slotIndex].isSelected = true;
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].selectedCustomTimeDateSlotModel!.availableSlots = serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![index].availableSlots!;
|
|
|
|
.customTimeDateSlotList![index]
|
|
|
|
|
|
|
|
.availableSlots![slotIndex]
|
|
|
|
|
|
|
|
.isSelected = true;
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
|
|
|
.selectedCustomTimeDateSlotModel!
|
|
|
|
|
|
|
|
.availableSlots =
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
|
|
|
.customTimeDateSlotList![index]
|
|
|
|
|
|
|
|
.availableSlots!;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -559,8 +486,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
int selectedSubServicesCounter = 0;
|
|
|
|
int selectedSubServicesCounter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
onItemUpdateOrSelected(int index, bool selected, int itemId) {
|
|
|
|
onItemUpdateOrSelected(int index, bool selected, int itemId) {
|
|
|
|
int serviceIndex = servicesInCurrentAppointment.indexWhere(
|
|
|
|
int serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
(element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
|
|
|
// print("servicesInCurrentAppointment: ${servicesInCurrentAppointment.length}");
|
|
|
|
// print("servicesInCurrentAppointment: ${servicesInCurrentAppointment.length}");
|
|
|
|
// if (serviceIndex == -1) {
|
|
|
|
// if (serviceIndex == -1) {
|
|
|
|
// return;
|
|
|
|
// return;
|
|
|
|
@ -575,28 +501,19 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
allSelectedItemsInAppointments.add(serviceItemsFromApi[index]);
|
|
|
|
allSelectedItemsInAppointments.add(serviceItemsFromApi[index]);
|
|
|
|
for (var element in allSelectedItemsInAppointments) {
|
|
|
|
for (var element in allSelectedItemsInAppointments) {
|
|
|
|
if (!ifItemAlreadySelected(element.id!)) {
|
|
|
|
if (!ifItemAlreadySelected(element.id!)) {
|
|
|
|
servicesInCurrentAppointment[serviceIndex]
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]);
|
|
|
|
.serviceItems!
|
|
|
|
|
|
|
|
.add(serviceItemsFromApi[index]);
|
|
|
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
servicesInCurrentAppointment[serviceIndex]
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
.currentTotalServicePrice +
|
|
|
|
|
|
|
|
double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!selected) {
|
|
|
|
if (!selected) {
|
|
|
|
selectedSubServicesCounter = selectedSubServicesCounter - 1;
|
|
|
|
selectedSubServicesCounter = selectedSubServicesCounter - 1;
|
|
|
|
currentServiceSelection!.serviceItems!
|
|
|
|
currentServiceSelection!.serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
.removeWhere((element) => element.id == itemId);
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId);
|
|
|
|
allSelectedItemsInAppointments
|
|
|
|
|
|
|
|
.removeWhere((element) => element.id == itemId);
|
|
|
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice -
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
servicesInCurrentAppointment[serviceIndex]
|
|
|
|
|
|
|
|
.serviceItems!
|
|
|
|
|
|
|
|
.removeWhere((element) => element.id == itemId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -608,8 +525,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
branchesFilterOptions[index].isSelected = true;
|
|
|
|
branchesFilterOptions[index].isSelected = true;
|
|
|
|
|
|
|
|
|
|
|
|
await getBranchesBasedOnCategoryFilters(
|
|
|
|
await getBranchesBasedOnCategoryFilters(categoryId: branchesFilterOptions[index].id);
|
|
|
|
categoryId: branchesFilterOptions[index].id);
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -628,8 +544,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
String pickHomeLocationError = "";
|
|
|
|
String pickHomeLocationError = "";
|
|
|
|
String selectSubServicesError = "";
|
|
|
|
String selectSubServicesError = "";
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel branchSelectedServiceId =
|
|
|
|
SelectionModel branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updatePickHomeLocationError(String value) {
|
|
|
|
void updatePickHomeLocationError(String value) {
|
|
|
|
pickHomeLocationError = value;
|
|
|
|
pickHomeLocationError = value;
|
|
|
|
@ -688,9 +603,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
double totalKms = 15.3;
|
|
|
|
double totalKms = 15.3;
|
|
|
|
return InfoBottomSheet(
|
|
|
|
return InfoBottomSheet(
|
|
|
|
title: LocaleKeys.chargesBreakdown
|
|
|
|
title: LocaleKeys.chargesBreakdown.tr().toText(fontSize: 24, isBold: true),
|
|
|
|
.tr()
|
|
|
|
|
|
|
|
.toText(fontSize: 24, isBold: true),
|
|
|
|
|
|
|
|
description: Column(
|
|
|
|
description: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
@ -698,16 +611,11 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
children: List.generate(
|
|
|
|
children: List.generate(
|
|
|
|
selectedService.serviceItems!.length,
|
|
|
|
selectedService.serviceItems!.length,
|
|
|
|
(index) =>
|
|
|
|
(index) => Row(
|
|
|
|
Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
|
|
fontSize: 12,
|
|
|
|
"${selectedService.serviceItems![index].price} SAR".toText(fontSize: 12, isBold: true),
|
|
|
|
color: MyColors.lightTextColor,
|
|
|
|
|
|
|
|
isBold: true),
|
|
|
|
|
|
|
|
"${selectedService.serviceItems![index].price} SAR"
|
|
|
|
|
|
|
|
.toText(fontSize: 12, isBold: true),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -715,32 +623,24 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
"${selectedService.currentTotalServicePrice} SAR"
|
|
|
|
"${selectedService.currentTotalServicePrice} SAR".toText(fontSize: 16, isBold: true),
|
|
|
|
.toText(fontSize: 16, isBold: true),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (selectedService.isHomeSelected) ...[
|
|
|
|
if (selectedService.isHomeSelected) ...[
|
|
|
|
20.height,
|
|
|
|
20.height,
|
|
|
|
LocaleKeys.homeLocation
|
|
|
|
LocaleKeys.homeLocation.tr().toText(fontSize: 16, isBold: true),
|
|
|
|
.tr()
|
|
|
|
|
|
|
|
.toText(fontSize: 16, isBold: true),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
"${totalKms}km ".toText(
|
|
|
|
"${totalKms}km ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
|
|
fontSize: 12,
|
|
|
|
"${selectedService.rangePricePerKm} x $totalKms".toText(fontSize: 12, isBold: true),
|
|
|
|
color: MyColors.lightTextColor,
|
|
|
|
|
|
|
|
isBold: true),
|
|
|
|
|
|
|
|
"${selectedService.rangePricePerKm} x $totalKms"
|
|
|
|
|
|
|
|
.toText(fontSize: 12, isBold: true),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
"${selectedService.rangePricePerKm ?? 0 * totalKms} SAR"
|
|
|
|
"${selectedService.rangePricePerKm ?? 0 * totalKms} SAR".toText(fontSize: 16, isBold: true),
|
|
|
|
.toText(fontSize: 16, isBold: true),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -748,9 +648,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
LocaleKeys.totalAmount
|
|
|
|
LocaleKeys.totalAmount.tr().toText(fontSize: 16, isBold: true),
|
|
|
|
.tr()
|
|
|
|
|
|
|
|
.toText(fontSize: 16, isBold: true),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
@ -759,13 +657,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
: "${selectedService.currentTotalServicePrice}")
|
|
|
|
: "${selectedService.currentTotalServicePrice}")
|
|
|
|
.toText(fontSize: 29, isBold: true),
|
|
|
|
.toText(fontSize: 29, isBold: true),
|
|
|
|
2.width,
|
|
|
|
2.width,
|
|
|
|
LocaleKeys.sar
|
|
|
|
LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
|
|
|
|
.tr()
|
|
|
|
|
|
|
|
.toText(
|
|
|
|
|
|
|
|
color: MyColors.lightTextColor,
|
|
|
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
|
|
|
isBold: true)
|
|
|
|
|
|
|
|
.paddingOnly(bottom: 5),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -785,8 +677,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
isValidated = false;
|
|
|
|
isValidated = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (schedule.selectedCustomTimeDateSlotModel!.date == null ||
|
|
|
|
if (schedule.selectedCustomTimeDateSlotModel!.date == null || !schedule.selectedCustomTimeDateSlotModel!.date!.isSelected) {
|
|
|
|
!schedule.selectedCustomTimeDateSlotModel!.date!.isSelected) {
|
|
|
|
|
|
|
|
isValidated = false;
|
|
|
|
isValidated = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -794,9 +685,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
isValidated = false;
|
|
|
|
isValidated = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
TimeSlotModel slot = schedule
|
|
|
|
TimeSlotModel slot = schedule.selectedCustomTimeDateSlotModel!.availableSlots!.firstWhere((element) => element.isSelected);
|
|
|
|
.selectedCustomTimeDateSlotModel!.availableSlots!
|
|
|
|
|
|
|
|
.firstWhere((element) => element.isSelected);
|
|
|
|
|
|
|
|
if (slot.date.isNotEmpty) {
|
|
|
|
if (slot.date.isNotEmpty) {
|
|
|
|
isValidated = true;
|
|
|
|
isValidated = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@ -824,8 +713,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList =
|
|
|
|
serviceAppointmentScheduleList = await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
|
|
|
|
serviceItemIdsForHome: serviceItemIdsForHome,
|
|
|
|
serviceItemIdsForHome: serviceItemIdsForHome,
|
|
|
|
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
|
|
|
|
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -838,21 +726,17 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
totalAmount = 0.0;
|
|
|
|
totalAmount = 0.0;
|
|
|
|
amountToPayForAppointment = 0.0;
|
|
|
|
amountToPayForAppointment = 0.0;
|
|
|
|
for (var schedule in serviceAppointmentScheduleList) {
|
|
|
|
for (var schedule in serviceAppointmentScheduleList) {
|
|
|
|
amountToPayForAppointment =
|
|
|
|
amountToPayForAppointment = amountToPayForAppointment + (schedule.amountToPay ?? 0.0);
|
|
|
|
amountToPayForAppointment + (schedule.amountToPay ?? 0.0);
|
|
|
|
|
|
|
|
totalAmount = totalAmount + (schedule.amountTotal ?? 0.0);
|
|
|
|
totalAmount = totalAmount + (schedule.amountTotal ?? 0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.bookAppointmenSchedulesView,
|
|
|
|
navigateWithName(context, AppRoutes.bookAppointmenSchedulesView, arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 1, appointmentId: 0)); // 1 For Creating an Appointment
|
|
|
|
arguments: ScreenArgumentsForAppointmentDetailPage(
|
|
|
|
|
|
|
|
routeFlag: 1, appointmentId: 0)); // 1 For Creating an Appointment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onRescheduleAppointmentPressed({required BuildContext context,
|
|
|
|
Future<void> onRescheduleAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async {
|
|
|
|
required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
|
|
|
|
|
|
|
List<String> serviceItemIdsForHome = [];
|
|
|
|
List<String> serviceItemIdsForHome = [];
|
|
|
|
@ -869,8 +753,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList =
|
|
|
|
serviceAppointmentScheduleList = await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
|
|
|
|
serviceItemIdsForHome: serviceItemIdsForHome,
|
|
|
|
serviceItemIdsForHome: serviceItemIdsForHome,
|
|
|
|
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
|
|
|
|
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -885,35 +768,29 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
navigateWithName(
|
|
|
|
navigateWithName(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
AppRoutes.bookAppointmenSchedulesView,
|
|
|
|
AppRoutes.bookAppointmenSchedulesView,
|
|
|
|
arguments: ScreenArgumentsForAppointmentDetailPage(
|
|
|
|
arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 2, appointmentId: appointmentListModel.id ?? 0),
|
|
|
|
routeFlag: 2, appointmentId: appointmentListModel.id ?? 0),
|
|
|
|
|
|
|
|
); // 2 For Rescheduling an Appointment
|
|
|
|
); // 2 For Rescheduling an Appointment
|
|
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onRescheduleAppointmentConfirmPressed({required BuildContext context,
|
|
|
|
Future<void> onRescheduleAppointmentConfirmPressed({required BuildContext context, required int appointmentId, required int selectedSlotId}) async {
|
|
|
|
required int appointmentId,
|
|
|
|
|
|
|
|
required int selectedSlotId}) async {
|
|
|
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GenericRespModel genericRespModel =
|
|
|
|
GenericRespModel genericRespModel = await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
|
|
|
|
serviceAppointmentID: appointmentId,
|
|
|
|
serviceAppointmentID: appointmentId,
|
|
|
|
serviceSlotID: selectedSlotId,
|
|
|
|
serviceSlotID: selectedSlotId,
|
|
|
|
appointmentScheduleAction: 1, // 1 for Reschedule and 2 for Cancel
|
|
|
|
appointmentScheduleAction: 1, // 1 for Reschedule and 2 for Cancel
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 2 ||
|
|
|
|
if (genericRespModel.messageStatus == 2 || genericRespModel.data == null) {
|
|
|
|
genericRespModel.data == null) {
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
context.read<DashboardVmCustomer>().onNavbarTapped(1);
|
|
|
|
context.read<DashboardVmCustomer>().onNavbarTapped(1);
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.cancelled);
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.cancelled);
|
|
|
|
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
Utils.showToast("${genericRespModel.message.toString()}");
|
|
|
|
getMyAppointments();
|
|
|
|
getMyAppointments();
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
@ -950,13 +827,9 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
Category category = await branchRepo.fetchBranchCategory();
|
|
|
|
Category category = await branchRepo.fetchBranchCategory();
|
|
|
|
category.data?.forEach((element) {
|
|
|
|
category.data?.forEach((element) {
|
|
|
|
branchesFilterOptions.add(FilterListModel(
|
|
|
|
branchesFilterOptions.add(FilterListModel(id: element.id ?? 0, isSelected: false, title: element.categoryName ?? "N/A"));
|
|
|
|
id: element.id ?? 0,
|
|
|
|
|
|
|
|
isSelected: false,
|
|
|
|
|
|
|
|
title: element.categoryName ?? "N/A"));
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
branchesFilterOptions.insert(
|
|
|
|
branchesFilterOptions.insert(0, FilterListModel(id: 0, isSelected: true, title: "All Branches"));
|
|
|
|
0, FilterListModel(id: 0, isSelected: true, title: "All Branches"));
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -966,10 +839,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
|
|
|
|
|
|
|
if (isFromRefresh) {
|
|
|
|
if (isFromRefresh) {
|
|
|
|
var selectedBranch =
|
|
|
|
var selectedBranch = branchesFilterOptions.firstWhere((element) => element.isSelected);
|
|
|
|
branchesFilterOptions.firstWhere((element) => element.isSelected);
|
|
|
|
nearbyBranches = await branchRepo.getBranchesByFilters(categoryIdsList: [selectedBranch.id]);
|
|
|
|
nearbyBranches = await branchRepo
|
|
|
|
|
|
|
|
.getBranchesByFilters(categoryIdsList: [selectedBranch.id]);
|
|
|
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -980,16 +851,14 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
void getBranchCategories() async {
|
|
|
|
void getBranchCategories() async {
|
|
|
|
for (var value in selectedBranchModel!.branchServices!) {
|
|
|
|
for (var value in selectedBranchModel!.branchServices!) {
|
|
|
|
if (!isCategoryAlreadyPresent(value.categoryId!)) {
|
|
|
|
if (!isCategoryAlreadyPresent(value.categoryId!)) {
|
|
|
|
branchCategories
|
|
|
|
branchCategories.add(DropValue(value.categoryId!, value.categoryName!, ""));
|
|
|
|
.add(DropValue(value.categoryId!, value.categoryName!, ""));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getBranchServices({required int categoryId}) async {
|
|
|
|
getBranchServices({required int categoryId}) async {
|
|
|
|
branchSelectedServiceId =
|
|
|
|
branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
isHomeTapped = false;
|
|
|
|
isHomeTapped = false;
|
|
|
|
pickedHomeLocation = "";
|
|
|
|
pickedHomeLocation = "";
|
|
|
|
pickHomeLocationError = "";
|
|
|
|
pickHomeLocationError = "";
|
|
|
|
@ -1002,16 +871,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ServiceModel> getFilteredBranchServices({required int categoryId}) {
|
|
|
|
List<ServiceModel> getFilteredBranchServices({required int categoryId}) {
|
|
|
|
List<ServiceModel> filteredServices = selectedBranchModel!.branchServices!
|
|
|
|
List<ServiceModel> filteredServices = selectedBranchModel!.branchServices!.where((element) => element.categoryId == categoryId).toList();
|
|
|
|
.where((element) => element.categoryId == categoryId)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
return filteredServices;
|
|
|
|
return filteredServices;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getBranchAndServices(int providerId) async {
|
|
|
|
getBranchAndServices(int providerId) async {
|
|
|
|
providerProfileModel = null;
|
|
|
|
providerProfileModel = null;
|
|
|
|
providerProfileModel =
|
|
|
|
providerProfileModel = await branchRepo.getBranchAndServicesByProviderId(providerId);
|
|
|
|
await branchRepo.getBranchAndServicesByProviderId(providerId);
|
|
|
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1068,16 +934,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel branchFilterSelectedProviderId =
|
|
|
|
SelectionModel branchFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateBranchFilterSelectedProviderId(SelectionModel id,
|
|
|
|
void updateBranchFilterSelectedProviderId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
|
|
|
if (isForSearch) {
|
|
|
|
if (isForSearch) {
|
|
|
|
DropValue providerDrop = providersDropList
|
|
|
|
DropValue providerDrop = providersDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
if (!ifAlreadyExist(list: branchFilterProviderSearchHistory, value: providerDrop)) {
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
|
|
|
list: branchFilterProviderSearchHistory, value: providerDrop)) {
|
|
|
|
|
|
|
|
addBranchFilterProviderSearchHistory(value: providerDrop);
|
|
|
|
addBranchFilterProviderSearchHistory(value: providerDrop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1111,16 +973,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel branchFilterSelectedCategoryId =
|
|
|
|
SelectionModel branchFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateBranchFilterSelectedCategoryId(SelectionModel id,
|
|
|
|
void updateBranchFilterSelectedCategoryId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
|
|
|
if (isForSearch) {
|
|
|
|
if (isForSearch) {
|
|
|
|
DropValue categoryDrop =
|
|
|
|
DropValue categoryDrop = categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
if (!ifAlreadyExist(list: branchFilterCategorySearchHistory, value: categoryDrop)) {
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
|
|
|
list: branchFilterCategorySearchHistory, value: categoryDrop)) {
|
|
|
|
|
|
|
|
addBranchFilterCategorySearchHistory(value: categoryDrop);
|
|
|
|
addBranchFilterCategorySearchHistory(value: categoryDrop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1154,16 +1012,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel branchFilterSelectedServiceId =
|
|
|
|
SelectionModel branchFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateBranchFilterSelectedServiceId(SelectionModel id,
|
|
|
|
void updateBranchFilterSelectedServiceId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
|
|
|
if (isForSearch) {
|
|
|
|
if (isForSearch) {
|
|
|
|
DropValue serviceDrop =
|
|
|
|
DropValue serviceDrop = servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
if (!ifAlreadyExist(list: branchFilterServicesSearchHistory, value: serviceDrop)) {
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
|
|
|
list: branchFilterServicesSearchHistory, value: serviceDrop)) {
|
|
|
|
|
|
|
|
addBranchFilterServicesSearchHistory(value: serviceDrop);
|
|
|
|
addBranchFilterServicesSearchHistory(value: serviceDrop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
@ -1204,8 +1058,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
|
|
providersDropList.clear();
|
|
|
|
providersDropList.clear();
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
List<ProviderBasicDataModel> providers =
|
|
|
|
List<ProviderBasicDataModel> providers = await branchRepo.getAllProvidersWitheBasicData();
|
|
|
|
await branchRepo.getAllProvidersWitheBasicData();
|
|
|
|
|
|
|
|
for (var element in providers) {
|
|
|
|
for (var element in providers) {
|
|
|
|
providersDropList.add(
|
|
|
|
providersDropList.add(
|
|
|
|
DropValue(element.id ?? 0, element.providerName ?? "N/A", ""),
|
|
|
|
DropValue(element.id ?? 0, element.providerName ?? "N/A", ""),
|
|
|
|
@ -1239,8 +1092,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
if (servicesDropList.isNotEmpty) return;
|
|
|
|
if (servicesDropList.isNotEmpty) return;
|
|
|
|
servicesDropList.clear();
|
|
|
|
servicesDropList.clear();
|
|
|
|
setState(ViewState.busy);
|
|
|
|
setState(ViewState.busy);
|
|
|
|
Services services = await branchRepo.fetchServicesByCategoryId(
|
|
|
|
Services services = await branchRepo.fetchServicesByCategoryId(serviceCategoryId: -1); // to get all services
|
|
|
|
serviceCategoryId: -1); // to get all services
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var element in services.data!) {
|
|
|
|
for (var element in services.data!) {
|
|
|
|
servicesDropList.add(
|
|
|
|
servicesDropList.add(
|
|
|
|
@ -1273,12 +1125,9 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void clearBranchFilterSelections() {
|
|
|
|
void clearBranchFilterSelections() {
|
|
|
|
branchFilterSelectedProviderId =
|
|
|
|
branchFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
branchFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
branchFilterSelectedCategoryId =
|
|
|
|
branchFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
branchFilterSelectedServiceId =
|
|
|
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getBranchesBasedOnFilters() async {
|
|
|
|
Future<void> getBranchesBasedOnFilters() async {
|
|
|
|
@ -1322,8 +1171,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(ViewState.busy);
|
|
|
|
setState(ViewState.busy);
|
|
|
|
nearbyBranches.clear();
|
|
|
|
nearbyBranches.clear();
|
|
|
|
nearbyBranches =
|
|
|
|
nearbyBranches = await branchRepo.getBranchesByFilters(categoryIdsList: [categoryId]);
|
|
|
|
await branchRepo.getBranchesByFilters(categoryIdsList: [categoryId]);
|
|
|
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1334,11 +1182,9 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Future<void> fetchAllBranchesBySelectedProviderId({required List<int> providersIdsList}) async {
|
|
|
|
Future<void> fetchAllBranchesBySelectedProviderId({required List<int> providersIdsList}) async {
|
|
|
|
branchesDropList.clear();
|
|
|
|
branchesDropList.clear();
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
List<BranchDetailModel> providers = await branchRepo.getBranchesByFilters(
|
|
|
|
List<BranchDetailModel> providers = await branchRepo.getBranchesByFilters(providerIdsList: providersIdsList);
|
|
|
|
providerIdsList: providersIdsList);
|
|
|
|
|
|
|
|
for (var element in providers) {
|
|
|
|
for (var element in providers) {
|
|
|
|
branchesDropList
|
|
|
|
branchesDropList.add(DropValue(element.id ?? 0, element.branchName ?? "N/A", ""));
|
|
|
|
.add(DropValue(element.id ?? 0, element.branchName ?? "N/A", ""));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
|
|
|
|
|
|
|
@ -1373,8 +1219,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
for (var element in appointmentFilterProviderSearchHistory) {
|
|
|
|
for (var element in appointmentFilterProviderSearchHistory) {
|
|
|
|
providerIdsSelected.add(element.id);
|
|
|
|
providerIdsSelected.add(element.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fetchAllBranchesBySelectedProviderId(
|
|
|
|
fetchAllBranchesBySelectedProviderId(providersIdsList: providerIdsSelected);
|
|
|
|
providersIdsList: providerIdsSelected);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (appointmentFilterProviderSearchHistory.isEmpty) {
|
|
|
|
if (appointmentFilterProviderSearchHistory.isEmpty) {
|
|
|
|
@ -1397,16 +1242,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedProviderId =
|
|
|
|
SelectionModel appointmentFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedProviderId(SelectionModel id,
|
|
|
|
void updateAppointmentFilterSelectedProviderId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
|
|
|
if (isForSearch) {
|
|
|
|
if (isForSearch) {
|
|
|
|
DropValue providerDrop = providersDropList
|
|
|
|
DropValue providerDrop = providersDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
if (!ifAlreadyExist(list: appointmentFilterProviderSearchHistory, value: providerDrop)) {
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
|
|
|
list: appointmentFilterProviderSearchHistory, value: providerDrop)) {
|
|
|
|
|
|
|
|
addAppointmentFilterProviderSearchHistory(value: providerDrop);
|
|
|
|
addAppointmentFilterProviderSearchHistory(value: providerDrop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1440,16 +1281,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedBranchId =
|
|
|
|
SelectionModel appointmentFilterSelectedBranchId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedBranchId(SelectionModel id,
|
|
|
|
void updateAppointmentFilterSelectedBranchId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
|
|
|
if (isForSearch) {
|
|
|
|
if (isForSearch) {
|
|
|
|
DropValue branchesDrop =
|
|
|
|
DropValue branchesDrop = branchesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
branchesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
if (!ifAlreadyExist(list: appointmentFilterBranchSearchHistory, value: branchesDrop)) {
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
|
|
|
list: appointmentFilterBranchSearchHistory, value: branchesDrop)) {
|
|
|
|
|
|
|
|
addAppointmentFilterBranchSearchHistory(value: branchesDrop);
|
|
|
|
addAppointmentFilterBranchSearchHistory(value: branchesDrop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1483,16 +1320,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedCategoryId =
|
|
|
|
SelectionModel appointmentFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedCategoryId(SelectionModel id,
|
|
|
|
void updateAppointmentFilterSelectedCategoryId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
|
|
|
if (isForSearch) {
|
|
|
|
if (isForSearch) {
|
|
|
|
DropValue categoryDrop =
|
|
|
|
DropValue categoryDrop = categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
if (!ifAlreadyExist(list: appointmentFilterCategorySearchHistory, value: categoryDrop)) {
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
|
|
|
list: appointmentFilterCategorySearchHistory, value: categoryDrop)) {
|
|
|
|
|
|
|
|
addAppointmentFilterCategorySearchHistory(value: categoryDrop);
|
|
|
|
addAppointmentFilterCategorySearchHistory(value: categoryDrop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1524,16 +1357,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedServiceId =
|
|
|
|
SelectionModel appointmentFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedServiceId(SelectionModel id,
|
|
|
|
void updateAppointmentFilterSelectedServiceId(SelectionModel id, {bool isForSearch = false}) async {
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
|
|
|
if (isForSearch) {
|
|
|
|
if (isForSearch) {
|
|
|
|
DropValue servicesDrop =
|
|
|
|
DropValue servicesDrop = servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
if (!ifAlreadyExist(list: appointmentFilterServicesSearchHistory, value: servicesDrop)) {
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
|
|
|
list: appointmentFilterServicesSearchHistory, value: servicesDrop)) {
|
|
|
|
|
|
|
|
addAppointmentFilterServicesSearchHistory(value: servicesDrop);
|
|
|
|
addAppointmentFilterServicesSearchHistory(value: servicesDrop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1542,14 +1371,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void clearAppointmentFilterSelections() {
|
|
|
|
void clearAppointmentFilterSelections() {
|
|
|
|
appointmentFilterSelectedProviderId =
|
|
|
|
appointmentFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
appointmentFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
appointmentFilterSelectedCategoryId =
|
|
|
|
appointmentFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
appointmentFilterSelectedBranchId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
appointmentFilterSelectedServiceId =
|
|
|
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
appointmentFilterSelectedBranchId =
|
|
|
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void clearAppointmentFilters() {
|
|
|
|
void clearAppointmentFilters() {
|
|
|
|
@ -1590,15 +1415,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
myAppointments =
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForCustomersByFilters(
|
|
|
|
await appointmentRepo.getMyAppointmentsForCustomersByFilters(
|
|
|
|
|
|
|
|
providerIdsList: providersIdsList.isNotEmpty ? providersIdsList : null,
|
|
|
|
providerIdsList: providersIdsList.isNotEmpty ? providersIdsList : null,
|
|
|
|
categoryIdsList: categoryIdsList.isNotEmpty ? categoryIdsList : null,
|
|
|
|
categoryIdsList: categoryIdsList.isNotEmpty ? categoryIdsList : null,
|
|
|
|
serviceIdsList: servicesIdsList.isNotEmpty ? servicesIdsList : null,
|
|
|
|
serviceIdsList: servicesIdsList.isNotEmpty ? servicesIdsList : null,
|
|
|
|
branchIdsList: branchesIdsList.isNotEmpty ? branchesIdsList : null,
|
|
|
|
branchIdsList: branchesIdsList.isNotEmpty ? branchesIdsList : null,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|