From 35ab0f994b3390504adaaf81cb36d58b142cca61 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Mon, 6 Oct 2025 10:58:28 +0530 Subject: [PATCH] FIX_bug fixes --- lib/core/services/api_service.dart | 15 ++- .../screens/Enquiry/enquiry/enquiry_tab.dart | 109 +++++++++++++----- .../screens/Enquiry/enquiry/policy_tab.dart | 4 +- .../Enquiry/enquiry/quotation_tab.dart | 1 + .../screens/Enquiry/enquiryList.dart | 48 ++++++-- .../Enquiry/policy_claims_endros/claims.dart | 25 ++-- .../policy_claims_endros/endrosment.dart | 23 ++-- .../policy_claims_endros/sub_claims.dart | 72 ++++++------ .../Agent/agentIncentiveFile.dart | 4 +- .../UserManagement/Agent/agentList.dart | 10 +- .../Profile/profile_mobile.dart | 8 +- .../UserManagement/Profile/profile_web.dart | 4 +- .../UserManagement/Staff/staffList.dart | 15 +-- .../screens/dashboard/dashboard.dart | 6 +- .../screens/staff/Enquiry/enquiry_list.dart | 62 ++++++---- .../screens/staff/policy/policy.dart | 8 +- .../screens/staff/policy/policy_list.dart | 38 +++--- .../screens/staff/quotations/quotation.dart | 8 +- 18 files changed, 283 insertions(+), 177 deletions(-) diff --git a/lib/core/services/api_service.dart b/lib/core/services/api_service.dart index 7d7f1d5..97ab947 100644 --- a/lib/core/services/api_service.dart +++ b/lib/core/services/api_service.dart @@ -154,7 +154,7 @@ class ApiService { } } - Future getPdfDownload(String path, String id) async { + Future getPdfDownload(BuildContext context,String path, String id) async { print('getPdfDownload 1'); print('getPdfDownload 1 - $path'); @@ -175,7 +175,17 @@ class ApiService { final response = await _makeGethttpRequest(url, headers); print('getPdfDownload 3'); + + if (response.statusCode == 200) { + final contentType = response.headers['content-type'] ?? ''; + if (contentType.contains('application/json')) { + final jsonResponse = jsonDecode(response.body); + if (jsonResponse['code'] == 404 || jsonResponse['code'] == 500) + { ToastHelper.showInfoToast(context, 'File Not Found'); } + else { ToastHelper.showInfoToast(context, 'No File Found'); } + return; + }else{ final blob = html.Blob([response.bodyBytes]); final blobUrl = html.Url.createObjectUrlFromBlob(blob); print('getPdfDownload $blobUrl'); @@ -199,6 +209,7 @@ class ApiService { ..click(); print('getPdfDownloadcontentDisp..4'); html.Url.revokeObjectUrl(blobUrl); + } } else if (response.statusCode == 404) { showDialog( context: context, @@ -245,7 +256,7 @@ class ApiService { } else if (apiUrl != null) { print("Download from API: $apiUrl"); print("Download from API: $apiId!"); - await getPdfDownload(apiUrl, apiId!); + await getPdfDownload(context,apiUrl, apiId!); } else { print("⚠️ No file available to download"); } diff --git a/lib/presentation/screens/Enquiry/enquiry/enquiry_tab.dart b/lib/presentation/screens/Enquiry/enquiry/enquiry_tab.dart index a2e5575..228c84f 100644 --- a/lib/presentation/screens/Enquiry/enquiry/enquiry_tab.dart +++ b/lib/presentation/screens/Enquiry/enquiry/enquiry_tab.dart @@ -93,7 +93,7 @@ class EnquiryTabState extends ConsumerState { Map dataDetails() { final data = { - "agent_id": 1, + "agent_id": userId, "name": controllers["name"]?.text, "mobile": controllers["mobile"]?.text, "email": controllers["email"]?.text, @@ -282,38 +282,89 @@ class EnquiryTabState extends ConsumerState { } } + // Future handleSave() async { + // if (!_formKey.currentState!.validate()) return; + // setState(() { + // if (_formKey.currentState!.validate()) { + // isSaving = true; + // dataDetails(); + // final dataSet = dataDetails(); + // print("dataSetAgent - $dataSet"); + // print("managerId - $managerId ,userId - $userId "); + // + // if ((docUploadedRCFile == null || + // (docUploadedRCFile?.bytes == null && + // docUploadedRCFile?.path == null)) && + // (rcFileUrlFromApi == null || rcFileUrlFromApi!.isEmpty)) { + // ToastHelper.showErrorToast(context, "Please upload RC Document"); + // return; + // } + // + // if ((docUploadedIDProof == null || + // (docUploadedIDProof?.bytes == null && + // docUploadedIDProof?.path == null)) && + // (idProofFileUrlFromApi == null || idProofFileUrlFromApi!.isEmpty)) { + // ToastHelper.showErrorToast(context, "Please upload ID Proof"); + // return; + // } + // createUserData(dataSet); + // } else { + // // isDisable = false; + // + // setState(() => isSaving = false); + // } + // }); + // } + Future handleSave() async { if (!_formKey.currentState!.validate()) return; + setState(() { - if (_formKey.currentState!.validate()) { - isSaving = true; - dataDetails(); - final dataSet = dataDetails(); - print("dataSetAgent - $dataSet"); - print("managerId - $managerId ,userId - $userId "); - - if ((docUploadedRCFile == null || - (docUploadedRCFile?.bytes == null && - docUploadedRCFile?.path == null)) && - (rcFileUrlFromApi == null || rcFileUrlFromApi!.isEmpty)) { - ToastHelper.showErrorToast(context, "Please upload RC Document"); - return; - } - - if ((docUploadedIDProof == null || - (docUploadedIDProof?.bytes == null && - docUploadedIDProof?.path == null)) && - (idProofFileUrlFromApi == null || idProofFileUrlFromApi!.isEmpty)) { - ToastHelper.showErrorToast(context, "Please upload ID Proof"); - return; - } - createUserData(dataSet); - } else { - // isDisable = false; - - setState(() => isSaving = false); - } + isSaving = true; // start saving }); + + final dataSet = dataDetails(); + + // check RC file + if ((docUploadedRCFile == null || + (docUploadedRCFile?.bytes == null && + docUploadedRCFile?.path == null)) && + (rcFileUrlFromApi == null || rcFileUrlFromApi!.isEmpty)) { + setState(() => isSaving = false); // reset button + ToastHelper.showErrorToast(context, "Please upload RC Document"); + return; + } + + // check ID proof + if ((docUploadedIDProof == null || + (docUploadedIDProof?.bytes == null && + docUploadedIDProof?.path == null)) && + (idProofFileUrlFromApi == null || idProofFileUrlFromApi!.isEmpty)) { + setState(() => isSaving = false); // reset button + ToastHelper.showErrorToast(context, "Please upload ID Proof"); + return; + } + + try { + await createUserData(dataSet); // API call + ToastHelper.showInfoToast(context, "Enquiry saved successfully"); + } catch (e) { + showDialog( + context: context, + builder: (_) => AlertDialog( + title: const Text('Error'), + content: Text(e.toString()), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: const Text('OK'), + ) + ], + ), + ); + } finally { + setState(() => isSaving = false); // re-enable button after save + } } Future attachFiles(http.MultipartRequest request) async { diff --git a/lib/presentation/screens/Enquiry/enquiry/policy_tab.dart b/lib/presentation/screens/Enquiry/enquiry/policy_tab.dart index 597cd75..3b26442 100644 --- a/lib/presentation/screens/Enquiry/enquiry/policy_tab.dart +++ b/lib/presentation/screens/Enquiry/enquiry/policy_tab.dart @@ -441,7 +441,7 @@ class PolicyTabState extends ConsumerState { // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/policy/downloadPolicyFile?policy_id=$selectedId&file_type=policy_pdf'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), @@ -480,7 +480,7 @@ class PolicyTabState extends ConsumerState { // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/policy/downloadPolicyFile?policy_id=$selectedId&file_type=policy_payment_receipt'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), diff --git a/lib/presentation/screens/Enquiry/enquiry/quotation_tab.dart b/lib/presentation/screens/Enquiry/enquiry/quotation_tab.dart index a3995cb..b0b22ed 100644 --- a/lib/presentation/screens/Enquiry/enquiry/quotation_tab.dart +++ b/lib/presentation/screens/Enquiry/enquiry/quotation_tab.dart @@ -698,6 +698,7 @@ class QuotationTabState extends ConsumerState { ); } + Widget buildDocuments(BuildContext context) { return buildResponsiveUploadField( label: 'Quotation Documents', diff --git a/lib/presentation/screens/Enquiry/enquiryList.dart b/lib/presentation/screens/Enquiry/enquiryList.dart index efdc040..96429d0 100644 --- a/lib/presentation/screens/Enquiry/enquiryList.dart +++ b/lib/presentation/screens/Enquiry/enquiryList.dart @@ -51,11 +51,17 @@ class EnquiryListState extends ConsumerState { Future.microtask(() { final id = ref.read(managerIdProvider); final roleId = ref.read(userRoleProvider); + final userId = ref.read(userIdProvider); + + print("A56 => r : $roleId | mId: $id | uId: $userId "); + + // Staff - sanjeev.p@venbainfotech.com - T E S T S - 9 evarukku 8th id is manager + // Manager - venbalap08@gmail.com - T E S T M - 8 evarukku 8th id is manager + // Agent - venba2026@gmail.com - T E S T A - 5 evarkku 8th id is manager + // so here i used userId + + if (userId != null) { getStaffList(userId, roleId); } - print("ENQroleId - $roleId"); - if (id != null) { - getStaffList(id, roleId); - } }); } @@ -63,7 +69,7 @@ class EnquiryListState extends ConsumerState { void refrshfilterDateRange() {} Future getStaffList(int managerId, role) async { - print('getClaimList called MagId - $managerId - $role'); + print('A72 => Fns called => $managerId | $role'); setState(() { isLoading = true; }); @@ -73,7 +79,7 @@ class EnquiryListState extends ConsumerState { if (response['status'] == 'success') { final data = response['data']; - print('getStaffListData - ${response['data']}'); + print('A82 => getStaffListData => ${response['data']}'); setState(() { if (data is List) { // Already a list of maps @@ -159,19 +165,22 @@ class EnquiryListState extends ConsumerState { filteredData = getStaffData.where((item) { // final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; - return (_formatDate(item['created_on']) ?? '').toLowerCase().contains( + return (_formatDate(item['created_on']) ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['reg_no'] ?? '').toLowerCase().contains( + (_formatDate(item['updated_on']) ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['insurer_name'] ?? '').toLowerCase().contains( + (item['reg_no'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['status'] ?? '').toLowerCase().contains( + (item['insurer_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['remarks'] ?? '').toLowerCase().contains(query.toLowerCase()); + (item['status'] ?? '-').toLowerCase().contains( + query.toLowerCase(), + ) || + (item['remarks'] ?? '-').toLowerCase().contains(query.toLowerCase()); }).toList(); }); } @@ -316,6 +325,7 @@ class EnquiryListState extends ConsumerState { headers: [ "id", "created_on", + "updated_on", "reg_no", "insurer_name", "status", @@ -402,7 +412,14 @@ class EnquiryListState extends ConsumerState { Expanded( flex: 2, child: Text( - 'Received Date & Time', + 'Created Date', + style: _headerStyle, + ), + ), + Expanded( + flex: 2, + child: Text( + 'Updated Date', style: _headerStyle, ), ), @@ -521,6 +538,13 @@ class EnquiryListState extends ConsumerState { style: _dataBold, ), ), + Expanded( + flex: 2, + child: Text( + _formatDate(item['updated_on']) ?? '-', + style: _dataBold, + ), + ), Expanded( flex: 1, child: Text(item['reg_no'] ?? '-', style: _dataBold), diff --git a/lib/presentation/screens/Enquiry/policy_claims_endros/claims.dart b/lib/presentation/screens/Enquiry/policy_claims_endros/claims.dart index 999f331..7dfba2b 100644 --- a/lib/presentation/screens/Enquiry/policy_claims_endros/claims.dart +++ b/lib/presentation/screens/Enquiry/policy_claims_endros/claims.dart @@ -43,16 +43,15 @@ class claimListState extends ConsumerState { Future.microtask(() { final id = ref.read(managerIdProvider); final roleId = ref.read(userRoleProvider); + final userId = ref.read(userIdProvider); + print("G47 => r : $roleId | mId: $id | uId: $userId "); + if (userId != null) { getStaffList(userId, roleId); } - print("ENQroleId - $roleId"); - if (id != null) { - getStaffList(id, roleId); - } }); } Future getStaffList(int managerId, role) async { - print('getClaimList called MagId - $managerId - $role'); + print('G54 => Fns called => $managerId | $role'); setState(() { isLoading = true; }); @@ -62,7 +61,7 @@ class claimListState extends ConsumerState { if (response['status'] == 'success') { final data = response['data']; - print('clImlist - ${response['data']}'); + print('F64 => clImlist => ${response['data']}'); setState(() { if (data is List) { // Already a list of maps @@ -114,23 +113,23 @@ class claimListState extends ConsumerState { filteredData = getStaffData.where((item) { // final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; - return (item['reg_no'] ?? '').toLowerCase().contains( + return (item['reg_no'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['insurer_name'] ?? '').toLowerCase().contains( + (item['insurer_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['policy_no'] ?? '').toLowerCase().contains( + (item['policy_no'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['claim_type_value'] ?? '').toLowerCase().contains( + (item['claim_type_value'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['claim_number'] ?? '').toLowerCase().contains( + (item['claim_number'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || (_formatDate( - item['policy_end_date'], + item['policy_end_date'] ?? '-', ).toLowerCase()).contains(query.toLowerCase()); }).toList(); }); @@ -248,7 +247,7 @@ class claimListState extends ConsumerState { "policy_no", "policy_end_date", "claim_number", - "claim_type", + "claim_type_value", ], ), diff --git a/lib/presentation/screens/Enquiry/policy_claims_endros/endrosment.dart b/lib/presentation/screens/Enquiry/policy_claims_endros/endrosment.dart index bb7a426..1cbf397 100644 --- a/lib/presentation/screens/Enquiry/policy_claims_endros/endrosment.dart +++ b/lib/presentation/screens/Enquiry/policy_claims_endros/endrosment.dart @@ -41,16 +41,15 @@ class endosementState extends ConsumerState { Future.microtask(() { final id = ref.read(managerIdProvider); final roleId = ref.read(userRoleProvider); + final userId = ref.read(userIdProvider); + print("F46 => r : $roleId | mId: $id | uId: $userId "); + if (userId != null) { getStaffList(userId, roleId); } - print("ENQroleId - $roleId"); - if (id != null) { - getStaffList(id, roleId); - } }); } Future getStaffList(int managerId, role) async { - print('getClaimList called MagId - $managerId - $role'); + print('F53 => Fns called => $managerId | $role'); setState(() { isLoading = true; }); @@ -60,7 +59,7 @@ class endosementState extends ConsumerState { if (response['status'] == 'success') { final data = response['data']; - print('getStaffListData - ${response['data']}'); + print('F62 => End rse mnt List => ${response['data']}'); setState(() { if (data is List) { // Already a list of maps @@ -112,19 +111,19 @@ class endosementState extends ConsumerState { filteredData = getStaffData.where((item) { // final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; - return (item['reg_no'] ?? '').toLowerCase().contains( + return (item['reg_no'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['insurer_name'] ?? '').toLowerCase().contains( + (item['insurer_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['policy_number'] ?? '').toLowerCase().contains( + (item['policy_number'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['endorsement_type'] ?? '').toLowerCase().contains( + (item['endorsement_type_value'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['endorsement_no'] ?? '').toLowerCase().contains( + (item['endorsement_no'] ?? '-').toLowerCase().contains( query.toLowerCase(), ); }).toList(); @@ -243,7 +242,7 @@ class endosementState extends ConsumerState { "reg_no", "insurer_name", "policy_number", - "endorsement_type", + "endorsement_type_value", "endorsement_no", ], ), diff --git a/lib/presentation/screens/Enquiry/policy_claims_endros/sub_claims.dart b/lib/presentation/screens/Enquiry/policy_claims_endros/sub_claims.dart index 6a27db6..217cb34 100644 --- a/lib/presentation/screens/Enquiry/policy_claims_endros/sub_claims.dart +++ b/lib/presentation/screens/Enquiry/policy_claims_endros/sub_claims.dart @@ -172,10 +172,10 @@ class ClaimsSubListState extends ConsumerState { child: Text('Status', style: _headerStyle), ), - Expanded( - flex: 1, - child: Text('Action', style: _headerStyle), - ), + // Expanded( + // flex: 1, + // child: Text('Action', style: _headerStyle), + // ), ], ), ), @@ -285,38 +285,38 @@ class ClaimsSubListState extends ConsumerState { child: Text(item['claim_status_value'] ?? '-', style: _dataBold), ), - Expanded( - flex: 1, - child: Row( - children: [ - PopupMenuButton( - color: Colors.white, - padding: EdgeInsets.zero, - offset: Offset(0, 30), - icon: Icon( - Icons.more_vert, - color: Color(0xFF475569), - size: 14, - ), - itemBuilder: (context) => [ - CustomPopupMenuEntry( - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 8, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: _buildPopupMenuActions(context, item), - ), - ), - ), - ], - ), - ], - ), - ), + // Expanded( + // flex: 1, + // child: Row( + // children: [ + // PopupMenuButton( + // color: Colors.white, + // padding: EdgeInsets.zero, + // offset: Offset(0, 30), + // icon: Icon( + // Icons.more_vert, + // color: Color(0xFF475569), + // size: 14, + // ), + // itemBuilder: (context) => [ + // CustomPopupMenuEntry( + // child: Container( + // padding: EdgeInsets.symmetric( + // horizontal: 8, + // vertical: 8, + // ), + // child: Column( + // mainAxisSize: MainAxisSize.min, + // mainAxisAlignment: MainAxisAlignment.center, + // children: _buildPopupMenuActions(context, item), + // ), + // ), + // ), + // ], + // ), + // ], + // ), + // ), ], ), ); diff --git a/lib/presentation/screens/UserManagement/Agent/agentIncentiveFile.dart b/lib/presentation/screens/UserManagement/Agent/agentIncentiveFile.dart index 08e8d28..b1011d6 100644 --- a/lib/presentation/screens/UserManagement/Agent/agentIncentiveFile.dart +++ b/lib/presentation/screens/UserManagement/Agent/agentIncentiveFile.dart @@ -134,7 +134,7 @@ class UploadIncentiveModalState extends ConsumerState { print("FilterDAta - $query"); setState(() { filteredIncentiveData = getAgentIncentiveFileData.where((item) { - return (item['incentive_month'] ?? '').toLowerCase().contains( + return (item['incentive_month'] ?? '-').toLowerCase().contains( query.toLowerCase(), ); }).toList(); @@ -664,7 +664,7 @@ class UploadIncentiveModalState extends ConsumerState { final selectedId = file['id']; final path = 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, onDelete: () async { print("Delete ${file['id']}"); diff --git a/lib/presentation/screens/UserManagement/Agent/agentList.dart b/lib/presentation/screens/UserManagement/Agent/agentList.dart index 11340fd..2dc1c53 100644 --- a/lib/presentation/screens/UserManagement/Agent/agentList.dart +++ b/lib/presentation/screens/UserManagement/Agent/agentList.dart @@ -83,11 +83,11 @@ class AgentListState extends ConsumerState { setState(() { filteredData = getAgentData.where((item) { final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; - return item['name'].toLowerCase().contains(query.toLowerCase()) || - item['email'].toLowerCase().contains(query.toLowerCase()) || - item['mobile'].toLowerCase().contains(query.toLowerCase()) || - item['address'].toLowerCase().contains(query.toLowerCase()) || - item['agent_code'].toLowerCase().contains(query.toLowerCase()) || + return (item['name'] ?? '-').toLowerCase().contains(query.toLowerCase()) || + (item['email'] ?? '-').toLowerCase().contains(query.toLowerCase()) || + (item['mobile'] ?? '-').toLowerCase().contains(query.toLowerCase()) || + (item['address'] ?? '-').toLowerCase().contains(query.toLowerCase()) || + (item['agent_code'] ?? '-').toLowerCase().contains(query.toLowerCase()) || (isActiveStatus.contains(query.toLowerCase())); }).toList(); }); diff --git a/lib/presentation/screens/UserManagement/Profile/profile_mobile.dart b/lib/presentation/screens/UserManagement/Profile/profile_mobile.dart index 658a288..f76aa4f 100644 --- a/lib/presentation/screens/UserManagement/Profile/profile_mobile.dart +++ b/lib/presentation/screens/UserManagement/Profile/profile_mobile.dart @@ -292,7 +292,7 @@ class ProfileState extends ConsumerState { path = 'api/agent/downloadAgentIncentiveFile?id=$latestId'; } - apiService.getPdfDownload( + apiService.getPdfDownload(context, path, latestId, ); @@ -386,7 +386,7 @@ class ProfileState extends ConsumerState { path = 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; } - apiService.getPdfDownload( + apiService.getPdfDownload(context, path, selectedId, ); @@ -549,7 +549,7 @@ class ProfileState extends ConsumerState { path = 'api/agent/downloadAgentIncentiveFile?id=$latestId'; } - apiService.getPdfDownload( + apiService.getPdfDownload(context, path, latestId, ); @@ -643,7 +643,7 @@ class ProfileState extends ConsumerState { path = 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; } - apiService.getPdfDownload( + apiService.getPdfDownload(context, path, selectedId, ); diff --git a/lib/presentation/screens/UserManagement/Profile/profile_web.dart b/lib/presentation/screens/UserManagement/Profile/profile_web.dart index 21bf6c2..3d2011e 100644 --- a/lib/presentation/screens/UserManagement/Profile/profile_web.dart +++ b/lib/presentation/screens/UserManagement/Profile/profile_web.dart @@ -285,7 +285,7 @@ class ProfilePopUpState extends ConsumerState { path = 'api/agent/downloadAgentIncentiveFile?id=$latestId'; } - apiService.getPdfDownload(path, latestId); + apiService.getPdfDownload(context,path, latestId); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -368,7 +368,7 @@ class ProfilePopUpState extends ConsumerState { path = 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; } - apiService.getPdfDownload( + apiService.getPdfDownload(context, path, selectedId, ); diff --git a/lib/presentation/screens/UserManagement/Staff/staffList.dart b/lib/presentation/screens/UserManagement/Staff/staffList.dart index 26e1030..c2b08bf 100644 --- a/lib/presentation/screens/UserManagement/Staff/staffList.dart +++ b/lib/presentation/screens/UserManagement/Staff/staffList.dart @@ -40,6 +40,7 @@ class StaffListState extends ConsumerState { Future.microtask(() { final id = ref.read(managerIdProvider); + print("E43 => mId: $id"); if (id != null) { getStaffList(id); } @@ -79,17 +80,17 @@ class StaffListState extends ConsumerState { filteredData = getStaffData.where((item) { final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; - return (item['name'] ?? '').toLowerCase().contains( + return (item['name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['email'] ?? '').toLowerCase().contains(query.toLowerCase()) || - (item['mobile'] ?? '').toLowerCase().contains( + (item['email'] ?? '-').toLowerCase().contains(query.toLowerCase()) || + (item['mobile'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['address'] ?? '').toLowerCase().contains( + (item['address'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['emp_id'] ?? item['agent_code'] ?? '').toLowerCase().contains( + (item['emp_id'] ?? item['agent_code'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || isActiveStatus.contains(query.toLowerCase()); @@ -100,7 +101,7 @@ class StaffListState extends ConsumerState { final TextEditingController _searchStaffController = TextEditingController(); Future getStaffList(int managerId) async { - print('getClaimList called MagId - $managerId'); + print('E104 => Fns called => $managerId'); setState(() { isLoading = true; }); @@ -109,7 +110,7 @@ class StaffListState extends ConsumerState { final response = await apiService.fetchStaffUserList(managerId); if (response['status'] == 'success') { - print('getStaffListData - ${response['data']}'); + print('E113 => getStaffListData => ${response['data']}'); setState(() { getStaffData = List>.from(response['data']); originalData = getStaffData; diff --git a/lib/presentation/screens/dashboard/dashboard.dart b/lib/presentation/screens/dashboard/dashboard.dart index 1e33e2f..b9641ad 100644 --- a/lib/presentation/screens/dashboard/dashboard.dart +++ b/lib/presentation/screens/dashboard/dashboard.dart @@ -78,7 +78,7 @@ class _DashboardScreenState extends ConsumerState { final id = ref.read(userIdProvider); final roleId = ref.read(userRoleProvider); - print("ENQroleId - $roleId"); + print("B81 => roleId: $roleId | userId: $id "); if (id != null) { getStaffList(id, roleId); } @@ -86,7 +86,7 @@ class _DashboardScreenState extends ConsumerState { } Future getStaffList(int managerId, role) async { - print('getClaimList called MagId - $managerId - $role'); + print('B89 => Fns called => $managerId | $role'); setState(() { isLoading = true; }); @@ -96,7 +96,7 @@ class _DashboardScreenState extends ConsumerState { if (response['status'] == 'success') { final data = response['data']; - print('go to 81 - getStaffListData - ${response['data']}'); + print('B99 => getStaffListData => ${response['data']}'); setState(() { policiesIssuedToday = data['policies_issued']['today'].toString(); policiesIssuedYear = data['policies_issued']['year'].toString(); diff --git a/lib/presentation/screens/staff/Enquiry/enquiry_list.dart b/lib/presentation/screens/staff/Enquiry/enquiry_list.dart index a3819c8..076c8d4 100644 --- a/lib/presentation/screens/staff/Enquiry/enquiry_list.dart +++ b/lib/presentation/screens/staff/Enquiry/enquiry_list.dart @@ -67,25 +67,26 @@ class EnquiryStaffState extends ConsumerState { Future.microtask(() { final id = ref.read(managerIdProvider); roleId = ref.read(userRoleProvider); + final userId = ref.read(userIdProvider); - print("ENQroleId - $roleId"); - if (id != null) { - getStaffList(id, roleId); - } + print("C72 => r : $roleId | mId: $id | uId: $userId "); + if (userId != null) { getStaffList(userId, roleId); } }); } void refresh() { final id = ref.read(managerIdProvider); final roleId = ref.read(userRoleProvider); + final userId = ref.read(userIdProvider); + + print("C82 => r : $roleId | mId: $id | uId: $userId "); + if (userId != null) { getStaffList(userId, roleId); } - if (id != null) { - getStaffList(id, roleId); - } } Future getStaffList(int managerId, role) async { - print('getClaimList called MagId - $managerId - $role'); + + print('C89 => Fns called => $managerId | $role'); setState(() { isLoading = true; }); @@ -95,7 +96,7 @@ class EnquiryStaffState extends ConsumerState { if (response['status'] == 'success') { final data = response['data']; - print('getStaffListData - ${response['data']}'); + print('C99 => getStaffListData => ${response['data']}'); setState(() { if (data is List) { // Already a list of maps @@ -159,34 +160,37 @@ class EnquiryStaffState extends ConsumerState { filteredData = getStaffData.where((item) { // final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; - return (item['agent_name'] ?? '').toLowerCase().contains( + return (item['agent_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['reg_no'] ?? '').toLowerCase().contains( + (item['reg_no'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['insurer_name'] ?? '').toLowerCase().contains( + (item['insurer_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['assigned_to_name'] ?? '').toLowerCase().contains( + (item['assigned_to_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['insured_name'] ?? '').toLowerCase().contains( + (item['insured_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['premium_amount'] ?? '').toLowerCase().contains( + (item['premium_amount'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['payment_mode'] ?? '').toLowerCase().contains( + (item['payment_mode'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (_formatDate(item['updated_on']) ?? '').toLowerCase().contains( + (_formatDate(item['created_on']) ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['policy_number'] ?? '').toLowerCase().contains( + (_formatDate(item['updated_on']) ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['status'] ?? '').toLowerCase().contains(query.toLowerCase()); + (item['policy_number'] ?? '-').toLowerCase().contains( + query.toLowerCase(), + ) || + (item['status'] ?? '-').toLowerCase().contains(query.toLowerCase()); }).toList(); }); } @@ -211,7 +215,7 @@ class EnquiryStaffState extends ConsumerState { regNum, ) { return [ - if (roleId == 'manager') ...[ + if (roleId == 'manager' && data['status'] != 'Quotation Created') ...[ Material( color: Colors.transparent, child: InkWell( @@ -424,6 +428,7 @@ class EnquiryStaffState extends ConsumerState { ? true : false, headers: [ + "created_on", "updated_on", "reg_no", "agent_name", @@ -493,9 +498,12 @@ class EnquiryStaffState extends ConsumerState { children: [ Expanded( flex: 3, - child: Text('Date', style: _headerStyle), + child: Text('Created Date', style: _headerStyle), + ), + Expanded( + flex: 3, + child: Text('Updated Date', style: _headerStyle), ), - Expanded( flex: 2, child: Text('Reg.No', style: _headerStyle), @@ -630,6 +638,15 @@ class EnquiryStaffState extends ConsumerState { ), child: Row( children: [ + Expanded( + flex: 3, + child: Text( + _formatDate(item['created_on']) ?? '-', + style: _dataBold, + softWrap: true, + maxLines: 3, + ), + ), Expanded( flex: 3, child: Text( @@ -639,7 +656,6 @@ class EnquiryStaffState extends ConsumerState { maxLines: 3, ), ), - Expanded( flex: 2, child: Text(item['reg_no'] ?? '-', style: _dataBold), diff --git a/lib/presentation/screens/staff/policy/policy.dart b/lib/presentation/screens/staff/policy/policy.dart index 7f43d04..b5e6a33 100644 --- a/lib/presentation/screens/staff/policy/policy.dart +++ b/lib/presentation/screens/staff/policy/policy.dart @@ -757,7 +757,7 @@ class PolicyScreenState extends ConsumerState { // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/enquiry/downloadEnquiryFile?enquiry_id=$selectedId&file_type=rc'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), @@ -798,7 +798,7 @@ class PolicyScreenState extends ConsumerState { // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/enquiry/downloadEnquiryFile?enquiry_id=$selectedId&file_type=id_proof'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), @@ -835,7 +835,7 @@ class PolicyScreenState extends ConsumerState { // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/enquiry/downloadEnquiryFile?enquiry_id=$selectedId&file_type=previous_policy'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), @@ -875,7 +875,7 @@ class PolicyScreenState extends ConsumerState { final path = 'api/quotation/downloadAdditionalUploadedFile?id=$acceptedQuotationId'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), diff --git a/lib/presentation/screens/staff/policy/policy_list.dart b/lib/presentation/screens/staff/policy/policy_list.dart index e953021..3ae37d1 100644 --- a/lib/presentation/screens/staff/policy/policy_list.dart +++ b/lib/presentation/screens/staff/policy/policy_list.dart @@ -44,10 +44,11 @@ class policylistState extends ConsumerState { Future.microtask(() { final id = ref.read(managerIdProvider); roleId = ref.read(userRoleProvider); + final userId = ref.read(userIdProvider); - print("ENQroleId - $roleId"); - if (id != null) { - getStaffList(id, roleId); + print("D49 => r : $roleId | mId: $id | uId: $userId "); + if (userId != null) { + getStaffList(userId, roleId); } }); } @@ -55,14 +56,16 @@ class policylistState extends ConsumerState { void refresh() { final id = ref.read(managerIdProvider); final roleId = ref.read(userRoleProvider); + final userId = ref.read(userIdProvider); - if (id != null) { - getStaffList(id, roleId); + print("D61 => r : $roleId | mId: $id | uId: $userId"); + if (userId != null) { + getStaffList(userId, roleId); } } Future getStaffList(int managerId, role) async { - print('getClaimList called MagId - $managerId - $role'); + print('D68 => Fns called => $managerId | $role'); setState(() { isLoading = true; }); @@ -75,7 +78,7 @@ class policylistState extends ConsumerState { if (response['status'] == 'success') { final data = response['data']; - print('getStaffListData - ${response['data']}'); + print('D81 => getStaffListData => ${response['data']}'); setState(() { if (data is List) { // Already a list of maps @@ -127,34 +130,34 @@ class policylistState extends ConsumerState { filteredData = getStaffData.where((item) { // final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; - return (item['agent_name'] ?? '').toLowerCase().contains( + return (item['agent_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['reg_no'] ?? '').toLowerCase().contains( + (item['reg_no'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['insurer_name'] ?? '').toLowerCase().contains( + (item['insurer_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['assigned_to_name'] ?? '').toLowerCase().contains( + (item['assigned_to_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['insured_name'] ?? '').toLowerCase().contains( + (item['insured_name'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['premium_amount'] ?? '').toLowerCase().contains( + (item['premium_amount'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['payment_mode'] ?? '').toLowerCase().contains( + (item['payment_mode'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (_formatDate(item['updated_on']) ?? '').toLowerCase().contains( + (_formatDate(item['updated_on']) ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['policy_number'] ?? '').toLowerCase().contains( + (item['policy_number'] ?? '-').toLowerCase().contains( query.toLowerCase(), ) || - (item['status'] ?? '').toLowerCase().contains(query.toLowerCase()); + (item['status'] ?? '-').toLowerCase().contains(query.toLowerCase()); ; }).toList(); }); @@ -374,6 +377,7 @@ class policylistState extends ConsumerState { "premium_amount", "payment_mode", "updated_on", + "policy_number", "status", ], ), diff --git a/lib/presentation/screens/staff/quotations/quotation.dart b/lib/presentation/screens/staff/quotations/quotation.dart index 8a125b9..ad07c74 100644 --- a/lib/presentation/screens/staff/quotations/quotation.dart +++ b/lib/presentation/screens/staff/quotations/quotation.dart @@ -522,7 +522,7 @@ class QuotationScreenState extends ConsumerState { // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/enquiry/downloadEnquiryFile?enquiry_id=$selectedId&file_type=rc'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), @@ -563,7 +563,7 @@ class QuotationScreenState extends ConsumerState { // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/enquiry/downloadEnquiryFile?enquiry_id=$selectedId&file_type=id_proof'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8), @@ -594,13 +594,13 @@ class QuotationScreenState extends ConsumerState { Widget buildDocPrevPolicy(BuildContext context, bool isMobile) { return GestureDetector( onTap: () { - print("Upload $selectedEnquiryId"); + print("QD597 Upload $selectedEnquiryId"); final selectedId = selectedEnquiryId; // final path = // 'api/agent/downloadAgentIncentiveFile?id=$selectedId'; final path = 'api/enquiry/downloadEnquiryFile?enquiry_id=$selectedId&file_type=previous_policy'; - apiService.getPdfDownload(path, selectedId); + apiService.getPdfDownload(context,path, selectedId); }, child: Container( padding: const EdgeInsets.all(8),