Minor Fixes

aamir_dev
Faiz Hashmi 11 months ago
parent b8e0304a94
commit 693083df6f

@ -372,28 +372,28 @@ class AppointmentsVM extends BaseVM {
if (appointmentStatusEnum == AppointmentStatusEnum.allAppointments) { if (appointmentStatusEnum == AppointmentStatusEnum.allAppointments) {
myFilteredAppointments = myAppointments; myFilteredAppointments = myAppointments;
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(); if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(myFilteredAppointments);
notifyListeners(); notifyListeners();
return; return;
} }
myFilteredAppointments = myAppointments.where((element) => element.appointmentStatusID! == appointmentStatusEnum.getIdFromAppointmentStatusEnum()).toList(); myFilteredAppointments = myAppointments.where((element) => element.appointmentStatusID! == appointmentStatusEnum.getIdFromAppointmentStatusEnum()).toList();
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(); if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(myFilteredAppointments);
notifyListeners(); notifyListeners();
} }
findAppointmentsBasedOnCustomers() { findAppointmentsBasedOnCustomers(List<AppointmentListModel> appointments) {
// Use a Set to ensure uniqueness of customerIDs // Use a Set to ensure uniqueness of customerIDs
Set<int> uniqueCustomerIDs = <int>{}; Set<int> uniqueCustomerIDs = <int>{};
// Extract unique customerIDs // Extract unique customerIDs
for (var item in myFilteredAppointments) { for (var item in appointments) {
uniqueCustomerIDs.add(item.customerID ?? 0); uniqueCustomerIDs.add(item.customerID ?? 0);
} }
// Create a list of CustomerData instances // Create a list of CustomerData instances
myFilteredAppointments2 = uniqueCustomerIDs.map((id) { myFilteredAppointments2 = uniqueCustomerIDs.map((id) {
List<AppointmentListModel> list = myFilteredAppointments.where((item) => item.customerID == id).toList(); List<AppointmentListModel> list = appointments.where((item) => item.customerID == id).toList();
list.sort((a, b) => DateHelper.parseStringToDate(DateHelper.formatDateT(b.appointmentDate!)) list.sort((a, b) => DateHelper.parseStringToDate(DateHelper.formatDateT(b.appointmentDate!))
.millisecondsSinceEpoch .millisecondsSinceEpoch
.compareTo(DateHelper.parseStringToDate(DateHelper.formatDateT(a.appointmentDate!)).millisecondsSinceEpoch)); .compareTo(DateHelper.parseStringToDate(DateHelper.formatDateT(a.appointmentDate!)).millisecondsSinceEpoch));
@ -1920,8 +1920,8 @@ class AppointmentsVM extends BaseVM {
customerPhonesList: customerPhonesList, customerPhonesList: customerPhonesList,
deliveryTypeIdsList: customerDeliveryTypesList, deliveryTypeIdsList: customerDeliveryTypesList,
serviceProviderServiceIdsList: servicesIdsList, serviceProviderServiceIdsList: servicesIdsList,
fromDate: selectedDateForAppointments, fromDate: '',
toDate: selectedDateForAppointments); toDate: '');
log(" myFilteredAppointments : ${myFilteredAppointments.length}"); log(" myFilteredAppointments : ${myFilteredAppointments.length}");
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true); applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true);

Loading…
Cancel
Save