Ancillary order fixes

pull/188/head
haroon amjad 2 days ago
parent 9413e54d3a
commit 2a819a2d97

@ -518,7 +518,12 @@ class MyAppointmentsViewModel extends ChangeNotifier {
final result = await myAppointmentsRepo.cancelAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel);
result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure),
// (failure) async => await errorHandlerService.handleError(failure: failure),
(failure) async {
if(onError != null) {
onError(failure.message);
}
},
(apiResponse) {
if (apiResponse.messageStatus == 2) {
onError!(apiResponse.errorMessage!);

@ -96,6 +96,8 @@ class TodoSectionRepoImp implements TodoSectionRepo {
}
}
ancillaryOrders.sort((a, b) => b.orderDate!.compareTo(a.orderDate!));
apiResponse = GenericApiModel<List<AncillaryOrderItem>>(
messageStatus: messageStatus,
statusCode: statusCode,

@ -145,8 +145,6 @@ class _AppointmentDetailsPageState extends State<AppointmentDetailsPage> {
});
},
onCancelTap: () async {
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.cancellingAppointmentPleaseWait.tr(context: context));
await myAppointmentsViewModel.cancelAppointment(
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
@ -165,6 +163,18 @@ class _AppointmentDetailsPageState extends State<AppointmentDetailsPage> {
isDismissible: false,
isFullScreen: false,
);
},
onError: (err) {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: err.toString()),
callBackFunc: () {},
title: "",
isCloseButtonVisible: true,
isDismissible: false,
isFullScreen: false,
);
});
var isEventAddedOrRemoved = await CalenderUtilsNew.instance.checkAndRemove( id:"${widget.patientAppointmentHistoryResponseModel.appointmentNo}", );
setState(() {

@ -103,7 +103,7 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocaleKeys.visaOrMastercard.tr(context: context).toText16(isBold: true).toShimmer2(isShow: todoVM.isProcessingPayment),
Image.asset(AppAssets.mada, width: 50.h, height: 50.h),
SizedBox(height: 16.h),
LocaleKeys.mada.tr(context: context).toText16(isBold: true).toShimmer2(isShow: todoVM.isProcessingPayment),
],
@ -468,86 +468,43 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
languageID: appState.isArabic() ? 1 : 2,
onSuccess: (response) {
LoaderBottomSheet.hideLoader();
final invoiceNo = response['AncillaryOrderInvoiceList']?[0]?['InvoiceNo'];
_showSuccessDialog(invoiceNo);
},
onError: (error) {
LoaderBottomSheet.hideLoader();
todoSectionViewModel.setProcessingPayment(false);
Utils.showToast(error);
showCommonBottomSheetWithoutHeight(context,
child: Utils.getErrorWidget(loadingText: error.toString()), isCloseButtonVisible: true, isDismissible: true, isFullScreen: false, callBackFunc: () {});
},
);
}
void _showSuccessDialog(dynamic invoiceNo) {
todoSectionViewModel.setProcessingPayment(false);
log("Ancillary order payment successful! Invoice #: $invoiceNo");
// Show success message and navigate
Utils.showToast("Payment successful! Invoice #: $invoiceNo");
// Utils.showToast("Payment successful! Invoice #: $invoiceNo");
// Navigate back to home after a short delay
Future.delayed(Duration(seconds: 1), () {
showCommonBottomSheetWithoutHeight(
context,
child: Column(
children: [
Row(
children: [
LocaleKeys.hereIsYourInvoiceNumber.tr(context: context).toText14(
color: AppColors.textColorLight,
weight: FontWeight.w500,
),
SizedBox(width: 4.w),
("12345").toText16(isBold: true),
],
),
SizedBox(height: 24.h),
Row(
children: [
Expanded(
child: CustomButton(
height: 56.h,
text: LocaleKeys.ok.tr(context: context),
onPressed: () {
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
},
backgroundColor: AppColors.secondaryLightRedColor,
borderColor: AppColors.secondaryLightRedColor,
textColor: AppColors.primaryRedColor,
),
),
],
),
],
),
// title: LocaleKeys.paymentCompletedSuccessfully.tr(context: context),
titleWidget: Utils.getSuccessWidget(loadingText: LocaleKeys.paymentCompletedSuccessfully.tr(context: context)),
isCloseButtonVisible: false,
isDismissible: false,
isFullScreen: false,
);
// Future.delayed(Duration(seconds: 1), () {
showCommonBottomSheetWithoutHeight(context,
child: Utils.getSuccessWidget(loadingText: "${LocaleKeys.paymentCompletedSuccessfully.tr(context: context)}, ${LocaleKeys.hereIsYourInvoiceNumber.tr(context: context)}$invoiceNo"),
isCloseButtonVisible: true,
isDismissible: true,
isFullScreen: false, callBackFunc: () {
// Pop until we reach the LandingPage
todoSectionViewModel.setIsAncillaryOrdersNeedReloading(true);
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
});
// });
}
_startApplePay() async {
showCommonBottomSheet(
context,
child: Utils.getLoadingWidget(),
callBackFunc: (str) {},
title: "",
height: ResponsiveExtension.screenHeight * 0.3,
isCloseButtonVisible: false,
isDismissible: false,
isFullScreen: false,
);
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingApplePayDetails.tr(context: context));
final user = appState.getAuthenticatedUser();
transID = Utils.getAdvancePaymentTransID(widget.projectID, user!.patientId!);
@ -604,7 +561,7 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
await payfortViewModel.applePayRequestInsert(applePayInsertRequest: applePayInsertRequest);
} catch (error) {
log("Apple Pay Insert Request Failed: $error");
Navigator.of(context).pop();
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: LocaleKeys.failedToInitializeApplePay.tr(context: context)),
@ -627,7 +584,7 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
currency: appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED",
onFailed: (failureResult) async {
log("failureResult: ${failureResult.message.toString()}");
Navigator.of(context).pop();
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: failureResult.message.toString()),
@ -637,7 +594,7 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
);
},
onSucceeded: (successResult) async {
Navigator.of(context).pop();
LoaderBottomSheet.hideLoader();
log("successResult: ${successResult.responseMessage.toString()}");
selectedPaymentMethod = successResult.paymentOption ?? "VISA";
_checkPaymentStatus();

Loading…
Cancel
Save