diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index fff3fbf4..23952514 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -57,10 +57,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future notifyMe(customerId, itemID, ) async { + Future notifyMe(customerId, itemID) async { hasError = false; setState(ViewState.BusyLocal); - await _productDetailService.notifyMe(customerId, itemID, ); + await _productDetailService.notifyMe(customerId, itemID); if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 4ca6476b..c414e61e 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; @@ -5,7 +6,6 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/custom-divider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; @@ -252,17 +252,19 @@ class __ProductDetailPageState extends State { Column( children: [ FlatButton( - onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); - await model.getProductLocationData(widget.product.sku); - GifLoaderDialogUtils.hideDialog(context); + onPressed: model.isStockAvailable + ? () async { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductLocationData(widget.product.sku); + GifLoaderDialogUtils.hideDialog(context); // - setState(() { - isDetails = false; - isReviews = false; - isAvailability = true; - }); - }, + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + } + : null, child: Text( TranslationBase.of(context).availability, style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), @@ -289,20 +291,18 @@ class __ProductDetailPageState extends State { previousModel: model, ) : isAvailability && widget.product.stockAvailability != "Out of stock" - ? AvailabilityInfo( - previousModel: model - ) + ? AvailabilityInfo(previousModel: model) : isAvailability && widget.product.stockAvailability == "Out of stock" - ? Container( - // padding: EdgeInsets.all(15), - padding: EdgeInsets.fromLTRB(15,15,15,20), - margin: EdgeInsets.only(bottom: 20), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).noLocationAvailable, - ), - ) - : Container(), + ? Container( + // padding: EdgeInsets.all(15), + padding: EdgeInsets.fromLTRB(15, 15, 15, 20), + margin: EdgeInsets.only(bottom: 20), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noLocationAvailable, + ), + ) + : Container(), ], ), ), @@ -369,8 +369,9 @@ class __ProductDetailPageState extends State { await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } -} -notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, }) async { - await model.notifyMe(customerId, itemId, ); + notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { + await model.notifyMe(customerId, itemId); + } + } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 389fda0d..d326c130 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -123,7 +123,7 @@ class ProductDetailService extends BaseService { return Future.value(localRes); } - Future notifyMe(customerId, itemID, ) async { + Future notifyMe(customerId, itemID) async { hasError = false; await baseAppClient.getPharmacy(SUBSCRIBE_PRODUCT + "SinceId=$customerId&ProductId=$itemID", onSuccess: (dynamic response, int statusCode) { AppToast.showSuccessToast(message: TranslationBase.of(AppGlobal.context).notifyMeMsg