|
|
|
|
@ -259,7 +259,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<FilterListModel> branchesFilterOptions = [];
|
|
|
|
|
List<FilterListModel> branchesCategoriesFilterOptions = [];
|
|
|
|
|
|
|
|
|
|
List<ServiceModel> servicesInCurrentAppointment = [];
|
|
|
|
|
ServiceModel? currentServiceSelection;
|
|
|
|
|
@ -478,6 +478,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
(element.appointmentStatusEnum == AppointmentStatusEnum.confirmed || element.appointmentStatusEnum == AppointmentStatusEnum.booked) &&
|
|
|
|
|
(DateHelper.parseStringToDate(element.appointmentDate!).isAfter(DateTime.now())))
|
|
|
|
|
.toList();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true);
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
@ -626,13 +627,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> applyFilterOnBranches({required int index}) async {
|
|
|
|
|
if (branchesFilterOptions.isEmpty) return;
|
|
|
|
|
for (var value in branchesFilterOptions) {
|
|
|
|
|
if (branchesCategoriesFilterOptions.isEmpty) return;
|
|
|
|
|
for (var value in branchesCategoriesFilterOptions) {
|
|
|
|
|
value.isSelected = false;
|
|
|
|
|
}
|
|
|
|
|
branchesFilterOptions[index].isSelected = true;
|
|
|
|
|
branchesCategoriesFilterOptions[index].isSelected = true;
|
|
|
|
|
|
|
|
|
|
await getBranchesBasedOnCategoryFilters(categoryId: branchesFilterOptions[index].id);
|
|
|
|
|
await getBranchesBasedOnCategoryFilters(categoryId: branchesCategoriesFilterOptions[index].id);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1019,14 +1020,14 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
List<ServiceModel> branchServices = [];
|
|
|
|
|
|
|
|
|
|
Future<void> populateBranchesFilterList() async {
|
|
|
|
|
if (branchesFilterOptions.isNotEmpty) return;
|
|
|
|
|
branchesFilterOptions.clear();
|
|
|
|
|
if (branchesCategoriesFilterOptions.isNotEmpty) return;
|
|
|
|
|
branchesCategoriesFilterOptions.clear();
|
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
|
Category category = await branchRepo.fetchBranchCategory();
|
|
|
|
|
category.data?.forEach((element) {
|
|
|
|
|
branchesFilterOptions.add(FilterListModel(id: element.id ?? 0, isSelected: false, title: element.categoryName ?? "N/A"));
|
|
|
|
|
branchesCategoriesFilterOptions.add(FilterListModel(id: element.id ?? 0, isSelected: false, iconUrl: element.serviceCategoryIconUrl ?? "", title: element.categoryName ?? "N/A"));
|
|
|
|
|
});
|
|
|
|
|
branchesFilterOptions.insert(0, FilterListModel(id: 0, isSelected: true, title: "All Branches"));
|
|
|
|
|
branchesCategoriesFilterOptions.insert(0, FilterListModel(id: 0, isSelected: true, title: "All Branches"));
|
|
|
|
|
notifyListeners();
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
@ -1036,7 +1037,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
|
|
|
|
|
if (isFromRefresh) {
|
|
|
|
|
var selectedFilter = branchesFilterOptions.firstWhere((element) => element.isSelected);
|
|
|
|
|
var selectedFilter = branchesCategoriesFilterOptions.firstWhere((element) => element.isSelected);
|
|
|
|
|
log("selectedFilter: ${selectedFilter.id}");
|
|
|
|
|
|
|
|
|
|
if (selectedFilter.id == 0) {
|
|
|
|
|
|