@ -38,9 +38,11 @@ import 'package:mc_common_app/view_models/dashboard_view_model_customer.dart';
import ' package:mc_common_app/view_models/payment_view_model.dart ' ;
import ' package:mc_common_app/views/appointments/book_appointment_schedules_view.dart ' ;
import ' package:mc_common_app/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart ' ;
import ' package:mc_common_app/widgets/button/show_fill_button.dart ' ;
import ' package:mc_common_app/widgets/common_widgets/info_bottom_sheet.dart ' ;
import ' package:mc_common_app/widgets/dropdown/dropdow_field.dart ' ;
import ' package:mc_common_app/widgets/extensions/extensions_widget.dart ' ;
import ' package:mc_common_app/widgets/txt_field.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:easy_localization/easy_localization.dart ' ;
@ -81,6 +83,7 @@ class AppointmentsVM extends BaseVM {
bool ifItemAlreadySelected ( int id ) {
int indexFound = allSelectedItemsInAppointments . indexWhere ( ( element ) = > element . id = = id ) ;
log ( " already selected at: $ indexFound " ) ;
if ( indexFound ! = - 1 ) {
return true ;
}
@ -101,6 +104,7 @@ class AppointmentsVM extends BaseVM {
}
resetCategorySelectionBottomSheet ( ) ;
notifyListeners ( ) ;
}
}
@ -134,7 +138,6 @@ class AppointmentsVM extends BaseVM {
} else {
isSuccess = false ;
Utils . showToast ( element [ ' message ' ] ) ;
return ;
}
} ) ;
@ -226,7 +229,7 @@ class AppointmentsVM extends BaseVM {
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
return ;
}
if ( genericRespModel . messageStatus = = 1 ) {
if ( genericRespModel . messageStatus = = 1 & & AppState ( ) . currentAppType = = AppType . customer ) {
context . read < DashboardVmCustomer > ( ) . onNavbarTapped ( 1 ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . cancelled ) ;
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
@ -236,6 +239,7 @@ class AppointmentsVM extends BaseVM {
navigateReplaceWithNameUntilRoute ( context , AppRoutes . dashboard ) ;
}
} catch ( e ) {
logger . e ( e . toString ( ) ) ;
Utils . showToast ( e . toString ( ) ) ;
}
}
@ -248,16 +252,16 @@ class AppointmentsVM extends BaseVM {
notifyListeners ( ) ;
}
String pickedHomeLocation = " " ;
void updatePickedHomeLocation ( String value ) {
pickedHomeLocation = value ;
pickHomeLocationError = " " ;
if ( currentServiceSelection ! = null ) {
currentServiceSelection ! . homeLocation = value ;
}
notifyListeners ( ) ;
}
/ / String pickedHomeLocation = " " ;
/ /
/ / void updatePickedHomeLocation ( String value ) {
/ / pickedHomeLocation = value ;
/ / pickHomeLocationError = " " ;
/ / if ( currentServiceSelection ! = null ) {
/ / currentServiceSelection ! . homeLocation = value ;
/ / }
/ / notifyListeners ( ) ;
/ / }
SelectionModel branchSelectedCategoryId = SelectionModel ( selectedOption: " " , selectedId: - 1 , errorValue: " " ) ;
@ -272,12 +276,64 @@ class AppointmentsVM extends BaseVM {
List < ServiceModel > servicesInCurrentAppointment = [ ] ;
ServiceModel ? currentServiceSelection ;
CurrentLocationInfoModel ? currentLocationInfoModel ;
void updateCurrentLocationInfoModel ( CurrentLocationInfoModel ? value ) {
currentLocationInfoModel = value ;
pickHomeLocationError = " " ;
if ( currentServiceSelection ! = null & & value ! = null ) {
currentServiceSelection ! . servicelocationInfo = value ;
}
if ( value ! = null ) {
for ( var service in servicesInCurrentAppointment ) {
service . servicelocationInfo . address = value . address ;
service . servicelocationInfo . latitude = value . latitude ;
service . servicelocationInfo . longitude = value . longitude ;
service . servicelocationInfo . distanceToBranch = value . distanceToBranch ;
service . servicelocationInfo . homeChargesInCurrentService = double . parse ( service . rangePricePerKm ? ? " 0.0 " ) ;
}
}
notifyListeners ( ) ;
}
void updateBranchServiceId ( SelectionModel id ) async {
branchSelectedServiceId = id ;
currentServiceSelection = branchServices . firstWhere ( ( element ) = > element . serviceProviderServiceId = = id . selectedId ) ;
if ( currentServiceSelection = = null ) {
return ;
}
servicesInCurrentAppointment . forEach ( ( i ) {
log ( " hlo1: ${ i . serviceDescription } ${ i . servicelocationInfo . homeChargesInCurrentService } " ) ;
} ) ;
if ( ! ( currentServiceSelection ! . isAllowAppointmentHome ? ? false ) ) {
updateIsHomeTapped ( false ) ;
return ;
}
if ( currentLocationInfoModel ! = null ) {
currentLocationInfoModel ! . homeChargesInCurrentService = double . parse ( currentServiceSelection ! . rangePricePerKm ? ? " 0.0 " ) ;
currentServiceSelection ! . servicelocationInfo = CurrentLocationInfoModel (
address: currentLocationInfoModel ! . address ,
latitude: currentLocationInfoModel ! . latitude ,
longitude: currentLocationInfoModel ! . longitude ,
distanceToBranch: currentLocationInfoModel ! . distanceToBranch ,
homeChargesInCurrentService: double . parse ( currentServiceSelection ! . rangePricePerKm ? ? " 0.0 " ) ,
) ;
/ / for ( var service in servicesInCurrentAppointment ) {
/ / service . servicelocationInfo . address = currentLocationInfoModel ! . address ;
/ / service . servicelocationInfo . latitude = currentLocationInfoModel ! . latitude ;
/ / service . servicelocationInfo . longitude = currentLocationInfoModel ! . longitude ;
/ / service . servicelocationInfo . distanceToBranch = currentLocationInfoModel ! . distanceToBranch ;
/ / }
}
servicesInCurrentAppointment . forEach ( ( i ) {
log ( " hlo2: ${ i . serviceDescription } ${ i . servicelocationInfo . homeChargesInCurrentService } " ) ;
} ) ;
log ( " currentServiceSelection isAllowAppointmentHome: ${ currentServiceSelection ! . isAllowAppointmentHome } " ) ;
log ( " currentServiceSelection serviceDescription: ${ currentServiceSelection ! . serviceDescription } " ) ;
notifyListeners ( ) ;
}
@ -298,9 +354,18 @@ class AppointmentsVM extends BaseVM {
}
resetAfterBookingAppointment ( ) {
/ / allSelectedItemsInAppointments . clear ( ) ;
allSelectedItemsInAppointments . clear ( ) ;
currentServiceSelection = null ;
for ( var element in servicesInCurrentAppointment ) {
if ( element . serviceItems ! = null ) {
element . serviceItems ! . clear ( ) ;
element . serviceItems = [ ] ;
}
}
servicesInCurrentAppointment . clear ( ) ;
/ / serviceAppointmentScheduleList . clear ( ) ;
servicesInCurrentAppointment = [ ] ;
currentLocationInfoModel = null ;
log ( " here servicesInCurrentAppointment: ${ servicesInCurrentAppointment . length } " ) ;
}
List < EnumsModel > myAppointmentsEnum = [ ] ;
@ -315,13 +380,11 @@ class AppointmentsVM extends BaseVM {
}
appointmentsFilterOptions . insert ( 0 , FilterListModel ( title: " All Appointments " , isSelected: true , id: 0 ) ) ;
/ / TODO: THIS SHOULD REMOVED AND ADDED IN THE ENUMS API
appointmentsFilterOptions . add ( FilterListModel ( title: " Work In Progress " , isSelected: false , id: 7 ) ) ;
appointmentsFilterOptions . add ( FilterListModel ( title: " Visit Completed " , isSelected: false , id: 8 ) ) ;
notifyListeners ( ) ;
}
applyFilterOnAppointmentsVM ( { required AppointmentStatusEnum appointmentStatusEnum , bool isNeedCustomerFilter = false } ) {
log ( " appointmentStatusEnum: ${ appointmentStatusEnum } " ) ;
/ / isNeedCustomerFilter IS ONLY FOR THE PROVIDER APP
if ( appointmentsFilterOptions . isEmpty ) return ;
for ( var value in appointmentsFilterOptions ) {
@ -405,7 +468,9 @@ class AppointmentsVM extends BaseVM {
myAppointments = await appointmentRepo . getMyAppointmentsForCustomersByFilters ( ) ;
/ / myFilteredAppointments = myAppointments ;
myUpComingAppointments = myAppointments
. where ( ( element ) = > ( element . appointmentStatusEnum = = AppointmentStatusEnum . booked | | element . appointmentStatusEnum = = AppointmentStatusEnum . confirmed ) & & ( DateHelper . parseStringToDate ( element . appointmentDate ! ) . isAfter ( DateTime . now ( ) ) ) )
. where ( ( element ) = >
( element . appointmentStatusEnum = = AppointmentStatusEnum . booked | | element . appointmentStatusEnum = = AppointmentStatusEnum . confirmed ) & &
( DateHelper . parseStringToDate ( element . appointmentDate ! ) . isAfter ( DateTime . now ( ) ) ) )
. toList ( ) ;
setState ( ViewState . idle ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . allAppointments ) ;
@ -433,39 +498,47 @@ class AppointmentsVM extends BaseVM {
myAppointments = await appointmentRepo . getMyAppointmentsForProvider ( map ) ;
myFilteredAppointments = myAppointments ;
myUpComingAppointments = myAppointments
. where ( ( element ) = > ( element . appointmentStatusEnum = = AppointmentStatusEnum . confirmed | | element . appointmentStatusEnum = = AppointmentStatusEnum . booked ) & & ( DateHelper . parseStringToDate ( element . appointmentDate ! ) . isAfter ( DateTime . now ( ) ) ) )
. where ( ( element ) = >
( element . appointmentStatusEnum = = AppointmentStatusEnum . confirmed | | element . appointmentStatusEnum = = AppointmentStatusEnum . booked ) & &
( DateHelper . parseStringToDate ( element . appointmentDate ! ) . isAfter ( DateTime . now ( ) ) ) )
. toList ( ) ;
applyFilterOnAppointmentsVM ( appointmentStatusEnum: AppointmentStatusEnum . allAppointments , isNeedCustomerFilter: true ) ;
setState ( ViewState . idle ) ;
}
updateAppointmentStatus( { required int appointmentId , required AppointmentStatusEnum appointmentStatusEnum , bool isNeedToRebuild = false } ) async {
Future< bool > updateAppointmentStatus( { required int appointmentId , required AppointmentStatusEnum appointmentStatusEnum , bool isNeedToRebuild = false } ) async {
if ( isNeedToRebuild ) setState ( ViewState . busy ) ;
try {
GenericRespModel genericRespModel = await appointmentRepo . updateAppointmentStatus ( appointmentId: appointmentId , appointmentStatusEnum: appointmentStatusEnum ) ;
if ( genericRespModel . messageStatus = = 1 ) {
Utils . showToast ( LocaleKeys . appointmentStatusUpdated . tr ( ) ) ;
return true ;
} else {
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
return false ;
}
} catch ( e ) {
Utils . showToast ( e . toString ( ) ) ;
return false ;
}
}
updateAppointmentPaymentStatus( Map < String , dynamic > map , { bool isNeedToRebuild = false } ) async {
Future< bool > updateAppointmentPaymentStatus( Map < String , dynamic > map , { bool isNeedToRebuild = false } ) async {
if ( isNeedToRebuild ) setState ( ViewState . busy ) ;
try {
GenericRespModel genericRespModel = await appointmentRepo . updateAppointmentPaymentStatus ( map ) ;
if ( genericRespModel . messageStatus = = 1 ) {
Utils . showToast ( LocaleKeys . paymentStatusUpdated . tr ( ) ) ;
return true ;
} else {
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
return false ;
}
} catch ( e ) {
Utils . showToast ( e . toString ( ) ) ;
return false ;
}
}
@ -484,7 +557,8 @@ class AppointmentsVM extends BaseVM {
bool inNeedToEnableMergeButton = false ;
void updateCheckBoxInMergeRequest ( int currentIndex ) {
myFilteredAppointments2 [ selectedAppointmentIndex ] . customerAppointmentList ! [ currentIndex ] . isSelected = ! ( myFilteredAppointments2 [ selectedAppointmentIndex ] . customerAppointmentList ? [ currentIndex ] . isSelected ? ? false ) ;
myFilteredAppointments2 [ selectedAppointmentIndex ] . customerAppointmentList ! [ currentIndex ] . isSelected =
! ( myFilteredAppointments2 [ selectedAppointmentIndex ] . customerAppointmentList ? [ currentIndex ] . isSelected ? ? false ) ;
int count = countSelected ( myFilteredAppointments2 [ selectedAppointmentIndex ] . customerAppointmentList ? ? [ ] ) ;
if ( count > 1 ) {
@ -540,38 +614,35 @@ class AppointmentsVM extends BaseVM {
void onItemUpdateOrSelected ( int index , bool selected , int itemId ) {
int serviceIndex = servicesInCurrentAppointment . indexWhere ( ( element ) = > element . serviceId = = currentServiceSelection ! . serviceId ! ) ;
log ( " index: $ index " ) ;
log ( " selected: $ selected " ) ;
log ( " itemId: $ itemId " ) ;
log ( " servicesInCurrentAppointment: ${ servicesInCurrentAppointment . length } " ) ;
serviceItemsFromApi [ index ] . isUpdateOrSelected = selected ;
serviceItemsFromApi [ index ] . isHomeSelected = isHomeTapped ;
log ( " serviceI temsFromApi[i ndex].isHomeSelected : $ { serviceI temsFromApi[ i ndex] . isHomeSelected } " ) ;
log ( " serviceIndex: $ serviceIndex " ) ;
if ( selected ) {
selectedSubServicesCounter = selectedSubServicesCounter + 1 ;
selectSubServicesError = " " ;
currentServiceSelection ! . serviceItems ! . add ( serviceItemsFromApi [ index ] ) ;
allSelectedItemsInAppointments . add ( serviceItemsFromApi [ index ] ) ;
for ( var element in allSelectedItemsInAppointments ) {
if ( ! ifItemAlreadySelected ( element . id ! ) ) {
if ( serviceIndex ! = - 1 ) {
servicesInCurrentAppointment [ serviceIndex ] . serviceItems ! . add ( serviceItemsFromApi [ index ] ) ;
servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice = servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice + double . parse ( ( serviceItemsFromApi [ index ] . price ) ? ? " 0.0 " ) ;
}
if ( ! ifItemAlreadySelected ( serviceItemsFromApi [ index ] . id ! ) ) {
currentServiceSelection ! . serviceItems ! . add ( serviceItemsFromApi [ index ] ) ;
allSelectedItemsInAppointments . add ( serviceItemsFromApi [ index ] ) ;
log ( " Here with: ${ serviceItemsFromApi [ index ] . description } " ) ;
if ( serviceIndex ! = - 1 ) {
/ / servicesInCurrentAppointment [ serviceIndex ] . serviceItems ! . add ( serviceItemsFromApi [ index ] ) ;
servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice =
servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice + double . parse ( ( serviceItemsFromApi [ index ] . price ) ? ? " 0.0 " ) ;
}
}
} else {
log ( " currentServiceSelection!.serviceItems: ${ currentServiceSelection ! . serviceItems ! . length } " ) ;
selectedSubServicesCounter = selectedSubServicesCounter - 1 ;
currentServiceSelection ! . serviceItems ! . removeWhere ( ( element ) = > element . id = = itemId ) ;
log ( " currentServiceSelection!.serviceItems: ${ currentServiceSelection ! . serviceItems ! . length } " ) ;
allSelectedItemsInAppointments . removeWhere ( ( element ) = > element . id = = itemId ) ;
if ( serviceIndex ! = - 1 ) {
servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice = servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice - double . parse ( ( serviceItemsFromApi [ index ] . price ) ? ? " 0.0 " ) ;
servicesInCurrentAppointment [ serviceIndex ] . serviceItems ! . removeWhere ( ( element ) = > element . id = = itemId ) ;
servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice =
servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice - double . parse ( ( serviceItemsFromApi [ index ] . price ) ? ? " 0.0 " ) ;
if ( servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice < 0.0 ) {
servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice = servicesInCurrentAppointment [ serviceIndex ] . currentTotalServicePrice * - 1 ;
}
/ / servicesInCurrentAppointment [ serviceIndex ] . serviceItems ! . removeWhere ( ( element ) = > element . id = = itemId ) ;
}
}
@ -593,9 +664,11 @@ class AppointmentsVM extends BaseVM {
setState ( ViewState . busy ) ;
serviceItemsFromApi . clear ( ) ;
serviceItemsFromApi = await branchRepo . getServiceItems ( serviceId ) ;
selectedSubServicesCounter = 0 ;
for ( var item in serviceItemsFromApi ) {
if ( ifItemAlreadySelected ( item . id ! ) ) {
item . isUpdateOrSelected = true ;
selectedSubServicesCounter + + ;
}
}
setState ( ViewState . idle ) ;
@ -618,7 +691,7 @@ class AppointmentsVM extends BaseVM {
}
if ( isHomeTapped ) {
if ( pickedHomeLocation = = " " ) {
if ( currentLocationInfoModel = = null | | currentLocationInfoModel ! . address = = " " ) {
updatePickHomeLocationError ( GlobalConsts . homeLocationEmptyError ) ;
return false ;
}
@ -662,8 +735,8 @@ class AppointmentsVM extends BaseVM {
isScrollControlled: true ,
enableDrag: true ,
builder: ( BuildContext context ) {
/ / TODO: It should be calculated from API
double totalKms = 15.3 ;
double totalKms = double . parse ( selectedService . servicelocationInfo . distanceToBranch . toStringAsFixed ( 2 ) ) ;
double pricePerKm = double . parse ( selectedService . servicelocationInfo . homeChargesInCurrentService . toStringAsFixed ( 2 ) ) ;
return InfoBottomSheet (
title: LocaleKeys . chargesBreakdown . tr ( ) . toText ( fontSize: 24 , isBold: true ) ,
description: Column (
@ -695,14 +768,14 @@ class AppointmentsVM extends BaseVM {
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
" ${ totalKms } km " . toText ( fontSize: 12 , color: MyColors . lightTextColor , isBold: true ) ,
" $ {selectedService . rangePricePerKm } x $ totalKms " . toText ( fontSize: 12 , isBold: true ) ,
" $ pricePerKm x $ totalKms " . toText ( fontSize: 12 , isBold: true ) ,
] ,
) ,
8. height ,
Row (
mainAxisAlignment: MainAxisAlignment . end ,
children: [
" ${ ( double . parse ( selectedService . rangePricePerKm ! ) ) * totalKms } ${ LocaleKeys . sar . tr ( ) } " . toText ( fontSize: 16 , isBold: true ) ,
" ${ ( ( pricePerKm ) * totalKms ) . toStringAsFixed ( 2 ) } ${ LocaleKeys . sar . tr ( ) } " . toText ( fontSize: 16 , isBold: true ) ,
] ,
) ,
] ,
@ -714,7 +787,7 @@ class AppointmentsVM extends BaseVM {
Row (
crossAxisAlignment: CrossAxisAlignment . end ,
children: [
( selectedService . isHomeSelected ? " ${ ( selectedService . currentTotalServicePrice ) + ( ( double . parse ( ( selectedService . rangePricePerKm ? ? " 0.0 " ) ) * totalKms ) ) } " : " ${ selectedService . currentTotalServicePrice } " )
( selectedService . isHomeSelected ? ( ( selectedService . currentTotalServicePrice ) + ( pricePerKm * totalKms ) ) . toStringAsFixed ( 2 ) : " ${ selectedService . currentTotalServicePrice } " )
. toText ( fontSize: 29 , isBold: true ) ,
2. width ,
LocaleKeys . sar . tr ( ) . toText ( color: MyColors . lightTextColor , fontSize: 16 , isBold: true ) . paddingOnly ( bottom: 5 ) ,
@ -762,7 +835,7 @@ class AppointmentsVM extends BaseVM {
void onServicesNextPressed ( BuildContext context ) async {
if ( allSelectedItemsInAppointments . isEmpty ) {
Utils . showToast ( " Please select at least one service. " ) ;
Utils . showToast ( LocaleKeys . pleaseSelectService . tr ( ) ) ;
return ;
}
Utils . showLoading ( context ) ;
@ -770,8 +843,6 @@ class AppointmentsVM extends BaseVM {
List < String > serviceItemIdsForHome = [ ] ;
List < String > serviceItemIdsForWorkshop = [ ] ;
for ( var serviceItem in allSelectedItemsInAppointments ) {
log ( " homeselcted for : ${ serviceItem . isHomeSelected } " ) ;
if ( serviceItem . isHomeSelected ! ) {
serviceItemIdsForHome . add ( serviceItem . id ! . toString ( ) ) ;
} else {
@ -794,6 +865,19 @@ class AppointmentsVM extends BaseVM {
for ( var schedule in serviceAppointmentScheduleList ) {
amountToPayForAppointment = amountToPayForAppointment + ( schedule . amountToPay ? ? 0.0 ) ;
totalAmount = totalAmount + ( schedule . amountTotal ? ? 0.0 ) ;
for ( var service in schedule . servicesListInAppointment ! ) {
int index = servicesInCurrentAppointment . indexWhere ( ( element ) = > element . serviceProviderServiceId = = service . serviceProviderServiceId ) ;
if ( index ! = - 1 ) {
if ( servicesInCurrentAppointment [ index ] . isHomeSelected ) {
service . servicelocationInfo = servicesInCurrentAppointment [ index ] . servicelocationInfo ;
schedule . locationInfoModel = servicesInCurrentAppointment [ index ] . servicelocationInfo ;
totalAmount =
totalAmount + ( ( servicesInCurrentAppointment [ index ] . servicelocationInfo . distanceToBranch ) * servicesInCurrentAppointment [ index ] . servicelocationInfo . homeChargesInCurrentService ) ;
schedule . totalLocationCharges = schedule . totalLocationCharges ! +
( servicesInCurrentAppointment [ index ] . servicelocationInfo . distanceToBranch * servicesInCurrentAppointment [ index ] . servicelocationInfo . homeChargesInCurrentService ) ;
}
}
}
}
Utils . hideLoading ( context ) ;
@ -867,7 +951,90 @@ class AppointmentsVM extends BaseVM {
}
}
/ / BRANCHES RELATED
/ / REPORT A COMPLAINT
String complaintDescription = " " ;
String complaintDescriptionError = " " ;
void updateComplaintDescription ( String value ) {
complaintDescription = value ;
if ( value . isNotEmpty ) {
complaintDescriptionError = " " ;
}
}
Future buildComplaintBottomSheet ( { required int customerID , required int complainType , required String customerName , required BuildContext context } ) {
return showModalBottomSheet (
context: context ,
isScrollControlled: true ,
enableDrag: true ,
builder: ( BuildContext context ) {
return InfoBottomSheet (
title: LocaleKeys . reportComplaint . tr ( ) . toText ( fontSize: 28 , isBold: true , letterSpacing: - 1.44 ) ,
description: Padding (
padding: EdgeInsets . only ( bottom: MediaQuery . of ( context ) . viewInsets . bottom ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
if ( customerName . isNotEmpty ) . . . [
( " ${ LocaleKeys . customerName . tr ( ) } : $ customerName " ) . toText ( fontSize: 15 , color: MyColors . lightTextColor ) ,
] ,
10. height ,
TxtField (
maxLines: 5 ,
value: complaintDescription ,
errorValue: complaintDescriptionError ,
keyboardType: TextInputType . text ,
hint: LocaleKeys . description . tr ( ) ,
onChanged: ( v ) = > updateComplaintDescription ( v ) ,
) ,
25. height ,
ShowFillButton (
title: LocaleKeys . submit . tr ( ) ,
onPressed: ( ) async {
if ( complaintDescription . isEmpty ) {
Utils . showToast ( LocaleKeys . descriptionCannotBeEmpty . tr ( ) ) ;
return ;
}
final status = await reportComplaintAgainstCustomer (
customerID: customerID ,
comment: complaintDescription ,
complaintType: complainType , / / 1 for Appointment and 2 for Requests
context: context ,
) ;
if ( status ) {
updateComplaintDescription ( " " ) ;
pop ( context ) ;
}
} ,
maxWidth: double . infinity ,
) ,
19. height ,
] ,
) ,
) ,
) ;
} ,
) ;
}
Future < bool > reportComplaintAgainstCustomer ( { required int customerID , required String comment , required int complaintType , required BuildContext context } ) async {
Utils . showLoading ( context ) ;
try {
GenericRespModel genericRespModel = await commonRepo . createComplainFromProvider ( customerId: customerID , comment: comment , complainType: complaintType ) ;
Utils . showToast ( genericRespModel . message . toString ( ) ) ;
Utils . hideLoading ( context ) ;
return genericRespModel . messageStatus = = 1 ;
} catch ( e , s ) {
logger . e ( s ) ;
Utils . hideLoading ( context ) ;
Utils . showToast ( e . toString ( ) ) ;
return false ;
}
}
/ / BRANCHES RELATED
List < BranchDetailModel > nearbyBranches = [ ] ;
List < BranchDetailModel > myRecentBranches = [ ] ;
@ -937,7 +1104,6 @@ class AppointmentsVM extends BaseVM {
Future < void > getBranchServices ( { required int categoryId } ) async {
branchSelectedServiceId = SelectionModel ( selectedOption: " " , selectedId: - 1 , errorValue: " " ) ;
isHomeTapped = false ;
pickedHomeLocation = " " ;
pickHomeLocationError = " " ;
if ( categoryId ! = - 1 ) {
isFetchingServices = true ;