diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index d8ba32a5..6d9ca71e 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -211,7 +211,7 @@ class ApiClientImp implements ApiClient { } // body['TokenID'] = "@dm!n"; - // body['PatientID'] = 226077; + // body['PatientID'] = 5422188; // body['PatientID'] = 53320; // body['PatientTypeID'] = 1; // body['PatientOutSA'] = 0; diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index fef90e8f..c6165af5 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -865,7 +865,8 @@ var GET_CUSTOMER_INFO = "VerifyCustomer"; //Pharmacy -var GET_PHARMACY_CATEGORISE = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; +var GET_PHARMACY_CATEGORISE = + 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; var GET_OFFERS_CATEGORISE = 'discountcategories'; var GET_OFFERS_PRODUCTS = 'offerproducts/'; var GET_CATEGORISE_PARENT = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; diff --git a/lib/features/book_appointments/book_appointments_view_model.dart b/lib/features/book_appointments/book_appointments_view_model.dart index dbed528e..a4530eee 100644 --- a/lib/features/book_appointments/book_appointments_view_model.dart +++ b/lib/features/book_appointments/book_appointments_view_model.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:easy_localization/easy_localization.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; @@ -842,67 +843,73 @@ class BookAppointmentsViewModel extends ChangeNotifier { } Future getDoctorFreeSlots({bool isBookingForLiveCare = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { - docFreeSlots.clear(); - DateTime date; - final DateFormat formatter = DateFormat('HH:mm', "en-US"); - final DateFormat dateFormatter = DateFormat('yyyy-MM-dd'); - Map _eventsParsed; - - final result = await bookAppointmentsRepo.getDoctorFreeSlots( - selectedDoctor.clinicID ?? 0, - selectedDoctor.projectID ?? 0, - selectedDoctor.doctorID ?? 0, - isBookingForLiveCare, - continueDentalPlan: isContinueDentalPlan, - onError: onError, - ); - - result.fold( - (failure) async { - print(failure); - if (onError != null) { - onError(failure.message); - } - }, - (apiResponse) { - if (apiResponse.messageStatus == 2) { - onError!(apiResponse.errorMessage ?? "Unknown error occurred"); - // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); - } else if (apiResponse.messageStatus == 1) { - if (apiResponse.data['FreeTimeSlots'] == null || apiResponse.data['FreeTimeSlots'].isEmpty) { - onError!("No free slots available".tr()); - return; + // try { + docFreeSlots.clear(); + DateTime date; + final DateFormat formatter = DateFormat('HH:mm', "en-US"); + // final DateFormat dateFormatter = DateFormat('yyyy-MM-dd'); + // Map _eventsParsed; + + final result = await bookAppointmentsRepo.getDoctorFreeSlots( + selectedDoctor.clinicID ?? 0, + selectedDoctor.projectID ?? 0, + selectedDoctor.doctorID ?? 0, + isBookingForLiveCare, + continueDentalPlan: isContinueDentalPlan, + onError: onError, + ); + + result.fold( + (failure) async { + print(failure); + if (onError != null) { + onError(failure.message); } - initialSlotDuration = apiResponse.data["InitialSlotDuration"]; - freeSlotsResponse = apiResponse.data['FreeTimeSlots']; - isWaitingAppointmentAvailable = apiResponse.data["IsAllowToBookWaitingAppointment"]; - - // isWaitingAppointmentAvailable = true; - - freeSlotsResponse.forEach((element) { - // date = (isLiveCareSchedule != null && isLiveCareSchedule) - // ? DateUtil.convertStringToDate(element) - // : - date = DateUtil.convertStringToDateSaudiTimezone(element, int.parse(selectedDoctor.projectID.toString())); - slotsList.add(FreeSlot(date, ['slot'])); - docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date, vidaDate: element)); - }); + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + onError!(apiResponse.errorMessage ?? "Unknown error occurred"); + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + if (apiResponse.data['FreeTimeSlots'] == null || apiResponse.data['FreeTimeSlots'].isEmpty) { + onError!("No free slots available".tr()); + return; + } + initialSlotDuration = apiResponse.data["InitialSlotDuration"]; + freeSlotsResponse = apiResponse.data['FreeTimeSlots']; + isWaitingAppointmentAvailable = apiResponse.data["IsAllowToBookWaitingAppointment"]; + + // isWaitingAppointmentAvailable = true; + + freeSlotsResponse.forEach((element) { + // date = (isLiveCareSchedule != null && isLiveCareSchedule) + // ? DateUtil.convertStringToDate(element) + // : + date = DateUtil.convertStringToDateSaudiTimezone(element, int.parse(selectedDoctor.projectID.toString())); + slotsList.add(FreeSlot(date, ['slot'])); + docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date, vidaDate: element)); + }); - notifyListeners(); - if (onSuccess != null) { - onSuccess(apiResponse); + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } } - } - }, - ); + }, + ); + // } catch(ex) { + // if (onError != null) { + // onError(ex.toString()); + // } + // } } Future getLiveCareDoctorFreeSlots({bool isBookingForLiveCare = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { docFreeSlots.clear(); DateTime date; final DateFormat formatter = DateFormat('HH:mm', "en-US"); - final DateFormat dateFormatter = DateFormat('yyyy-MM-dd'); - Map _eventsParsed; + // final DateFormat dateFormatter = DateFormat('yyyy-MM-dd'); + // Map _eventsParsed; final result = await bookAppointmentsRepo.getLiveCareDoctorFreeSlots( selectedDoctor.clinicID ?? 0, selectedLiveCareClinic.serviceID ?? 0, selectedDoctor.projectID ?? 0, selectedDoctor.doctorID ?? 0, isBookingForLiveCare, diff --git a/lib/features/immediate_livecare/immediate_livecare_view_model.dart b/lib/features/immediate_livecare/immediate_livecare_view_model.dart index e2e8d2cb..57bf6553 100644 --- a/lib/features/immediate_livecare/immediate_livecare_view_model.dart +++ b/lib/features/immediate_livecare/immediate_livecare_view_model.dart @@ -135,7 +135,9 @@ class ImmediateLiveCareViewModel extends ChangeNotifier { result.fold( (failure) async { - onError!(failure.message); + if(onError != null) { + onError(failure.message); + } }, (apiResponse) { if (apiResponse.messageStatus == 2) { diff --git a/lib/main.dart b/lib/main.dart index 3c621dc8..28f86f0d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -117,6 +117,8 @@ Future callInitializations() async { WidgetsFlutterBinding.ensureInitialized(); await EasyLocalization.ensureInitialized(); + Intl.defaultLocale = "en_US"; + SafeDevice.init( SafeDeviceConfig(mockLocationCheckEnabled: false), // disables mock location check on Android ); diff --git a/lib/presentation/book_appointment/book_appointment_page.dart b/lib/presentation/book_appointment/book_appointment_page.dart index 53d4b1b1..c2560ecd 100644 --- a/lib/presentation/book_appointment/book_appointment_page.dart +++ b/lib/presentation/book_appointment/book_appointment_page.dart @@ -523,6 +523,7 @@ class _BookAppointmentPageState extends State { ], ).onPress(() { bookAppointmentsViewModel.setIsDoctorSearchByNameStarted(false); + bookAppointmentsViewModel.setIsLiveCareSchedule(false); bookAppointmentsViewModel.setProjectID(null); Navigator.of(context).push( CustomPageRoute( @@ -554,6 +555,7 @@ class _BookAppointmentPageState extends State { ).onPress(() { Clarity.sendCustomEvent('Select_Region_Page'); bookAppointmentsViewModel.setProjectID(null); + bookAppointmentsViewModel.setIsLiveCareSchedule(false); openRegionListBottomSheet(context, RegionBottomSheetType.FOR_REGION); }), ], diff --git a/lib/presentation/book_appointment/search_doctor_by_name.dart b/lib/presentation/book_appointment/search_doctor_by_name.dart index 4e9f1435..f1f391b0 100644 --- a/lib/presentation/book_appointment/search_doctor_by_name.dart +++ b/lib/presentation/book_appointment/search_doctor_by_name.dart @@ -218,7 +218,7 @@ class _SearchDoctorByNameState extends State { bookAppointmentsViewModel: bookAppointmentsViewModel, isDoctorNameSearch: true, ).paddingSymmetrical(16.h, 0.h).onPress(() async { - if (bookAppointmentsVM.filteredDoctorList[index].clinicID == 17 && getIt.get().getAuthenticatedUser()!.age! < 12) { + if (getIt.get().isAuthenticated && bookAppointmentsVM.filteredDoctorList[index].clinicID == 17 && getIt.get().getAuthenticatedUser()!.age! < 12) { bookAppointmentsViewModel.setProjectID(bookAppointmentsVM.filteredDoctorList[index].projectID.toString()); bookAppointmentsViewModel.setSelectedClinic(GetClinicsListResponseModel( clinicID: bookAppointmentsVM.filteredDoctorList[index].clinicID, diff --git a/lib/presentation/book_appointment/widgets/doctor_card.dart b/lib/presentation/book_appointment/widgets/doctor_card.dart index d2f431a9..23a9cbcd 100644 --- a/lib/presentation/book_appointment/widgets/doctor_card.dart +++ b/lib/presentation/book_appointment/widgets/doctor_card.dart @@ -186,7 +186,7 @@ class DoctorCard extends StatelessWidget { if (isDoctorNameSearch && doctorsListResponseModel.clinicID == 17) { GetClinicsListResponseModel selectedClinic = GetClinicsListResponseModel( clinicID: doctorsListResponseModel.clinicID, clinicDescription: doctorsListResponseModel.clinicName, isLiveCareClinicAndOnline: false, liveCareServiceID: 0, liveCareClinicID: 0); - if (getIt.get().getAuthenticatedUser()!.age! > 12) { + if (getIt.get().isAuthenticated && getIt.get().getAuthenticatedUser()!.age! > 12) { bookAppointmentsViewModel.setProjectID(doctorsListResponseModel.projectID.toString()); bookAppointmentsViewModel.setSelectedClinic(selectedClinic); bookAppointmentsViewModel.setIsChiefComplaintsListLoading(true); diff --git a/lib/splashPage.dart b/lib/splashPage.dart index fe223fc2..cf407d41 100644 --- a/lib/splashPage.dart +++ b/lib/splashPage.dart @@ -116,8 +116,8 @@ class _SplashScreenState extends State { logLevel: LogLevel.Error, // Optional: Set the log level (Verbose, Debug, Info, Warning, Error, None) ); - Clarity.initialize(context, config); - + Clarity.initialize(getIt.get().navigatorKey.currentContext!, config); + // Set initial app context tags try { final appState = getIt.get();