From 2c7a8d035cc5fe56f38ce97f00052480c2622213 Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 <50428976+WaseemAbbasi22@users.noreply.github.com> Date: Wed, 10 Jun 2026 10:45:21 +0300 Subject: [PATCH] added new payload for adding traf as requested by backend and added some missing data in details page --- .../traf_module/create_traf_request_page.dart | 2 +- .../traf_module/traf_request_detail_page.dart | 30 ++++++--- .../traf_module/traf_request_model.dart | 65 +++++++++++++++++++ 3 files changed, 86 insertions(+), 11 deletions(-) diff --git a/lib/modules/traf_module/create_traf_request_page.dart b/lib/modules/traf_module/create_traf_request_page.dart index 206d1350..1cc00f1c 100644 --- a/lib/modules/traf_module/create_traf_request_page.dart +++ b/lib/modules/traf_module/create_traf_request_page.dart @@ -549,7 +549,7 @@ class _CreateTRAFRequestPageState extends State { } Utils.showLoading(context); - bool isSuccess = await Provider.of(context, listen: false).addTraf(trafRequest!.toJson()); + bool isSuccess = await Provider.of(context, listen: false).addTraf(trafRequest!.toJsonNew()); Utils.hideLoading(context); if (isSuccess) { Navigator.pop(context); diff --git a/lib/modules/traf_module/traf_request_detail_page.dart b/lib/modules/traf_module/traf_request_detail_page.dart index e4a804c7..e56b043a 100644 --- a/lib/modules/traf_module/traf_request_detail_page.dart +++ b/lib/modules/traf_module/traf_request_detail_page.dart @@ -1,3 +1,4 @@ +import 'dart:developer'; import 'dart:io'; import 'package:flutter/material.dart'; @@ -42,7 +43,9 @@ class _TrafRequestDetailPageState extends State { @override void initState() { super.initState(); - Provider.of(context, listen: false).getTRAFById(widget.trafId); + WidgetsBinding.instance.addPostFrameCallback((_) { + Provider.of(context, listen: false).getTRAFById(widget.trafId); + }); } @override @@ -60,6 +63,9 @@ class _TrafRequestDetailPageState extends State { builder: (_, isLoading, __) { if (isLoading) return const ALoading(); TrafRequestProvider trafProvider = Provider.of(context, listen: false); + if (trafProvider.trafRequestDataModel?.attachments != null) { + _attachments = trafProvider.trafRequestDataModel!.attachments!.map((e) => File(URLs.getFileUrl(e.attachmentName ?? '') ?? '')).toList(); + } return trafProvider.trafRequestDataModel == null ? const NoDataFound().center : Column( @@ -72,15 +78,6 @@ class _TrafRequestDetailPageState extends State { requestInformation(trafProvider.trafRequestDataModel!), 12.height, assetInformation(trafProvider.trafRequestDataModel!), - if (_attachments.isNotEmpty) ...[ - 12.height, - Text( - "Attachments".addTranslation, - style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ), - 8.height, - FilesList(images: trafProvider.trafRequestDataModel?.attachments?.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []), - ], ], ).expanded, // // if (isEngineer) @@ -134,6 +131,10 @@ class _TrafRequestDetailPageState extends State { 8.height, 'TRAF No: ${data.reqCode ?? '-'}'.bodyText(context), 'Request type: ${data.requestTypeName ?? '-'}'.bodyText(context), + if (data.requestTypeValue == 1) ...[ + 4.height, + 'Requested Quantity: ${data.qty ?? '-'}'.bodyText(context), + ], 4.height, 'How would the requested technology solve the current situation and/or serve the purpose?: ${data.purposeAnswer ?? '-'}'.bodyText(context), 4.height, @@ -164,6 +165,15 @@ class _TrafRequestDetailPageState extends State { 4.height, 'Equipment going to be used with combination of other equipments:\n${data.usedWithCombination ?? '-'}'.bodyText(context), ], + if (_attachments.isNotEmpty) ...[ + 4.height, + Text( + "Attachments".addTranslation, + style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + ), + // 8.height, + FilesList(images: _attachments.map((e) => URLs.getFileUrl(e.path ?? '') ?? '').toList() ?? []), + ], ], ).toShadowContainer(context, borderRadius: 20, padding: 12); } diff --git a/lib/modules/traf_module/traf_request_model.dart b/lib/modules/traf_module/traf_request_model.dart index 88295bdd..09079f3f 100644 --- a/lib/modules/traf_module/traf_request_model.dart +++ b/lib/modules/traf_module/traf_request_model.dart @@ -88,6 +88,7 @@ class TrafRequestDataModel { String? isEffectedName; String? effectedServices; int? isCombinationId; + int?requestTypeValue; String? isCombinationName; String? usedWithCombination; String? comment; @@ -187,6 +188,7 @@ class TrafRequestDataModel { this.isEffectedName, this.effectedServices, this.isCombinationId, + this.requestTypeValue, this.isCombinationName, this.usedWithCombination, this.comment, @@ -301,6 +303,7 @@ class TrafRequestDataModel { isEffectedName = json['isEffectedName']; effectedServices = json['effectedServices']; isCombinationId = json['isCombinationId']; + requestTypeValue = json['requestTypeValue']; isCombinationName = json['isCombinationName']; usedWithCombination = json['usedWithCombination']; comment = json['comment']; @@ -418,6 +421,7 @@ class TrafRequestDataModel { data['isEffectedName'] = this.isEffectedName; data['effectedServices'] = this.effectedServices; data['isCombinationId'] = this.isCombinationId; + data['requestTypeValue'] = this.requestTypeValue; data['isCombinationName'] = this.isCombinationName; data['usedWithCombination'] = this.usedWithCombination; data['comment'] = this.comment; @@ -478,6 +482,67 @@ class TrafRequestDataModel { data['modifiedDate'] = this.modifiedDate; return data; } + Map toJsonNew() { + final Map data = {}; + + data['id'] = id; + data['reqNo'] = reqNo; + data['reqCode'] = reqCode; + data['employeeId'] = employeeId; + data['positionId'] = positionId; + + data['departments'] = + departments?.map((v) => v.toJson()).toList() ?? []; + if (this.trafDepartments != null) { + data['trafDepartments'] = this.trafDepartments!.map((v) => v.toJson()).toList(); + } + + data['siteId'] = siteId; + data['siteName'] = siteName; + data['requesterExtensionNumber'] = requesterExtensionNumber; + data['requesterExtensionName'] = requesterExtensionName; + data['requesterExtensionPositionId'] = requesterExtensionPositionId; + + data['requestTypeId'] = requestTypeId; + + data['assetNDId'] = assetNDId; + data['assetId'] = assetId; + data['qty'] = qty; + + data['purposeAnswer'] = purposeAnswer; + data['currentPractise'] = currentPractise; + + data['censusQ1'] = censusQ1; + data['censusQ2'] = censusQ2; + data['censusQ3'] = censusQ3; + data['censusQ4'] = censusQ4; + + data['isFromMobile'] = isFromMobile; + + data['trafContacts'] = + trafContacts?.map((v) => v.toJson()).toList() ?? []; + + data['usingSolelyOrSharedId'] = usingSolelyOrSharedId; + + data['isEffectedId'] = isEffectedId; + data['effectedServices'] = effectedServices; + + data['isCombinationId'] = isCombinationId; + data['usedWithCombination'] = usedWithCombination; + + data['comment'] = comment; + + data['isBudgetId'] = isBudgetId; + + data['attachments'] = + attachments?.map((v) => v.toJson()).toList() ?? []; + + return data; + } + + + + } class TrafContacts {