diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 0a8ec974..b034ed89 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -1842,5 +1842,6 @@ "liveCareNotificationPermissionsMessage": "يتطلب لايف كير أذونات الإشعارات، يرجى السماح بهذه الأذونات للمتابعة.", "weatherIndicators": "طقس", "submitRating": "إرسال التقييم", - "completedPrescriptionOrder": "تمت الخدمة" + "maxOneFileAllowed": "يمكن رفع ملف واحد فقط", + "fileSizeExceedsLimit": "يجب ألا يتجاوز حجم الملف 1 ميغابايت" } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 9b969f79..ece2f0d9 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1832,7 +1832,8 @@ "liveCareNotificationPermissionsMessage": "LiveCare requires Notifications permission, Please allow to proceed.", "weatherIndicators": "Weather", "submitRating": "Submit", - "completedPrescriptionOrder": "Completed" + "maxOneFileAllowed": "Only 1 file can be uploaded", + "fileSizeExceedsLimit": "File size must not exceed 1 MB" } diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 601f8fb0..b796a719 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -601,7 +601,7 @@ SPEC CHECKSUMS: OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94 package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4 path_provider_foundation: 0b743cbb62d8e47eab856f09262bb8c1ddcfe6ba - PayFortSDK: e12f79051ae15b2e29536771a45354900180bfcb + PayFortSDK: 233eabe9a45601fdbeac67fa6e5aae46ed8faf82 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 Polyline: 2a1f29f87f8d9b7de868940f4f76deb8c678a5b1 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 @@ -612,7 +612,7 @@ SPEC CHECKSUMS: shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6 Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d - SwiftProtobuf: 9e106a71456f4d3f6a3b0c8fd87ef0be085efc38 + SwiftProtobuf: e1b437c8e31a4c5577b643249a0bb62ed4f02153 SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 Turf: aa2ede4298009639d10db36aba1a7ebaad072a5e url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index d02607c5..ef48f388 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -1033,24 +1033,33 @@ class AuthenticationViewModel extends ChangeNotifier { } Future insertPatientIMEIData(int loginType) async { + final authenticatedUser = _appState.getAuthenticatedUser(); + if (authenticatedUser == null) { + log("insertPatientIMEIData: authenticatedUser is null, skipping."); + return; + } + if (authenticatedUser.patientId == null) { + log("insertPatientIMEIData: patientId is null, skipping."); + return; + } final resultEither = await _authenticationRepo.insertPatientIMEIData( patientIMEIDataRequest: PatientInsertDeviceImei( imei: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), - patientId: _appState.getAuthenticatedUser()!.patientId!, - patientIdentificationNo: _appState.getAuthenticatedUser()!.patientIdentificationNo!, - identificationNo: _appState.getAuthenticatedUser()!.patientIdentificationNo!, - firstName: _appState.getAuthenticatedUser()!.firstName!, - lastName: _appState.getAuthenticatedUser()!.lastName!, - patientTypeId: _appState.getAuthenticatedUser()!.patientType, - mobileNo: _appState.getAuthenticatedUser()!.mobileNumber!, + patientId: authenticatedUser.patientId!, + patientIdentificationNo: authenticatedUser.patientIdentificationNo ?? '', + identificationNo: authenticatedUser.patientIdentificationNo ?? '', + firstName: authenticatedUser.firstName ?? '', + lastName: authenticatedUser.lastName ?? '', + patientTypeId: authenticatedUser.patientType, + mobileNo: authenticatedUser.mobileNumber ?? '', logInTypeId: loginType, - patientOutSa: _appState.getAuthenticatedUser()!.outSa!, - outSa: _appState.getAuthenticatedUser()!.outSa == 1 ? true : false, + patientOutSa: authenticatedUser.outSa ?? 0, + outSa: authenticatedUser.outSa == 1 ? true : false, biometricEnabled: loginType == 1 || loginType == 2 ? false : true, - firstNameN: _appState.getAuthenticatedUser()!.firstNameN, - lastNameN: _appState.getAuthenticatedUser()!.lastNameN, - zipCode: _appState.getAuthenticatedUser()!.zipCode //selectedCountrySignup == CountryEnum.others ? '0': selectedCountrySignup.countryCode, + firstNameN: authenticatedUser.firstNameN, + lastNameN: authenticatedUser.lastNameN, + zipCode: authenticatedUser.zipCode //selectedCountrySignup == CountryEnum.others ? '0': selectedCountrySignup.countryCode, ) .toJson()); resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { @@ -1064,22 +1073,27 @@ class AuthenticationViewModel extends ChangeNotifier { } Future insertPatientDeviceData(int loginType) async { + final authenticatedUser = _appState.getAuthenticatedUser(); + if (authenticatedUser == null || authenticatedUser.patientId == null) { + log("insertPatientDeviceData: authenticatedUser or patientId is null, skipping."); + return; + } final resultEither = await _authenticationRepo.insertPatientDeviceData( patientDeviceDataRequest: InsertPatientMobileDeviceInfo( deviceToken: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), - patientId: _appState.getAuthenticatedUser()!.patientId!, - patientTypeId: _appState.getAuthenticatedUser()!.patientType, - patientOutSa: _appState.getAuthenticatedUser()!.outSa!, + patientId: authenticatedUser.patientId!, + patientTypeId: authenticatedUser.patientType, + patientOutSa: authenticatedUser.outSa ?? 0, loginType: loginType, languageId: _appState.getLanguageID(), latitude: _appState.userLat, longitude: _appState.userLong, voipToken: "", deviceType: _appState.deviceTypeID, - patientMobileNumber: _appState.getAuthenticatedUser()!.mobileNumber, - nationalId: _appState.getAuthenticatedUser()!.patientIdentificationNo, - gender: _appState.getAuthenticatedUser()!.gender) + patientMobileNumber: authenticatedUser.mobileNumber, + nationalId: authenticatedUser.patientIdentificationNo, + gender: authenticatedUser.gender) .toJson()); resultEither.fold((failure) async { // await _errorHandlerService.handleError(failure: failure); diff --git a/lib/features/hmg_services/hmg_services_view_model.dart b/lib/features/hmg_services/hmg_services_view_model.dart index 9f468f76..5ced7d57 100644 --- a/lib/features/hmg_services/hmg_services_view_model.dart +++ b/lib/features/hmg_services/hmg_services_view_model.dart @@ -135,7 +135,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -168,7 +168,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -207,7 +207,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -242,7 +242,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -335,7 +335,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -379,7 +379,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -412,7 +412,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -451,7 +451,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -498,7 +498,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -577,7 +577,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -609,7 +609,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -646,7 +646,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -687,7 +687,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -718,9 +718,8 @@ class HmgServicesViewModel extends ChangeNotifier { result.fold( (failure) async { notifyListeners(); - // await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -753,7 +752,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -837,7 +836,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -872,7 +871,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { @@ -908,7 +907,7 @@ class HmgServicesViewModel extends ChangeNotifier { notifyListeners(); await errorHandlerService.handleError(failure: failure); if (onError != null) { - onError(failure.toString()); + onError(failure.message); } }, (apiResponse) { diff --git a/lib/presentation/authentication/register_step2.dart b/lib/presentation/authentication/register_step2.dart index 4a628fd3..ffde3227 100644 --- a/lib/presentation/authentication/register_step2.dart +++ b/lib/presentation/authentication/register_step2.dart @@ -60,8 +60,8 @@ class _RegisterNew extends State { var name = authVM!.isUserFromUAE() ? "" : appState.getLanguageCode() == "en" - ? ("${appState.getNHICUserData.firstNameEn!.toUpperCase()} ${appState.getNHICUserData.lastNameEn!.toUpperCase()}") - : ("${appState.getNHICUserData.firstNameAr!.toUpperCase()} ${appState.getNHICUserData.lastNameAr!.toUpperCase()}"); + ? ("${(appState.getNHICUserData.firstNameEn ?? '').toUpperCase()} ${(appState.getNHICUserData.lastNameEn ?? '').toUpperCase()}").trim() + : ("${(appState.getNHICUserData.firstNameAr ?? '').toUpperCase()} ${(appState.getNHICUserData.lastNameAr ?? '').toUpperCase()}").trim(); return Scaffold( backgroundColor: AppColors.bgScaffoldColor, appBar: CustomAppBar( @@ -267,8 +267,8 @@ class _RegisterNew extends State { : TextInputWidget( labelText: LocaleKeys.maritalStatus.tr(context: context), hintText: appState.isArabic() - ? (MaritalStatusTypeExtension.fromValue(appState.getNHICUserData.maritalStatusCode)!.typeAr) - : (MaritalStatusTypeExtension.fromValue(appState.getNHICUserData.maritalStatusCode)!.type), + ? (MaritalStatusTypeExtension.fromValue(appState.getNHICUserData.maritalStatusCode)?.typeAr ?? '') + : (MaritalStatusTypeExtension.fromValue(appState.getNHICUserData.maritalStatusCode)?.type ?? ''), isEnable: true, prefix: null, isAllowRadius: false, @@ -352,7 +352,7 @@ class _RegisterNew extends State { ), TextInputWidget( labelText: LocaleKeys.dob.tr(context: context), - hintText: authVM!.isUserFromUAE() ? appState.getUserRegistrationPayload.dob! : appState.getNHICUserData.dateOfBirth ?? "", + hintText: authVM!.isUserFromUAE() ? (appState.getUserRegistrationPayload.dob ?? '') : (appState.getNHICUserData.dateOfBirth ?? ""), controller: authVM!.isUserFromUAE() ? authVM!.dobController : null, isEnable: false, prefix: null, diff --git a/lib/presentation/e_referral/e_referral_form_manager.dart b/lib/presentation/e_referral/e_referral_form_manager.dart index 9e5cbe8c..bcdd6915 100644 --- a/lib/presentation/e_referral/e_referral_form_manager.dart +++ b/lib/presentation/e_referral/e_referral_form_manager.dart @@ -129,6 +129,18 @@ class ReferralFormManager extends ChangeNotifier { notifyListeners(); // Only notify when errors change } + void setFieldError(String field, String? message) { + switch (field) { + case 'medicalReport': + _errors.medicalReport = message; + break; + case 'insuredDocument': + _errors.insuredDocument = message; + break; + } + notifyListeners(); + } + void clearAllErrors() { _errors.requesterName = null; _errors.requesterPhone = null; diff --git a/lib/presentation/e_referral/widget/e_referral_other_details.dart b/lib/presentation/e_referral/widget/e_referral_other_details.dart index c30b67c3..cb0f434d 100644 --- a/lib/presentation/e_referral/widget/e_referral_other_details.dart +++ b/lib/presentation/e_referral/widget/e_referral_other_details.dart @@ -289,6 +289,17 @@ class _OtherDetailsStepState extends State { } void _addMedicalReport(String image, File file, ReferralFormManager formManager) { + // Max 1 file + if (formManager.formData.medicalReportImages.isNotEmpty) { + formManager.setFieldError('medicalReport', LocaleKeys.maxOneFileAllowed.tr(context: context)); + return; + } + // Max 1 MB + final fileSizeInBytes = file.lengthSync(); + if (fileSizeInBytes > 1 * 1024 * 1024) { + formManager.setFieldError('medicalReport', LocaleKeys.fileSizeExceedsLimit.tr(context: context)); + return; + } final newAttachment = EReferralAttachment( fileName: 'medical_report_${formManager.formData.medicalReportImages.length + 1}.png', base64String: image @@ -304,6 +315,17 @@ class _OtherDetailsStepState extends State { } void _addInsuranceDocument(String image, File file, ReferralFormManager formManager) { + // Max 1 file + if (formManager.formData.insuredPatientImages.isNotEmpty) { + formManager.setFieldError('insuredDocument', LocaleKeys.maxOneFileAllowed.tr(context: context)); + return; + } + // Max 1 MB + final fileSizeInBytes = file.lengthSync(); + if (fileSizeInBytes > 1 * 1024 * 1024) { + formManager.setFieldError('insuredDocument', LocaleKeys.fileSizeExceedsLimit.tr(context: context)); + return; + } final newAttachment = EReferralAttachment( fileName: 'insurance_${formManager.formData.insuredPatientImages.length + 1}.png', base64String: image diff --git a/pubspec.lock b/pubspec.lock index 3bd9576a..dd27bab8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1042,13 +1042,13 @@ packages: source: hosted version: "1.2.1" image_picker_android: - dependency: "direct main" + dependency: transitive description: name: image_picker_android - sha256: "66810af8e99b2657ee98e5c6f02064f69bb63f7a70e343937f70946c5f8c6622" + sha256: "5e9bf126c37c117cf8094215373c6d561117a3cfb50ebc5add1a61dc6e224677" url: "https://pub.dev" source: hosted - version: "0.8.13+16" + version: "0.8.13+10" image_picker_for_web: dependency: transitive description: @@ -1082,7 +1082,7 @@ packages: source: hosted version: "0.2.2+1" image_picker_platform_interface: - dependency: "direct main" + dependency: transitive description: name: image_picker_platform_interface sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c" diff --git a/pubspec.yaml b/pubspec.yaml index 33ced45d..5db6c526 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -101,7 +101,9 @@ dependencies: flutter_widget_from_html: ^0.17.1 huawei_map: ^6.12.0+301 flutter_image_compress: ^2.3.0 + scrollable_positioned_list: ^0.3.8 + in_app_review: ^2.0.11 dev_dependencies: