|
|
|
@ -239,7 +239,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.removeAt(index);
|
|
|
|
|
notifyListeners();
|
|
|
|
@ -360,7 +362,8 @@ 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();
|
|
|
|
@ -431,7 +434,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
bool inNeedToEnableMergeButton = false;
|
|
|
|
|
|
|
|
|
|
updateCheckBoxInMergeRequest(int currentIndex) {
|
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
|
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected =
|
|
|
|
|
!(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
|
|
|
|
|
|
|
|
|
|
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []);
|
|
|
|
|
if (count > 1)
|
|
|
|
@ -442,7 +446,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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}) {
|
|
|
|
@ -500,7 +507,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
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");
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -508,7 +516,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
selectedSubServicesCounter = selectedSubServicesCounter - 1;
|
|
|
|
|
currentServiceSelection!.serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId);
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
@ -608,7 +617,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
Column(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
selectedService.serviceItems!.length,
|
|
|
|
|
(index) => Row(
|
|
|
|
|
(index) =>
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
|
|
@ -649,7 +659,8 @@ 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),
|
|
|
|
@ -1491,4 +1502,11 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isShowMergeButton() {
|
|
|
|
|
return myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
.customerAppointmentList!
|
|
|
|
|
.every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|