@ -20,6 +20,7 @@ import 'package:mc_common_app/models/provider_branches_models/branch_detail_mode
import ' package:mc_common_app/models/provider_branches_models/branch_review_model.dart ' ;
import ' package:mc_common_app/models/provider_branches_models/profile/categroy.dart ' ;
import ' package:mc_common_app/models/provider_branches_models/profile/services.dart ' ;
import ' package:mc_common_app/models/provider_branches_models/provider_contact_info_model.dart ' ;
import ' package:mc_common_app/models/provider_branches_models/provider_model.dart ' ;
import ' package:mc_common_app/models/provider_branches_models/provider_profile_model.dart ' ;
import ' package:mc_common_app/models/services_models/item_model.dart ' ;
@ -62,9 +63,9 @@ class AppointmentsVM extends BaseVM {
List < AppointmentListModel > myAppointments = [ ] ;
List < AppointmentListModel > myUpComingAppointments = [ ] ;
List < AppointmentListModel > myFilteredAppointments = [ ] ;
List < AppointmentListModel > myFilteredAppointments ForCustomers = [ ] ;
List < FilterListModel > appointmentsFilterOptions = [ ] ;
List < AppointmentListModel > myFilteredAppointments 2 = [ ] ;
List < AppointmentListModel > myFilteredAppointments ForProvider = [ ] ;
bool isFetchingServices = false ;
@ -140,7 +141,7 @@ class AppointmentsVM extends BaseVM {
}
context . read < DashboardVmCustomer > ( ) . onNavbarTapped ( 1 ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . booked ) ;
applyFilterOnAppointmentsVM ForCustomers ( appointmentStatusEnum: AppointmentStatusEnum . booked ) ;
Utils . hideLoading ( context ) ;
resetAfterBookingAppointment ( ) ;
if ( isSuccess ) {
@ -149,7 +150,6 @@ class AppointmentsVM extends BaseVM {
navigateWithName ( context , AppRoutes . paymentMethodsView , arguments: PaymentTypes . appointment ) ;
} else {
Utils . showToast ( LocaleKeys . appointmentBookedSuccessfully . tr ( ) ) ;
getMyAppointmentsForCustomer ( ) ;
navigateReplaceWithNameUntilRoute ( context , AppRoutes . dashboard ) ;
}
}
@ -227,9 +227,8 @@ class AppointmentsVM extends BaseVM {
}
if ( genericRespModel . messageStatus = = 1 & & AppState ( ) . currentAppType = = AppType . customer ) {
context . read < DashboardVmCustomer > ( ) . onNavbarTapped ( 1 ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . cancelled ) ;
applyFilterOnAppointmentsVM ForCustomers ( appointmentStatusEnum: AppointmentStatusEnum . cancelled ) ;
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
await getMyAppointmentsForCustomer ( ) ;
Utils . hideLoading ( context ) ;
navigateReplaceWithNameUntilRoute ( context , AppRoutes . dashboard ) ;
}
@ -353,46 +352,69 @@ class AppointmentsVM extends BaseVM {
notifyListeners ( ) ;
}
applyFilterOnAppointmentsVM ( { required AppointmentStatusEnum appointmentStatusEnum , bool isNeedCustomerFilter = false } ) {
log ( " appointmentStatusEnum: $ appointmentStatusEnum " ) ;
/ / isNeedCustomerFilter IS ONLY FOR THE PROVIDER APP
bool isAppointmentLoading = false ;
applyFilterOnAppointmentsVMForProviders ( { int ? branchID , required AppointmentStatusEnum appointmentStatusEnum , bool isNeedCustomerFilter = false , bool shouldPopulateUpcoming = false } ) async {
if ( appointmentsFilterOptions . isEmpty ) return ;
for ( var value in appointmentsFilterOptions ) {
value . isSelected = false ;
}
int index = appointmentsFilterOptions . indexWhere ( ( element ) = > element . id = = appointmentStatusEnum . getIdFromAppointmentStatusEnum ( ) ) ;
appointmentsFilterOptions [ index ] . isSelected = true ;
for ( var element in appointmentsFilterOptions ) {
if ( element . id = = appointmentStatusEnum . getIdFromAppointmentStatusEnum ( ) ) {
element . isSelected = true ;
}
isAppointmentLoading = true ;
notifyListeners ( ) ;
myFilteredAppointmentsForProvider = await getAppointmentsBasedOnFiltersForProviders ( branchID: branchID ? ? selectedBranchIdForAppointments , appointmentStatus: appointmentStatusEnum ) ;
isAppointmentLoading = false ;
if ( shouldPopulateUpcoming ) {
myUpComingAppointments = myFilteredAppointmentsForProvider
. where ( ( element ) = >
( element . appointmentStatusEnum = = AppointmentStatusEnum . booked | | element . appointmentStatusEnum = = AppointmentStatusEnum . confirmed ) & &
( DateHelper . parseStringToDate ( element . appointmentDate ! ) . isAfter ( DateTime . now ( ) ) ) )
. toList ( ) ;
}
/ / appointmentsFilterOptions [
/ / appointmentStatusEnum . getIdFromAppointmentStatusEnum ( ) ]
/ / . isSelected = true ;
if ( appointmentStatusEnum = = AppointmentStatusEnum . allAppointments ) {
myFilteredAppointments = myAppointments ;
if ( isNeedCustomerFilter ) findAppointmentsBasedOnCustomers ( myFilteredAppointments ) ;
notifyListeners ( ) ;
return ;
log ( " myUpComingAppointments: ${ myUpComingAppointments . length } " ) ;
if ( isNeedCustomerFilter ) {
myFilteredAppointmentsForProvider = findAppointmentsBasedOnCustomers ( myFilteredAppointmentsForProvider ) ;
}
notifyListeners ( ) ;
}
applyFilterOnAppointmentsVMForCustomers ( { required AppointmentStatusEnum appointmentStatusEnum , bool shouldPopulateUpcoming = false } ) async {
log ( " appointmentsFilterOptions: ${ appointmentsFilterOptions . isEmpty } " ) ;
if ( appointmentsFilterOptions . isEmpty ) return ;
for ( var value in appointmentsFilterOptions ) {
value . isSelected = false ;
}
int index = appointmentsFilterOptions . indexWhere ( ( element ) = > element . id = = appointmentStatusEnum . getIdFromAppointmentStatusEnum ( ) ) ;
appointmentsFilterOptions [ index ] . isSelected = true ;
isAppointmentLoading = true ;
notifyListeners ( ) ;
myFilteredAppointmentsForCustomers = await getAppointmentsBasedOnFiltersForCustomer ( ) ;
isAppointmentLoading = false ;
if ( shouldPopulateUpcoming ) {
myUpComingAppointments = myFilteredAppointmentsForCustomers
. where ( ( element ) = >
( element . appointmentStatusEnum = = AppointmentStatusEnum . booked | | element . appointmentStatusEnum = = AppointmentStatusEnum . confirmed ) & &
( DateHelper . parseStringToDate ( element . appointmentDate ! ) . isAfter ( DateTime . now ( ) ) ) )
. toList ( ) ;
}
myFilteredAppointments = myAppointments . where ( ( element ) = > element . appointmentStatusID ! = = appointmentStatusEnum . getIdFromAppointmentStatusEnum ( ) ) . toList ( ) ;
if ( isNeedCustomerFilter ) findAppointmentsBasedOnCustomers ( myFilteredAppointments ) ;
notifyListeners ( ) ;
}
findAppointmentsBasedOnCustomers ( List < AppointmentListModel > appointments ) {
/ / Use a Set to ensure uniqueness of customerIDs
List < AppointmentListModel > findAppointmentsBasedOnCustomers ( List < AppointmentListModel > appointments ) {
Set < int > uniqueCustomerIDs = < int > { } ;
/ / Extract unique customerIDs
for ( var item in appointments ) {
uniqueCustomerIDs . add ( item . customerID ? ? 0 ) ;
}
/ / Create a list of CustomerData instances
myFilteredAppointments2 = uniqueCustomerIDs . map ( ( id ) {
List < AppointmentListModel > groupedList = uniqueCustomerIDs . map ( ( id ) {
List < AppointmentListModel > list = appointments . where ( ( item ) = > item . customerID = = id ) . toList ( ) ;
list . sort ( ( a , b ) = > DateHelper . parseStringToDate ( DateHelper . formatDateT ( b . appointmentDate ! ) )
. millisecondsSinceEpoch
@ -402,61 +424,16 @@ class AppointmentsVM extends BaseVM {
return model ;
} ) . toList ( ) ;
/ / customersAppointments = uniqueCustomerIDs . map ( ( id ) {
/ / List < AppointmentListModel > list = myFilteredAppointments
/ / . where ( ( item ) = > item . customerID = = id )
/ / . toList ( ) ;
/ / var customerItem =
/ / myFilteredAppointments . firstWhere ( ( item ) = > item . customerID = = id ) ;
/ /
/ / return CustomerData (
/ / customerID: id ,
/ / customerName: customerItem . customerName ? ? " " ,
/ / appointmentList: list ,
/ / ) ;
/ / } ) . toList ( ) ;
}
/ / Future < void > getMyAppointments ( ) async {
/ / setState ( ViewState . busy ) ;
/ /
/ / myAppointments =
/ / await appointmentRepo . getMyAppointmentsForCustomersByFilters ( ) ;
/ / myFilteredAppointments = myAppointments ;
/ / myUpComingAppointments = myAppointments
/ / . where ( ( element ) = >
/ / element . appointmentStatusEnum = = AppointmentStatusEnum . booked )
/ / . toList ( ) ;
/ / applyFilterOnAppointmentsVM (
/ / appointmentStatusEnum: AppointmentStatusEnum . allAppointments ) ;
/ / if ( myUpComingAppointments . isEmpty ) {
/ / isShowEmptyMessage = true ;
/ / }
/ / setState ( ViewState . idle ) ;
/ / notifyListeners ( ) ;
/ / }
Future < void > getMyAppointmentsForCustomer ( { bool isNeedToRebuild = false } ) async {
if ( isNeedToRebuild ) setState ( ViewState . busy ) ;
myAppointments = await appointmentRepo . getMyAppointmentsForCustomersByFilters ( ) ;
/ / myFilteredAppointments = myAppointments ;
setState ( ViewState . idle ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . allAppointments ) ;
myUpComingAppointments = myAppointments
. where ( ( element ) = >
( element . appointmentStatusEnum = = AppointmentStatusEnum . booked | | element . appointmentStatusEnum = = AppointmentStatusEnum . confirmed ) & &
( DateHelper . parseStringToDate ( element . appointmentDate ! ) . isAfter ( DateTime . now ( ) ) ) )
. toList ( ) ;
notifyListeners ( ) ;
return groupedList ;
}
AppointmentSlots ? appointmentSlots ;
Future < void > getAppointmentSlotsInfo ( { required int branchID , required BuildContext context , bool isNeedToRebuild = false } ) async {
if ( isNeedToRebuild ) setState ( ViewState . busy ) ;
bool isSlotsLoading = true ;
Future < void > getAppointmentSlotsInfo ( { required int branchID } ) async {
isSlotsLoading = true ;
notifyListeners ( ) ;
try {
GenericRespModel genericRespModel = await appointmentRepo . getAppointmentSlots ( branchID: branchID , fromDate: selectedDateForAppointments , toDate: selectedDateForAppointments ) ;
if ( genericRespModel . messageStatus = = 1 ) {
@ -464,25 +441,15 @@ class AppointmentsVM extends BaseVM {
} else {
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
}
isSlotsLoading = false ;
notifyListeners ( ) ;
} catch ( e ) {
isSlotsLoading = false ;
notifyListeners ( ) ;
Utils . showToast ( e . toString ( ) ) ;
}
}
Future < void > getMyAppointmentsForProvider ( { required int branchID } ) async {
setState ( ViewState . busy ) ;
myAppointments = await appointmentRepo . getMyAppointmentsForProvidersByFilters ( branchID: branchID ) ;
myFilteredAppointments = myAppointments ;
myUpComingAppointments = myAppointments
. where ( ( element ) = >
( 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 ) ;
}
Future < bool > updateAppointmentStatus ( { required int appointmentId , required AppointmentStatusEnum appointmentStatusEnum , bool isNeedToRebuild = false } ) async {
if ( isNeedToRebuild ) setState ( ViewState . busy ) ;
try {
@ -520,8 +487,8 @@ class AppointmentsVM extends BaseVM {
}
bool isShowMergeButton ( ) {
return myFilteredAppointments 2 [ selectedAppointmentIndex ] . customerAppointmentList ! . every ( ( appointment ) = > appointment . appointmentStatusEnum = = AppointmentStatusEnum . confirmed ) & &
myFilteredAppointments 2 [ selectedAppointmentIndex ] . customerAppointmentList ! . length > 1 ;
return myFilteredAppointments ForProvider [ selectedAppointmentIndex ] . customerAppointmentList ! . every ( ( appointment ) = > appointment . appointmentStatusEnum = = AppointmentStatusEnum . confirmed ) & &
myFilteredAppointments ForProvider [ selectedAppointmentIndex ] . customerAppointmentList ! . length > 1 ;
}
Future < GenericRespModel > createMergeAppointment ( Map < String , dynamic > map , { bool isNeedToRebuild = false } ) async {
@ -534,10 +501,10 @@ class AppointmentsVM extends BaseVM {
bool inNeedToEnableMergeButton = false ;
void updateCheckBoxInMergeRequest ( int currentIndex ) {
myFilteredAppointments 2 [ selectedAppointmentIndex ] . customerAppointmentList ! [ currentIndex ] . isSelected =
! ( myFilteredAppointments 2 [ selectedAppointmentIndex ] . customerAppointmentList ? [ currentIndex ] . isSelected ? ? false ) ;
myFilteredAppointments ForProvider [ selectedAppointmentIndex ] . customerAppointmentList ! [ currentIndex ] . isSelected =
! ( myFilteredAppointments ForProvider [ selectedAppointmentIndex ] . customerAppointmentList ? [ currentIndex ] . isSelected ? ? false ) ;
int count = countSelected ( myFilteredAppointments 2 [ selectedAppointmentIndex ] . customerAppointmentList ? ? [ ] ) ;
int count = countSelected ( myFilteredAppointments ForProvider [ selectedAppointmentIndex ] . customerAppointmentList ? ? [ ] ) ;
if ( count > 1 ) {
inNeedToEnableMergeButton = true ;
} else {
@ -573,9 +540,9 @@ class AppointmentsVM extends BaseVM {
element . isSelected = false ;
}
}
int i ndex = serviceAppointmentScheduleList [ scheduleIndex ] . selectedDateIndex ! ;
serviceAppointmentScheduleList [ scheduleIndex ] . customTimeDateSlotList ! [ i ndex] . availableSlots ! [ slotIndex ] . isSelected = true ;
serviceAppointmentScheduleList [ scheduleIndex ] . selectedCustomTimeDateSlotModel ! . availableSlots = serviceAppointmentScheduleList [ scheduleIndex ] . customTimeDateSlotList ! [ i ndex] . availableSlots ! ;
int dateI ndex = serviceAppointmentScheduleList [ scheduleIndex ] . selectedDateIndex ! ;
serviceAppointmentScheduleList [ scheduleIndex ] . customTimeDateSlotList ! [ dateI ndex] . availableSlots ! [ slotIndex ] . isSelected = true ;
serviceAppointmentScheduleList [ scheduleIndex ] . selectedCustomTimeDateSlotModel ! . availableSlots = serviceAppointmentScheduleList [ scheduleIndex ] . customTimeDateSlotList ! [ dateI ndex] . availableSlots ! ;
notifyListeners ( ) ;
}
@ -633,7 +600,7 @@ class AppointmentsVM extends BaseVM {
}
branchesCategoriesFilterOptions [ index ] . isSelected = true ;
await getBranchesBasedOnCategoryFilters ( cat egory Id: branchesCategoriesFilterOptions [ index ] . id ) ;
await getBranchesBasedOnCategoryFilters ( servi ceId: branchesCategoriesFilterOptions [ index ] . id ) ;
notifyListeners ( ) ;
}
@ -917,9 +884,8 @@ class AppointmentsVM extends BaseVM {
}
if ( genericRespModel . messageStatus = = 1 ) {
context . read < DashboardVmCustomer > ( ) . onNavbarTapped ( 1 ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . cancelled ) ;
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
getMyAppointmentsForCustomer( ) ;
applyFilterOnAppointmentsVMForCustomers( appointmentStatusEnum: AppointmentStatusEnum . cancelled ) ;
Utils . hideLoading ( context ) ;
navigateReplaceWithNameUntilRoute ( context , AppRoutes . dashboard ) ;
}
@ -1011,6 +977,20 @@ class AppointmentsVM extends BaseVM {
}
}
Future < ProviderContactInfoModel ? > getProvidersContactInfo ( { required int providerId , required BuildContext context } ) async {
Utils . showLoading ( context ) ;
try {
ProviderContactInfoModel contactInfoModel = await commonRepo . getProvidersContactInfo ( providerId: providerId ) ;
Utils . hideLoading ( context ) ;
return contactInfoModel ;
} catch ( e , s ) {
logger . e ( s ) ;
Utils . hideLoading ( context ) ;
Utils . showToast ( e . toString ( ) ) ;
return null ;
}
}
/ / BRANCHES RELATED
List < BranchDetailModel > nearbyBranches = [ ] ;
@ -1023,9 +1003,9 @@ class AppointmentsVM extends BaseVM {
if ( branchesCategoriesFilterOptions . isNotEmpty ) return ;
branchesCategoriesFilterOptions . clear ( ) ;
setOnlyState ( ViewState . busy ) ;
Category category = await branchRepo . fetchBranchCategory ( ) ;
category . data ? . forEach ( ( element ) {
branchesCategoriesFilterOptions . add ( FilterListModel ( id: element . id ? ? 0 , isSelected: false , iconUrl: element . service Category IconUrl ? ? " " , title: element . categoryName ? ? " N/A " ) ) ;
Services services = await branchRepo . fetchServicesByCategoryId ( serviceCategoryId: - 1 ) ;
services . data ? . forEach ( ( element ) {
branchesCategoriesFilterOptions . add ( FilterListModel ( id: element . id ? ? 0 , isSelected: false , iconUrl: element . service IconUrl ? ? " " , title: element . description ? ? " " ) ) ;
} ) ;
branchesCategoriesFilterOptions . insert ( 0 , FilterListModel ( id: 0 , isSelected: true , title: " All Branches " ) ) ;
notifyListeners ( ) ;
@ -1440,15 +1420,15 @@ class AppointmentsVM extends BaseVM {
setState ( ViewState . idle ) ;
}
Future < void > getBranchesBasedOnCategoryFilters ( { required int cat egory Id} ) async {
Future < void > getBranchesBasedOnCategoryFilters ( { required int servi ceId} ) async {
setState ( ViewState . busy ) ;
if ( cat egory Id = = 0 ) {
if ( servi ceId = = 0 ) {
await getAllNearBranches ( ) ;
return ;
}
nearbyBranches . clear ( ) ;
nearbyBranches = await branchRepo . getBranchesByFilters (
cat egory IdsList: [ cat egory Id] ,
servi ceIdsList: [ servi ceId] ,
latitude: AppState ( ) . currentLocation . latitude ,
longitude: AppState ( ) . currentLocation . longitude ,
) ;
@ -1827,105 +1807,120 @@ class AppointmentsVM extends BaseVM {
clearAppointmentFilterSelections ( ) ;
if ( AppState ( ) . currentAppType = = AppType . provider ) {
getMyAppointmentsForProvider( branchID: selectedBranchIdForAppointments ) ;
applyFilterOnAppointmentsVMForProviders( appointmentStatusEnum: AppointmentStatusEnum . allAppointments , isNeedCustomerFilter: true ) ;
} else {
getMyAppointmentsForCustomer( ) ;
applyFilterOnAppointmentsVMForCustomers( appointmentStatusEnum: AppointmentStatusEnum . allAppointments ) ;
}
notifyListeners ( ) ;
}
Future < void > getAppointmentsBasedOnFiltersForCustomer ( ) async {
setState ( ViewState . busy ) ;
List < String > providersIdsList = [ ] ;
if ( appointmentFilterProviderSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterProviderSearchHistory ) {
providersIdsList . add ( element . id . toString ( ) ) ;
Future < List < AppointmentListModel > > getAppointmentsBasedOnFiltersForCustomer ( ) async {
try {
setState ( ViewState . busy ) ;
List < String > providersIdsList = [ ] ;
if ( appointmentFilterProviderSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterProviderSearchHistory ) {
providersIdsList . add ( element . id . toString ( ) ) ;
}
}
}
List < String > categoryIdsList = [ ] ;
i f ( appointmentFilterCategorySearchHistor y. isNotEmpt y) {
for ( var element in appointmentFilterCategorySearchHistory ) {
categoryIdsList . add ( element . id . toString ( ) ) ;
List < String > categoryIdsList = [ ] ;
if ( appointmentFilterCategorySearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterCategorySearchHistor y) {
categoryIdsList . add ( element . id . toString ( ) ) ;
}
}
}
List < String > servicesIdsList = [ ] ;
i f ( appointmentFilterServicesSearchHistor y. isNotEmpt y) {
for ( var element in appointmentFilterServicesSearchHistory ) {
servicesIdsList . add ( element . id . toString ( ) ) ;
List < String > servicesIdsList = [ ] ;
if ( appointmentFilterServicesSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterServicesSearchHistor y) {
servicesIdsList . add ( element . id . toString ( ) ) ;
}
}
}
List < String > itemIdsList = [ ] ;
i f ( appointmentFilterItemsSearchHistor y. isNotEmpt y) {
for ( var element in appointmentFilterItemsSearchHistory ) {
itemIdsList . add ( element . id . toString ( ) ) ;
List < String > itemIdsList = [ ] ;
if ( appointmentFilterItemsSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterItemsSearchHistor y) {
itemIdsList . add ( element . id . toString ( ) ) ;
}
}
}
List < String > branchesIdsList = [ ] ;
i f ( appointmentFilterBranchSearchHistor y. isNotEmpt y) {
for ( var element in appointmentFilterBranchSearchHistory ) {
branchesIdsList . add ( element . id . toString ( ) ) ;
List < String > branchesIdsList = [ ] ;
if ( appointmentFilterBranchSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterBranchSearchHistor y) {
branchesIdsList . add ( element . id . toString ( ) ) ;
}
}
}
myAppointments = await appointmentRepo . getMyAppointmentsForCustomersByFilters (
providerIdsList: providersIdsList ,
categoryIdsList: categoryIdsList ,
serviceIdsList: servicesIdsList ,
itemIdsList: itemIdsList ,
branchIdsList: branchesIdsList ,
) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . allAppointments ) ;
setState ( ViewState . idle ) ;
List < AppointmentListModel > myAppointments = await appointmentRepo . getMyAppointmentsForCustomersByFilters (
providerIdsList: providersIdsList ,
categoryIdsList: categoryIdsList ,
serviceIdsList: servicesIdsList ,
itemIdsList: itemIdsList ,
branchIdsList: branchesIdsList ,
) ;
setState ( ViewState . idle ) ;
return myAppointments ;
} catch ( e ) {
logger . e ( e ) ;
setState ( ViewState . idle ) ;
Utils . showToast ( e . toString ( ) ) ;
return [ ] ;
}
}
String selectedDateForAppointments = " " ;
Future < void > getAppointmentsBasedOnFiltersForProviders ( { required int branchID } ) async {
setState ( ViewState . busy ) ;
List < String > servicesIdsList = [ ] ;
if ( appointmentFilterServicesSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterServicesSearchHistory ) {
servicesIdsList . add ( element . id . toString ( ) ) ;
Future < List < AppointmentListModel > > getAppointmentsBasedOnFiltersForProviders ( { required int branchID , AppointmentStatusEnum ? appointmentStatus } ) async {
try {
setState ( ViewState . busy ) ;
List < String > servicesIdsList = [ ] ;
if ( appointmentFilterServicesSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterServicesSearchHistory ) {
servicesIdsList . add ( element . id . toString ( ) ) ;
}
}
}
List < String > customerNamesList = [ ] ;
if ( appointmentFilterCustomerNameSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterCustomerNameSearchHistory ) {
customerNamesList . add ( element . toString ( ) ) ;
List < String > customerNamesList = [ ] ;
if ( appointmentFilterCustomerNameSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterCustomerNameSearchHistory ) {
customerNamesList . add ( element . toString ( ) ) ;
}
}
}
List < String > customerPhonesList = [ ] ;
if ( appointmentFilterMobilePhoneSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterMobilePhoneSearchHistory ) {
customerPhonesList . add ( element . toString ( ) ) ;
List < String > customerPhonesList = [ ] ;
if ( appointmentFilterMobilePhoneSearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterMobilePhoneSearchHistory ) {
customerPhonesList . add ( element . toString ( ) ) ;
}
}
}
List < String > customerDeliveryTypesList = [ ] ;
i f ( appointmentFilterServiceDeliverySearchHistor y. isNotEmpt y) {
for ( var element in appointmentFilterServiceDeliverySearchHistory ) {
customerDeliveryTypesList . add ( element . id . toString ( ) ) ;
List < String > customerDeliveryTypesList = [ ] ;
if ( appointmentFilterServiceDeliverySearchHistory . isNotEmpty ) {
for ( var element in appointmentFilterServiceDeliverySearchHistor y) {
customerDeliveryTypesList . add ( element . id . toString ( ) ) ;
}
}
}
log ( " customerNamesList: $ customerNamesList " ) ;
log ( " customerPhonesList: $ customerPhonesList " ) ;
log ( " customerDeliveryTypesList: $ customerDeliveryTypesList " ) ;
log ( " servicesIdsList: $ servicesIdsList " ) ;
myAppointments = await appointmentRepo . getMyAppointmentsForProvidersByFilters (
branchID: branchID ,
customerNamesList: customerNamesList ,
customerPhonesList: customerPhonesList ,
deliveryTypeIdsList: customerDeliveryTypesList ,
serviceProviderServiceIdsList: servicesIdsList ,
fromDate: ' ' ,
toDate: ' ' ) ;
log ( " myFilteredAppointments : ${ myFilteredAppointments . length } " ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . allAppointments , isNeedCustomerFilter: true ) ;
setState ( ViewState . idle ) ;
log ( " customerNamesList: $ customerNamesList " ) ;
log ( " customerPhonesList: $ customerPhonesList " ) ;
log ( " customerDeliveryTypesList: $ customerDeliveryTypesList " ) ;
log ( " servicesIdsList: $ servicesIdsList " ) ;
List < AppointmentListModel > myAppointments = await appointmentRepo . getMyAppointmentsForProvidersByFilters (
branchID: branchID ,
customerNamesList: customerNamesList ,
customerPhonesList: customerPhonesList ,
deliveryTypeIdsList: customerDeliveryTypesList ,
serviceProviderServiceIdsList: servicesIdsList ,
appointmentStatusEnum: appointmentStatus ,
fromDate: ' ' ,
toDate: ' ' ) ;
setState ( ViewState . idle ) ;
return myAppointments ? ? [ ] ;
} catch ( e ) {
logger . e ( e ) ;
setState ( ViewState . idle ) ;
Utils . showToast ( e . toString ( ) ) ;
return [ ] ;
}
}
Future < bool > addProviderToFavorite ( { required int serviceProviderID , required BuildContext context } ) async {