|
|
|
|
@ -49,7 +49,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
AppointmentsVM({required this.commonServices, required this.appointmentRepo, required this.commonRepo, required this.branchRepo});
|
|
|
|
|
|
|
|
|
|
bool isUpcommingEnabled = true;
|
|
|
|
|
bool isUpcomingEnabled = true;
|
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
|
int selectedBranch = 0;
|
|
|
|
|
int selectedAppointmentIndex = 0;
|
|
|
|
|
@ -229,10 +229,9 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeServiceInCurrentAppointment(int index) {
|
|
|
|
|
int serviceId = servicesInCurrentAppointment
|
|
|
|
|
.elementAt(index)
|
|
|
|
|
.serviceProviderServiceId ?? -1;
|
|
|
|
|
int serviceId = servicesInCurrentAppointment.elementAt(index).serviceProviderServiceId ?? -1;
|
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.serviceProviderServiceId == serviceId);
|
|
|
|
|
servicesInCurrentAppointment[index].serviceItems!.clear();
|
|
|
|
|
servicesInCurrentAppointment.removeAt(index);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
@ -256,7 +255,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
Future<void> populateAppointmentsFilterList() async {
|
|
|
|
|
if (appointmentsFilterOptions.isNotEmpty) return;
|
|
|
|
|
|
|
|
|
|
myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: 13); // 13 is to get Appointments Filter Enums
|
|
|
|
|
myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: AppEnums.appointmentsFilterEnumId); // 13 is to get Appointments Filter Enums
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < myAppointmentsEnum.length; i++) {
|
|
|
|
|
appointmentsFilterOptions.add(FilterListModel(title: myAppointmentsEnum[i].enumValueStr, isSelected: false, id: myAppointmentsEnum[i].enumValue));
|
|
|
|
|
@ -352,8 +351,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
|
// myFilteredAppointments = myAppointments;
|
|
|
|
|
myUpComingAppointments =
|
|
|
|
|
myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList();
|
|
|
|
|
myUpComingAppointments = myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList();
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -414,6 +412,11 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isShowMergeButton() {
|
|
|
|
|
return myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList!.every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed) &&
|
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList!.length > 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<GenericRespModel> createMergeAppointment(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
GenericRespModel genericRespModel = await appointmentRepo.createMergeAppointment(map);
|
|
|
|
|
@ -423,23 +426,20 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
bool inNeedToEnableMergeButton = false;
|
|
|
|
|
|
|
|
|
|
updateCheckBoxInMergeRequest(int currentIndex) {
|
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected =
|
|
|
|
|
!(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
|
|
|
|
|
void updateCheckBoxInMergeRequest(int currentIndex) {
|
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
|
|
|
|
|
|
|
|
|
|
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []);
|
|
|
|
|
if (count > 1)
|
|
|
|
|
if (count > 1) {
|
|
|
|
|
inNeedToEnableMergeButton = true;
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
inNeedToEnableMergeButton = false;
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int countSelected(List<AppointmentListModel> appointments) {
|
|
|
|
|
return appointments
|
|
|
|
|
.where((appointment) => appointment.isSelected == true)
|
|
|
|
|
.toList()
|
|
|
|
|
.length;
|
|
|
|
|
return appointments.where((appointment) => appointment.isSelected == true).toList().length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) {
|
|
|
|
|
@ -481,10 +481,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
int selectedSubServicesCounter = 0;
|
|
|
|
|
|
|
|
|
|
void onItemUpdateOrSelected(int index, bool selected, int itemId) {
|
|
|
|
|
int serviceIndex = 0;
|
|
|
|
|
if (servicesInCurrentAppointment.isNotEmpty) {
|
|
|
|
|
serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
}
|
|
|
|
|
int serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
|
|
|
|
|
log("index: $index");
|
|
|
|
|
log("selected: $selected");
|
|
|
|
|
@ -500,9 +497,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
allSelectedItemsInAppointments.add(serviceItemsFromApi[index]);
|
|
|
|
|
for (var element in allSelectedItemsInAppointments) {
|
|
|
|
|
if (!ifItemAlreadySelected(element.id!)) {
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]);
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
if (serviceIndex != -1) {
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]);
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
@ -512,10 +510,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
log("currentServiceSelection!.serviceItems: ${currentServiceSelection!.serviceItems!.length}");
|
|
|
|
|
|
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId);
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
|
if (serviceIndex != -1) {
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -613,14 +613,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
Column(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
selectedService.serviceItems!.length,
|
|
|
|
|
(index) =>
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
|
|
|
"${selectedService.serviceItems![index].price} SAR".toText(fontSize: 12, isBold: true),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
(index) => Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
|
|
|
"${selectedService.serviceItems![index].price} SAR".toText(fontSize: 12, isBold: true),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
@ -655,8 +654,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
(selectedService.isHomeSelected ? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}" : "${selectedService
|
|
|
|
|
.currentTotalServicePrice}")
|
|
|
|
|
(selectedService.isHomeSelected ? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}" : "${selectedService.currentTotalServicePrice}")
|
|
|
|
|
.toText(fontSize: 29, isBold: true),
|
|
|
|
|
2.width,
|
|
|
|
|
LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
|
|
|
|
|
@ -803,7 +801,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BRANCHES RELATED
|
|
|
|
|
// BRANCHES RELATED
|
|
|
|
|
|
|
|
|
|
List<BranchDetailModel> nearbyBranches = [];
|
|
|
|
|
List<BranchDetailModel> myRecentBranches = [];
|
|
|
|
|
@ -912,7 +910,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Provider Filter
|
|
|
|
|
// Provider Filter
|
|
|
|
|
List<DropValue> branchFilterProviderSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeBranchFilterProviderSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
@ -951,7 +949,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Category Filter
|
|
|
|
|
// Category Filter
|
|
|
|
|
List<DropValue> branchFilterCategorySearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeBranchFilterCategorySearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
@ -990,7 +988,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Services Filter
|
|
|
|
|
// Services Filter
|
|
|
|
|
List<DropValue> branchFilterServicesSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeBranchFilterServicesSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
@ -1043,7 +1041,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rating filter
|
|
|
|
|
// Rating filter
|
|
|
|
|
|
|
|
|
|
double branchFilterByRating = 4.0;
|
|
|
|
|
|
|
|
|
|
@ -1080,10 +1078,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
DropValue(
|
|
|
|
|
element.id ?? 0,
|
|
|
|
|
((element.categoryName!.isEmpty
|
|
|
|
|
? "N/A"
|
|
|
|
|
: countryCode == "SA"
|
|
|
|
|
? element.categoryNameN
|
|
|
|
|
: element.categoryName) ??
|
|
|
|
|
? "N/A"
|
|
|
|
|
: countryCode == "SA"
|
|
|
|
|
? element.categoryNameN
|
|
|
|
|
: element.categoryName) ??
|
|
|
|
|
"N/A"),
|
|
|
|
|
""),
|
|
|
|
|
);
|
|
|
|
|
@ -1178,7 +1176,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Appointments Filter Screen
|
|
|
|
|
// Appointments Filter Screen
|
|
|
|
|
|
|
|
|
|
List<DropValue> branchesDropList = [];
|
|
|
|
|
|
|
|
|
|
@ -1207,7 +1205,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Provider Filter For Appointments
|
|
|
|
|
// Provider Filter For Appointments
|
|
|
|
|
List<DropValue> appointmentFilterProviderSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeAppointmentFilterProviderSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
@ -1258,7 +1256,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Branches Filter For Appointments
|
|
|
|
|
// Branches Filter For Appointments
|
|
|
|
|
|
|
|
|
|
List<DropValue> appointmentFilterBranchSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
@ -1297,7 +1295,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Category Filter For Appointments
|
|
|
|
|
// Category Filter For Appointments
|
|
|
|
|
|
|
|
|
|
List<DropValue> appointmentFilterCategorySearchHistory = [];
|
|
|
|
|
|
|
|
|
|
@ -1498,11 +1496,4 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isShowMergeButton() {
|
|
|
|
|
return myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
.customerAppointmentList!
|
|
|
|
|
.every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|