|
|
|
@ -6,12 +6,14 @@ import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/models/ppm/recurrent_wo.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
import 'package:test_sa/views/widgets/qr/scan_qr.dart';
|
|
|
|
import 'package:test_sa/views/widgets/qr/scan_qr.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
import '../models/cleaner_task_search_result.dart';
|
|
|
|
import '../models/cleaner_task_search_result.dart';
|
|
|
|
import '../provider/cleaner_provider.dart';
|
|
|
|
import '../provider/cleaner_provider.dart';
|
|
|
|
import '../../pm_module/recurrent_wo/recurrent_work_order_view.dart';
|
|
|
|
import '../../pm_module/recurrent_wo/recurrent_work_order_view.dart';
|
|
|
|
@ -34,8 +36,12 @@ class CleanerSearchDetailsView extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
late CleanerProvider _cleanerProvider;
|
|
|
|
late CleanerProvider _cleanerProvider;
|
|
|
|
bool _isQRScanned = false;
|
|
|
|
|
|
|
|
|
|
|
|
// bool _isQRScanned = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool _isRequestOpen = false;
|
|
|
|
CleanerTaskSearchResult? _taskData;
|
|
|
|
CleanerTaskSearchResult? _taskData;
|
|
|
|
|
|
|
|
RecurrentWoData? _recurrentWoData;
|
|
|
|
bool _isLoading = false;
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
@ -61,17 +67,18 @@ class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
|
|
|
|
|
|
|
|
// Map RecurrentWoData to CleanerTaskSearchResult
|
|
|
|
// Map RecurrentWoData to CleanerTaskSearchResult
|
|
|
|
if (allRequestsProvider.recurrentWoData != null) {
|
|
|
|
if (allRequestsProvider.recurrentWoData != null) {
|
|
|
|
final recurrentData = allRequestsProvider.recurrentWoData!;
|
|
|
|
_recurrentWoData = allRequestsProvider.recurrentWoData!;
|
|
|
|
|
|
|
|
_isRequestOpen = _recurrentWoData?.status?.value == 4;
|
|
|
|
_taskData = CleanerTaskSearchResult(
|
|
|
|
_taskData = CleanerTaskSearchResult(
|
|
|
|
id: recurrentData.id,
|
|
|
|
id: _recurrentWoData!.id,
|
|
|
|
taskNo: recurrentData.taskNo,
|
|
|
|
taskNo: _recurrentWoData!.taskNo,
|
|
|
|
siteName: recurrentData.site?.siteName,
|
|
|
|
siteName: _recurrentWoData!.site?.siteName,
|
|
|
|
buildingName: recurrentData.building?.name,
|
|
|
|
buildingName: _recurrentWoData!.building?.name,
|
|
|
|
floorName: recurrentData.floor?.name,
|
|
|
|
floorName: _recurrentWoData!.floor?.name,
|
|
|
|
departmentName: recurrentData.department?.name,
|
|
|
|
departmentName: _recurrentWoData!.department?.name,
|
|
|
|
roomName: recurrentData.room?.name,
|
|
|
|
roomName: _recurrentWoData!.room?.name,
|
|
|
|
locationDescription: null,
|
|
|
|
locationDescription: null,
|
|
|
|
createdDate: recurrentData.scheduleDate,
|
|
|
|
createdDate: _recurrentWoData!.scheduleDate,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
@ -126,7 +133,7 @@ class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
if (!_isQRScanned) ...[
|
|
|
|
if (_isRequestOpen) ...[
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Icon(Icons.info_outline_rounded, size: 16, color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
|
|
Icon(Icons.info_outline_rounded, size: 16, color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
|
|
|
@ -135,7 +142,7 @@ class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
child: Text(
|
|
|
|
child: Text(
|
|
|
|
'By scanning the QR code you will accept this task'.addTranslation,
|
|
|
|
'By scanning the QR code you will accept this task'.addTranslation,
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
style: AppTextStyles.bodyText.copyWith(
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(
|
|
|
|
color: context.isDark ? AppColor.neutral10 : AppColor.neutral120,
|
|
|
|
color: context.isDark ? AppColor.neutral10 : AppColor.neutral120,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -145,53 +152,27 @@ class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
AppFilledButton(
|
|
|
|
AppFilledButton(
|
|
|
|
label: _isQRScanned ? 'Update' : 'Scan QR Code',
|
|
|
|
label: _isRequestOpen ? 'Scan QR Code' : 'Update',
|
|
|
|
maxWidth: true,
|
|
|
|
maxWidth: true,
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
onPressed: () async {
|
|
|
|
onPressed: () async {
|
|
|
|
if (_isQRScanned) {
|
|
|
|
if (_isRequestOpen) {
|
|
|
|
// If QR is already scanned, navigate to recurrent work order view
|
|
|
|
final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => const ScanQr()));
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
|
|
builder: (_) => RecurrentWorkOrderView(taskId: widget.requestId),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Open QR scanner
|
|
|
|
|
|
|
|
final result = await Navigator.push(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
|
|
builder: (context) => const ScanQr(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If QR code was scanned successfully, check if it matches the room
|
|
|
|
|
|
|
|
if (result != null && result is String && result.isNotEmpty) {
|
|
|
|
if (result != null && result is String && result.isNotEmpty) {
|
|
|
|
// Show loading indicator
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
showDialog(
|
|
|
|
final isValid = await CleanerProvider().checkQRSameRoom(planRecurrentTaskId: widget.requestId, qrCode: result);
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
|
|
|
builder: (context) => const AppLazyLoading(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Call the API to check if QR matches the same room
|
|
|
|
|
|
|
|
final isValid = await CleanerProvider().checkQRSameRoom(
|
|
|
|
|
|
|
|
planRecurrentTaskId: widget.requestId,
|
|
|
|
|
|
|
|
qrCode: result,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Close loading dialog
|
|
|
|
|
|
|
|
if (mounted) Navigator.pop(context);
|
|
|
|
if (mounted) Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
|
|
if (isValid) {
|
|
|
|
if (isValid) {
|
|
|
|
// Update state to show "Update" button instead of navigating
|
|
|
|
|
|
|
|
if (mounted) {
|
|
|
|
if (mounted) {
|
|
|
|
setState(() {
|
|
|
|
getInitialData();
|
|
|
|
_isQRScanned = true;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
|
|
|
MaterialPageRoute(builder: (_) => RecurrentWorkOrderView(taskId: widget.requestId)),
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -230,12 +211,24 @@ class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
// Text(
|
|
|
|
'Request Information',
|
|
|
|
// 'Request Information',
|
|
|
|
style: AppTextStyles.heading4.copyWith(
|
|
|
|
// style: AppTextStyles.heading4.copyWith(
|
|
|
|
color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
|
|
|
|
// color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
if (_recurrentWoData?.status?.name != null)
|
|
|
|
|
|
|
|
StatusLabel(
|
|
|
|
|
|
|
|
label: _recurrentWoData?.status?.name!,
|
|
|
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, _recurrentWoData?.status?.name!),
|
|
|
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, _recurrentWoData?.status?.name!),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
8.width,
|
|
|
|
|
|
|
|
// StatusLabel(
|
|
|
|
|
|
|
|
// label: taskModel?.taskJobStatus?.name ?? widget.requestDetails?.status!,
|
|
|
|
|
|
|
|
// textColor: AppColor.getRequestStatusTextColorByName(context, taskModel?.taskJobStatus?.name ?? widget.requestDetails?.status!),
|
|
|
|
|
|
|
|
// backgroundColor: AppColor.getRequestStatusColorByName(context, taskModel?.taskJobStatus?.name ?? widget.requestDetails?.status!),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
if (taskResult.createdDate != null)
|
|
|
|
if (taskResult.createdDate != null)
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
taskResult.createdDate!.toServiceRequestCardFormat,
|
|
|
|
taskResult.createdDate!.toServiceRequestCardFormat,
|
|
|
|
@ -245,6 +238,13 @@ class _CleanerSearchDetailsViewState extends State<CleanerSearchDetailsView> {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
if (_recurrentWoData?.title?.isNotEmpty ?? false)
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
_recurrentWoData?.title ?? "",
|
|
|
|
|
|
|
|
style: AppTextStyles.heading4.copyWith(
|
|
|
|
|
|
|
|
color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
if (taskResult.taskNo != null && taskResult.taskNo!.isNotEmpty)
|
|
|
|
if (taskResult.taskNo != null && taskResult.taskNo!.isNotEmpty)
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
'Task No: ${taskResult.taskNo!}',
|
|
|
|
'Task No: ${taskResult.taskNo!}',
|
|
|
|
|