diff --git a/lib/view_models/ad_view_model.dart b/lib/view_models/ad_view_model.dart index 3e757c7..8088f17 100644 --- a/lib/view_models/ad_view_model.dart +++ b/lib/view_models/ad_view_model.dart @@ -1559,18 +1559,19 @@ class AdVM extends BaseVM { for (var value in specialServiceCards) { adsSelectedServices.add(value.serviceSelectedId!.selectedId); } + log("selectionDurationStartDate: $selectionDurationStartDate"); if (selectionDurationStartDate.isNotEmpty) { // Define the format of the input string - DateTime startDate = DateTime.parse( - "${selectionDurationStartDate.split('-')[2]}-${selectionDurationStartDate.split('-')[1]}-${selectionDurationStartDate.split('-')[0]}", - ); + DateTime startDate = DateHelper.parseStringToDate(selectionDurationStartDate); DateTime currentDate = DateTime.now(); if (startDate.isBefore(currentDate)) { selectionDurationStartDate = DateHelper.formatAsYearMonthDay(currentDate); } } + + log("selectionDurationStartDate: $selectionDurationStartDate"); Ads ads = Ads( id: isAdEditEnabled ? previousAdDetails!.id : null, adsDurationID: vehicleAdDurationId.selectedId == -1 ? 0 : vehicleAdDurationId.selectedId, diff --git a/lib/view_models/appointments_view_model.dart b/lib/view_models/appointments_view_model.dart index b7be248..9a1efc0 100644 --- a/lib/view_models/appointments_view_model.dart +++ b/lib/view_models/appointments_view_model.dart @@ -373,10 +373,9 @@ class AppointmentsVM extends BaseVM { (element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && (DateHelper.parseStringToDate(element.appointmentDate!).isAfter(DateTime.now()))) .toList(); + log("myUpComingAppointments: ${myUpComingAppointments.length}"); } - log("myUpComingAppointments: ${myUpComingAppointments.length}"); - if (isNeedCustomerFilter) { myFilteredAppointmentsForProvider = findAppointmentsBasedOnCustomers(myFilteredAppointmentsForProvider); } @@ -391,10 +390,9 @@ class AppointmentsVM extends BaseVM { } int index = appointmentsFilterOptions.indexWhere((element) => element.id == appointmentStatusEnum.getIdFromAppointmentStatusEnum()); appointmentsFilterOptions[index].isSelected = true; - isAppointmentLoading = true; notifyListeners(); - myFilteredAppointmentsForCustomers = await getAppointmentsBasedOnFiltersForCustomer(); + myFilteredAppointmentsForCustomers = await getAppointmentsBasedOnFiltersForCustomer(appointmentStatusEnum: appointmentStatusEnum); isAppointmentLoading = false; if (shouldPopulateUpcoming) { @@ -1814,7 +1812,7 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - Future> getAppointmentsBasedOnFiltersForCustomer() async { + Future> getAppointmentsBasedOnFiltersForCustomer({required AppointmentStatusEnum appointmentStatusEnum}) async { try { setState(ViewState.busy); List providersIdsList = []; @@ -1854,6 +1852,7 @@ class AppointmentsVM extends BaseVM { serviceIdsList: servicesIdsList, itemIdsList: itemIdsList, branchIdsList: branchesIdsList, + appointmentStatusEnum: appointmentStatusEnum, ); setState(ViewState.idle); diff --git a/lib/view_models/dashboard_view_model_customer.dart b/lib/view_models/dashboard_view_model_customer.dart index 3f849b2..195d763 100644 --- a/lib/view_models/dashboard_view_model_customer.dart +++ b/lib/view_models/dashboard_view_model_customer.dart @@ -64,10 +64,10 @@ class DashboardVmCustomer extends BaseVM { RequestsVM requestsVM = Provider.of(context, listen: false); ChatVM chatVM = Provider.of(context, listen: false); - appointmentsVM.populateBranchesFilterList(); - appointmentsVM.populateAppointmentsFilterList(); - adVM.populateAdsFilterList(); - requestsVM.populateDataForRequestsFilter(); + await appointmentsVM.populateBranchesFilterList(); + await appointmentsVM.populateAppointmentsFilterList(); + await adVM.populateAdsFilterList(); + await requestsVM.populateDataForRequestsFilter(); await appointmentsVM.applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, shouldPopulateUpcoming: true); await appointmentsVM.applyFilterOnBranches(index: 0); // to get all branches! await appointmentsVM.getMyRecentBranches(); // to get my recent branches