Wallet amount reload

pull/324/head
Haroon Amjad 1 month ago
parent 89670445b3
commit 3590dfc511

@ -30,6 +30,7 @@ class HabibWalletViewModel extends ChangeNotifier {
num habibWalletAmount = 0; num habibWalletAmount = 0;
num walletRechargeAmount = 0; num walletRechargeAmount = 0;
String notesText = ""; String notesText = "";
bool isWalletAmountToBeLoaded = true;
bool isBottomSheetContentLoading = false; bool isBottomSheetContentLoading = false;
@ -392,6 +393,11 @@ class HabibWalletViewModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
setIsWalletAmountToBeLoaded(bool value) {
isWalletAmountToBeLoaded = value;
notifyListeners();
}
String getSelectedRechargeTypeValue() { String getSelectedRechargeTypeValue() {
switch (selectedRechargeType) { switch (selectedRechargeType) {
case 1: case 1:
@ -406,6 +412,9 @@ class HabibWalletViewModel extends ChangeNotifier {
} }
Future<void> getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async { Future<void> getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async {
if (!isWalletAmountToBeLoaded) {
return;
}
isWalletAmountLoading = true; isWalletAmountLoading = true;
notifyListeners(); notifyListeners();
@ -425,6 +434,7 @@ class HabibWalletViewModel extends ChangeNotifier {
habibWalletBalanceList.removeWhere((element) => element.patientAdvanceBalanceAmount == 0); habibWalletBalanceList.removeWhere((element) => element.patientAdvanceBalanceAmount == 0);
isWalletAmountLoading = false; isWalletAmountLoading = false;
isWalletAmountToBeLoaded = false;
notifyListeners(); notifyListeners();
if (onSuccess != null) { if (onSuccess != null) {
onSuccess(apiResponse); onSuccess(apiResponse);
@ -462,12 +472,7 @@ class HabibWalletViewModel extends ChangeNotifier {
Function(dynamic)? onSuccess, Function(dynamic)? onSuccess,
Function(String)? onError}) async { Function(String)? onError}) async {
final result = await habibWalletRepo.HISCreateAdvancePayment( final result = await habibWalletRepo.HISCreateAdvancePayment(
paymentMethodName: paymentMethodName, paymentMethodName: paymentMethodName, paidAmount: paidAmount, paymentReference: paymentReference, patientID: patientID, projectID: projectID, depositorName: depositorName);
paidAmount: paidAmount,
paymentReference: paymentReference,
patientID: patientID,
projectID: projectID,
depositorName: depositorName);
result.fold( result.fold(
// (failure) async => await errorHandlerService.handleError(failure: failure), // (failure) async => await errorHandlerService.handleError(failure: failure),
@ -489,8 +494,7 @@ class HabibWalletViewModel extends ChangeNotifier {
); );
} }
Future<void> addAdvanceNumberRequest( Future<void> addAdvanceNumberRequest({required String advanceNumber, required String paymentReference, Function(dynamic)? onSuccess, Function(String)? onError}) async {
{required String advanceNumber, required String paymentReference, Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await habibWalletRepo.addAdvanceNumberRequest(advanceNumber: advanceNumber, paymentReference: paymentReference); final result = await habibWalletRepo.addAdvanceNumberRequest(advanceNumber: advanceNumber, paymentReference: paymentReference);
result.fold( result.fold(
@ -538,8 +542,7 @@ class HabibWalletViewModel extends ChangeNotifier {
lakumAccountInfo = LakumInquiryInformationResponseModel(); lakumAccountInfo = LakumInquiryInformationResponseModel();
notifyListeners(); notifyListeners();
final result = await habibWalletRepo.getLakumAccountInformation( final result = await habibWalletRepo.getLakumAccountInformation(identificationNumber: getIt.get<AppState>().getAuthenticatedUser()!.patientIdentificationNo ?? "");
identificationNumber: getIt.get<AppState>().getAuthenticatedUser()!.patientIdentificationNo ?? "");
result.fold( result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure), (failure) async => await errorHandlerService.handleError(failure: failure),

Loading…
Cancel
Save