diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index a75a1ab..62339bf 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -176,8 +176,8 @@ class ApiClientImp implements ApiClient { body[_appState.isAuthenticated ? 'TokenID' : 'LogInTokenID'] = _appState.appAuthToken; } - body['TokenID'] = "@dm!n"; - body['PatientID'] = 3628599; + // body['TokenID'] = "@dm!n"; + // body['PatientID'] = 3628599; } body.removeWhere((key, value) => value == null); diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index d31679c..f802818 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -723,7 +723,7 @@ const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_In class ApiConsts { static const maxSmallScreen = 660; - static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; + static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT diff --git a/lib/features/habib_wallet/habib_wallet_view_model.dart b/lib/features/habib_wallet/habib_wallet_view_model.dart index c620b08..5291646 100644 --- a/lib/features/habib_wallet/habib_wallet_view_model.dart +++ b/lib/features/habib_wallet/habib_wallet_view_model.dart @@ -1,6 +1,8 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_repo.dart'; import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart'; +import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/services/error_handler_service.dart'; class HabibWalletViewModel extends ChangeNotifier { @@ -8,6 +10,10 @@ class HabibWalletViewModel extends ChangeNotifier { num habibWalletAmount = 0; num walletRechargeAmount = 0; + bool isBottomSheetContentLoading = false; + + bool isSearchedFileNumberDataShown = false; + int currentIndex = 0; List advancePaymentHospitals = []; @@ -21,12 +27,16 @@ class HabibWalletViewModel extends ChangeNotifier { String depositorName = ''; String mobileNumber = ''; + num selectedRechargeType = 1; + HabibWalletViewModel({required this.habibWalletRepo, required this.errorHandlerService}); initHabibWalletProvider() { isWalletAmountLoading = true; + isBottomSheetContentLoading = false; habibWalletAmount = 0; walletRechargeAmount = 0; + selectedRechargeType = 1; advancePaymentHospitals.clear(); selectedHospital = null; fileNumber = ''; @@ -35,6 +45,11 @@ class HabibWalletViewModel extends ChangeNotifier { notifyListeners(); } + setSelectedRechargeType(num type) { + selectedRechargeType = type; + notifyListeners(); + } + setSelectedHospital(HospitalsModel hospital) { selectedHospital = hospital; notifyListeners(); @@ -57,6 +72,19 @@ class HabibWalletViewModel extends ChangeNotifier { notifyListeners(); } + String getSelectedRechargeTypeValue() { + switch (selectedRechargeType) { + case 1: + return LocaleKeys.myAccount.tr(); + case 2: + return LocaleKeys.family.tr(); + case 3: + return LocaleKeys.otherAccount.tr(); + default: + return LocaleKeys.myAccount.tr(); + } + } + Future getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async { isWalletAmountLoading = true; notifyListeners(); @@ -144,14 +172,21 @@ class HabibWalletViewModel extends ChangeNotifier { } Future getPatientInfoByPatientID({required String patientID, Function(dynamic)? onSuccess, Function(String)? onError}) async { + isBottomSheetContentLoading = true; + notifyListeners(); final result = await habibWalletRepo.getPatientInfoByPatientID(patientID: patientID); result.fold( - (failure) async => await errorHandlerService.handleError(failure: failure), + (failure) async { + isBottomSheetContentLoading = false; + notifyListeners(); + await errorHandlerService.handleError(failure: failure); + }, (apiResponse) { if (apiResponse.messageStatus == 2) { // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); } else if (apiResponse.messageStatus == 1) { + isBottomSheetContentLoading = false; notifyListeners(); if (onSuccess != null) { onSuccess(apiResponse); diff --git a/lib/presentation/appointments/widgets/appointment_card.dart b/lib/presentation/appointments/widgets/appointment_card.dart index a87012c..a4705d9 100644 --- a/lib/presentation/appointments/widgets/appointment_card.dart +++ b/lib/presentation/appointments/widgets/appointment_card.dart @@ -151,8 +151,12 @@ class _AppointmentCardState extends State { spacing: 3.h, runSpacing: 4.h, children: [ - widget.isFromHomePage ? SizedBox.shrink() : AppCustomChipWidget(labelText: widget.isLoading ? "Cardiology" : widget.patientAppointmentHistoryResponseModel.clinicName!).toShimmer2(isShow: widget.isLoading), - widget.isFromHomePage ? SizedBox.shrink() : AppCustomChipWidget(labelText: widget.isLoading ? "Olaya" : widget.patientAppointmentHistoryResponseModel.projectName!).toShimmer2(isShow: widget.isLoading), + widget.isFromHomePage + ? SizedBox.shrink() + : AppCustomChipWidget(labelText: widget.isLoading ? "Cardiology" : widget.patientAppointmentHistoryResponseModel.clinicName!).toShimmer2(isShow: widget.isLoading), + widget.isFromHomePage + ? SizedBox.shrink() + : AppCustomChipWidget(labelText: widget.isLoading ? "Olaya" : widget.patientAppointmentHistoryResponseModel.projectName!).toShimmer2(isShow: widget.isLoading), AppCustomChipWidget( icon: AppAssets.appointment_calendar_icon, labelText: diff --git a/lib/presentation/habib_wallet/habib_wallet_page.dart b/lib/presentation/habib_wallet/habib_wallet_page.dart index e1d1ba2..2e909d2 100644 --- a/lib/presentation/habib_wallet/habib_wallet_page.dart +++ b/lib/presentation/habib_wallet/habib_wallet_page.dart @@ -102,7 +102,7 @@ class _HabibWalletState extends State { fontSize: 14, fontWeight: FontWeight.bold, borderRadius: 12, - padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + // padding: EdgeInsets.fromLTRB(10, 0, 10, 0), height: 40.h, ), ], diff --git a/lib/presentation/habib_wallet/recharge_wallet_page.dart b/lib/presentation/habib_wallet/recharge_wallet_page.dart index 098610b..0cd2d69 100644 --- a/lib/presentation/habib_wallet/recharge_wallet_page.dart +++ b/lib/presentation/habib_wallet/recharge_wallet_page.dart @@ -34,11 +34,15 @@ class _RechargeWalletPageState extends State { FocusNode textFocusNode = FocusNode(); late HabibWalletViewModel habibWalletVM; + late AppState appState; final TextEditingController amountTextController = TextEditingController(); @override void initState() { scheduleMicrotask(() { + habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", + appState.getAuthenticatedUser()!.mobileNumber!); + habibWalletVM.setSelectedRechargeType(0); habibWalletVM.getProjectsList(); }); super.initState(); @@ -47,7 +51,7 @@ class _RechargeWalletPageState extends State { @override Widget build(BuildContext context) { habibWalletVM = Provider.of(context, listen: false); - AppState appState = getIt.get(); + appState = getIt.get(); return Scaffold( backgroundColor: AppColors.bgScaffoldColor, body: Column( @@ -136,8 +140,8 @@ class _RechargeWalletPageState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.myAccount.tr(context: context).toText16(color: AppColors.textColor, weight: FontWeight.w500), - "${LocaleKeys.medicalFile.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}" + (habibWalletVM.getSelectedRechargeTypeValue()).toText16(color: AppColors.textColor, weight: FontWeight.w500), + "${LocaleKeys.medicalFile.tr(context: context)}: ${habibWalletVM.fileNumber}" .toText14(color: AppColors.greyTextColor, weight: FontWeight.w500), ], ), @@ -276,8 +280,8 @@ class _RechargeWalletPageState extends State { ); } else { habibWalletVM.setWalletRechargeAmount(num.parse(amountTextController.text)); - habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", - appState.getAuthenticatedUser()!.mobileNumber!); + // habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", + // appState.getAuthenticatedUser()!.mobileNumber!); Navigator.of(context).push( CustomPageRoute( page: WalletPaymentConfirmPage(), diff --git a/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart b/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart index 329a3fe..c10a025 100644 --- a/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart +++ b/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart @@ -189,7 +189,7 @@ class _WalletPaymentConfirmPageState extends State { if (Utils.havePrivilege(103)) { startApplePay(); } else { - openPaymentURL("applepay"); + openPaymentURL("ApplePay"); } }) : SizedBox(height: 12.h), @@ -214,8 +214,8 @@ class _WalletPaymentConfirmPageState extends State { applePayInsertRequest.clinicID = 0; applePayInsertRequest.currency = appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED"; - applePayInsertRequest.customerEmail = "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com"; - applePayInsertRequest.customerID = appState.getAuthenticatedUser()!.patientId.toString(); + applePayInsertRequest.customerEmail = "CustID_${habibWalletVM.fileNumber.toString()}@HMG.com"; + applePayInsertRequest.customerID = habibWalletVM.fileNumber.toString(); applePayInsertRequest.customerName = "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}"; applePayInsertRequest.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken); @@ -224,7 +224,7 @@ class _WalletPaymentConfirmPageState extends State { applePayInsertRequest.projectID = habibWalletVM.selectedHospital!.iD!.toString(); applePayInsertRequest.serviceID = ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(); applePayInsertRequest.channelID = 3; - applePayInsertRequest.patientID = appState.getAuthenticatedUser()!.patientId.toString(); + applePayInsertRequest.patientID = habibWalletVM.fileNumber.toString(); applePayInsertRequest.patientTypeID = appState.getAuthenticatedUser()!.patientType; applePayInsertRequest.patientOutSA = appState.getAuthenticatedUser()!.outSa; applePayInsertRequest.appointmentDate = null; @@ -237,7 +237,7 @@ class _WalletPaymentConfirmPageState extends State { applePayInsertRequest.isSchedule = "0"; applePayInsertRequest.language = appState.isArabic() ? 'ar' : 'en'; applePayInsertRequest.languageID = appState.isArabic() ? 1 : 2; - applePayInsertRequest.userName = appState.getAuthenticatedUser()!.patientId; + applePayInsertRequest.userName = int.parse(habibWalletVM.fileNumber); applePayInsertRequest.responseContinueURL = "http://hmg.com/Documents/success.html"; applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html"; applePayInsertRequest.paymentOption = "ApplePay"; @@ -330,6 +330,7 @@ class _WalletPaymentConfirmPageState extends State { }, onError: (err) {}); } else { + LoaderBottomSheet.hideLoader(); showCommonBottomSheetWithoutHeight( context, child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation), @@ -403,11 +404,11 @@ class _WalletPaymentConfirmPageState extends State { "Advance Payment", transID, habibWalletVM.selectedHospital!.iD!.toString(), - "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com", + "CustID_${habibWalletVM.fileNumber.toString()}@HMG.com", selectedPaymentMethod, appState.getAuthenticatedUser()!.patientType.toString(), - "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", - appState.getAuthenticatedUser()!.patientId.toString(), + habibWalletVM.depositorName, + habibWalletVM.fileNumber.toString(), appState.getAuthenticatedUser()!, browser!, false, diff --git a/lib/presentation/habib_wallet/widgets/select-medical_file.dart b/lib/presentation/habib_wallet/widgets/select-medical_file.dart index 1c56cdd..73a7dfe 100644 --- a/lib/presentation/habib_wallet/widgets/select-medical_file.dart +++ b/lib/presentation/habib_wallet/widgets/select-medical_file.dart @@ -29,6 +29,7 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; +import 'package:hmg_patient_app_new/services/dialog_service.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; import 'package:hmg_patient_app_new/widgets/input_widget.dart'; @@ -43,6 +44,7 @@ class MultiPageBottomSheet extends StatefulWidget { class _MultiPageBottomSheetState extends State { late AppState appState; + static final DialogService _dialogService = getIt.get(); TextEditingController fileNumberEditingController = TextEditingController(); @@ -52,7 +54,7 @@ class _MultiPageBottomSheetState extends State { return Consumer(builder: (context, habibWalletVM, child) { return Padding( padding: MediaQuery.of(context).viewInsets, - child: getCurrentIndexWidget(habibWalletVM), + child: habibWalletVM.isBottomSheetContentLoading ? Utils.getLoadingWidget() : getCurrentIndexWidget(habibWalletVM), ); }); } @@ -80,13 +82,12 @@ class _MultiPageBottomSheetState extends State { labelText: LocaleKeys.fileNumber.tr(), hintText: "xxxxxxxxx", controller: fileNumberEditingController, - // focusNode: _nationalIdFocusNode, isEnable: true, prefix: null, isAllowRadius: true, isBorderAllowed: false, isAllowLeadingIcon: true, - autoFocus: true, + autoFocus: false, padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 8.h), leadingIcon: AppAssets.requests, ).withVerticalPadding(8), @@ -94,9 +95,23 @@ class _MultiPageBottomSheetState extends State { CustomButton( text: LocaleKeys.submit.tr(), onPressed: () async { - await habibWalletVM.getPatientInfoByPatientID(patientID: fileNumberEditingController.text, onSuccess: (response) { - print(response.data["GetPatientInfoByPatientIDList"][0]["FullName"]); - }, onError: (error) {}); + await habibWalletVM.getPatientInfoByPatientID( + patientID: fileNumberEditingController.text, + onSuccess: (response) async { + print(response.data["GetPatientInfoByPatientIDList"][0]["FullName"]); + await _dialogService.showCommonBottomSheetWithoutH( + message: "A file was found with name: ${response.data["GetPatientInfoByPatientIDList"][0]["FullName"]}, Would you like to recharge wallet for this file number?".needTranslation, + label: LocaleKeys.notice.tr(), + onOkPressed: () { + habibWalletVM.setSelectedRechargeType(3); + habibWalletVM.setDepositorDetails(response.data["GetPatientInfoByPatientIDList"][0]["PatientID"].toString(), response.data["GetPatientInfoByPatientIDList"][0]["FullName"], + response.data["GetPatientInfoByPatientIDList"][0]["MobileNumber"]); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + onCancelPressed: () {}); + }, + onError: (error) {}); }, backgroundColor: AppColors.primaryRedColor, borderColor: AppColors.primaryRedBorderColor, diff --git a/lib/widgets/buttons/custom_button.dart b/lib/widgets/buttons/custom_button.dart index 81eb292..d0b4a6c 100644 --- a/lib/widgets/buttons/custom_button.dart +++ b/lib/widgets/buttons/custom_button.dart @@ -62,16 +62,19 @@ class CustomButton extends StatelessWidget { children: [ if (icon != null) Padding( - padding: const EdgeInsets.only(right: 8.0, left: 8.0, bottom: 4.5), + padding: const EdgeInsets.only(right: 8.0, left: 8.0), child: Utils.buildSvgWithAssets(icon: icon!, iconColor: iconColor, isDisabled: isDisabled, width: iconSize, height: iconSize), ), - Text( - text, - style: context.dynamicTextStyle( - fontSize: fontSize.fSize, - color: isDisabled ? textColor.withOpacity(0.5) : textColor, - letterSpacing: -0.4, - fontWeight: fontWeight, + Padding( + padding: EdgeInsets.only(top: 2.5), + child: Text( + text, + style: context.dynamicTextStyle( + fontSize: fontSize.fSize, + color: isDisabled ? textColor.withOpacity(0.5) : textColor, + letterSpacing: -0.4, + fontWeight: fontWeight, + ), ), ), ],