|
|
|
|
@ -45,11 +45,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
final BranchRepo branchRepo;
|
|
|
|
|
final AppointmentRepo appointmentRepo;
|
|
|
|
|
|
|
|
|
|
AppointmentsVM(
|
|
|
|
|
{required this.commonServices,
|
|
|
|
|
required this.appointmentRepo,
|
|
|
|
|
required this.commonRepo,
|
|
|
|
|
required this.branchRepo});
|
|
|
|
|
AppointmentsVM({required this.commonServices,
|
|
|
|
|
required this.appointmentRepo,
|
|
|
|
|
required this.commonRepo,
|
|
|
|
|
required this.branchRepo});
|
|
|
|
|
|
|
|
|
|
bool isUpcommingEnabled = true;
|
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
|
@ -72,6 +71,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
List<DropValue> branchCategories = [];
|
|
|
|
|
|
|
|
|
|
bool isHomeTapped = false;
|
|
|
|
|
bool isShowEmptyMessage = false;
|
|
|
|
|
|
|
|
|
|
List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleList = [];
|
|
|
|
|
|
|
|
|
|
@ -99,7 +99,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
Future<void> onItemsSelectedInService() async {
|
|
|
|
|
if (currentServiceSelection != null) {
|
|
|
|
|
int index = servicesInCurrentAppointment.indexWhere((element) =>
|
|
|
|
|
element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
double totalPrice = 0.0;
|
|
|
|
|
@ -115,8 +115,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onPayNowPressedForAppointment(
|
|
|
|
|
{required BuildContext context, required int appointmentID}) async {
|
|
|
|
|
Future<void> onPayNowPressedForAppointment({required BuildContext context, required int appointmentID}) async {
|
|
|
|
|
context
|
|
|
|
|
.read<PaymentVM>()
|
|
|
|
|
.updateAppointmentIdsForPayment(ids: [appointmentID]);
|
|
|
|
|
@ -130,7 +129,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
List<int> appointmentIdsList = [];
|
|
|
|
|
try {
|
|
|
|
|
GenericRespModel genericRespModel =
|
|
|
|
|
await appointmentRepo.createServiceAppointment(
|
|
|
|
|
await appointmentRepo.createServiceAppointment(
|
|
|
|
|
schedules: serviceAppointmentScheduleList,
|
|
|
|
|
serviceProviderID: selectedBranchModel!.serviceProviderId ?? 0,
|
|
|
|
|
);
|
|
|
|
|
@ -178,8 +177,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onConfirmAppointmentPressed(
|
|
|
|
|
{required BuildContext context, required appointmentId}) async {
|
|
|
|
|
Future<void> onConfirmAppointmentPressed({required BuildContext context, required appointmentId}) async {
|
|
|
|
|
context
|
|
|
|
|
.read<PaymentVM>()
|
|
|
|
|
.updateAppointmentIdsForPayment(ids: [appointmentId]);
|
|
|
|
|
@ -187,13 +185,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
arguments: PaymentTypes.appointment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onCancelAppointmentPressed(
|
|
|
|
|
{required BuildContext context,
|
|
|
|
|
required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
Future<void> onCancelAppointmentPressed({required BuildContext context,
|
|
|
|
|
required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
GenericRespModel genericRespModel =
|
|
|
|
|
await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
|
await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
|
serviceAppointmentID: appointmentListModel.id ?? 0,
|
|
|
|
|
serviceSlotID: appointmentListModel.serviceSlotID ?? 0,
|
|
|
|
|
appointmentScheduleAction: 2, // 1 for Reschedule and 2 for Cancel
|
|
|
|
|
@ -240,7 +237,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel branchSelectedCategoryId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateProviderCategoryId(SelectionModel id) {
|
|
|
|
|
branchSelectedCategoryId = id;
|
|
|
|
|
@ -256,18 +253,18 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
void updateBranchServiceId(SelectionModel id) async {
|
|
|
|
|
branchSelectedServiceId = id;
|
|
|
|
|
currentServiceSelection = branchServices.firstWhere(
|
|
|
|
|
(element) => element.serviceProviderServiceId == id.selectedId);
|
|
|
|
|
(element) => element.serviceProviderServiceId == id.selectedId);
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeServiceInCurrentAppointment(int index) {
|
|
|
|
|
int serviceId = servicesInCurrentAppointment
|
|
|
|
|
.elementAt(index)
|
|
|
|
|
.serviceProviderServiceId ??
|
|
|
|
|
.elementAt(index)
|
|
|
|
|
.serviceProviderServiceId ??
|
|
|
|
|
-1;
|
|
|
|
|
allSelectedItemsInAppointments.removeWhere(
|
|
|
|
|
(element) => element.serviceProviderServiceId == serviceId);
|
|
|
|
|
(element) => element.serviceProviderServiceId == serviceId);
|
|
|
|
|
servicesInCurrentAppointment.removeAt(index);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
@ -314,9 +311,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
|
{required AppointmentStatusEnum appointmentStatusEnum,
|
|
|
|
|
bool isNeedCustomerFilter = false}) {
|
|
|
|
|
applyFilterOnAppointmentsVM({required AppointmentStatusEnum appointmentStatusEnum,
|
|
|
|
|
bool isNeedCustomerFilter = false}) {
|
|
|
|
|
// isNeedCustomerFilter IS ONLY FOR THE PROVIDER APP
|
|
|
|
|
if (appointmentsFilterOptions.isEmpty) return;
|
|
|
|
|
for (var value in appointmentsFilterOptions) {
|
|
|
|
|
@ -336,17 +332,15 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
if (appointmentStatusEnum.getIdFromAppointmentStatusEnum() == 0) {
|
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
|
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
myFilteredAppointments = myAppointments
|
|
|
|
|
.where((element) =>
|
|
|
|
|
element.appointmentStatusID! ==
|
|
|
|
|
appointmentStatusEnum.getIdFromAppointmentStatusEnum())
|
|
|
|
|
element.appointmentStatusID! ==
|
|
|
|
|
appointmentStatusEnum.getIdFromAppointmentStatusEnum())
|
|
|
|
|
.toList();
|
|
|
|
|
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findAppointmentsBasedOnCustomers() {
|
|
|
|
|
@ -382,32 +376,35 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
// }).toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getMyAppointments({bool isNeedToRebuild = false}) async {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
Future<void> getMyAppointments() async {
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
|
|
|
|
|
myAppointments =
|
|
|
|
|
await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
|
// myFilteredAppointments = myAppointments;
|
|
|
|
|
await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
|
myUpComingAppointments = myAppointments
|
|
|
|
|
.where((element) =>
|
|
|
|
|
element.appointmentStatusEnum == AppointmentStatusEnum.confirmed)
|
|
|
|
|
element.appointmentStatusEnum == AppointmentStatusEnum.confirmed)
|
|
|
|
|
.toList();
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
|
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
|
if (myUpComingAppointments.isEmpty) {
|
|
|
|
|
isShowEmptyMessage = true;
|
|
|
|
|
}
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppointmentSlots? appointmentSlots;
|
|
|
|
|
|
|
|
|
|
Future<void> getAppointmentSlotsInfo(
|
|
|
|
|
{required Map<String, dynamic> map,
|
|
|
|
|
required BuildContext context,
|
|
|
|
|
bool isNeedToRebuild = false}) async {
|
|
|
|
|
Future<void> getAppointmentSlotsInfo({required Map<String, dynamic> map,
|
|
|
|
|
required BuildContext context,
|
|
|
|
|
bool isNeedToRebuild = false}) async {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
try {
|
|
|
|
|
MResponse genericRespModel =
|
|
|
|
|
await appointmentRepo.getAppointmentSlots(map);
|
|
|
|
|
await appointmentRepo.getAppointmentSlots(map);
|
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
|
appointmentSlots = AppointmentSlots.fromJson(genericRespModel.data);
|
|
|
|
|
} else {
|
|
|
|
|
@ -418,17 +415,14 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getMyAppointmentsForProvider(Map<String, dynamic> map,
|
|
|
|
|
{bool isNeedToRebuild = false}) async {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
|
|
|
|
|
Future<void> getMyAppointmentsForProvider(Map<String, dynamic> map,) async {
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForProvider(map);
|
|
|
|
|
myFilteredAppointments = myAppointments;
|
|
|
|
|
myUpComingAppointments = myAppointments
|
|
|
|
|
myUpComingAppointments = await myAppointments
|
|
|
|
|
.where((element) =>
|
|
|
|
|
element.appointmentStatusEnum == AppointmentStatusEnum.booked)
|
|
|
|
|
element.appointmentStatusEnum == AppointmentStatusEnum.confirmed)
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
applyFilterOnAppointmentsVM(
|
|
|
|
|
appointmentStatusEnum: AppointmentStatusEnum.allAppointments,
|
|
|
|
|
isNeedCustomerFilter: true);
|
|
|
|
|
@ -440,7 +434,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
try {
|
|
|
|
|
MResponse genericRespModel =
|
|
|
|
|
await appointmentRepo.updateAppointmentStatus(map);
|
|
|
|
|
await appointmentRepo.updateAppointmentStatus(map);
|
|
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
|
Utils.showToast(LocaleKeys.appointmentStatusUpdated.tr());
|
|
|
|
|
@ -457,7 +451,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
try {
|
|
|
|
|
MResponse genericRespModel =
|
|
|
|
|
await appointmentRepo.updateAppointmentPaymentStatus(map);
|
|
|
|
|
await appointmentRepo.updateAppointmentPaymentStatus(map);
|
|
|
|
|
|
|
|
|
|
if (genericRespModel.messageStatus == 1) {
|
|
|
|
|
Utils.showToast(LocaleKeys.paymentStatusUpdated.tr());
|
|
|
|
|
@ -473,7 +467,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
{bool isNeedToRebuild = false}) async {
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
MResponse genericRespModel =
|
|
|
|
|
await appointmentRepo.createMergeAppointment(map);
|
|
|
|
|
await appointmentRepo.createMergeAppointment(map);
|
|
|
|
|
|
|
|
|
|
return genericRespModel;
|
|
|
|
|
}
|
|
|
|
|
@ -484,12 +478,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
.customerAppointmentList![currentIndex]
|
|
|
|
|
.isSelected = !(myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
.customerAppointmentList?[currentIndex]
|
|
|
|
|
.isSelected ??
|
|
|
|
|
.customerAppointmentList?[currentIndex]
|
|
|
|
|
.isSelected ??
|
|
|
|
|
false);
|
|
|
|
|
|
|
|
|
|
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
.customerAppointmentList ??
|
|
|
|
|
.customerAppointmentList ??
|
|
|
|
|
[]);
|
|
|
|
|
if (count > 1)
|
|
|
|
|
inNeedToEnableMergeButton = true;
|
|
|
|
|
@ -505,8 +499,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateSelectedAppointmentDate(
|
|
|
|
|
{required int dateIndex, required int scheduleIndex}) {
|
|
|
|
|
updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) {
|
|
|
|
|
for (var element in serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
.customTimeDateSlotList!) {
|
|
|
|
|
element.date!.isSelected = false;
|
|
|
|
|
@ -534,8 +527,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateSelectedAppointmentSlotByDate(
|
|
|
|
|
{required int scheduleIndex, required int slotIndex}) {
|
|
|
|
|
updateSelectedAppointmentSlotByDate({required int scheduleIndex, required int slotIndex}) {
|
|
|
|
|
for (var element in serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
.customTimeDateSlotList!) {
|
|
|
|
|
for (var element in element.availableSlots!) {
|
|
|
|
|
@ -543,17 +535,17 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int index =
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex!;
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex!;
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
.customTimeDateSlotList![index]
|
|
|
|
|
.availableSlots![slotIndex]
|
|
|
|
|
.isSelected = true;
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
.selectedCustomTimeDateSlotModel!
|
|
|
|
|
.availableSlots =
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
.customTimeDateSlotList![index]
|
|
|
|
|
.availableSlots!;
|
|
|
|
|
.selectedCustomTimeDateSlotModel!
|
|
|
|
|
.availableSlots =
|
|
|
|
|
serviceAppointmentScheduleList[scheduleIndex]
|
|
|
|
|
.customTimeDateSlotList![index]
|
|
|
|
|
.availableSlots!;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -568,7 +560,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
onItemUpdateOrSelected(int index, bool selected, int itemId) {
|
|
|
|
|
int serviceIndex = servicesInCurrentAppointment.indexWhere(
|
|
|
|
|
(element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
(element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
// print("servicesInCurrentAppointment: ${servicesInCurrentAppointment.length}");
|
|
|
|
|
// if (serviceIndex == -1) {
|
|
|
|
|
// return;
|
|
|
|
|
@ -588,7 +580,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
.add(serviceItemsFromApi[index]);
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
|
servicesInCurrentAppointment[serviceIndex]
|
|
|
|
|
.currentTotalServicePrice +
|
|
|
|
|
.currentTotalServicePrice +
|
|
|
|
|
double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -637,7 +629,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
String selectSubServicesError = "";
|
|
|
|
|
|
|
|
|
|
SelectionModel branchSelectedServiceId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updatePickHomeLocationError(String value) {
|
|
|
|
|
pickHomeLocationError = value;
|
|
|
|
|
@ -677,8 +669,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
return totalPrice.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openTheAddServiceBottomSheet(
|
|
|
|
|
BuildContext context, AppointmentsVM appointmentsVM) {
|
|
|
|
|
void openTheAddServiceBottomSheet(BuildContext context, AppointmentsVM appointmentsVM) {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
@ -689,8 +680,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void priceBreakDownClicked(
|
|
|
|
|
BuildContext context, ServiceModel selectedService) {
|
|
|
|
|
void priceBreakDownClicked(BuildContext context, ServiceModel selectedService) {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
@ -708,17 +698,18 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
Column(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
selectedService.serviceItems!.length,
|
|
|
|
|
(index) => Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: MyColors.lightTextColor,
|
|
|
|
|
isBold: true),
|
|
|
|
|
"${selectedService.serviceItems![index].price} SAR"
|
|
|
|
|
.toText(fontSize: 12, isBold: true),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
(index) =>
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: MyColors.lightTextColor,
|
|
|
|
|
isBold: true),
|
|
|
|
|
"${selectedService.serviceItems![index].price} SAR"
|
|
|
|
|
.toText(fontSize: 12, isBold: true),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
@ -764,16 +755,16 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
(selectedService.isHomeSelected
|
|
|
|
|
? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}"
|
|
|
|
|
: "${selectedService.currentTotalServicePrice}")
|
|
|
|
|
? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}"
|
|
|
|
|
: "${selectedService.currentTotalServicePrice}")
|
|
|
|
|
.toText(fontSize: 29, isBold: true),
|
|
|
|
|
2.width,
|
|
|
|
|
LocaleKeys.sar
|
|
|
|
|
.tr()
|
|
|
|
|
.toText(
|
|
|
|
|
color: MyColors.lightTextColor,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
isBold: true)
|
|
|
|
|
color: MyColors.lightTextColor,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
isBold: true)
|
|
|
|
|
.paddingOnly(bottom: 5),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
@ -834,7 +825,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList =
|
|
|
|
|
await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
|
await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
|
serviceItemIdsForHome: serviceItemIdsForHome,
|
|
|
|
|
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
|
|
|
|
|
);
|
|
|
|
|
@ -860,9 +851,8 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onRescheduleAppointmentPressed(
|
|
|
|
|
{required BuildContext context,
|
|
|
|
|
required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
Future<void> onRescheduleAppointmentPressed({required BuildContext context,
|
|
|
|
|
required AppointmentListModel appointmentListModel}) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
|
|
|
|
|
List<String> serviceItemIdsForHome = [];
|
|
|
|
|
@ -880,7 +870,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serviceAppointmentScheduleList =
|
|
|
|
|
await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
|
await appointmentRepo.mergeServiceIntoAvailableSchedules(
|
|
|
|
|
serviceItemIdsForHome: serviceItemIdsForHome,
|
|
|
|
|
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
|
|
|
|
|
);
|
|
|
|
|
@ -902,14 +892,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onRescheduleAppointmentConfirmPressed(
|
|
|
|
|
{required BuildContext context,
|
|
|
|
|
required int appointmentId,
|
|
|
|
|
required int selectedSlotId}) async {
|
|
|
|
|
Future<void> onRescheduleAppointmentConfirmPressed({required BuildContext context,
|
|
|
|
|
required int appointmentId,
|
|
|
|
|
required int selectedSlotId}) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
GenericRespModel genericRespModel =
|
|
|
|
|
await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
|
await appointmentRepo.cancelOrRescheduleServiceAppointment(
|
|
|
|
|
serviceAppointmentID: appointmentId,
|
|
|
|
|
serviceSlotID: selectedSlotId,
|
|
|
|
|
appointmentScheduleAction: 1, // 1 for Reschedule and 2 for Cancel
|
|
|
|
|
@ -972,14 +961,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getAllNearBranches(
|
|
|
|
|
{bool isNeedToRebuild = false, bool isFromRefresh = false}) async {
|
|
|
|
|
Future<void> getAllNearBranches({bool isNeedToRebuild = false, bool isFromRefresh = false}) async {
|
|
|
|
|
nearbyBranches.clear();
|
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
|
|
|
|
|
|
if (isFromRefresh) {
|
|
|
|
|
var selectedBranch =
|
|
|
|
|
branchesFilterOptions.firstWhere((element) => element.isSelected);
|
|
|
|
|
branchesFilterOptions.firstWhere((element) => element.isSelected);
|
|
|
|
|
nearbyBranches = await branchRepo
|
|
|
|
|
.getBranchesByFilters(categoryIdsList: [selectedBranch.id]);
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
@ -1023,7 +1011,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
getBranchAndServices(int providerId) async {
|
|
|
|
|
providerProfileModel = null;
|
|
|
|
|
providerProfileModel =
|
|
|
|
|
await branchRepo.getBranchAndServicesByProviderId(providerId);
|
|
|
|
|
await branchRepo.getBranchAndServicesByProviderId(providerId);
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1058,8 +1046,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
// Provider Filter
|
|
|
|
|
List<DropValue> branchFilterProviderSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeBranchFilterProviderSearchHistory(
|
|
|
|
|
{bool isClear = false, required int index}) {
|
|
|
|
|
void removeBranchFilterProviderSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
branchFilterProviderSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1082,7 +1069,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel branchFilterSelectedProviderId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateBranchFilterSelectedProviderId(SelectionModel id,
|
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
@ -1102,8 +1089,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
// Category Filter
|
|
|
|
|
List<DropValue> branchFilterCategorySearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeBranchFilterCategorySearchHistory(
|
|
|
|
|
{bool isClear = false, required int index}) {
|
|
|
|
|
void removeBranchFilterCategorySearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
branchFilterCategorySearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1126,13 +1112,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel branchFilterSelectedCategoryId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateBranchFilterSelectedCategoryId(SelectionModel id,
|
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
if (isForSearch) {
|
|
|
|
|
DropValue categoryDrop =
|
|
|
|
|
categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
list: branchFilterCategorySearchHistory, value: categoryDrop)) {
|
|
|
|
|
addBranchFilterCategorySearchHistory(value: categoryDrop);
|
|
|
|
|
@ -1146,8 +1132,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
// Services Filter
|
|
|
|
|
List<DropValue> branchFilterServicesSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeBranchFilterServicesSearchHistory(
|
|
|
|
|
{bool isClear = false, required int index}) {
|
|
|
|
|
void removeBranchFilterServicesSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
branchFilterServicesSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1170,13 +1155,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel branchFilterSelectedServiceId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateBranchFilterSelectedServiceId(SelectionModel id,
|
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
if (isForSearch) {
|
|
|
|
|
DropValue serviceDrop =
|
|
|
|
|
servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
list: branchFilterServicesSearchHistory, value: serviceDrop)) {
|
|
|
|
|
addBranchFilterServicesSearchHistory(value: serviceDrop);
|
|
|
|
|
@ -1220,7 +1205,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
providersDropList.clear();
|
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
|
List<ProviderBasicDataModel> providers =
|
|
|
|
|
await branchRepo.getAllProvidersWitheBasicData();
|
|
|
|
|
await branchRepo.getAllProvidersWitheBasicData();
|
|
|
|
|
for (var element in providers) {
|
|
|
|
|
providersDropList.add(
|
|
|
|
|
DropValue(element.id ?? 0, element.providerName ?? "N/A", ""),
|
|
|
|
|
@ -1239,10 +1224,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
DropValue(
|
|
|
|
|
element.id ?? 0,
|
|
|
|
|
((element.categoryName!.isEmpty
|
|
|
|
|
? "N/A"
|
|
|
|
|
: countryCode == "SA"
|
|
|
|
|
? element.categoryNameN
|
|
|
|
|
: element.categoryName) ??
|
|
|
|
|
? "N/A"
|
|
|
|
|
: countryCode == "SA"
|
|
|
|
|
? element.categoryNameN
|
|
|
|
|
: element.categoryName) ??
|
|
|
|
|
"N/A"),
|
|
|
|
|
""),
|
|
|
|
|
);
|
|
|
|
|
@ -1330,8 +1315,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getBranchesBasedOnCategoryFilters(
|
|
|
|
|
{required int categoryId}) async {
|
|
|
|
|
Future<void> getBranchesBasedOnCategoryFilters({required int categoryId}) async {
|
|
|
|
|
if (categoryId == 0) {
|
|
|
|
|
await getAllNearBranches();
|
|
|
|
|
return;
|
|
|
|
|
@ -1339,7 +1323,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
nearbyBranches.clear();
|
|
|
|
|
nearbyBranches =
|
|
|
|
|
await branchRepo.getBranchesByFilters(categoryIdsList: [categoryId]);
|
|
|
|
|
await branchRepo.getBranchesByFilters(categoryIdsList: [categoryId]);
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1347,8 +1331,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
List<DropValue> branchesDropList = [];
|
|
|
|
|
|
|
|
|
|
Future<void> fetchAllBranchesBySelectedProviderId(
|
|
|
|
|
{required List<int> providersIdsList}) async {
|
|
|
|
|
Future<void> fetchAllBranchesBySelectedProviderId({required List<int> providersIdsList}) async {
|
|
|
|
|
branchesDropList.clear();
|
|
|
|
|
setOnlyState(ViewState.busy);
|
|
|
|
|
List<BranchDetailModel> providers = await branchRepo.getBranchesByFilters(
|
|
|
|
|
@ -1378,8 +1361,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
// Provider Filter For Appointments
|
|
|
|
|
List<DropValue> appointmentFilterProviderSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeAppointmentFilterProviderSearchHistory(
|
|
|
|
|
{bool isClear = false, required int index}) {
|
|
|
|
|
void removeAppointmentFilterProviderSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
appointmentFilterProviderSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1416,7 +1398,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedProviderId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedProviderId(SelectionModel id,
|
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
@ -1436,8 +1418,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
List<DropValue> appointmentFilterBranchSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeAppointmentFilterBranchSearchHistory(
|
|
|
|
|
{bool isClear = false, required int index}) {
|
|
|
|
|
void removeAppointmentFilterBranchSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
appointmentFilterBranchSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1460,13 +1441,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedBranchId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedBranchId(SelectionModel id,
|
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
if (isForSearch) {
|
|
|
|
|
DropValue branchesDrop =
|
|
|
|
|
branchesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
branchesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
list: appointmentFilterBranchSearchHistory, value: branchesDrop)) {
|
|
|
|
|
addAppointmentFilterBranchSearchHistory(value: branchesDrop);
|
|
|
|
|
@ -1480,8 +1461,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
List<DropValue> appointmentFilterCategorySearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeAppointmentFilterCategorySearchHistory(
|
|
|
|
|
{bool isClear = false, required int index}) {
|
|
|
|
|
void removeAppointmentFilterCategorySearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
appointmentFilterCategorySearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1504,13 +1484,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedCategoryId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedCategoryId(SelectionModel id,
|
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
if (isForSearch) {
|
|
|
|
|
DropValue categoryDrop =
|
|
|
|
|
categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
categoryDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
list: appointmentFilterCategorySearchHistory, value: categoryDrop)) {
|
|
|
|
|
addAppointmentFilterCategorySearchHistory(value: categoryDrop);
|
|
|
|
|
@ -1522,8 +1502,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
List<DropValue> appointmentFilterServicesSearchHistory = [];
|
|
|
|
|
|
|
|
|
|
void removeAppointmentFilterServicesSearchHistory(
|
|
|
|
|
{bool isClear = false, required int index}) {
|
|
|
|
|
void removeAppointmentFilterServicesSearchHistory({bool isClear = false, required int index}) {
|
|
|
|
|
if (isClear) {
|
|
|
|
|
appointmentFilterServicesSearchHistory.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -1546,13 +1525,13 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SelectionModel appointmentFilterSelectedServiceId =
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
|
|
|
|
|
|
void updateAppointmentFilterSelectedServiceId(SelectionModel id,
|
|
|
|
|
{bool isForSearch = false}) async {
|
|
|
|
|
if (isForSearch) {
|
|
|
|
|
DropValue servicesDrop =
|
|
|
|
|
servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
servicesDropList.firstWhere((element) => element.id == id.selectedId);
|
|
|
|
|
if (!ifAlreadyExist(
|
|
|
|
|
list: appointmentFilterServicesSearchHistory, value: servicesDrop)) {
|
|
|
|
|
addAppointmentFilterServicesSearchHistory(value: servicesDrop);
|
|
|
|
|
@ -1612,7 +1591,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
myAppointments =
|
|
|
|
|
await appointmentRepo.getMyAppointmentsForCustomersByFilters(
|
|
|
|
|
await appointmentRepo.getMyAppointmentsForCustomersByFilters(
|
|
|
|
|
providerIdsList: providersIdsList.isNotEmpty ? providersIdsList : null,
|
|
|
|
|
categoryIdsList: categoryIdsList.isNotEmpty ? categoryIdsList : null,
|
|
|
|
|
serviceIdsList: servicesIdsList.isNotEmpty ? servicesIdsList : null,
|
|
|
|
|
|