|
|
|
|
@ -13,6 +13,7 @@ import 'package:test_sa/modules/cm_module/cm_detail_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/chat/chat_page.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/chat/chat_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/chat/chat_widget.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/survey/survey_page.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/pages/create_loan_request_page.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
@ -23,8 +24,9 @@ import 'views/components/service_request_detail_view.dart';
|
|
|
|
|
|
|
|
|
|
class CMDetailPage extends StatefulWidget {
|
|
|
|
|
final int requestId;
|
|
|
|
|
final int moduleId;
|
|
|
|
|
|
|
|
|
|
CMDetailPage({Key? key, required this.requestId}) : super(key: key);
|
|
|
|
|
CMDetailPage({Key? key, required this.requestId, required this.moduleId}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_CMDetailPageState createState() {
|
|
|
|
|
@ -40,6 +42,7 @@ class _CMDetailPageState extends State<CMDetailPage> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_requestProvider = Provider.of<CMDetailProvider>(context, listen: false);
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
Provider.of<ChatProvider>(context, listen: false).reset();
|
|
|
|
|
getInitialData();
|
|
|
|
|
@ -89,85 +92,46 @@ class _CMDetailPageState extends State<CMDetailPage> {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
actions: [
|
|
|
|
|
if (context.userProvider.isEngineer || context.userProvider.isNurse)
|
|
|
|
|
Selector<CMDetailProvider, bool>(
|
|
|
|
|
selector: (_, myModel) => myModel.isLoading, // Selects only the userName
|
|
|
|
|
builder: (_, isLoading, __) {
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
} else {
|
|
|
|
|
CMDetailProvider provider = Provider.of<CMDetailProvider>(context, listen: false);
|
|
|
|
|
int? statusValue = provider.currentWorkOrder?.data?.status?.value;
|
|
|
|
|
if (statusValue == 2 || statusValue == 3 || statusValue == 5 || statusValue == 6) {
|
|
|
|
|
getChatToken(moduleId, provider.currentWorkOrder?.data?.workOrderNo ?? "");
|
|
|
|
|
return Consumer<ChatProvider>(builder: (pContext, requestProvider, _) {
|
|
|
|
|
return IconButton(
|
|
|
|
|
icon: const Icon(Icons.chat_bubble),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => ChatPage(
|
|
|
|
|
moduleId: moduleId,
|
|
|
|
|
requestId: widget.requestId,
|
|
|
|
|
title: _requestProvider.currentWorkOrder?.data?.workOrderNo ?? "",
|
|
|
|
|
readOnly: _requestProvider.isReadOnlyRequest,
|
|
|
|
|
)));
|
|
|
|
|
},
|
|
|
|
|
).toShimmer(context: context, isShow: requestProvider.chatLoginTokenLoading, radius: 30, height: 30, width: 30);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
if (isNurse)
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: 'qr'.toSvgAsset(height: 24, width: 24),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
ServiceRequestBottomSheet.getQRCodeBottomSheet(context: context);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
else ...[
|
|
|
|
|
Selector<CMDetailProvider, bool>(
|
|
|
|
|
selector: (_, myModel) => myModel.isLoading, // Selects only the userName
|
|
|
|
|
builder: (_, isLoading, __) {
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
} else {
|
|
|
|
|
CMDetailProvider provider = Provider.of<CMDetailProvider>(context, listen: false);
|
|
|
|
|
int? statusValue = provider.currentWorkOrder?.data?.status?.value;
|
|
|
|
|
if (statusValue == 2) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 6),
|
|
|
|
|
margin: const EdgeInsets.only(left: 2),
|
|
|
|
|
decoration: BoxDecoration(color: context.isDark ? AppColor.neutral50 : AppColor.neutral30, borderRadius: BorderRadius.circular(16)),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(Icons.add, size: 20, color: AppColor.black1E),
|
|
|
|
|
Text(
|
|
|
|
|
"Loan",
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.black1E),
|
|
|
|
|
),
|
|
|
|
|
4.width,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
CMDetailProvider provider = Provider.of<CMDetailProvider>(context, listen: false);
|
|
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CreateLoanRequestPage(workOrderId: widget.requestId, workOrder: provider.currentWorkOrder!.data)));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
Selector<CMDetailProvider, bool>(
|
|
|
|
|
selector: (_, myModel) => myModel.isLoading, // Selects only the userName
|
|
|
|
|
builder: (_, isLoading, __) {
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
} else {
|
|
|
|
|
CMDetailProvider provider = Provider.of<CMDetailProvider>(context, listen: false);
|
|
|
|
|
if ((context.userProvider.isEngineer || context.userProvider.isNurse) &&
|
|
|
|
|
provider.currentWorkOrder?.data?.assignedEmployee != null &&
|
|
|
|
|
(provider.currentWorkOrder?.data?.workOrderContactPerson?.isNotEmpty ?? false)) {
|
|
|
|
|
return ChatWidget(
|
|
|
|
|
moduleId: widget.moduleId,
|
|
|
|
|
isShow: context.settingProvider.isUserFlowMedical && (context.userProvider.isEngineer || context.userProvider.isNurse) && provider.currentWorkOrder?.data?.assignedEmployee != null,
|
|
|
|
|
isReadOnly: _requestProvider.isReadOnlyRequest,
|
|
|
|
|
requestId: widget.requestId.toInt(),
|
|
|
|
|
assigneeEmployeeNumber: provider.currentWorkOrder?.data?.assignedEmployee!.employeeId!,
|
|
|
|
|
myLoginUserID: context.userProvider.user!.employeeId ?? context.userProvider.user!.username!,
|
|
|
|
|
contactEmployeeINumber: provider.currentWorkOrder?.data?.workOrderContactPerson.first.employeeId,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.home),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// stopTimer();
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
isNurse
|
|
|
|
|
? IconButton(
|
|
|
|
|
icon: 'qr'.toSvgAsset(
|
|
|
|
|
height: 24,
|
|
|
|
|
width: 24,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
ServiceRequestBottomSheet.getQRCodeBottomSheet(context: context);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
: IconButton(
|
|
|
|
|
icon: const Icon(Icons.home),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// stopTimer();
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: DefaultTabController(
|
|
|
|
|
|