CMC Tweaks Completed
parent
da579dfd09
commit
95bd2a2a7e
@ -1,26 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/comprehensive_checkup/widgets/cmc_hospital_bottom_sheet_body.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CmcHospitalSelectionHelper {
|
||||
static void showHospitalSelectionBottomSheet({
|
||||
required BuildContext context,
|
||||
required Function(dynamic) onHospitalSelected,
|
||||
}) {
|
||||
final hmgServicesViewModel = context.read<HmgServicesViewModel>();
|
||||
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
context,
|
||||
title: "Select Hospital".needTranslation,
|
||||
child: CmcHospitalBottomSheetBody(
|
||||
onHospitalSelected: (hospital) {
|
||||
hmgServicesViewModel.setSelectedHospitalForOrder(hospital);
|
||||
onHospitalSelected(hospital);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,110 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/comprehensive_checkup/widgets/cmc_hospital_bottom_sheet_body.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/route_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/hmg_services/models/req_models/order_update_req_model.dart';
|
||||
import 'package:hmg_patient_app_new/features/hmg_services/models/resq_models/get_cmc_all_orders_resp_model.dart';
|
||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.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/loader/bottomsheet_loader.dart';
|
||||
|
||||
class CmcUiSelectionHelper {
|
||||
static void showHospitalSelectionBottomSheet({
|
||||
required BuildContext context,
|
||||
required Function(dynamic) onHospitalSelected,
|
||||
}) {
|
||||
final hmgServicesViewModel = context.read<HmgServicesViewModel>();
|
||||
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
context,
|
||||
title: "Select Hospital".needTranslation,
|
||||
child: CmcHospitalBottomSheetBody(
|
||||
onHospitalSelected: (hospital) {
|
||||
hmgServicesViewModel.setSelectedHospitalForOrder(hospital);
|
||||
onHospitalSelected(hospital);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static void showCancelConfirmationDialog({
|
||||
required BuildContext context,
|
||||
required GetCMCAllOrdersResponseModel order,
|
||||
}) {
|
||||
final HmgServicesViewModel hmgServicesViewModel = context.read<HmgServicesViewModel>();
|
||||
|
||||
return showCommonBottomSheetWithoutHeight(
|
||||
title: LocaleKeys.notice.tr(context: context),
|
||||
context,
|
||||
child: Utils.getWarningWidget(
|
||||
loadingText: "Are you sure you want to cancel this order?".needTranslation,
|
||||
isShowActionButtons: true,
|
||||
onCancelTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onConfirmTap: () async {
|
||||
Navigator.pop(context);
|
||||
LoaderBottomSheet.showLoader();
|
||||
|
||||
final requestModel = OrderUpdateRequestModel(
|
||||
presOrderID: order.iD,
|
||||
rejectionReason: "Cancelled by user",
|
||||
presOrderStatus: 4, // Cancelled status
|
||||
editedBy: 3,
|
||||
);
|
||||
|
||||
await hmgServicesViewModel.updateCmcPresOrder(
|
||||
requestModel: requestModel,
|
||||
onSuccess: (_) async {
|
||||
LoaderBottomSheet.hideLoader();
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
context,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.w),
|
||||
child: Column(
|
||||
children: [
|
||||
Utils.getSuccessWidget(loadingText: "Order has been cancelled successfully".needTranslation),
|
||||
SizedBox(height: 24.h),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CustomButton(
|
||||
height: 56.h,
|
||||
text: LocaleKeys.ok.tr(),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.pop();
|
||||
hmgServicesViewModel.getAllCmcOrders();
|
||||
},
|
||||
textColor: AppColors.whiteColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
isCloseButtonVisible: false,
|
||||
isDismissible: false,
|
||||
isFullScreen: false,
|
||||
);
|
||||
},
|
||||
onError: (error) {
|
||||
LoaderBottomSheet.hideLoader();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
callBackFunc: () {},
|
||||
isFullScreen: false,
|
||||
isCloseButtonVisible: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue