|
|
|
|
@ -13,6 +13,7 @@ import 'package:test_sa/modules/cm_module/service_request_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/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
@ -22,8 +23,9 @@ import 'components/service_request_detail_view.dart';
|
|
|
|
|
|
|
|
|
|
class ServiceRequestDetailMain extends StatefulWidget {
|
|
|
|
|
final int requestId;
|
|
|
|
|
final int moduleId;
|
|
|
|
|
|
|
|
|
|
ServiceRequestDetailMain({Key? key, required this.requestId}) : super(key: key);
|
|
|
|
|
ServiceRequestDetailMain({Key? key, required this.requestId, required this.moduleId}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ServiceRequestDetailMainState createState() {
|
|
|
|
|
@ -88,37 +90,29 @@ class _ServiceRequestDetailMainState extends State<ServiceRequestDetailMain> {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
actions: [
|
|
|
|
|
if (context.userProvider.isEngineer || context.userProvider.isNurse)
|
|
|
|
|
Selector<ServiceRequestDetailProvider, bool>(
|
|
|
|
|
selector: (_, myModel) => myModel.isLoading, // Selects only the userName
|
|
|
|
|
builder: (_, isLoading, __) {
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
} else {
|
|
|
|
|
ServiceRequestDetailProvider provider = Provider.of<ServiceRequestDetailProvider>(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();
|
|
|
|
|
Selector<ServiceRequestDetailProvider, bool>(
|
|
|
|
|
selector: (_, myModel) => myModel.isLoading, // Selects only the userName
|
|
|
|
|
builder: (_, isLoading, __) {
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
} else {
|
|
|
|
|
ServiceRequestDetailProvider provider = Provider.of<ServiceRequestDetailProvider>(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.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!.username!,
|
|
|
|
|
contactEmployeeINumber: provider.currentWorkOrder?.data?.workOrderContactPerson.first.employeeId,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
isNurse
|
|
|
|
|
? IconButton(
|
|
|
|
|
icon: 'qr'.toSvgAsset(
|
|
|
|
|
|