|
|
|
|
@ -8,8 +8,11 @@ import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/helper/utils.dart';
|
|
|
|
|
import 'package:test_sa/models/device/device_transfer.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/chat/chat_widget.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/bottom_sheets/rejection_reason_bottom_sheet.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/files_list.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
|
|
|
@ -191,7 +194,15 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
|
|
|
|
|
_internalRequestDetailsCard() {
|
|
|
|
|
bool isCurrentEngineerEligibleForEdit = _model?.senderAssignedEmployeeId == _userProvider!.user?.userID;
|
|
|
|
|
bool isCurrentRequestEditAble = (!(_model?.senderMachineStatusValue == 3));
|
|
|
|
|
bool isCurrentRequestEditAble = (!(_model?.senderMachineStatusValue == 5));
|
|
|
|
|
bool isCurrentRequestInProgress = (_model?.senderMachineStatusValue == 1);
|
|
|
|
|
|
|
|
|
|
// bool isCurrentRequestClosed = isSender ? ((_model?.senderMachineStatusValue == 3)) : ((_model?.receiverMachineStatusValue == 3));
|
|
|
|
|
bool isCurrentRequestOpen = _model?.senderMachineStatusValue == 4;
|
|
|
|
|
|
|
|
|
|
bool engineerCanAssignToHimself = (_userProvider!.user?.type == UsersTypes.engineer) && isCurrentRequestOpen && context.settingProvider.isUserFlowMedical;
|
|
|
|
|
bool engineerCanCancel = (_userProvider!.user?.type == UsersTypes.engineer) && isCurrentRequestInProgress && isCurrentEngineerEligibleForEdit && context.settingProvider.isUserFlowMedical;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
@ -257,6 +268,42 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
_buildTextWidget(_model?.senderComment ?? ''),
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
if (engineerCanAssignToHimself) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
await Provider.of<DeviceTransferProvider>(context, listen: false).assignEngineerToHimselfInternal(_model!.id!.toInt(), context.userProvider.user!.userID!);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
label: 'Assign To Me',
|
|
|
|
|
),
|
|
|
|
|
] else if (engineerCanCancel) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.cancel,
|
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
|
loading: false,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
RejectionReasonBottomSheet(
|
|
|
|
|
onRejectPressed: (int reasonId, String comment) async {
|
|
|
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
|
|
|
var data = await Provider.of<DeviceTransferProvider>(context, listen: false)
|
|
|
|
|
.engineerReject({"assetTransferId": _model!.id!.toInt(), "rejectReasonId": reasonId, "rejectComment": comment});
|
|
|
|
|
return data != null;
|
|
|
|
|
},
|
|
|
|
|
onRefreshed: () {
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
title: "Rejection Reason".addTranslation);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
@ -267,6 +314,11 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
bool isCurrentEngineerEligibleForEdit = isSender ? _model?.senderAssignedEmployeeId == _userProvider!.user?.userID : _model?.receiverAssignedEmployeeId == _userProvider!.user?.userID;
|
|
|
|
|
|
|
|
|
|
bool isCurrentRequestClosed = isSender ? ((_model?.senderMachineStatusValue == 3)) : ((_model?.receiverMachineStatusValue == 3));
|
|
|
|
|
bool isCurrentRequestOpen = isSender ? ((_model?.senderMachineStatusValue == 4)) : ((_model?.receiverMachineStatusValue == 4));
|
|
|
|
|
|
|
|
|
|
bool engineerCanAssignToHimself = (_userProvider!.user?.type == UsersTypes.engineer) && isCurrentRequestOpen && context.settingProvider.isUserFlowMedical;
|
|
|
|
|
bool engineerCanCancel = (_userProvider!.user?.type == UsersTypes.engineer) && isCurrentEngineerEligibleForEdit && context.settingProvider.isUserFlowMedical;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
@ -287,7 +339,7 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
isShow: context.settingProvider.isUserFlowMedical && (isSender ? _deviceTransfer.senderMachineStatusValue! : _deviceTransfer.receiverMachineStatusValue!) != 0,
|
|
|
|
|
isReadOnly: (isSender ? _deviceTransfer.senderMachineStatusValue! : _deviceTransfer.receiverMachineStatusValue) != 1,
|
|
|
|
|
requestId: widget.model.id!.toInt(),
|
|
|
|
|
assigneeEmployeeNumber: isSender ? _deviceTransfer.senderAssignedEmployeeNumber! : _deviceTransfer.receiverAssignedEmployeeNumber!,
|
|
|
|
|
assigneeEmployeeNumber: isSender ? _deviceTransfer.senderAssignedEmployeeNumber : _deviceTransfer.receiverAssignedEmployeeNumber,
|
|
|
|
|
myLoginUserID: context.userProvider.user!.employeeId ?? context.userProvider.user!.username!,
|
|
|
|
|
contactEmployeeINumber: _deviceTransfer.assetTransferContactPersons!.first.employeeNumber,
|
|
|
|
|
),
|
|
|
|
|
@ -319,6 +371,41 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
_buildTextWidget(comment),
|
|
|
|
|
],
|
|
|
|
|
if (engineerCanAssignToHimself) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
await Provider.of<DeviceTransferProvider>(context, listen: false).assignEngineerToHimselfExternal(_model!.id!.toInt(), isSender, context.userProvider.user!.userID!);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
label: 'Assign To Me',
|
|
|
|
|
),
|
|
|
|
|
] else if (engineerCanCancel) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.cancel,
|
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
|
loading: false,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
RejectionReasonBottomSheet(
|
|
|
|
|
onRejectPressed: (int reasonId, String comment) async {
|
|
|
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
|
|
|
var data = await Provider.of<DeviceTransferProvider>(context, listen: false)
|
|
|
|
|
.engineerReject({"assetTransferId": _model!.id!.toInt(), "rejectReasonId": reasonId, "rejectComment": comment});
|
|
|
|
|
return data != null;
|
|
|
|
|
},
|
|
|
|
|
onRefreshed: () {
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
title: "Rejection Reason".addTranslation);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
|