From c02fc2f1b1324fc654b584619a7c623ad4a70a4f Mon Sep 17 00:00:00 2001 From: waseemabbasi22 Date: Wed, 19 Nov 2025 16:38:19 +0300 Subject: [PATCH] api integration inprogress --- lib/controllers/api_routes/urls.dart | 8 +-- .../loan_module/models/loan_form_model.dart | 49 ++++++++++++++++--- .../pages/create_loan_request_view.dart | 3 +- .../provider/loan_period_provider.dart | 2 +- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index c37dbcf8..e283defd 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -4,14 +4,14 @@ class URLs { static const String appReleaseBuildNumber = "28"; // static const host1 = "https://atomsm.hmg.com"; // production url - // static const host1 = "https://atomsmdev.hmg.com"; // local DEV url - static const host1 = "https://atomsmuat.hmg.com"; // local UAT url + static const host1 = "https://atomsmdev.hmg.com"; // local DEV url + // static const host1 = "https://atomsmuat.hmg.com"; // local UAT url // static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url // static String _baseUrl = "$_host/mobile"; - // static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis - static final String _baseUrl = "$_host/v4/mobile"; // for asset inventory on UAT + static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis + // static final String _baseUrl = "$_host/v4/mobile"; // for asset inventory on UAT // static final String _baseUrl = "$_host/mobile"; // host local UAT // static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM // static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation diff --git a/lib/modules/loan_module/models/loan_form_model.dart b/lib/modules/loan_module/models/loan_form_model.dart index 03b4c169..40e55232 100644 --- a/lib/modules/loan_module/models/loan_form_model.dart +++ b/lib/modules/loan_module/models/loan_form_model.dart @@ -40,22 +40,59 @@ class LoanFormModel { this.department, }); + //{ + // "id": 0, + // "employeeId": "fa29a9de-1337-4729-b823-68c6ecffdd33", + // "requestorUserID": "fa29a9de-1337-4729-b823-68c6ecffdd33", + // "employeeName": "engineer-dev", + // "employeeEmail": "Engineer_Dev@yahoo.com", + // "positionName": "High", + // "requesterExtensionNumber": "7726", + // "requesterContactNumber": "72132197", + // "siteId": 1, + // "departmentId": 5, + // "loanTypeId": 6448, + // "doctorName": "Doctor A", + // "doctorContact": "0561432451", + // "doctorEmail": "doctor@test.com", + // "itemDescription": "Test item", + // "requestDescription": "Test request", + // "loanPeriodId": 6453, + // "assetId": null, + // "assetNumber": "", + // "assetName": "", + // "assetSerialNumber": "", + // "model": "Model A", + // "manufacturer": "Siemens", + // "vendorName": "Vendor A", + // "vendorRepName": "Vendor Rep A", + // "vendorContact": "0561432455", + // "vendorEmail": "vendor@test.com", + // "loanStatusId": 1, + // "loanAttachments": [], + // "submittedAt": "2025-11-13T12:11:12.673Z", + // "updatedAt": null, + // "cMWOItemId": null + // } + + Map toJson() { return { - "docName": docName, - "docNumber": docNumber, - "docEmail": docEmail, + "doctorName": docName, + "doctorContact": docNumber, + "doctorEmail": docEmail, "itemDescription": itemDescription, "requestDescription": requestDescription, "model": model, "manufacturer": manufacturer, - "loanProvided": loanProvided?.toJson(), + "loanPeriodId": loanProvided?.id, "vendorName": vendorName, "vendorRepresentativeName": vendorRepresentativeName, "vendorNumber": vendorNumber, "vendorEmail": vendorEmail, - 'site' : site?.toJson(), - "loanAttachment": loanAttachment != null ? loanAttachment!.map((v) => v.toJson()).toList() : [], + 'siteId' : site?.id, + 'departmentId' : department?.id, + "loanAttachments": loanAttachment != null ? loanAttachment!.map((v) => v.toJson()).toList() : [], }; } } diff --git a/lib/modules/loan_module/pages/create_loan_request_view.dart b/lib/modules/loan_module/pages/create_loan_request_view.dart index 2989f238..5f836178 100644 --- a/lib/modules/loan_module/pages/create_loan_request_view.dart +++ b/lib/modules/loan_module/pages/create_loan_request_view.dart @@ -68,7 +68,7 @@ class _CreateLoanRequestViewState extends State with Tick void initState() { // TODO: implement initState super.initState(); - Provider.of(context, listen: false).reset(); + Provider.of(context, listen: false).reset(); } @override @@ -218,6 +218,7 @@ class _CreateLoanRequestViewState extends State with Tick showShadow: false, showAsBottomSheet: true, initialValue: _loanFormModel.department, + requestById: context.userProvider.user?.clientId, backgroundColor: AppColor.fieldBgColor(context), onSelect: (value) { _loanFormModel.department = value; diff --git a/lib/modules/loan_module/provider/loan_period_provider.dart b/lib/modules/loan_module/provider/loan_period_provider.dart index 3f9704e7..6d863a20 100644 --- a/lib/modules/loan_module/provider/loan_period_provider.dart +++ b/lib/modules/loan_module/provider/loan_period_provider.dart @@ -8,7 +8,7 @@ import 'package:test_sa/providers/loading_list_notifier.dart'; class LoanPeriodProvider extends LoadingListNotifier { @override - Future getData() async { + Future getData({int?id}) async { if (loading == true) return -2; loading = true; notifyListeners();