advance payment implementation done for self & other file number

pull/53/head
haroon amjad 1 month ago
parent 3e95999bf3
commit 97038f1a25

@ -176,8 +176,8 @@ class ApiClientImp implements ApiClient {
body[_appState.isAuthenticated ? 'TokenID' : 'LogInTokenID'] = _appState.appAuthToken; body[_appState.isAuthenticated ? 'TokenID' : 'LogInTokenID'] = _appState.appAuthToken;
} }
body['TokenID'] = "@dm!n"; // body['TokenID'] = "@dm!n";
body['PatientID'] = 3628599; // body['PatientID'] = 3628599;
} }
body.removeWhere((key, value) => value == null); body.removeWhere((key, value) => value == null);

@ -723,7 +723,7 @@ const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_In
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; 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 // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -1,6 +1,8 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.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/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/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'; import 'package:hmg_patient_app_new/services/error_handler_service.dart';
class HabibWalletViewModel extends ChangeNotifier { class HabibWalletViewModel extends ChangeNotifier {
@ -8,6 +10,10 @@ class HabibWalletViewModel extends ChangeNotifier {
num habibWalletAmount = 0; num habibWalletAmount = 0;
num walletRechargeAmount = 0; num walletRechargeAmount = 0;
bool isBottomSheetContentLoading = false;
bool isSearchedFileNumberDataShown = false;
int currentIndex = 0; int currentIndex = 0;
List<HospitalsModel> advancePaymentHospitals = []; List<HospitalsModel> advancePaymentHospitals = [];
@ -21,12 +27,16 @@ class HabibWalletViewModel extends ChangeNotifier {
String depositorName = ''; String depositorName = '';
String mobileNumber = ''; String mobileNumber = '';
num selectedRechargeType = 1;
HabibWalletViewModel({required this.habibWalletRepo, required this.errorHandlerService}); HabibWalletViewModel({required this.habibWalletRepo, required this.errorHandlerService});
initHabibWalletProvider() { initHabibWalletProvider() {
isWalletAmountLoading = true; isWalletAmountLoading = true;
isBottomSheetContentLoading = false;
habibWalletAmount = 0; habibWalletAmount = 0;
walletRechargeAmount = 0; walletRechargeAmount = 0;
selectedRechargeType = 1;
advancePaymentHospitals.clear(); advancePaymentHospitals.clear();
selectedHospital = null; selectedHospital = null;
fileNumber = ''; fileNumber = '';
@ -35,6 +45,11 @@ class HabibWalletViewModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
setSelectedRechargeType(num type) {
selectedRechargeType = type;
notifyListeners();
}
setSelectedHospital(HospitalsModel hospital) { setSelectedHospital(HospitalsModel hospital) {
selectedHospital = hospital; selectedHospital = hospital;
notifyListeners(); notifyListeners();
@ -57,6 +72,19 @@ class HabibWalletViewModel extends ChangeNotifier {
notifyListeners(); 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<void> getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async { Future<void> getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async {
isWalletAmountLoading = true; isWalletAmountLoading = true;
notifyListeners(); notifyListeners();
@ -144,14 +172,21 @@ class HabibWalletViewModel extends ChangeNotifier {
} }
Future<void> getPatientInfoByPatientID({required String patientID, Function(dynamic)? onSuccess, Function(String)? onError}) async { Future<void> getPatientInfoByPatientID({required String patientID, Function(dynamic)? onSuccess, Function(String)? onError}) async {
isBottomSheetContentLoading = true;
notifyListeners();
final result = await habibWalletRepo.getPatientInfoByPatientID(patientID: patientID); final result = await habibWalletRepo.getPatientInfoByPatientID(patientID: patientID);
result.fold( result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure), (failure) async {
isBottomSheetContentLoading = false;
notifyListeners();
await errorHandlerService.handleError(failure: failure);
},
(apiResponse) { (apiResponse) {
if (apiResponse.messageStatus == 2) { if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) { } else if (apiResponse.messageStatus == 1) {
isBottomSheetContentLoading = false;
notifyListeners(); notifyListeners();
if (onSuccess != null) { if (onSuccess != null) {
onSuccess(apiResponse); onSuccess(apiResponse);

@ -151,8 +151,12 @@ class _AppointmentCardState extends State<AppointmentCard> {
spacing: 3.h, spacing: 3.h,
runSpacing: 4.h, runSpacing: 4.h,
children: [ children: [
widget.isFromHomePage ? SizedBox.shrink() : AppCustomChipWidget(labelText: widget.isLoading ? "Cardiology" : widget.patientAppointmentHistoryResponseModel.clinicName!).toShimmer2(isShow: widget.isLoading), widget.isFromHomePage
widget.isFromHomePage ? SizedBox.shrink() : AppCustomChipWidget(labelText: widget.isLoading ? "Olaya" : widget.patientAppointmentHistoryResponseModel.projectName!).toShimmer2(isShow: widget.isLoading), ? 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( AppCustomChipWidget(
icon: AppAssets.appointment_calendar_icon, icon: AppAssets.appointment_calendar_icon,
labelText: labelText:

@ -102,7 +102,7 @@ class _HabibWalletState extends State<HabibWalletPage> {
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
borderRadius: 12, borderRadius: 12,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0), // padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 40.h, height: 40.h,
), ),
], ],

@ -34,11 +34,15 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
FocusNode textFocusNode = FocusNode(); FocusNode textFocusNode = FocusNode();
late HabibWalletViewModel habibWalletVM; late HabibWalletViewModel habibWalletVM;
late AppState appState;
final TextEditingController amountTextController = TextEditingController(); final TextEditingController amountTextController = TextEditingController();
@override @override
void initState() { void initState() {
scheduleMicrotask(() { scheduleMicrotask(() {
habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
appState.getAuthenticatedUser()!.mobileNumber!);
habibWalletVM.setSelectedRechargeType(0);
habibWalletVM.getProjectsList(); habibWalletVM.getProjectsList();
}); });
super.initState(); super.initState();
@ -47,7 +51,7 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false); habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false);
AppState appState = getIt.get<AppState>(); appState = getIt.get<AppState>();
return Scaffold( return Scaffold(
backgroundColor: AppColors.bgScaffoldColor, backgroundColor: AppColors.bgScaffoldColor,
body: Column( body: Column(
@ -136,8 +140,8 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
LocaleKeys.myAccount.tr(context: context).toText16(color: AppColors.textColor, weight: FontWeight.w500), (habibWalletVM.getSelectedRechargeTypeValue()).toText16(color: AppColors.textColor, weight: FontWeight.w500),
"${LocaleKeys.medicalFile.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}" "${LocaleKeys.medicalFile.tr(context: context)}: ${habibWalletVM.fileNumber}"
.toText14(color: AppColors.greyTextColor, weight: FontWeight.w500), .toText14(color: AppColors.greyTextColor, weight: FontWeight.w500),
], ],
), ),
@ -276,8 +280,8 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
); );
} else { } else {
habibWalletVM.setWalletRechargeAmount(num.parse(amountTextController.text)); habibWalletVM.setWalletRechargeAmount(num.parse(amountTextController.text));
habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", // habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
appState.getAuthenticatedUser()!.mobileNumber!); // appState.getAuthenticatedUser()!.mobileNumber!);
Navigator.of(context).push( Navigator.of(context).push(
CustomPageRoute( CustomPageRoute(
page: WalletPaymentConfirmPage(), page: WalletPaymentConfirmPage(),

@ -189,7 +189,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
if (Utils.havePrivilege(103)) { if (Utils.havePrivilege(103)) {
startApplePay(); startApplePay();
} else { } else {
openPaymentURL("applepay"); openPaymentURL("ApplePay");
} }
}) })
: SizedBox(height: 12.h), : SizedBox(height: 12.h),
@ -214,8 +214,8 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
applePayInsertRequest.clinicID = 0; applePayInsertRequest.clinicID = 0;
applePayInsertRequest.currency = appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED"; applePayInsertRequest.currency = appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED";
applePayInsertRequest.customerEmail = "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com"; applePayInsertRequest.customerEmail = "CustID_${habibWalletVM.fileNumber.toString()}@HMG.com";
applePayInsertRequest.customerID = appState.getAuthenticatedUser()!.patientId.toString(); applePayInsertRequest.customerID = habibWalletVM.fileNumber.toString();
applePayInsertRequest.customerName = "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}"; applePayInsertRequest.customerName = "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}";
applePayInsertRequest.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken); applePayInsertRequest.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken);
@ -224,7 +224,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
applePayInsertRequest.projectID = habibWalletVM.selectedHospital!.iD!.toString(); applePayInsertRequest.projectID = habibWalletVM.selectedHospital!.iD!.toString();
applePayInsertRequest.serviceID = ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(); applePayInsertRequest.serviceID = ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString();
applePayInsertRequest.channelID = 3; applePayInsertRequest.channelID = 3;
applePayInsertRequest.patientID = appState.getAuthenticatedUser()!.patientId.toString(); applePayInsertRequest.patientID = habibWalletVM.fileNumber.toString();
applePayInsertRequest.patientTypeID = appState.getAuthenticatedUser()!.patientType; applePayInsertRequest.patientTypeID = appState.getAuthenticatedUser()!.patientType;
applePayInsertRequest.patientOutSA = appState.getAuthenticatedUser()!.outSa; applePayInsertRequest.patientOutSA = appState.getAuthenticatedUser()!.outSa;
applePayInsertRequest.appointmentDate = null; applePayInsertRequest.appointmentDate = null;
@ -237,7 +237,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
applePayInsertRequest.isSchedule = "0"; applePayInsertRequest.isSchedule = "0";
applePayInsertRequest.language = appState.isArabic() ? 'ar' : 'en'; applePayInsertRequest.language = appState.isArabic() ? 'ar' : 'en';
applePayInsertRequest.languageID = appState.isArabic() ? 1 : 2; 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.responseContinueURL = "http://hmg.com/Documents/success.html";
applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html"; applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html";
applePayInsertRequest.paymentOption = "ApplePay"; applePayInsertRequest.paymentOption = "ApplePay";
@ -330,6 +330,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
}, },
onError: (err) {}); onError: (err) {});
} else { } else {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight( showCommonBottomSheetWithoutHeight(
context, context,
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation), child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
@ -403,11 +404,11 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
"Advance Payment", "Advance Payment",
transID, transID,
habibWalletVM.selectedHospital!.iD!.toString(), habibWalletVM.selectedHospital!.iD!.toString(),
"CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com", "CustID_${habibWalletVM.fileNumber.toString()}@HMG.com",
selectedPaymentMethod, selectedPaymentMethod,
appState.getAuthenticatedUser()!.patientType.toString(), appState.getAuthenticatedUser()!.patientType.toString(),
"${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", habibWalletVM.depositorName,
appState.getAuthenticatedUser()!.patientId.toString(), habibWalletVM.fileNumber.toString(),
appState.getAuthenticatedUser()!, appState.getAuthenticatedUser()!,
browser!, browser!,
false, false,

@ -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/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.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/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/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/input_widget.dart'; import 'package:hmg_patient_app_new/widgets/input_widget.dart';
@ -43,6 +44,7 @@ class MultiPageBottomSheet extends StatefulWidget {
class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> { class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
late AppState appState; late AppState appState;
static final DialogService _dialogService = getIt.get<DialogService>();
TextEditingController fileNumberEditingController = TextEditingController(); TextEditingController fileNumberEditingController = TextEditingController();
@ -52,7 +54,7 @@ class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
return Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) { return Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) {
return Padding( return Padding(
padding: MediaQuery.of(context).viewInsets, padding: MediaQuery.of(context).viewInsets,
child: getCurrentIndexWidget(habibWalletVM), child: habibWalletVM.isBottomSheetContentLoading ? Utils.getLoadingWidget() : getCurrentIndexWidget(habibWalletVM),
); );
}); });
} }
@ -80,13 +82,12 @@ class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
labelText: LocaleKeys.fileNumber.tr(), labelText: LocaleKeys.fileNumber.tr(),
hintText: "xxxxxxxxx", hintText: "xxxxxxxxx",
controller: fileNumberEditingController, controller: fileNumberEditingController,
// focusNode: _nationalIdFocusNode,
isEnable: true, isEnable: true,
prefix: null, prefix: null,
isAllowRadius: true, isAllowRadius: true,
isBorderAllowed: false, isBorderAllowed: false,
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
autoFocus: true, autoFocus: false,
padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 8.h), padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 8.h),
leadingIcon: AppAssets.requests, leadingIcon: AppAssets.requests,
).withVerticalPadding(8), ).withVerticalPadding(8),
@ -94,9 +95,23 @@ class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
CustomButton( CustomButton(
text: LocaleKeys.submit.tr(), text: LocaleKeys.submit.tr(),
onPressed: () async { onPressed: () async {
await habibWalletVM.getPatientInfoByPatientID(patientID: fileNumberEditingController.text, onSuccess: (response) { await habibWalletVM.getPatientInfoByPatientID(
print(response.data["GetPatientInfoByPatientIDList"][0]["FullName"]); patientID: fileNumberEditingController.text,
}, onError: (error) {}); 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, backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedBorderColor, borderColor: AppColors.primaryRedBorderColor,

@ -62,16 +62,19 @@ class CustomButton extends StatelessWidget {
children: [ children: [
if (icon != null) if (icon != null)
Padding( 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), child: Utils.buildSvgWithAssets(icon: icon!, iconColor: iconColor, isDisabled: isDisabled, width: iconSize, height: iconSize),
), ),
Text( Padding(
text, padding: EdgeInsets.only(top: 2.5),
style: context.dynamicTextStyle( child: Text(
fontSize: fontSize.fSize, text,
color: isDisabled ? textColor.withOpacity(0.5) : textColor, style: context.dynamicTextStyle(
letterSpacing: -0.4, fontSize: fontSize.fSize,
fontWeight: fontWeight, color: isDisabled ? textColor.withOpacity(0.5) : textColor,
letterSpacing: -0.4,
fontWeight: fontWeight,
),
), ),
), ),
], ],

Loading…
Cancel
Save