From 558a957101a84cb34ade470236c59d7d1ba68fe1 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Wed, 15 Jul 2026 11:55:13 +0300 Subject: [PATCH] Offers And Discounts --- assets/langs/ar-SA.json | 18 +- assets/langs/en-US.json | 48 +- lib/core/api_consts.dart | 2 +- lib/presentation/home/landing_page.dart | 26 - ...and_discounts_full_screen_swiper_page.dart | 69 +-- .../offers_and_discount_payment_page.dart | 452 +++++++++--------- .../offers_and_discounts_detailed_page.dart | 18 +- 7 files changed, 347 insertions(+), 286 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 8fcf72c8..9be065c6 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -768,7 +768,7 @@ "viewTerms": "لعرض الشروط والأحكام", "wantConnectHmgNetwork": "عزيزي العميل، لا يوجد وصول إلى الإنترنت، هل ترغب في الاتصال بشبكة مجموعة الحبيب الطبية لاستخدام تطبيقنا، تأكد من أنك في نطاق شبكة مجموعة الحبيب الطبية", "failedToAccessHmgServices": "متصل بشبكة مجموعة الحبيب الطبية،\n\nلكن فشل في الوصول إلى خدمات مجموعة الحبيب الطبية", - "offerAndPackages": "عروض وباقات", + "offerAndPackages": "العروض و الباقات", "offerAndPackagesDetails": "تتيح لك هذه الخدمة عرض جميع عروض مجموعة الحبيب الطبية:", "invoiceNo": "رقم الفاتورة", "invoiceDate": "تاريخ الفاتورة", @@ -1967,9 +1967,9 @@ "notAvailable": "غير متاح", "hide": "إخفاء", "paymentSuccessful": "تم الدفع بنجاح", - "typeAnyOffer": "اكتب أي عرض", - "validTill": "صالح حتى", - "buyNow": "اشتري الآن", + "typeAnyOffer": "ابحث عن العروض و الباقات", + "validTill": "صالح لغاية", + "buyNow": "اشترِ الآن", "availableAt": "متاح في", "includedServices": "الخدمات المشمولة", "off": "خصم", @@ -1977,8 +1977,8 @@ "orderLabel": "الطلب", "purchased": "تم الشراء", "validUntil": "صالح حتى", - "viewOfferDetails": "عرض تفاصيل العرض", - "viewOrderDetails": "عرض تفاصيل الطلب", + "viewOfferDetails": "تفاصيل العرض", + "viewOrderDetails": "تفاصيل الطلب", "hospitalNA": "المستشفى: غير متوفر", "hospitalLabel": "المستشفى", "showLess": "عرض أقل", @@ -2001,10 +2001,12 @@ "errorLoadingQRCode": "خطأ في تحميل رمز الاستجابة السريعة", "noOfferDetailsAvailable": "لا توجد تفاصيل عرض متاحة", "noImagesAvailable": "لا توجد صور متاحة", - "checkOutThisAmazingOffer": "تحقق من هذا العرض المذهل!", + "checkOutThisAmazingOffer": "تحقق من هذا العرض من مستشفى سلمان الحبيب", "offerPayment": "دفع العرض", "unableToCreateOrder": "غير قادر على إنشاء الطلب. معلومات العرض أو المستخدم مفقودة.", "failedToCreateOrder": "فشل في إنشاء الطلب. يرجى المحاولة مرة أخرى.", "unableToCompletePayment": "غير قادر على إكمال الدفع. معلومات الطلب مفقودة.", - "paymentConfirmationFailed": "تم تسجيل الدفع لكن التأكيد فشل. يرجى الاتصال بالدعم." + "paymentConfirmationFailed": "تم تسجيل الدفع لكن التأكيد فشل. يرجى الاتصال بالدعم.", + "offerAndPackageDetails": "تفاصيل العروض والباقات", + "myOrders": "طلباتي" } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 22d3e7ed..e5841d45 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1956,7 +1956,53 @@ "weeklyShift": "Weekly Shift", "dayOff": "Off", "hide": "Hide", - "paymentSuccessful": "Payment SuccessFul" + "paymentSuccessful": "Payment SuccessFul", + "typeAnyOffer": "Type any offer", + "validTill": "Valid till", + "buyNow": "Buy Now", + "availableAt": "Available at", + "includedServices": "Included Services", + "off": "OFF", + "failedToLoadOfferDetails": "Failed to load offer details", + "orderLabel": "Order", + "purchased": "Purchased", + "validUntil": "Valid until", + "viewOfferDetails": "View Offer Details", + "viewOrderDetails": "View Order Details", + "hospitalNA": "Hospital: N/A", + "hospitalLabel": "Hospital", + "showLess": "Show less", + "redeemed": "Redeemed", + "partiallyRedeemed": "Partially Redeemed", + "available": "Available", + "saveQRCode": "Save QR Code", + "voucherNo": "Voucher No", + "expiresOn": "Expires on", + "saveTheQRCode": "Save the QR Code", + "pleaseShowQRCodeInHospital": "Please save it to your device and show it in hospital to proceed.", + "voucherCodeCopied": "Voucher code copied to clipboard", + "qrCodeNotAvailableToShare": "QR Code not available to share", + "failedToShareQRCode": "Failed to share QR Code", + "failedToSaveQRCode": "Failed to save QR Code", + "qrCodeSavedSuccessfully": "QR Code Saved Successfully", + "qrCodeSavedToDevice": "Your QR code has been saved to your device", + "viewOrderHistory": "View Order History", + "qrCodeNotAvailable": "QR Code not available", + "errorLoadingQRCode": "Error loading QR Code", + "noOfferDetailsAvailable": "No offer details available", + "noImagesAvailable": "No images available", + "checkOutThisAmazingOffer": "Checkout this Offer From HMG", + "offerPayment": "Offer Payment", + "unableToCreateOrder": "Unable to create order. Missing offer or user information.", + "failedToCreateOrder": "Failed to create order. Please try again.", + "unableToCompletePayment": "Unable to complete payment. Missing order information.", + "paymentConfirmationFailed": "Payment recorded but confirmation failed. Please contact support.", + "offerAndPackageDetails": "Offers and Package Detail", + "myOrders": "My Orders" + + } + + diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 2abe2cb9..c0f69300 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -5,7 +5,7 @@ import 'package:hmg_patient_app_new/core/enums.dart'; 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/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 517faedc..dd37fffa 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -543,32 +543,6 @@ class _LandingPageState extends State { ).paddingSymmetrical(24.w, 0.h) : SizedBox.shrink(), - // Offers And Discounts Carousel - Auto-scrolling from right to left - appState.isAuthenticated && appState.isEnabledOffersAndDiscountsCarousel - ? Column( - children: [ - SizedBox(height: 12.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ("${LocaleKeys.offers.tr(context: context)} & ${LocaleKeys.discount.tr(context: context)}").toText16(isBold: true), - Row( - children: [ - LocaleKeys.viewAll.tr(context: context).toText14(color: AppColors.primaryRedColor, isBold: true), - SizedBox(width: 2.h), - Icon(Icons.arrow_forward_ios, color: AppColors.primaryRedColor, size: 14.h), - ], - ), - ], - ).paddingSymmetrical(24.h, 0.h).onPress(() { - Navigator.of(context).push(CustomPageRoute(page: OffersAndDiscountsPage())); - }), - SizedBox(height: 16.h), - OffersAndDiscountsCarousel().paddingSymmetrical(24.h, 0.h), - SizedBox(height: 18.h), - ], - ) - : SizedBox.shrink(), appState.isAuthenticated ? Column( diff --git a/lib/presentation/offers_and_discounts/offer_and_discounts_full_screen_swiper_page.dart b/lib/presentation/offers_and_discounts/offer_and_discounts_full_screen_swiper_page.dart index 49f82860..c65d006f 100644 --- a/lib/presentation/offers_and_discounts/offer_and_discounts_full_screen_swiper_page.dart +++ b/lib/presentation/offers_and_discounts/offer_and_discounts_full_screen_swiper_page.dart @@ -15,6 +15,7 @@ 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/common_bottom_sheet.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; import 'package:provider/provider.dart'; import 'package:share_plus/share_plus.dart' hide Share; @@ -288,37 +289,47 @@ class _OfferAndDiscountsFullScreenSwiperPageState extends State().onLoginPressed(); }); } else { - // Ensure patient is authenticated (will re-authenticate if needed) - final isAuthenticated = await vm.ensureAuthenticated( - onSuccess: () { - // Authentication successful, continue - }, - onError: (error) { - // Show error to user - showCommonBottomSheetWithoutHeight( - context, - child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)), - callBackFunc: () {}, - isFullScreen: false, - isCloseButtonVisible: true, - ); - }, - ); - - if (!isAuthenticated) { - return; - } - - // Set the selected offer and navigate to payment page - if (vm.offerDetails != null) { - vm.setSelectedOffer(vm.offerDetails!); - Navigator.of(context).push( - CustomPageRoute( - page: OffersAndDiscountPaymentPage(), - ), + // Show loader during authentication + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.pleaseWait.tr(context: context)); + + // Ensure patient is authenticated (will re-authenticate if needed) + final isAuthenticated = await vm.ensureAuthenticated( + onSuccess: () { + // Authentication successful, continue + }, + onError: (error) { + // Hide loader on error + LoaderBottomSheet.hideLoader(); + // Show error to user + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }, ); + + if (!isAuthenticated) { + // Hide loader if authentication failed + LoaderBottomSheet.hideLoader(); + return; + } + + // Hide loader on success + LoaderBottomSheet.hideLoader(); + + // Set the selected offer and navigate to payment page + if (vm.offerDetails != null) { + vm.setSelectedOffer(vm.offerDetails!); + Navigator.of(context).push( + CustomPageRoute( + page: OffersAndDiscountPaymentPage(), + ), + ); + } } - } }, backgroundColor: AppColors.primaryRedColor, borderColor: AppColors.primaryRedColor, diff --git a/lib/presentation/offers_and_discounts/offers_and_discount_payment_page.dart b/lib/presentation/offers_and_discounts/offers_and_discount_payment_page.dart index 03b227a3..fa8aaa96 100644 --- a/lib/presentation/offers_and_discounts/offers_and_discount_payment_page.dart +++ b/lib/presentation/offers_and_discounts/offers_and_discount_payment_page.dart @@ -94,13 +94,16 @@ class _OffersAndDiscountPaymentPageState extends State().onLoginPressed(); }); } else { + // Show loader during authentication + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.pleaseWait.tr(context: context)); + // Ensure patient is authenticated (will re-authenticate if needed) final isAuthenticated = await viewModel.ensureAuthenticated( onSuccess: () { // Authentication successful, continue }, onError: (error) { + // Hide loader on error + LoaderBottomSheet.hideLoader(); + // Show error to user showCommonBottomSheetWithoutHeight( context, child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)), @@ -150,8 +156,15 @@ class _OffersAndDiscountsDetailedPageState extends State