From 693083df6f7ece69b3cfd31c00725500d3dcc2d2 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Mon, 16 Dec 2024 10:24:28 +0300 Subject: [PATCH] Minor Fixes --- lib/view_models/appointments_view_model.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/view_models/appointments_view_model.dart b/lib/view_models/appointments_view_model.dart index 83bfa2a..82770d0 100644 --- a/lib/view_models/appointments_view_model.dart +++ b/lib/view_models/appointments_view_model.dart @@ -372,28 +372,28 @@ class AppointmentsVM extends BaseVM { if (appointmentStatusEnum == AppointmentStatusEnum.allAppointments) { myFilteredAppointments = myAppointments; - if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(); + if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(myFilteredAppointments); notifyListeners(); return; } myFilteredAppointments = myAppointments.where((element) => element.appointmentStatusID! == appointmentStatusEnum.getIdFromAppointmentStatusEnum()).toList(); - if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(); + if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(myFilteredAppointments); notifyListeners(); } - findAppointmentsBasedOnCustomers() { + findAppointmentsBasedOnCustomers(List appointments) { // Use a Set to ensure uniqueness of customerIDs Set uniqueCustomerIDs = {}; // Extract unique customerIDs - for (var item in myFilteredAppointments) { + for (var item in appointments) { uniqueCustomerIDs.add(item.customerID ?? 0); } // Create a list of CustomerData instances myFilteredAppointments2 = uniqueCustomerIDs.map((id) { - List list = myFilteredAppointments.where((item) => item.customerID == id).toList(); + List list = appointments.where((item) => item.customerID == id).toList(); list.sort((a, b) => DateHelper.parseStringToDate(DateHelper.formatDateT(b.appointmentDate!)) .millisecondsSinceEpoch .compareTo(DateHelper.parseStringToDate(DateHelper.formatDateT(a.appointmentDate!)).millisecondsSinceEpoch)); @@ -1920,8 +1920,8 @@ class AppointmentsVM extends BaseVM { customerPhonesList: customerPhonesList, deliveryTypeIdsList: customerDeliveryTypesList, serviceProviderServiceIdsList: servicesIdsList, - fromDate: selectedDateForAppointments, - toDate: selectedDateForAppointments); + fromDate: '', + toDate: ''); log(" myFilteredAppointments : ${myFilteredAppointments.length}"); applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true);