loan attachment added & improvements.

design_3.0_asset_delivery_module
Sikander Saleem 3 months ago
parent 22fd3c8cc9
commit 07ec866315

@ -353,26 +353,41 @@ class URLs {
//internal Audit //internal Audit
static get getInternalAuditEquipmentById => "$_baseUrl/InternalAuditEquipments/GetInternalAuditEquipmentById"; static get getInternalAuditEquipmentById => "$_baseUrl/InternalAuditEquipments/GetInternalAuditEquipmentById";
static get getInternalAuditSystemById => "$_baseUrl/InternalAuditSystems/GetInternalAuditSystemByIdV2"; static get getInternalAuditSystemById => "$_baseUrl/InternalAuditSystems/GetInternalAuditSystemByIdV2";
static get getInternalAuditChecklist => "$_baseUrl/Lookups/GetLookup?lookupEnum=43"; static get getInternalAuditChecklist => "$_baseUrl/Lookups/GetLookup?lookupEnum=43";
static get getInternalAuditWoType => "$_baseUrl/Lookups/GetLookup?lookupEnum=2500"; static get getInternalAuditWoType => "$_baseUrl/Lookups/GetLookup?lookupEnum=2500";
static get getInternalAuditFindingType => "$_baseUrl/Lookups/GetLookup?lookupEnum=2502"; static get getInternalAuditFindingType => "$_baseUrl/Lookups/GetLookup?lookupEnum=2502";
static get addOrUpdateEquipmentInternalAudit => "$_baseUrl/InternalAuditEquipments/AddOrUpdateAuditEquipment"; static get addOrUpdateEquipmentInternalAudit => "$_baseUrl/InternalAuditEquipments/AddOrUpdateAuditEquipment";
static get addOrUpdateInternalAuditSystem => "$_baseUrl/InternalAuditSystems/AddOrUpdateInternalAuditSystem"; static get addOrUpdateInternalAuditSystem => "$_baseUrl/InternalAuditSystems/AddOrUpdateInternalAuditSystem";
static get getWoAutoComplete => "$_baseUrl/InternalAuditSystems/AutoCompleteAllWorkOrder"; static get getWoAutoComplete => "$_baseUrl/InternalAuditSystems/AutoCompleteAllWorkOrder";
static get updateAuditEquipmentsEngineer => "$_baseUrl/InternalAuditEquipments/UpdateAuditEquipmentsEngineer"; static get updateAuditEquipmentsEngineer => "$_baseUrl/InternalAuditEquipments/UpdateAuditEquipmentsEngineer";
static get updateAuditSystemEngineer => "$_baseUrl/InternalAuditSystems/UpdateAuditSystemEngineer"; static get updateAuditSystemEngineer => "$_baseUrl/InternalAuditSystems/UpdateAuditSystemEngineer";
static get loadAllWorkOrderDetailsByID => "$_baseUrl/InternalAuditSystems/LoadAllWorkOrderDetailsByID"; static get loadAllWorkOrderDetailsByID => "$_baseUrl/InternalAuditSystems/LoadAllWorkOrderDetailsByID";
//chat //chat
static get chatSdkToken => '$chatHubUrlApi/auth/sdk-token'; static get chatSdkToken => '$chatHubUrlApi/auth/sdk-token';
//survey //survey
static get getQuestionnaire => '$_baseUrl/SurveyQuestionnaire/GetQuestionnaire'; static get getQuestionnaire => '$_baseUrl/SurveyQuestionnaire/GetQuestionnaire';
static get submitSurvey => '$_baseUrl/SurveyQuestionnaire/SubmitSurvey'; static get submitSurvey => '$_baseUrl/SurveyQuestionnaire/SubmitSurvey';
// load module // load module
static get getLoanPeriod => "$_baseUrl/Lookups/GetLookup?lookupEnum=3051"; static get getLoanPeriod => "$_baseUrl/Lookups/GetLookup?lookupEnum=3051";
static get getMedDepartmentBasedOnSite => "$_baseUrl/TRAFDataSource/GetDepartmentBasedOnSite"; static get getMedDepartmentBasedOnSite => "$_baseUrl/TRAFDataSource/GetDepartmentBasedOnSite";
static get getLoanById => '$_baseUrl/Loan/GetLoanById'; static get getLoanById => '$_baseUrl/Loan/GetLoanById';
static get addLoan => '$_baseUrl/Loan/AddLoan'; static get addLoan => '$_baseUrl/Loan/AddLoan';
} }

@ -14,6 +14,7 @@ import 'package:test_sa/modules/cm_module/views/components/bottom_sheets/service
import 'package:test_sa/modules/cx_module/chat/chat_page.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_provider.dart';
import 'package:test_sa/modules/cx_module/survey/survey_page.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'; 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/views/widgets/loaders/no_data_found.dart'; import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
@ -119,23 +120,39 @@ class _CMDetailPageState extends State<CMDetailPage> {
return const SizedBox(); return const SizedBox();
} }
}), }),
isNurse if (isNurse)
? IconButton( IconButton(
icon: 'qr'.toSvgAsset( icon: 'qr'.toSvgAsset(height: 24, width: 24),
height: 24, onPressed: () {
width: 24, ServiceRequestBottomSheet.getQRCodeBottomSheet(context: context);
},
)
else ...[
Container(
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 6),
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),
), ),
onPressed: () { 4.width,
ServiceRequestBottomSheet.getQRCodeBottomSheet(context: context); ],
}, ),
) ).onPress(() {
: IconButton( Navigator.push(context, MaterialPageRoute(builder: (context) => CreateLoanRequestPage(workOrderId: widget.requestId)));
icon: const Icon(Icons.home), }),
onPressed: () { IconButton(
// stopTimer(); icon: const Icon(Icons.home),
Navigator.pop(context); onPressed: () {
}, // stopTimer();
), Navigator.pop(context);
},
)
],
], ],
), ),
body: DefaultTabController( body: DefaultTabController(

@ -286,8 +286,6 @@ class ChatApiClient {
// This is the most important part: prevent automatic redirection. // This is the most important part: prevent automatic redirection.
request.followRedirects = false; request.followRedirects = false;
print("Making initial request to: $url");
final streamedResponse = await client.send(request); final streamedResponse = await client.send(request);
// --- Step 2: Check the response and handle the redirect --- // --- Step 2: Check the response and handle the redirect ---

@ -0,0 +1,39 @@
class LoanAttachmentModel {
int? loanId;
String? attachmentName;
int? loanAttachmentTypeId;
String? attachmentDescription;
int? id;
String? createdBy;
String? createdDate;
String? modifiedBy;
String? modifiedDate;
LoanAttachmentModel({this.loanId, this.attachmentName, this.loanAttachmentTypeId, this.attachmentDescription, this.id, this.createdBy, this.createdDate, this.modifiedBy, this.modifiedDate});
LoanAttachmentModel.fromJson(Map<String, dynamic> json) {
loanId = json['loanId'];
attachmentName = json['attachmentName'];
loanAttachmentTypeId = json['loanAttachmentTypeId'];
attachmentDescription = json['attachmentDescription'];
id = json['id'];
createdBy = json['createdBy'];
createdDate = json['createdDate'];
modifiedBy = json['modifiedBy'];
modifiedDate = json['modifiedDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['loanId'] = this.loanId;
data['attachmentName'] = this.attachmentName;
data['loanAttachmentTypeId'] = this.loanAttachmentTypeId;
data['attachmentDescription'] = this.attachmentDescription;
data['id'] = this.id;
data['createdBy'] = this.createdBy;
data['createdDate'] = this.createdDate;
data['modifiedBy'] = this.modifiedBy;
data['modifiedDate'] = this.modifiedDate;
return data;
}
}

@ -87,7 +87,9 @@ class LoanFormModel {
"loanPeriodId": loanProvided?.id, "loanPeriodId": loanProvided?.id,
"vendorName": vendorName, "vendorName": vendorName,
"vendorRepresentativeName": vendorRepresentativeName, "vendorRepresentativeName": vendorRepresentativeName,
"vendorRepName": vendorRepresentativeName,
"vendorNumber": vendorNumber, "vendorNumber": vendorNumber,
"vendorContact": vendorNumber,
"vendorEmail": vendorEmail, "vendorEmail": vendorEmail,
'siteId': site?.id, 'siteId': site?.id,
'departmentId': department?.id, 'departmentId': department?.id,
@ -97,38 +99,40 @@ class LoanFormModel {
} }
class LoanAttachments { class LoanAttachments {
LoanAttachments({ num? id;
this.id, num? loanAttachmentTypeId;
this.name, num? loanId;
this.originalName, String? attachmentName;
}); String? attachmentDescription;
LoanAttachments({this.id, this.loanAttachmentTypeId, this.attachmentName, this.loanId, this.attachmentDescription});
LoanAttachments.fromJson(dynamic json) { LoanAttachments.fromJson(dynamic json) {
id = json['id']; id = json['id'];
name = json['name']; loanAttachmentTypeId = json['loanAttachmentTypeId'];
originalName = json['originalName']; loanId = json['loanId'];
attachmentName = json['attachmentName'];
attachmentDescription = json['attachmentDescription'];
} }
num? id; // LoanAttachments copyWith({
String? name; // num? id, // Parameter is now nullable
String? originalName; // String? name, // Parameter is now nullable
// String? originalName, // Parameter is now nullable
LoanAttachments copyWith({ // }) =>
num? id, // Parameter is now nullable // LoanAttachments(
String? name, // Parameter is now nullable // id: id ?? this.id,
String? originalName, // Parameter is now nullable // name: name ?? this.name,
}) => // originalName: originalName ?? this.originalName,
LoanAttachments( // );
id: id ?? this.id,
name: name ?? this.name,
originalName: originalName ?? this.originalName,
);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['id'] = id; map['id'] = id;
map['name'] = name; map['loanAttachmentTypeId'] = loanAttachmentTypeId;
map['originalName'] = originalName; map['attachmentName'] = attachmentName;
map['loanId'] = loanId;
map['attachmentDescription'] = attachmentDescription;
return map; return map;
} }
} }

@ -1,3 +1,7 @@
import 'package:test_sa/models/lookup.dart';
import 'loan_attachment_model.dart';
class LoanRequestModel { class LoanRequestModel {
String? requestorUserID; String? requestorUserID;
int? reqNo; int? reqNo;
@ -31,14 +35,14 @@ class LoanRequestModel {
String? vendorRepName; String? vendorRepName;
String? vendorContact; String? vendorContact;
String? vendorEmail; String? vendorEmail;
List<Null>? loanAttachments; List<LoanAttachmentModel>? loanAttachments;
int? loanStatusId; int? loanStatusId;
String? loanStatusName; String? loanStatusName;
int? loanStatusValue; int? loanStatusValue;
String? installationEDD; String? installationEDD;
String? pulloutEDD; String? pulloutEDD;
String? mdUserID; String? mdUserID;
String? mdUser; MdUser? mdUser;
String? mesUserID; String? mesUserID;
String? mesUser; String? mesUser;
String? assignedFEForInstallationUserID; String? assignedFEForInstallationUserID;
@ -49,6 +53,8 @@ class LoanRequestModel {
int? installationWOItemId; int? installationWOItemId;
int? pulloutWOItemId; int? pulloutWOItemId;
int? id; int? id;
String? installationDate;
String? pulloutDate;
String? createdBy; String? createdBy;
String? createdDate; String? createdDate;
String? modifiedBy; String? modifiedBy;
@ -106,6 +112,8 @@ class LoanRequestModel {
this.pulloutWOItemId, this.pulloutWOItemId,
this.id, this.id,
this.createdBy, this.createdBy,
this.installationDate,
this.pulloutDate,
this.createdDate, this.createdDate,
this.modifiedBy, this.modifiedBy,
this.modifiedDate}); this.modifiedDate});
@ -143,10 +151,11 @@ class LoanRequestModel {
vendorRepName = json['vendorRepName']; vendorRepName = json['vendorRepName'];
vendorContact = json['vendorContact']; vendorContact = json['vendorContact'];
vendorEmail = json['vendorEmail']; vendorEmail = json['vendorEmail'];
loanAttachments = <LoanAttachmentModel>[];
if (json['loanAttachments'] != null) { if (json['loanAttachments'] != null) {
loanAttachments = <Null>[]; loanAttachments = <LoanAttachmentModel>[];
json['loanAttachments'].forEach((v) { json['loanAttachments'].forEach((v) {
// loanAttachments!.add(new Null.fromJson(v)); loanAttachments!.add(new LoanAttachmentModel.fromJson(v));
}); });
} }
loanStatusId = json['loanStatusId']; loanStatusId = json['loanStatusId'];
@ -155,7 +164,7 @@ class LoanRequestModel {
installationEDD = json['installationEDD']; installationEDD = json['installationEDD'];
pulloutEDD = json['pulloutEDD']; pulloutEDD = json['pulloutEDD'];
mdUserID = json['mdUserID']; mdUserID = json['mdUserID'];
mdUser = json['mdUser']; mdUser = json['mdUser'] == null ? null : MdUser.fromJson(json['mdUser']);
mesUserID = json['mesUserID']; mesUserID = json['mesUserID'];
mesUser = json['mesUser']; mesUser = json['mesUser'];
assignedFEForInstallationUserID = json['assignedFEForInstallationUserID']; assignedFEForInstallationUserID = json['assignedFEForInstallationUserID'];
@ -166,6 +175,8 @@ class LoanRequestModel {
installationWOItemId = json['installationWOItemId']; installationWOItemId = json['installationWOItemId'];
pulloutWOItemId = json['pulloutWOItemId']; pulloutWOItemId = json['pulloutWOItemId'];
id = json['id']; id = json['id'];
installationDate = json['installationDate'];
pulloutDate = json['pulloutDate'];
createdBy = json['createdBy']; createdBy = json['createdBy'];
createdDate = json['createdDate']; createdDate = json['createdDate'];
modifiedBy = json['modifiedBy']; modifiedBy = json['modifiedBy'];
@ -207,7 +218,7 @@ class LoanRequestModel {
data['vendorContact'] = this.vendorContact; data['vendorContact'] = this.vendorContact;
data['vendorEmail'] = this.vendorEmail; data['vendorEmail'] = this.vendorEmail;
if (this.loanAttachments != null) { if (this.loanAttachments != null) {
// data['loanAttachments'] = this.loanAttachments!.map((v) => v.toJson()).toList(); data['loanAttachments'] = this.loanAttachments!.map((v) => v.toJson()).toList();
} }
data['loanStatusId'] = this.loanStatusId; data['loanStatusId'] = this.loanStatusId;
data['loanStatusName'] = this.loanStatusName; data['loanStatusName'] = this.loanStatusName;
@ -215,7 +226,7 @@ class LoanRequestModel {
data['installationEDD'] = this.installationEDD; data['installationEDD'] = this.installationEDD;
data['pulloutEDD'] = this.pulloutEDD; data['pulloutEDD'] = this.pulloutEDD;
data['mdUserID'] = this.mdUserID; data['mdUserID'] = this.mdUserID;
data['mdUser'] = this.mdUser; data['mdUser'] = this.mdUser?.toJson();
data['mesUserID'] = this.mesUserID; data['mesUserID'] = this.mesUserID;
data['mesUser'] = this.mesUser; data['mesUser'] = this.mesUser;
data['assignedFEForInstallationUserID'] = this.assignedFEForInstallationUserID; data['assignedFEForInstallationUserID'] = this.assignedFEForInstallationUserID;
@ -226,6 +237,8 @@ class LoanRequestModel {
data['installationWOItemId'] = this.installationWOItemId; data['installationWOItemId'] = this.installationWOItemId;
data['pulloutWOItemId'] = this.pulloutWOItemId; data['pulloutWOItemId'] = this.pulloutWOItemId;
data['id'] = this.id; data['id'] = this.id;
data['installationDate'] = this.installationDate;
data['pulloutDate'] = this.pulloutDate;
data['createdBy'] = this.createdBy; data['createdBy'] = this.createdBy;
data['createdDate'] = this.createdDate; data['createdDate'] = this.createdDate;
data['modifiedBy'] = this.modifiedBy; data['modifiedBy'] = this.modifiedBy;
@ -233,3 +246,22 @@ class LoanRequestModel {
return data; return data;
} }
} }
class MdUser {
String? id;
String? name;
MdUser({this.id, this.name});
MdUser.fromJson(dynamic json) {
id = json['id'] ?? '';
name = json['name'] ?? '';
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
return map;
}
}

@ -486,7 +486,7 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
_loanFormModel.loanAttachment = []; _loanFormModel.loanAttachment = [];
for (var item in attachments) { for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? ''; String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_loanFormModel.loanAttachment?.add(LoanAttachments(id: item.id, name: fileName)); _loanFormModel.loanAttachment?.add(LoanAttachments(id: 0, attachmentName: fileName, loanId: 0));
} }
Utils.showLoading(context); Utils.showLoading(context);
LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false); LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false);

@ -14,6 +14,7 @@ import 'package:test_sa/modules/internal_audit_module/models/system_internal_aud
import 'package:test_sa/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart'; import 'package:test_sa/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart';
import 'package:test_sa/modules/internal_audit_module/pages/system_internal_audit/update_system_internal_audit_page.dart'; import 'package:test_sa/modules/internal_audit_module/pages/system_internal_audit/update_system_internal_audit_page.dart';
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart'; import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
import 'package:test_sa/modules/loan_module/models/loan_attachment_model.dart';
import 'package:test_sa/modules/loan_module/provider/loan_provider.dart'; import 'package:test_sa/modules/loan_module/provider/loan_provider.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/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
@ -26,185 +27,91 @@ import 'package:test_sa/views/widgets/requests/request_status.dart';
import '../models/loan_request_model.dart'; import '../models/loan_request_model.dart';
class LoanEquipmentDetailPage extends StatefulWidget { class LoanEquipmentDetailPage extends StatelessWidget {
static const String id = "/loan-equipment-detail-page"; static const String id = "/loan-equipment-detail-page";
final int loanId; final int loanId;
LoanEquipmentDetailPage({Key? key, required this.loanId}) : super(key: key); LoanEquipmentDetailPage({Key? key, required this.loanId}) : super(key: key);
@override
_LoanEquipmentDetailPageState createState() {
return _LoanEquipmentDetailPageState();
}
}
class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
bool isWoType = true;
late LoanProvider _loanProvider;
List<InternalAuditAttachments> allAttachments = [];
@override
void initState() {
super.initState();
_loanProvider = Provider.of<LoanProvider>(context, listen: false);
WidgetsBinding.instance.addPostFrameCallback((_) {
_loanProvider.getLoanById(widget.loanId);
});
}
// Future<void> getLoanData() async {
// model = await _loanProvider.getLoanById(widget.loanId);
// allAttachments.clear();
// allAttachments = [
// // ...(model?.attachments ?? []),
// // ...(model?.engineerData?.attachments ?? []),
// ];
// }
@override
void dispose() {
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: const DefaultAppBar(title: "Request Details"), appBar: const DefaultAppBar(title: "Request Details"),
body: Selector<LoanProvider, bool>( body: SafeArea(
selector: (_, provider) => provider.isLoading, child: FutureBuilder<LoanRequestModel?>(
builder: (_, isLoading, __) { future: Provider.of<LoanProvider>(context, listen: false).getLoanById(loanId),
if (isLoading) return const CircularProgressIndicator(color: AppColor.primary10).center; builder: (BuildContext context, AsyncSnapshot<LoanRequestModel?> snapshot) {
LoanRequestModel? model = Provider.of<LoanProvider>(context, listen: false).loanData; if (snapshot.connectionState == ConnectionState.waiting) return const CircularProgressIndicator(color: AppColor.primary10).center;
if (model == null) const NoDataFound().center; if (snapshot.data == null) return const NoDataFound().center;
List<LoanAttachmentModel> allAttachments = snapshot.data!.loanAttachments!;
return Column( return ListView(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleChildScrollView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Row( children: [
crossAxisAlignment: CrossAxisAlignment.start, Row(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
// StatusLabel( children: [
// label: model.priority!, StatusLabel(
// textColor: AppColor.getRequestStatusTextColorByName(context, widget.requestDetails?.priority!), label: snapshot.data!.loanStatusName!,
// backgroundColor: AppColor.getRequestStatusColorByName(context, widget.requestDetails?.priority!), textColor: AppColor.getRequestStatusTextColorByName(context, snapshot.data!.loanStatusName!),
// ), backgroundColor: AppColor.getRequestStatusColorByName(context, snapshot.data!.loanStatusName!),
// 8.width, ),
StatusLabel( 1.width.expanded,
label: model?.loanStatusName!, Text(
textColor: AppColor.getRequestStatusTextColorByName(context, model?.loanStatusName!), snapshot.data!.createdDate?.toServiceRequestCardFormat ?? "-",
backgroundColor: AppColor.getRequestStatusColorByName(context, model?.loanStatusName!), textAlign: TextAlign.end,
), style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
1.width.expanded, ),
],
),
12.height,
...requesterDetails(context, snapshot.data!),
12.height,
...requestDetails(context, snapshot.data!),
12.height,
...assetDetails(context, snapshot.data!),
12.height,
...installationDetails(context, snapshot.data!),
12.height,
...doctorDetails(context, snapshot.data!),
12.height,
...vendorDetails(context, snapshot.data!),
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
Text( Text(
model?.createdDate?.toServiceRequestCardFormat ?? "-", "Attachments".addTranslation,
textAlign: TextAlign.end, style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
), ),
8.height,
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
], ],
),
12.height,
...requestDetails(model!),
12.height,
...assetDetails(model),
12.height,
...requesterDetails(model),
12.height,
...doctorDetails(model),
12.height,
...vendorDetails(model),
// assetInformation(),
// 8.height,
// workOrderInformation(),
// 8.height,
// //TODO need to check for comments
// if (model?.findingDescription?.isNotEmpty ?? false) ...[
// const Divider().defaultStyle(context),
// // Text(
// // "Comments".addTranslation,
// // style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
// // ),
// model!.findingDescription!.bodyText(context),
// ],
//TODO need to check for attachments
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
Text(
"Attachments".addTranslation,
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
8.height,
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
], ],
], ).toShadowContainer(context),
).paddingAll(0).toShadowContainer(context), ],
).expanded, );
// if (context.userProvider.isEngineer) }),
// FooterActionButton.footerContainer(
// context: context,
// child: AppFilledButton(
// buttonColor: AppColor.primary10,
// label: "Update",
// onPressed: () async {
// final result = await Navigator.of(context).push(
// MaterialPageRoute(
// builder: (_) => UpdateSystemInternalAuditPage(model: model),
// ),
// );
// if (result == true) {
// // await getAuditData();
// // setState(() {}); // refresh UI with new model
// }
// }),
// ),
],
);
},
)); ));
} }
// Widget workOrderInformation() { List<Widget> requestDetails(BuildContext context, LoanRequestModel loanData) {
// final details = model?.workOrderDetails;
// return Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// const Divider().defaultStyle(context),
// Text(
// "WO Info",
// style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
// ),
// 6.height,
// labelValueText(context, context.translation.woNumber, details?.workOrderNo),
// labelValueText(context, 'WO Type'.addTranslation, model?.workOrderType?.name),
// labelValueText(context, context.translation.site, details?.woSite),
// labelValueText(context, context.translation.assetName, details?.woAssetName),
// labelValueText(context, context.translation.manufacture, details?.woManufacturer),
// labelValueText(context, context.translation.model, details?.woModel),
// ],
// );
// }
List<Widget> requestDetails(LoanRequestModel loanData) {
return [ return [
Text("Request Details", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), Text("Request Details", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
6.height, 6.height,
'Loan Type: ${loanData.loanTypeName ?? "-"}'.bodyText(context), 'Loan Type: ${loanData.loanTypeName ?? "-"}'.bodyText(context),
'Loan No: ${loanData.reqCode ?? "-"}'.bodyText(context), 'Loan No: ${loanData.reqCode ?? "-"}'.bodyText(context),
'Loan Period: ${loanData.loanPeriodName ?? "-"}'.bodyText(context), 'Loan Period: ${loanData.loanPeriodName ?? "-"}'.bodyText(context),
'Item Description: ${loanData.itemDescription ?? "-"}'.bodyText(context),
'Request Description: ${loanData.requestDescription ?? "-"}'.bodyText(context),
'${context.translation.site}: ${loanData.siteName ?? "-"}'.bodyText(context), '${context.translation.site}: ${loanData.siteName ?? "-"}'.bodyText(context),
'${context.translation.department}: ${loanData.departmentName ?? "-"}'.bodyText(context), '${context.translation.department}: ${loanData.departmentName ?? "-"}'.bodyText(context),
'Item Description: ${loanData.itemDescription ?? "-"}'.bodyText(context),
'Request Description: ${loanData.requestDescription ?? "-"}'.bodyText(context),
]; ];
} }
List<Widget> vendorDetails(LoanRequestModel loanData) { List<Widget> vendorDetails(BuildContext context, LoanRequestModel loanData) {
return [ return [
Text("Vendor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), Text("Vendor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
'Name: ${loanData.vendorName ?? "-"}'.bodyText(context), 'Name: ${loanData.vendorName ?? "-"}'.bodyText(context),
@ -214,7 +121,7 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
]; ];
} }
List<Widget> assetDetails(LoanRequestModel loanData) { List<Widget> assetDetails(BuildContext context, LoanRequestModel loanData) {
return [ return [
Text("Asset Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), Text("Asset Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
'${context.translation.assetName}: ${loanData.assetName ?? "-"}'.bodyText(context), '${context.translation.assetName}: ${loanData.assetName ?? "-"}'.bodyText(context),
@ -225,7 +132,17 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
]; ];
} }
List<Widget> doctorDetails(LoanRequestModel loanData) { List<Widget> installationDetails(BuildContext context, LoanRequestModel loanData) {
return [
Text("Installation & Pullout Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
'Installation EDD: ${loanData.installationEDD?.toServiceRequestDetailsFormat ?? "-"}'.bodyText(context),
'Installation Date: ${loanData.installationEDD?.toAssetDetailsFormat ?? "-"}'.bodyText(context),
'Pullout EDD: ${loanData.pulloutEDD?.toServiceRequestDetailsFormat ?? "-"}'.bodyText(context),
'Pullout Date: ${loanData.pulloutDate?.toAssetDetailsFormat ?? "-"}'.bodyText(context),
];
}
List<Widget> doctorDetails(BuildContext context, LoanRequestModel loanData) {
return [ return [
Text("Doctor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), Text("Doctor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
'Name: ${loanData.doctorName ?? "-"}'.bodyText(context), 'Name: ${loanData.doctorName ?? "-"}'.bodyText(context),
@ -234,7 +151,7 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
]; ];
} }
List<Widget> requesterDetails(LoanRequestModel loanData) { List<Widget> requesterDetails(BuildContext context, LoanRequestModel loanData) {
return [ return [
Text("Requester Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), Text("Requester Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
'Name: ${loanData.requestorUserIdForDisplay ?? "-"}'.bodyText(context), 'Name: ${loanData.requestorUserIdForDisplay ?? "-"}'.bodyText(context),
@ -244,25 +161,6 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
]; ];
} }
// Widget assetInformation() {
// final details = model?.workOrderDetails;
// return Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "Asset Details",
// style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
// ),
// 6.height,
// labelValueText(context, context.translation.assetName, details?.woAssetName),
// labelValueText(context, context.translation.assetNo, details?.woAssetNo),
// labelValueText(context, context.translation.manufacture, details?.woManufacturer),
// labelValueText(context, context.translation.model, details?.woModel),
// ],
// );
// }
Widget labelValueText(BuildContext context, String label, String? value) { Widget labelValueText(BuildContext context, String label, String? value) {
if (value == null || value.isEmpty) return const SizedBox.shrink(); if (value == null || value.isEmpty) return const SizedBox.shrink();
@ -277,7 +175,7 @@ class _LoanEquipmentDetailPageState extends State<LoanEquipmentDetailPage> {
); );
} }
Widget checklistWidget({required String value}) { Widget checklistWidget(BuildContext context, {required String value}) {
return Row( return Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [

@ -88,7 +88,7 @@ class LoanEquipmentItemView extends StatelessWidget {
(requestDetails?.nameOfType ?? "Loan Request").heading5(context), (requestDetails?.nameOfType ?? "Loan Request").heading5(context),
8.height, 8.height,
infoWidget(label: context.translation.requestType, value: requestDetails!.requestType, context: context), infoWidget(label: context.translation.requestType, value: requestDetails!.requestType, context: context),
infoWidget(label: context.translation.requestNo, value: requestDetails!.requestType, context: context), infoWidget(label: context.translation.requestNo, value: requestDetails!.requestNo, context: context),
infoWidget(label: context.translation.site, value: requestDetails!.site, context: context), infoWidget(label: context.translation.site, value: requestDetails!.site, context: context),
8.height, 8.height,
Row( Row(

@ -21,23 +21,16 @@ class LoanProvider extends ChangeNotifier {
bool isLoading = false; bool isLoading = false;
LoanRequestModel? loanData; Future<LoanRequestModel?> getLoanById(int id) async {
LoanRequestModel? loanData;
Future<void> getLoanById(int id) async {
loanData = null;
isLoading = true;
notifyListeners();
try { try {
Response response = await ApiManager.instance.get(URLs.getLoanById + "?loanId=$id"); Response response = await ApiManager.instance.get(URLs.getLoanById + "?loanId=$id");
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
loanData = LoanRequestModel.fromJson(json.decode(response.body)["data"]); loanData = LoanRequestModel.fromJson(json.decode(response.body)["data"]);
} }
// return data;
} catch (error) { } catch (error) {
// return data; print(error);
} }
isLoading = false; return loanData;
notifyListeners();
} }
} }

@ -267,7 +267,7 @@ class AppColor {
case 0: case 0:
return green15; return green15;
case 1: case 1:
//high priority //high priority
return white10; return white10;
case 82: case 82:
//high priority //high priority

Loading…
Cancel
Save