Appointment Flow Testing

mirza_development
FaizHashmiCS22 2 years ago
parent d029656866
commit 3f7527f4b2

@ -3,7 +3,6 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/enums.dart';
extension EmailValidator on String { extension EmailValidator on String {
Widget toText( Widget toText(
@ -25,10 +24,7 @@ extension EmailValidator on String {
style: TextStyle( style: TextStyle(
fontStyle: isItalic ? FontStyle.italic : null, fontStyle: isItalic ? FontStyle.italic : null,
height: height, height: height,
decoration: isUnderLine decoration: isUnderLine ? TextDecoration.underline : textDecoration ?? TextDecoration.none,
? TextDecoration.underline
: textDecoration ?? TextDecoration.none,
fontSize: fontSize ?? 10, fontSize: fontSize ?? 10,
fontWeight: isBold ? FontWeight.bold : fontWeight ?? FontWeight.w600, fontWeight: isBold ? FontWeight.bold : fontWeight ?? FontWeight.w600,
color: color ?? MyColors.darkTextColor, color: color ?? MyColors.darkTextColor,
@ -37,9 +33,7 @@ extension EmailValidator on String {
); );
bool isValidEmail() { bool isValidEmail() {
return RegExp( return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this);
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')
.hasMatch(this);
} }
bool isNum() { bool isNum() {
@ -428,6 +422,10 @@ extension PaymentTypesToInt on PaymentTypes {
case PaymentTypes.request: case PaymentTypes.request:
return 5; return 5;
case PaymentTypes.extendAds:
return 6;
case PaymentTypes.partialAppointment:
return 7;
default: default:
return 0; return 0;

@ -4,18 +4,16 @@ import 'package:mc_common_app/api/api_client.dart';
import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/config/dependencies.dart'; import 'package:mc_common_app/config/dependencies.dart';
import 'package:mc_common_app/models/appointments_models/schedule_model.dart';
import 'package:mc_common_app/models/appointments_models/service_schedule_model.dart';
import 'package:mc_common_app/models/general_models/generic_resp_model.dart'; import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
import 'package:mc_common_app/models/general_models/m_response.dart'; import 'package:mc_common_app/models/general_models/m_response.dart';
import 'package:mc_common_app/models/provider_branches_models/profile/services.dart'; import 'package:mc_common_app/models/provider_branches_models/profile/services.dart';
import 'package:mc_common_app/models/appointments_models/schedule_model.dart';
import 'package:mc_common_app/models/appointments_models/service_schedule_model.dart';
import 'package:mc_common_app/utils/enums.dart';
import '../models/appointments_models/appointment_list_model.dart'; import '../models/appointments_models/appointment_list_model.dart';
abstract class AppointmentRepo { abstract class AppointmentRepo {
Future<List<AppointmentListModel>> getMyAppointments( Future<List<AppointmentListModel>> getMyAppointments(Map<String, dynamic> map);
Map<String, dynamic> map);
Future<MResponse> updateAppointmentStatus(Map<String, dynamic> map); Future<MResponse> updateAppointmentStatus(Map<String, dynamic> map);
@ -37,20 +35,14 @@ abstract class AppointmentRepo {
Future<MResponse> updateServicesInSchedule(Map map); Future<MResponse> updateServicesInSchedule(Map map);
Future<List<ServiceAppointmentScheduleModel>> Future<List<ServiceAppointmentScheduleModel>> mergeServiceIntoAvailableSchedules({
mergeServiceIntoAvailableSchedules({
required List<String> serviceItemIdsForHome, required List<String> serviceItemIdsForHome,
required List<String> serviceItemIdsForWorkshop, required List<String> serviceItemIdsForWorkshop,
}); });
Future<GenericRespModel> createServiceAppointment( Future<GenericRespModel> createServiceAppointment({required List<ServiceAppointmentScheduleModel> schedules, required int serviceProviderID});
{required List<ServiceAppointmentScheduleModel> schedules,
required int serviceProviderID});
Future<GenericRespModel> cancelOrRescheduleServiceAppointment( Future<GenericRespModel> cancelOrRescheduleServiceAppointment({required int serviceAppointmentID, required int serviceSlotID, required int appointmentScheduleAction});
{required int serviceAppointmentID,
required int serviceSlotID,
required int appointmentScheduleAction});
} }
class AppointmentRepoImp implements AppointmentRepo { class AppointmentRepoImp implements AppointmentRepo {
@ -58,25 +50,19 @@ class AppointmentRepoImp implements AppointmentRepo {
Future<Services> getAllServices(String branchId) async { Future<Services> getAllServices(String branchId) async {
Map<String, dynamic> map = {"ProviderBranchID": branchId}; Map<String, dynamic> map = {"ProviderBranchID": branchId};
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().getJsonForObject( return await injector.get<ApiClient>().getJsonForObject((json) => Services.fromJson(json), ApiConsts.getServicesOfBranch, token: t, queryParameters: map);
(json) => Services.fromJson(json), ApiConsts.getServicesOfBranch,
token: t, queryParameters: map);
} }
@override @override
Future<MResponse> createSchedule(Map map) async { Future<MResponse> createSchedule(Map map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().postJsonForObject( return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createSchedule, map, token: t);
(json) => MResponse.fromJson(json), ApiConsts.createSchedule, map,
token: t);
} }
@override @override
Future<MResponse> addServicesInSchedule(Map map) async { Future<MResponse> addServicesInSchedule(Map map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().postJsonForObject( return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createGroup, map, token: t);
(json) => MResponse.fromJson(json), ApiConsts.createGroup, map,
token: t);
} }
@override @override
@ -84,36 +70,29 @@ class AppointmentRepoImp implements AppointmentRepo {
Map<String, dynamic> map = {"ServiceProviderBranchID": branchId}; Map<String, dynamic> map = {"ServiceProviderBranchID": branchId};
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
GenericRespModel adsGenericModel = GenericRespModel adsGenericModel = await injector.get<ApiClient>().getJsonForObject(
await injector.get<ApiClient>().getJsonForObject(
(json) => GenericRespModel.fromJson(json), (json) => GenericRespModel.fromJson(json),
ApiConsts.getSchedule, ApiConsts.getSchedule,
token: t, token: t,
queryParameters: map, queryParameters: map,
); );
return List.generate(adsGenericModel.data.length, return List.generate(adsGenericModel.data.length, (index) => ScheduleData.fromJson(adsGenericModel.data[index]));
(index) => ScheduleData.fromJson(adsGenericModel.data[index]));
} }
@override @override
Future<MResponse> updateSchedule(Map map) async { Future<MResponse> updateSchedule(Map map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().postJsonForObject( return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.updateSchedule, map, token: t);
(json) => MResponse.fromJson(json), ApiConsts.updateSchedule, map,
token: t);
} }
@override @override
Future<MResponse> updateServicesInSchedule(Map map) async { Future<MResponse> updateServicesInSchedule(Map map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().postJsonForObject( return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.updateGroup, map, token: t);
(json) => MResponse.fromJson(json), ApiConsts.updateGroup, map,
token: t);
} }
Future<List<ServiceAppointmentScheduleModel>> Future<List<ServiceAppointmentScheduleModel>> mergeServiceIntoAvailableSchedules({
mergeServiceIntoAvailableSchedules({
required List<String> serviceItemIdsForHome, required List<String> serviceItemIdsForHome,
required List<String> serviceItemIdsForWorkshop, required List<String> serviceItemIdsForWorkshop,
}) async { }) async {
@ -128,29 +107,21 @@ class AppointmentRepoImp implements AppointmentRepo {
"ServiceItemIDs": serviceItemIdsForWorkshop, "ServiceItemIDs": serviceItemIdsForWorkshop,
} }
]; ];
GenericRespModel adsGenericModel = GenericRespModel adsGenericModel = await injector.get<ApiClient>().postJsonForObject(
await injector.get<ApiClient>().postJsonForObject(
(json) => GenericRespModel.fromJson(json), (json) => GenericRespModel.fromJson(json),
ApiConsts.GetServiceItemAppointmentScheduleSlots, ApiConsts.GetServiceItemAppointmentScheduleSlots,
queryParameters, queryParameters,
token: t, token: t,
); );
if (adsGenericModel.data == null) { if (adsGenericModel.data == null) {
return []; return [];
} }
List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleModel = List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleModel =
List.generate( List.generate(adsGenericModel.data.length, (index) => ServiceAppointmentScheduleModel.fromJson(adsGenericModel.data[index], isForAppointment: true));
adsGenericModel.data.length,
(index) =>
ServiceAppointmentScheduleModel.fromJson(
adsGenericModel.data[index],
isForAppointment: true));
return serviceAppointmentScheduleModel; return serviceAppointmentScheduleModel;
} }
Future<GenericRespModel> createServiceAppointment( Future<GenericRespModel> createServiceAppointment({required List<ServiceAppointmentScheduleModel> schedules, required int serviceProviderID}) async {
{required List<ServiceAppointmentScheduleModel> schedules,
required int serviceProviderID}) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
int customerId = AppState().getUser.data!.userInfo!.customerId ?? 0; int customerId = AppState().getUser.data!.userInfo!.customerId ?? 0;
@ -169,23 +140,20 @@ class AppointmentRepoImp implements AppointmentRepo {
"serviceItemID": serviceItemIds, "serviceItemID": serviceItemIds,
}); });
}); });
log("maplist: ${mapList.toString() }");
GenericRespModel adsGenericModel = GenericRespModel adsGenericModel = await injector.get<ApiClient>().postJsonForObject(
await injector.get<ApiClient>().postJsonForObject(
(json) => GenericRespModel.fromJson(json), (json) => GenericRespModel.fromJson(json),
ApiConsts.ServiceProvidersAppointmentCreate, ApiConsts.ServiceProvidersAppointmentCreate,
mapList, mapList,
token: t, token: t,
); );
return adsGenericModel; return adsGenericModel;
} }
@override @override
Future<GenericRespModel> cancelOrRescheduleServiceAppointment( Future<GenericRespModel> cancelOrRescheduleServiceAppointment({required int serviceAppointmentID, required int serviceSlotID, required int appointmentScheduleAction}) async {
{required int serviceAppointmentID,
required int serviceSlotID,
required int appointmentScheduleAction}) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
final payload = { final payload = {
@ -194,33 +162,27 @@ class AppointmentRepoImp implements AppointmentRepo {
"appointmentScheduleAction": appointmentScheduleAction, "appointmentScheduleAction": appointmentScheduleAction,
}; };
GenericRespModel adsGenericModel = GenericRespModel adsGenericModel = await injector.get<ApiClient>().postJsonForObject(
await injector.get<ApiClient>().postJsonForObject(
(json) => GenericRespModel.fromJson(json), (json) => GenericRespModel.fromJson(json),
ApiConsts.ServiceProviderAppointmentRescheduleCancelAppointment, ApiConsts.ServiceProviderAppointmentRescheduleCancelAppointment,
payload, payload,
token: t, token: t,
); );
return adsGenericModel; return adsGenericModel;
} }
@override @override
Future<List<AppointmentListModel>> getMyAppointments( Future<List<AppointmentListModel>> getMyAppointments(Map<String, dynamic> map) async {
Map<String, dynamic> map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
GenericRespModel genericRespModel = GenericRespModel genericRespModel = await injector.get<ApiClient>().getJsonForObject(
await injector.get<ApiClient>().getJsonForObject( token: t,
token: t,
(json) => GenericRespModel.fromJson(json), (json) => GenericRespModel.fromJson(json),
queryParameters: map, queryParameters: map,
ApiConsts.serviceProvidersAppointmentGet, ApiConsts.serviceProvidersAppointmentGet,
); );
List<AppointmentListModel> appointmentList = List.generate( List<AppointmentListModel> appointmentList = List.generate(genericRespModel.data.length, (index) => AppointmentListModel.fromJson(genericRespModel.data[index]));
genericRespModel.data.length,
(index) =>
AppointmentListModel.fromJson(genericRespModel.data[index]));
return appointmentList; return appointmentList;
} }
@ -228,42 +190,31 @@ class AppointmentRepoImp implements AppointmentRepo {
Future<MResponse> getAppointmentSlots(Map<String, dynamic> map) async { Future<MResponse> getAppointmentSlots(Map<String, dynamic> map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
MResponse adsGenericModel = MResponse adsGenericModel = await injector.get<ApiClient>().getJsonForObject(
await injector.get<ApiClient>().getJsonForObject(
(json) => MResponse.fromJson(json), (json) => MResponse.fromJson(json),
ApiConsts.getAppointmentSlots, ApiConsts.getAppointmentSlots,
token: t, token: t,
queryParameters: map, queryParameters: map,
); );
return adsGenericModel; return adsGenericModel;
} }
@override @override
Future<MResponse> updateAppointmentPaymentStatus( Future<MResponse> updateAppointmentPaymentStatus(Map<String, dynamic> map) async {
Map<String, dynamic> map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().postJsonForObject( return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.updateAppointmentPaymentStatus, map, token: t);
(json) => MResponse.fromJson(json),
ApiConsts.updateAppointmentPaymentStatus, map,
token: t);
} }
@override @override
Future<MResponse> updateAppointmentStatus(Map<String, dynamic> map) async { Future<MResponse> updateAppointmentStatus(Map<String, dynamic> map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().postJsonForObject( return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.updateAppointmentStatus, map, token: t);
(json) => MResponse.fromJson(json),
ApiConsts.updateAppointmentStatus, map,
token: t);
} }
@override @override
Future<MResponse> createMergeAppointment(Map<String, dynamic> map) async { Future<MResponse> createMergeAppointment(Map<String, dynamic> map) async {
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await injector.get<ApiClient>().postJsonForObject( return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createMergeAppointment, map, token: t);
(json) => MResponse.fromJson(json),
ApiConsts.createMergeAppointment, map,
token: t);
} }
} }

@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -8,7 +7,6 @@ import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/services/my_in_app_browser.dart'; import 'package:mc_common_app/services/my_in_app_browser.dart';
import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/utils.dart';
abstract class PaymentService { abstract class PaymentService {
Future<void> placePayment({ Future<void> placePayment({
@ -30,11 +28,11 @@ class PaymentServiceImp implements PaymentService {
MyInAppBrowser? myInAppBrowser; MyInAppBrowser? myInAppBrowser;
var inAppBrowserOptions = InAppBrowserClassOptions( var inAppBrowserOptions = InAppBrowserClassOptions(
inAppWebViewGroupOptions: inAppWebViewGroupOptions:
InAppWebViewGroupOptions(crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true, transparentBackground: false), ios: IOSInAppWebViewOptions(applePayAPIEnabled: true)), InAppWebViewGroupOptions(crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true, transparentBackground: false), ios: IOSInAppWebViewOptions(applePayAPIEnabled: true)),
crossPlatform: InAppBrowserOptions(hideUrlBar: true, toolbarTopBackgroundColor: Colors.black), crossPlatform: InAppBrowserOptions(hideUrlBar: true, toolbarTopBackgroundColor: Colors.black),
android: AndroidInAppBrowserOptions(), android: AndroidInAppBrowserOptions(),
ios: ios:
IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN)); IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN));
@override @override
Future<void> placePayment({ Future<void> placePayment({
@ -51,6 +49,7 @@ class PaymentServiceImp implements PaymentService {
urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&OrderProviderSubscriptionID=$id"; urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&OrderProviderSubscriptionID=$id";
break; break;
case PaymentTypes.appointment: case PaymentTypes.appointment:
case PaymentTypes.partialAppointment:
String appointIds = ''; String appointIds = '';
for (int i = 0; i < appointmentIds!.length; i++) { for (int i = 0; i < appointmentIds!.length; i++) {
var element = appointmentIds[i]; var element = appointmentIds[i];

@ -82,6 +82,7 @@ enum PaymentTypes {
ads, ads,
request, request,
extendAds, extendAds,
partialAppointment
} }
enum AdCreationSteps { enum AdCreationSteps {

@ -4,15 +4,15 @@ import 'package:mc_common_app/config/routes.dart';
import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/appointments_models/appointment_list_model.dart'; import 'package:mc_common_app/models/appointments_models/appointment_list_model.dart';
import 'package:mc_common_app/models/appointments_models/service_schedule_model.dart';
import 'package:mc_common_app/models/general_models/enums_model.dart'; import 'package:mc_common_app/models/general_models/enums_model.dart';
import 'package:mc_common_app/models/general_models/generic_resp_model.dart'; import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
import 'package:mc_common_app/models/general_models/m_response.dart'; import 'package:mc_common_app/models/general_models/m_response.dart';
import 'package:mc_common_app/models/general_models/widgets_models.dart';
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart'; import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
import 'package:mc_common_app/models/provider_branches_models/provider_profile_model.dart'; import 'package:mc_common_app/models/provider_branches_models/provider_profile_model.dart';
import 'package:mc_common_app/models/appointments_models/service_schedule_model.dart';
import 'package:mc_common_app/models/services_models/item_model.dart'; import 'package:mc_common_app/models/services_models/item_model.dart';
import 'package:mc_common_app/models/services_models/service_model.dart'; import 'package:mc_common_app/models/services_models/service_model.dart';
import 'package:mc_common_app/models/general_models/widgets_models.dart';
import 'package:mc_common_app/repositories/appointment_repo.dart'; import 'package:mc_common_app/repositories/appointment_repo.dart';
import 'package:mc_common_app/repositories/common_repo.dart'; import 'package:mc_common_app/repositories/common_repo.dart';
import 'package:mc_common_app/repositories/provider_repo.dart'; import 'package:mc_common_app/repositories/provider_repo.dart';
@ -39,10 +39,7 @@ class AppointmentsVM extends BaseVM {
final ProviderRepo providerRepo; final ProviderRepo providerRepo;
final AppointmentRepo scheduleRepo; final AppointmentRepo scheduleRepo;
AppointmentsVM({required this.commonServices, AppointmentsVM({required this.commonServices, required this.scheduleRepo, required this.providerRepo, required this.commonRepo});
required this.scheduleRepo,
required this.providerRepo,
required this.commonRepo});
bool isUpcommingEnabled = true; bool isUpcommingEnabled = true;
bool isFetchingLists = false; bool isFetchingLists = false;
@ -69,8 +66,7 @@ class AppointmentsVM extends BaseVM {
List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleList = []; List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleList = [];
bool ifItemAlreadySelected(int id) { bool ifItemAlreadySelected(int id) {
int indexFound = allSelectedItemsInAppointments int indexFound = allSelectedItemsInAppointments.indexWhere((element) => element.id == id);
.indexWhere((element) => element.id == id);
if (indexFound != -1) { if (indexFound != -1) {
return true; return true;
} }
@ -81,25 +77,17 @@ class AppointmentsVM extends BaseVM {
setupProviderAppointmentFilter() { setupProviderAppointmentFilter() {
appointmentsFilterOptions.clear(); appointmentsFilterOptions.clear();
appointmentsFilterOptions.add( appointmentsFilterOptions.add(FilterListModel(id: 0, title: "All Appointments", isSelected: true));
FilterListModel(id: 0, title: "All Appointments", isSelected: true)); appointmentsFilterOptions.add(FilterListModel(id: 2, title: "Confirmed", isSelected: false));
appointmentsFilterOptions appointmentsFilterOptions.add(FilterListModel(id: 3, title: "Arrived", isSelected: false));
.add(FilterListModel(id: 2, title: "Confirmed", isSelected: false)); appointmentsFilterOptions.add(FilterListModel(id: 7, title: "Work In Progress", isSelected: false));
appointmentsFilterOptions appointmentsFilterOptions.add(FilterListModel(id: 8, title: "Completed", isSelected: false));
.add(FilterListModel(id: 3, title: "Arrived", isSelected: false)); appointmentsFilterOptions.add(FilterListModel(id: 4, title: "Canceled", isSelected: false));
appointmentsFilterOptions
.add(
FilterListModel(id: 7, title: "Work In Progress", isSelected: false));
appointmentsFilterOptions
.add(FilterListModel(id: 8, title: "Completed", isSelected: false));
appointmentsFilterOptions
.add(FilterListModel(id: 4, title: "Canceled", isSelected: false));
} }
Future<void> onItemsSelectedInService() async { Future<void> onItemsSelectedInService() async {
if (currentServiceSelection != null) { if (currentServiceSelection != null) {
int index = servicesInCurrentAppointment.indexWhere((element) => int index = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
element.serviceId == currentServiceSelection!.serviceId!);
if (index == -1) { if (index == -1) {
double totalPrice = 0.0; double totalPrice = 0.0;
@ -115,47 +103,49 @@ class AppointmentsVM extends BaseVM {
} }
} }
Future<void> onPayNowPressedForAppointment({required BuildContext context, required int appointmentID}) async {
context.read<PaymentVM>().updateAppointmentIdsForPayment(ids: [appointmentID]);
navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.partialAppointment);
}
Future<void> onBookAppointmentPressed(BuildContext context) async { Future<void> onBookAppointmentPressed(BuildContext context) async {
Utils.showLoading(context); Utils.showLoading(context);
bool isSuccess = false; bool isSuccess = false;
List<int> appointmentIdsList = []; List<int> appointmentIdsList = [];
try { try {
GenericRespModel genericRespModel = GenericRespModel genericRespModel = await scheduleRepo.createServiceAppointment(
await scheduleRepo.createServiceAppointment(
schedules: serviceAppointmentScheduleList, schedules: serviceAppointmentScheduleList,
serviceProviderID: selectedBranchModel!.serviceProviderId ?? 0, serviceProviderID: selectedBranchModel!.serviceProviderId ?? 0,
); );
if (genericRespModel.messageStatus == 2 || if (genericRespModel.data.isEmpty) {
genericRespModel.data == null) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.showToast("${genericRespModel.message.toString()}"); Utils.showToast("${genericRespModel.message.toString()}");
return; return;
} }
if (genericRespModel.data != null) {
if (genericRespModel.data != null && genericRespModel.data.isNotEmpty) {
genericRespModel.data.forEach((element) { genericRespModel.data.forEach((element) {
if (element['appointmentID'] != 0) { if (element['appointmentID'] != 0) {
appointmentIdsList.add(element['appointmentID']); appointmentIdsList.add(element['appointmentID']);
isSuccess = true; isSuccess = true;
} else { } else {
isSuccess = false; isSuccess = false;
Utils.showToast(element['message']);
return; return;
} }
}); });
} }
context.read<DashboardVmCustomer>().onNavbarTapped(1); context.read<DashboardVmCustomer>().onNavbarTapped(1);
applyFilterOnAppointmentsVM( applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.booked);
appointmentStatusEnum: AppointmentStatusEnum.booked);
Utils.hideLoading(context); Utils.hideLoading(context);
resetAfterBookingAppointment(); resetAfterBookingAppointment();
if (isSuccess) { if (isSuccess) {
if (amountToPayForAppointment > 0) { if (amountToPayForAppointment > 0) {
context context.read<PaymentVM>().updateAppointmentIdsForPayment(ids: appointmentIdsList);
.read<PaymentVM>() navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.appointment);
.updateAppointmentIdsForPayment(ids: appointmentIdsList);
navigateWithName(context, AppRoutes.paymentMethodsView,
arguments: PaymentTypes.appointment);
} else { } else {
Utils.showToast("Your appointment has been booked successfully!"); Utils.showToast("Your appointment has been booked successfully!");
getMyAppointments(); getMyAppointments();
@ -167,36 +157,28 @@ class AppointmentsVM extends BaseVM {
} }
} }
Future<void> onConfirmAppointmentPressed( Future<void> onConfirmAppointmentPressed({required BuildContext context, required appointmentId}) async {
{required BuildContext context, required appointmentId}) async { context.read<PaymentVM>().updateAppointmentIdsForPayment(ids: [appointmentId]);
context navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.appointment);
.read<PaymentVM>()
.updateAppointmentIdsForPayment(ids: [appointmentId]);
navigateWithName(context, AppRoutes.paymentMethodsView,
arguments: PaymentTypes.appointment);
} }
Future<void> onCancelAppointmentPressed({required BuildContext context, Future<void> onCancelAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async {
required AppointmentListModel appointmentListModel}) async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
GenericRespModel genericRespModel = GenericRespModel genericRespModel = await scheduleRepo.cancelOrRescheduleServiceAppointment(
await scheduleRepo.cancelOrRescheduleServiceAppointment(
serviceAppointmentID: appointmentListModel.id ?? 0, serviceAppointmentID: appointmentListModel.id ?? 0,
serviceSlotID: appointmentListModel.serviceSlotID ?? 0, serviceSlotID: appointmentListModel.serviceSlotID ?? 0,
appointmentScheduleAction: 2, // 1 for Reschedule and 2 for Cancel appointmentScheduleAction: 2, // 1 for Reschedule and 2 for Cancel
); );
if (genericRespModel.messageStatus == 2 || if (genericRespModel.messageStatus == 2 || genericRespModel.data == null) {
genericRespModel.data == null) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.showToast("${genericRespModel.message.toString()}"); Utils.showToast("${genericRespModel.message.toString()}");
return; return;
} }
if (genericRespModel.messageStatus == 1) { if (genericRespModel.messageStatus == 1) {
context.read<DashboardVmCustomer>().onNavbarTapped(1); context.read<DashboardVmCustomer>().onNavbarTapped(1);
applyFilterOnAppointmentsVM( applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.cancelled);
appointmentStatusEnum: AppointmentStatusEnum.cancelled);
Utils.showToast("${genericRespModel.message.toString()}"); Utils.showToast("${genericRespModel.message.toString()}");
await getMyAppointments(); await getMyAppointments();
Utils.hideLoading(context); Utils.hideLoading(context);
@ -227,8 +209,7 @@ class AppointmentsVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
SelectionModel branchSelectedCategoryId = SelectionModel branchSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
void updateProviderCategoryId(SelectionModel id) { void updateProviderCategoryId(SelectionModel id) {
branchSelectedCategoryId = id; branchSelectedCategoryId = id;
@ -247,37 +228,30 @@ class AppointmentsVM extends BaseVM {
void updateBranchServiceId(SelectionModel id) async { void updateBranchServiceId(SelectionModel id) async {
branchSelectedServiceId = id; branchSelectedServiceId = id;
currentServiceSelection = branchServices.firstWhere( currentServiceSelection = branchServices.firstWhere((element) => element.serviceProviderServiceId == id.selectedId);
(element) => element.serviceProviderServiceId == id.selectedId);
notifyListeners(); notifyListeners();
} }
void removeServiceInCurrentAppointment(int index) { void removeServiceInCurrentAppointment(int index) {
int serviceId = servicesInCurrentAppointment int serviceId = servicesInCurrentAppointment.elementAt(index).serviceProviderServiceId ?? -1;
.elementAt(index) allSelectedItemsInAppointments.removeWhere((element) => element.serviceProviderServiceId == serviceId);
.serviceProviderServiceId ??
-1;
allSelectedItemsInAppointments.removeWhere(
(element) => element.serviceProviderServiceId == serviceId);
servicesInCurrentAppointment.removeAt(index); servicesInCurrentAppointment.removeAt(index);
notifyListeners(); notifyListeners();
} }
resetCategorySelectionBottomSheet() { resetCategorySelectionBottomSheet() {
selectedSubServicesCounter = 0; selectedSubServicesCounter = 0;
branchSelectedCategoryId = branchSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
isHomeTapped = false; isHomeTapped = false;
branchSelectedServiceId = branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
currentServiceSelection = null; currentServiceSelection = null;
} }
resetAfterBookingAppointment() { resetAfterBookingAppointment() {
allSelectedItemsInAppointments.clear(); // allSelectedItemsInAppointments.clear();
// servicesInCurrentAppointment.clear(); servicesInCurrentAppointment.clear();
serviceAppointmentScheduleList.clear(); // serviceAppointmentScheduleList.clear();
} }
List<EnumsModel> myAppointmentsEnum = []; List<EnumsModel> myAppointmentsEnum = [];
@ -285,32 +259,28 @@ class AppointmentsVM extends BaseVM {
populateAppointmentsFilterList() async { populateAppointmentsFilterList() async {
appointmentsFilterOptions.clear(); appointmentsFilterOptions.clear();
myAppointmentsEnum = await commonRepo.getEnumTypeValues( myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: 13); //TODO: 13 is to get Appointments Filter Enums
enumTypeID: 13); //TODO: 13 is to get Appointments Filter Enums
for (int i = 0; i < myAppointmentsEnum.length; i++) { for (int i = 0; i < myAppointmentsEnum.length; i++) {
appointmentsFilterOptions.add(FilterListModel( appointmentsFilterOptions.add(FilterListModel(title: myAppointmentsEnum[i].enumValueStr, isSelected: false, id: myAppointmentsEnum[i].enumValue));
title: myAppointmentsEnum[i].enumValueStr,
isSelected: false,
id: myAppointmentsEnum[i].enumValue));
} }
appointmentsFilterOptions.insert( appointmentsFilterOptions.insert(0, FilterListModel(title: "All Appointments", isSelected: true, id: 0));
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(); notifyListeners();
} }
applyFilterOnAppointmentsVM( applyFilterOnAppointmentsVM({required AppointmentStatusEnum appointmentStatusEnum, bool isNeedCustomerFilter = false}) {
{required AppointmentStatusEnum appointmentStatusEnum,
bool isNeedCustomerFilter = false}) {
if (appointmentsFilterOptions.isEmpty) return; if (appointmentsFilterOptions.isEmpty) return;
for (var value in appointmentsFilterOptions) { for (var value in appointmentsFilterOptions) {
value.isSelected = false; value.isSelected = false;
} }
appointmentsFilterOptions.forEach((element) { appointmentsFilterOptions.forEach((element) {
if (element.id == if (element.id == appointmentStatusEnum.getIdFromAppointmentStatusEnum()) {
appointmentStatusEnum.getIdFromAppointmentStatusEnum()) {
element.isSelected = true; element.isSelected = true;
} }
}); });
@ -325,16 +295,11 @@ class AppointmentsVM extends BaseVM {
return; return;
} }
myFilteredAppointments = myAppointments myFilteredAppointments = myAppointments.where((element) => element.appointmentStatusID! == appointmentStatusEnum.getIdFromAppointmentStatusEnum()).toList();
.where((element) =>
element.appointmentStatusID! ==
appointmentStatusEnum.getIdFromAppointmentStatusEnum())
.toList();
if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers(); if (isNeedCustomerFilter) findAppointmentsBasedOnCustomers();
notifyListeners(); notifyListeners();
} }
findAppointmentsBasedOnCustomers() { findAppointmentsBasedOnCustomers() {
// Use a Set to ensure uniqueness of customerIDs // Use a Set to ensure uniqueness of customerIDs
Set<int> uniqueCustomerIDs = Set<int>(); Set<int> uniqueCustomerIDs = Set<int>();
@ -346,9 +311,7 @@ class AppointmentsVM extends BaseVM {
// Create a list of CustomerData instances // Create a list of CustomerData instances
myFilteredAppointments2 = uniqueCustomerIDs.map((id) { myFilteredAppointments2 = uniqueCustomerIDs.map((id) {
List<AppointmentListModel> list = myFilteredAppointments List<AppointmentListModel> list = myFilteredAppointments.where((item) => item.customerID == id).toList();
.where((item) => item.customerID == id)
.toList();
AppointmentListModel model = list.first; AppointmentListModel model = list.first;
model.customerAppointmentList = list; model.customerAppointmentList = list;
return model; return model;
@ -373,10 +336,7 @@ class AppointmentsVM extends BaseVM {
myAppointments = await commonRepo.getMyAppointments(); myAppointments = await commonRepo.getMyAppointments();
myFilteredAppointments = myAppointments; myFilteredAppointments = myAppointments;
myUpComingAppointments = myAppointments myUpComingAppointments = myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList();
.where((element) =>
element.appointmentStatusEnum == AppointmentStatusEnum.confirmed)
.toList();
setState(ViewState.idle); setState(ViewState.idle);
// applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments); // applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
notifyListeners(); notifyListeners();
@ -384,9 +344,7 @@ class AppointmentsVM extends BaseVM {
AppointmentSlots? appointmentSlots; AppointmentSlots? appointmentSlots;
Future<void> getAppointmentSlotsInfo({required Map<String, dynamic> map, Future<void> getAppointmentSlotsInfo({required Map<String, dynamic> map, required BuildContext context, bool isNeedToRebuild = false}) async {
required BuildContext context,
bool isNeedToRebuild = false}) async {
if (isNeedToRebuild) setState(ViewState.busy); if (isNeedToRebuild) setState(ViewState.busy);
try { try {
MResponse genericRespModel = await scheduleRepo.getAppointmentSlots(map); MResponse genericRespModel = await scheduleRepo.getAppointmentSlots(map);
@ -400,20 +358,14 @@ class AppointmentsVM extends BaseVM {
} }
} }
Future<void> getProviderMyAppointments(Map<String, dynamic> map, Future<void> getProviderMyAppointments(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
{bool isNeedToRebuild = false}) async {
if (isNeedToRebuild) setState(ViewState.busy); if (isNeedToRebuild) setState(ViewState.busy);
myAppointments = await scheduleRepo.getMyAppointments(map); myAppointments = await scheduleRepo.getMyAppointments(map);
myFilteredAppointments = myAppointments; myFilteredAppointments = myAppointments;
myUpComingAppointments = myAppointments myUpComingAppointments = myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked).toList();
.where((element) =>
element.appointmentStatusEnum == AppointmentStatusEnum.booked) applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true);
.toList();
applyFilterOnAppointmentsVM(
appointmentStatusEnum: AppointmentStatusEnum.allAppointments,
isNeedCustomerFilter: true);
setState(ViewState.idle); setState(ViewState.idle);
} }
@ -423,12 +375,10 @@ class AppointmentsVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
updateAppointmentStatus(Map<String, dynamic> map, updateAppointmentStatus(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
{bool isNeedToRebuild = false}) async {
if (isNeedToRebuild) setState(ViewState.busy); if (isNeedToRebuild) setState(ViewState.busy);
try { try {
MResponse genericRespModel = MResponse genericRespModel = await scheduleRepo.updateAppointmentStatus(map);
await scheduleRepo.updateAppointmentStatus(map);
if (genericRespModel.messageStatus == 1) { if (genericRespModel.messageStatus == 1) {
Utils.showToast("appointment status updated"); Utils.showToast("appointment status updated");
@ -440,12 +390,10 @@ class AppointmentsVM extends BaseVM {
} }
} }
updateAppointmentPaymentStatus(Map<String, dynamic> map, updateAppointmentPaymentStatus(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
{bool isNeedToRebuild = false}) async {
if (isNeedToRebuild) setState(ViewState.busy); if (isNeedToRebuild) setState(ViewState.busy);
try { try {
MResponse genericRespModel = MResponse genericRespModel = await scheduleRepo.updateAppointmentPaymentStatus(map);
await scheduleRepo.updateAppointmentPaymentStatus(map);
if (genericRespModel.messageStatus == 1) { if (genericRespModel.messageStatus == 1) {
Utils.showToast("payment status updated"); Utils.showToast("payment status updated");
@ -457,11 +405,9 @@ class AppointmentsVM extends BaseVM {
} }
} }
Future<MResponse> createMergeAppointment(Map<String, dynamic> map, Future<MResponse> createMergeAppointment(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
{bool isNeedToRebuild = false}) async {
if (isNeedToRebuild) setState(ViewState.busy); if (isNeedToRebuild) setState(ViewState.busy);
MResponse genericRespModel = MResponse genericRespModel = await scheduleRepo.createMergeAppointment(map);
await scheduleRepo.createMergeAppointment(map);
return genericRespModel; return genericRespModel;
} }
@ -469,16 +415,10 @@ class AppointmentsVM extends BaseVM {
bool inNeedToEnableMergeButton = false; bool inNeedToEnableMergeButton = false;
updateCheckBoxInMergeRequest(int currentIndex) { updateCheckBoxInMergeRequest(int currentIndex) {
myFilteredAppointments2[selectedAppointmentIndex] myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected =
.customerAppointmentList![currentIndex] !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
.isSelected = !(myFilteredAppointments2[selectedAppointmentIndex]
.customerAppointmentList?[currentIndex] int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []);
.isSelected ??
false);
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex]
.customerAppointmentList ??
[]);
if (count > 1) if (count > 1)
inNeedToEnableMergeButton = true; inNeedToEnableMergeButton = true;
else else
@ -487,61 +427,35 @@ class AppointmentsVM extends BaseVM {
} }
int countSelected(List<AppointmentListModel> appointments) { int countSelected(List<AppointmentListModel> appointments) {
return appointments return appointments.where((appointment) => appointment.isSelected == true).toList().length;
.where((appointment) => appointment.isSelected == true)
.toList()
.length;
} }
updateSelectedAppointmentDate( updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) {
{required int dateIndex, required int scheduleIndex}) { for (var element in serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList!) {
for (var element in serviceAppointmentScheduleList[scheduleIndex]
.customTimeDateSlotList!) {
element.date!.isSelected = false; element.date!.isSelected = false;
} }
serviceAppointmentScheduleList[scheduleIndex] serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.isSelected = true;
.customTimeDateSlotList![dateIndex]
.date!
.isSelected = true;
serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex = dateIndex; serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex = dateIndex;
final date = TimeSlotModel( final date = TimeSlotModel(
date: serviceAppointmentScheduleList[scheduleIndex] date: serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.date,
.customTimeDateSlotList![dateIndex] slotId: serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.slotId,
.date!
.date,
slotId: serviceAppointmentScheduleList[scheduleIndex]
.customTimeDateSlotList![dateIndex]
.date!
.slotId,
isSelected: true, isSelected: true,
slot: "", slot: "",
); );
serviceAppointmentScheduleList[scheduleIndex] serviceAppointmentScheduleList[scheduleIndex].selectedCustomTimeDateSlotModel = CustomTimeDateSlotModel(date: date);
.selectedCustomTimeDateSlotModel = CustomTimeDateSlotModel(date: date);
notifyListeners(); notifyListeners();
} }
updateSelectedAppointmentSlotByDate( updateSelectedAppointmentSlotByDate({required int scheduleIndex, required int slotIndex}) {
{required int scheduleIndex, required int slotIndex}) { for (var element in serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList!) {
for (var element in serviceAppointmentScheduleList[scheduleIndex]
.customTimeDateSlotList!) {
for (var element in element.availableSlots!) { for (var element in element.availableSlots!) {
element.isSelected = false; element.isSelected = false;
} }
} }
int index = int index = serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex!;
serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex!; serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![index].availableSlots![slotIndex].isSelected = true;
serviceAppointmentScheduleList[scheduleIndex] serviceAppointmentScheduleList[scheduleIndex].selectedCustomTimeDateSlotModel!.availableSlots = serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![index].availableSlots!;
.customTimeDateSlotList![index]
.availableSlots![slotIndex]
.isSelected = true;
serviceAppointmentScheduleList[scheduleIndex]
.selectedCustomTimeDateSlotModel!
.availableSlots =
serviceAppointmentScheduleList[scheduleIndex]
.customTimeDateSlotList![index]
.availableSlots!;
notifyListeners(); notifyListeners();
} }
@ -555,9 +469,7 @@ class AppointmentsVM extends BaseVM {
int selectedSubServicesCounter = 0; int selectedSubServicesCounter = 0;
onItemUpdateOrSelected(int index, bool selected, int itemId) { onItemUpdateOrSelected(int index, bool selected, int itemId) {
int serviceIndex = servicesInCurrentAppointment.indexWhere( int serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
(element) =>
element.serviceId == currentServiceSelection!.serviceId!);
// print("servicesInCurrentAppointment: ${servicesInCurrentAppointment.length}"); // print("servicesInCurrentAppointment: ${servicesInCurrentAppointment.length}");
// if (serviceIndex == -1) { // if (serviceIndex == -1) {
// return; // return;
@ -572,28 +484,19 @@ class AppointmentsVM extends BaseVM {
allSelectedItemsInAppointments.add(serviceItemsFromApi[index]); allSelectedItemsInAppointments.add(serviceItemsFromApi[index]);
for (var element in allSelectedItemsInAppointments) { for (var element in allSelectedItemsInAppointments) {
if (!ifItemAlreadySelected(element.id!)) { if (!ifItemAlreadySelected(element.id!)) {
servicesInCurrentAppointment[serviceIndex] servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]);
.serviceItems!
.add(serviceItemsFromApi[index]);
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
servicesInCurrentAppointment[serviceIndex] servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0");
.currentTotalServicePrice +
double.parse((serviceItemsFromApi[index].price) ?? "0.0");
} }
} }
} }
if (!selected) { if (!selected) {
selectedSubServicesCounter = selectedSubServicesCounter - 1; selectedSubServicesCounter = selectedSubServicesCounter - 1;
currentServiceSelection!.serviceItems! currentServiceSelection!.serviceItems!.removeWhere((element) => element.id == itemId);
.removeWhere((element) => element.id == itemId); allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId);
allSelectedItemsInAppointments
.removeWhere((element) => element.id == itemId);
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
double.parse((serviceItemsFromApi[index].price) ?? "0.0"); servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId);
servicesInCurrentAppointment[serviceIndex]
.serviceItems!
.removeWhere((element) => element.id == itemId);
} }
notifyListeners(); notifyListeners();
} }
@ -649,8 +552,7 @@ class AppointmentsVM extends BaseVM {
String pickHomeLocationError = ""; String pickHomeLocationError = "";
String selectSubServicesError = ""; String selectSubServicesError = "";
SelectionModel branchSelectedServiceId = SelectionModel branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
bool isCategoryAlreadyPresent(int id) { bool isCategoryAlreadyPresent(int id) {
final contain = branchCategories.where((element) => element.id == id); final contain = branchCategories.where((element) => element.id == id);
@ -663,16 +565,14 @@ class AppointmentsVM extends BaseVM {
void getBranchCategories() async { void getBranchCategories() async {
for (var value in selectedBranchModel!.branchServices!) { for (var value in selectedBranchModel!.branchServices!) {
if (!isCategoryAlreadyPresent(value.categoryId!)) { if (!isCategoryAlreadyPresent(value.categoryId!)) {
branchCategories branchCategories.add(DropValue(value.categoryId!, value.categoryName!, ""));
.add(DropValue(value.categoryId!, value.categoryName!, ""));
} }
} }
notifyListeners(); notifyListeners();
} }
getBranchServices({required int categoryId}) async { getBranchServices({required int categoryId}) async {
branchSelectedServiceId = branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
isHomeTapped = false; isHomeTapped = false;
pickedHomeLocation = ""; pickedHomeLocation = "";
pickHomeLocationError = ""; pickHomeLocationError = "";
@ -685,9 +585,7 @@ class AppointmentsVM extends BaseVM {
} }
List<ServiceModel> getFilteredBranchServices({required int categoryId}) { List<ServiceModel> getFilteredBranchServices({required int categoryId}) {
List<ServiceModel> filteredServices = selectedBranchModel!.branchServices! List<ServiceModel> filteredServices = selectedBranchModel!.branchServices!.where((element) => element.categoryId == categoryId).toList();
.where((element) => element.categoryId == categoryId)
.toList();
return filteredServices; return filteredServices;
} }
@ -729,8 +627,7 @@ class AppointmentsVM extends BaseVM {
return totalPrice.toString(); return totalPrice.toString();
} }
void openTheAddServiceBottomSheet(BuildContext context, void openTheAddServiceBottomSheet(BuildContext context, AppointmentsVM appointmentsVM) {
AppointmentsVM appointmentsVM) {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
@ -741,8 +638,7 @@ class AppointmentsVM extends BaseVM {
); );
} }
void priceBreakDownClicked(BuildContext context, void priceBreakDownClicked(BuildContext context, ServiceModel selectedService) {
ServiceModel selectedService) {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
@ -758,27 +654,19 @@ class AppointmentsVM extends BaseVM {
Column( Column(
children: List.generate( children: List.generate(
selectedService.serviceItems!.length, selectedService.serviceItems!.length,
(index) => (index) => Row(
Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
children: [ "${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
"${selectedService.serviceItems![index].name}" "${selectedService.serviceItems![index].price} SAR".toText(fontSize: 12, isBold: true),
.toText( ],
fontSize: 12, ),
color: MyColors.lightTextColor,
isBold: true),
"${selectedService.serviceItems![index]
.price} SAR"
.toText(fontSize: 12, isBold: true),
],
),
), ),
), ),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
"${selectedService.currentTotalServicePrice} SAR" "${selectedService.currentTotalServicePrice} SAR".toText(fontSize: 16, isBold: true),
.toText(fontSize: 16, isBold: true),
], ],
), ),
if (selectedService.isHomeSelected) ...[ if (selectedService.isHomeSelected) ...[
@ -787,20 +675,15 @@ class AppointmentsVM extends BaseVM {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
"${totalKms}km ".toText( "${totalKms}km ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
fontSize: 12, "${selectedService.rangePricePerKm} x $totalKms".toText(fontSize: 12, isBold: true),
color: MyColors.lightTextColor,
isBold: true),
"${selectedService.rangePricePerKm} x $totalKms"
.toText(fontSize: 12, isBold: true),
], ],
), ),
8.height, 8.height,
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
"${selectedService.rangePricePerKm ?? 0 * totalKms} SAR" "${selectedService.rangePricePerKm ?? 0 * totalKms} SAR".toText(fontSize: 16, isBold: true),
.toText(fontSize: 16, isBold: true),
], ],
), ),
], ],
@ -813,18 +696,11 @@ class AppointmentsVM extends BaseVM {
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
(selectedService.isHomeSelected (selectedService.isHomeSelected
? "${(selectedService.currentTotalServicePrice) + ? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}"
(double.parse((selectedService.rangePricePerKm ?? : "${selectedService.currentTotalServicePrice}")
"0.0")) * totalKms)}"
: "${selectedService.currentTotalServicePrice}")
.toText(fontSize: 29, isBold: true), .toText(fontSize: 29, isBold: true),
2.width, 2.width,
"SAR" "SAR".toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
.toText(
color: MyColors.lightTextColor,
fontSize: 16,
isBold: true)
.paddingOnly(bottom: 5),
], ],
) )
], ],
@ -844,8 +720,7 @@ class AppointmentsVM extends BaseVM {
isValidated = false; isValidated = false;
break; break;
} }
if (schedule.selectedCustomTimeDateSlotModel!.date == null || if (schedule.selectedCustomTimeDateSlotModel!.date == null || !schedule.selectedCustomTimeDateSlotModel!.date!.isSelected) {
!schedule.selectedCustomTimeDateSlotModel!.date!.isSelected) {
isValidated = false; isValidated = false;
break; break;
} else { } else {
@ -853,9 +728,7 @@ class AppointmentsVM extends BaseVM {
isValidated = false; isValidated = false;
break; break;
} else { } else {
TimeSlotModel slot = schedule TimeSlotModel slot = schedule.selectedCustomTimeDateSlotModel!.availableSlots!.firstWhere((element) => element.isSelected);
.selectedCustomTimeDateSlotModel!.availableSlots!
.firstWhere((element) => element.isSelected);
if (slot.date.isNotEmpty) { if (slot.date.isNotEmpty) {
isValidated = true; isValidated = true;
break; break;
@ -864,8 +737,7 @@ class AppointmentsVM extends BaseVM {
} }
} }
if (!isValidated) { if (!isValidated) {
Utils.showToast( Utils.showToast("You must select appointment time for each schedule's appointment.");
"You must select appointment time for each schedule's appointment.");
return; return;
} }
navigateWithName(context, AppRoutes.reviewAppointmentView); navigateWithName(context, AppRoutes.reviewAppointmentView);
@ -884,36 +756,30 @@ class AppointmentsVM extends BaseVM {
} }
} }
serviceAppointmentScheduleList = serviceAppointmentScheduleList = await scheduleRepo.mergeServiceIntoAvailableSchedules(
await scheduleRepo.mergeServiceIntoAvailableSchedules(
serviceItemIdsForHome: serviceItemIdsForHome, serviceItemIdsForHome: serviceItemIdsForHome,
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop, serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
); );
if (serviceAppointmentScheduleList.isEmpty) { if (serviceAppointmentScheduleList.isEmpty) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.showToast( Utils.showToast("There are no available appointments for selected Items.");
"There are no available appointments for selected Items.");
return; return;
} }
totalAmount = 0.0; totalAmount = 0.0;
amountToPayForAppointment = 0.0; amountToPayForAppointment = 0.0;
for (var schedule in serviceAppointmentScheduleList) { for (var schedule in serviceAppointmentScheduleList) {
amountToPayForAppointment = amountToPayForAppointment = amountToPayForAppointment + (schedule.amountToPay ?? 0.0);
amountToPayForAppointment + (schedule.amountToPay ?? 0.0);
totalAmount = totalAmount + (schedule.amountTotal ?? 0.0); totalAmount = totalAmount + (schedule.amountTotal ?? 0.0);
} }
Utils.hideLoading(context); Utils.hideLoading(context);
navigateWithName(context, AppRoutes.bookAppointmenSchedulesView, navigateWithName(context, AppRoutes.bookAppointmenSchedulesView, arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 1, appointmentId: 0)); // 1 For Creating an Appointment
arguments: ScreenArgumentsForAppointmentDetailPage(
routeFlag: 1, appointmentId: 0)); // 1 For Creating an Appointment
notifyListeners(); notifyListeners();
} }
Future<void> onRescheduleAppointmentPressed({required BuildContext context, Future<void> onRescheduleAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async {
required AppointmentListModel appointmentListModel}) async {
Utils.showLoading(context); Utils.showLoading(context);
List<String> serviceItemIdsForHome = []; List<String> serviceItemIdsForHome = [];
@ -930,16 +796,14 @@ class AppointmentsVM extends BaseVM {
} }
} }
serviceAppointmentScheduleList = serviceAppointmentScheduleList = await scheduleRepo.mergeServiceIntoAvailableSchedules(
await scheduleRepo.mergeServiceIntoAvailableSchedules(
serviceItemIdsForHome: serviceItemIdsForHome, serviceItemIdsForHome: serviceItemIdsForHome,
serviceItemIdsForWorkshop: serviceItemIdsForWorkshop, serviceItemIdsForWorkshop: serviceItemIdsForWorkshop,
); );
if (serviceAppointmentScheduleList.isEmpty) { if (serviceAppointmentScheduleList.isEmpty) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.showToast( Utils.showToast("There are no available appointments for selected Items.");
"There are no available appointments for selected Items.");
return; return;
} }
Utils.hideLoading(context); Utils.hideLoading(context);
@ -947,36 +811,29 @@ class AppointmentsVM extends BaseVM {
navigateWithName( navigateWithName(
context, context,
AppRoutes.bookAppointmenSchedulesView, AppRoutes.bookAppointmenSchedulesView,
arguments: ScreenArgumentsForAppointmentDetailPage( arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 2, appointmentId: appointmentListModel.id ?? 0),
routeFlag: 2, appointmentId: appointmentListModel.id ?? 0),
); // 2 For Rescheduling an Appointment ); // 2 For Rescheduling an Appointment
notifyListeners(); notifyListeners();
} }
Future<void> onRescheduleAppointmentConfirmPressed( Future<void> onRescheduleAppointmentConfirmPressed({required BuildContext context, required int appointmentId, required int selectedSlotId}) async {
{required BuildContext context,
required int appointmentId,
required int selectedSlotId}) async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
GenericRespModel genericRespModel = GenericRespModel genericRespModel = await scheduleRepo.cancelOrRescheduleServiceAppointment(
await scheduleRepo.cancelOrRescheduleServiceAppointment(
serviceAppointmentID: appointmentId, serviceAppointmentID: appointmentId,
serviceSlotID: selectedSlotId, serviceSlotID: selectedSlotId,
appointmentScheduleAction: 1, // 1 for Reschedule and 2 for Cancel appointmentScheduleAction: 1, // 1 for Reschedule and 2 for Cancel
); );
if (genericRespModel.messageStatus == 2 || if (genericRespModel.messageStatus == 2 || genericRespModel.data == null) {
genericRespModel.data == null) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.showToast("${genericRespModel.message.toString()}"); Utils.showToast("${genericRespModel.message.toString()}");
return; return;
} }
if (genericRespModel.messageStatus == 1) { if (genericRespModel.messageStatus == 1) {
context.read<DashboardVmCustomer>().onNavbarTapped(1); context.read<DashboardVmCustomer>().onNavbarTapped(1);
applyFilterOnAppointmentsVM( applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.cancelled);
appointmentStatusEnum: AppointmentStatusEnum.cancelled);
Utils.showToast("${genericRespModel.message.toString()}"); Utils.showToast("${genericRespModel.message.toString()}");
getMyAppointments(); getMyAppointments();
Utils.hideLoading(context); Utils.hideLoading(context);

@ -76,7 +76,7 @@ class PaymentVM extends ChangeNotifier {
await Future.delayed(const Duration(seconds: 2)); await Future.delayed(const Duration(seconds: 2));
Utils.hideLoading(context); Utils.hideLoading(context);
print("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}"); log("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}");
if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) { if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Failed!"); Utils.showToast("Payment Failed!");
@ -96,7 +96,7 @@ class PaymentVM extends ChangeNotifier {
await Future.delayed(const Duration(seconds: 2)); await Future.delayed(const Duration(seconds: 2));
Utils.hideLoading(context); Utils.hideLoading(context);
print("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}"); log("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}");
if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) { if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Failed!"); Utils.showToast("Payment Failed!");
@ -114,6 +114,7 @@ class PaymentVM extends ChangeNotifier {
case PaymentTypes.subscription: case PaymentTypes.subscription:
return orderProviderSubscriptionId; return orderProviderSubscriptionId;
case PaymentTypes.appointment: case PaymentTypes.appointment:
case PaymentTypes.partialAppointment:
return -1; return -1;
case PaymentTypes.request: case PaymentTypes.request:
return requestId; return requestId;
@ -151,10 +152,15 @@ class PaymentVM extends ChangeNotifier {
break; break;
case PaymentTypes.extendAds: case PaymentTypes.extendAds:
// TODO: Handle this case. // TODO: Handle this case.
break;
case PaymentTypes.partialAppointment:
log("Partial Appointment Payment has been Failed!!");
break; break;
} }
}, },
onSuccess: () async { onSuccess: () async {
// TOD0: we have to take payment confirmation methods from Backend team and make success callbacks like onAdsPaymentSuccess
switch (paymentTypeEnum) { switch (paymentTypeEnum) {
case PaymentTypes.subscription: case PaymentTypes.subscription:
break; break;
@ -168,6 +174,9 @@ class PaymentVM extends ChangeNotifier {
case PaymentTypes.extendAds: case PaymentTypes.extendAds:
await onAdsPaymentSuccess(context: context, paymentTypeId: paymentTypeEnum.getIdFromPaymentTypesEnum(), currentAdId: currentAdId); await onAdsPaymentSuccess(context: context, paymentTypeId: paymentTypeEnum.getIdFromPaymentTypesEnum(), currentAdId: currentAdId);
break; break;
case PaymentTypes.partialAppointment:
log("Partial Appointment Payment has been Succeeded");
break;
} }
}, },
); );
@ -177,6 +186,7 @@ class PaymentVM extends ChangeNotifier {
currentPaymentType = paymentType; currentPaymentType = paymentType;
switch (currentPaymentType) { switch (currentPaymentType) {
case PaymentTypes.appointment: case PaymentTypes.appointment:
case PaymentTypes.partialAppointment:
if (appointmentIdsForPayment.isEmpty) return; if (appointmentIdsForPayment.isEmpty) return;
await placeThePayment(context: context, paymentTypeEnum: paymentType); await placeThePayment(context: context, paymentTypeEnum: paymentType);
break; break;

@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/classes/consts.dart';
@ -40,6 +41,7 @@ class AdsDetailView extends StatefulWidget {
class _AdsDetailViewState extends State<AdsDetailView> { class _AdsDetailViewState extends State<AdsDetailView> {
@override @override
void initState() { void initState() {
log("ad: ${widget.adDetails.id}");
scheduleMicrotask(() { scheduleMicrotask(() {
onAdDetailsLoaded(); onAdDetailsLoaded();
}); });

@ -33,6 +33,7 @@ class AppointmentDetailView extends StatelessWidget {
} }
Widget getArrivedBottomActionButton({required BuildContext context, required AppointmentPaymentStatusEnum appointmentPaymentStatusEnum}) { Widget getArrivedBottomActionButton({required BuildContext context, required AppointmentPaymentStatusEnum appointmentPaymentStatusEnum}) {
final appointmentVM = context.read<AppointmentsVM>();
switch (appointmentPaymentStatusEnum) { switch (appointmentPaymentStatusEnum) {
case AppointmentPaymentStatusEnum.defaultStatus: case AppointmentPaymentStatusEnum.defaultStatus:
case AppointmentPaymentStatusEnum.paid: case AppointmentPaymentStatusEnum.paid:
@ -42,19 +43,34 @@ class AppointmentDetailView extends StatelessWidget {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Row( child: Row(
children: [ children: [
getBaseActionButtonWidget(color: MyColors.grey98Color.withOpacity(0.3), textColor: MyColors.lightTextColor, onPressed: () {}, text: "In Progress"), getBaseActionButtonWidget(
color: MyColors.grey98Color.withOpacity(0.3),
textColor: MyColors.lightTextColor,
onPressed: () {},
text: "Work In Progress",
),
], ],
), ),
); );
case AppointmentPaymentStatusEnum.payNow: case AppointmentPaymentStatusEnum.payNow:
return Expanded( return Align(
child: ShowFillButton( alignment: Alignment.bottomCenter,
maxHeight: 55, child: Row(
title: "Pay Now", children: [
onPressed: () {}, getBaseActionButtonWidget(
backgroundColor: MyColors.darkPrimaryColor, color: MyColors.darkPrimaryColor,
txtColor: MyColors.white, textColor: MyColors.white,
fontSize: 18, onPressed: () {
if (appointmentListModel.remainingAmount != null && appointmentListModel.remainingAmount! > 0.0) {
appointmentVM.onPayNowPressedForAppointment(
context: context,
appointmentID: appointmentListModel.id ?? 0,
);
}
},
text: "Pay Now",
),
],
), ),
); );
} }
@ -87,7 +103,23 @@ class AppointmentDetailView extends StatelessWidget {
], ],
), ),
); );
case AppointmentStatusEnum.visitCompleted:
return Align(
alignment: Alignment.bottomCenter,
child: Row(
children: [
getBaseActionButtonWidget(
color: MyColors.grey98Color.withOpacity(0.3),
textColor: MyColors.lightTextColor,
onPressed: () {},
text: "Visit Completed",
),
],
),
);
case AppointmentStatusEnum.arrived: case AppointmentStatusEnum.arrived:
case AppointmentStatusEnum.workStarted:
return getArrivedBottomActionButton(appointmentPaymentStatusEnum: appointmentListModel.appointmentPaymentStatusEnum ?? AppointmentPaymentStatusEnum.defaultStatus, context: context); return getArrivedBottomActionButton(appointmentPaymentStatusEnum: appointmentListModel.appointmentPaymentStatusEnum ?? AppointmentPaymentStatusEnum.defaultStatus, context: context);
case AppointmentStatusEnum.cancelled: case AppointmentStatusEnum.cancelled:
return Align( return Align(
@ -223,10 +255,7 @@ class AppointmentDetailView extends StatelessWidget {
((service.currentTotalServicePrice).toString()).toText(fontSize: 25, isBold: true), ((service.currentTotalServicePrice).toString()).toText(fontSize: 25, isBold: true),
2.width, 2.width,
"SAR".toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5), "SAR".toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
Icon( const Icon(Icons.arrow_drop_down, size: 30)
Icons.arrow_drop_down,
size: 30,
)
], ],
).onPress(() => appointmentsVM.priceBreakDownClicked(context, service)), ).onPress(() => appointmentsVM.priceBreakDownClicked(context, service)),
], ],
@ -235,28 +264,30 @@ class AppointmentDetailView extends StatelessWidget {
), ),
], ],
15.height, 15.height,
Row( if (appointmentListModel.appointmentStatusEnum != AppointmentStatusEnum.workStarted && appointmentListModel.appointmentStatusEnum != AppointmentStatusEnum.visitCompleted) ...[
children: [ Row(
CardButtonWithIcon( children: [
title: "Reschedule Appointment",
onCardTapped: () {
context.read<AppointmentsVM>().onRescheduleAppointmentPressed(context: context, appointmentListModel: appointmentListModel);
},
icon: MyAssets.scheduleAppointmentIcon.buildSvg(),
),
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.booked) ...[
10.width,
CardButtonWithIcon( CardButtonWithIcon(
title: "Pay for Appointment", title: "Reschedule Appointment",
onCardTapped: () { onCardTapped: () {
context.read<AppointmentsVM>().onConfirmAppointmentPressed(context: context, appointmentId: appointmentListModel.id); context.read<AppointmentsVM>().onRescheduleAppointmentPressed(context: context, appointmentListModel: appointmentListModel);
}, },
icon: MyAssets.creditCardIcon.buildSvg(), icon: MyAssets.scheduleAppointmentIcon.buildSvg(),
), ),
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.booked) ...[
10.width,
CardButtonWithIcon(
title: "Pay for Appointment",
onCardTapped: () {
context.read<AppointmentsVM>().onConfirmAppointmentPressed(context: context, appointmentId: appointmentListModel.id);
},
icon: MyAssets.creditCardIcon.buildSvg(),
),
],
], ],
], ),
), 15.height,
15.height, ],
], ],
).toWhiteContainer(width: double.infinity, allPading: 12), ).toWhiteContainer(width: double.infinity, allPading: 12),
buildBottomActionButton(appointmentStatusEnum: appointmentListModel.appointmentStatusEnum!, context: context), buildBottomActionButton(appointmentStatusEnum: appointmentListModel.appointmentStatusEnum!, context: context),

Loading…
Cancel
Save