enquiry_list_search

This commit is contained in:
venbaittech 2025-12-12 18:43:01 +05:30
parent 46ef0c20d6
commit dcbf177dde
11 changed files with 368 additions and 249 deletions

File diff suppressed because one or more lines are too long

View File

@ -35,8 +35,10 @@ class ApiService {
context.go(AppRoutes.login); context.go(AppRoutes.login);
} }
Future<Map<String, dynamic>> _makeGetRequest(Uri url, Future<Map<String, dynamic>> _makeGetRequest(
Map<String, String> headers,) async { Uri url,
Map<String, String> headers,
) async {
final response = await http.get(url, headers: headers); final response = await http.get(url, headers: headers);
return _handleResponse(response); return _handleResponse(response);
} }
@ -58,8 +60,10 @@ class ApiService {
// } // }
// } // }
Future<http.Response> _makeGethttpRequest(Uri url, Future<http.Response> _makeGethttpRequest(
Map<String, String> headers,) async { Uri url,
Map<String, String> headers,
) async {
final response = await http.get(url, headers: headers); final response = await http.get(url, headers: headers);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -73,9 +77,11 @@ class ApiService {
} }
} }
Future<Map<String, dynamic>> _makePostRequestJson(Uri url, Future<Map<String, dynamic>> _makePostRequestJson(
Map<String, dynamic> body, Uri url,
Map<String, String> headers,) async { Map<String, dynamic> body,
Map<String, String> headers,
) async {
final response = await http.post( final response = await http.post(
url, url,
headers: headers, headers: headers,
@ -151,8 +157,10 @@ class ApiService {
} }
} }
Future<Map<String, dynamic>> CheckDuplicate(BuildContext context, Future<Map<String, dynamic>> CheckDuplicate(
String value,) async { BuildContext context,
String value,
) async {
if (_token == null) { if (_token == null) {
await _initializeToken(); await _initializeToken();
} }
@ -193,8 +201,7 @@ class ApiService {
return {}; return {};
} else { } else {
throw Exception( throw Exception(
'Failed to load checkDuplicate data. Status code: ${response 'Failed to load checkDuplicate data. Status code: ${response.statusCode}',
.statusCode}',
); );
} }
} }
@ -288,9 +295,11 @@ class ApiService {
return fallback; return fallback;
} }
Future<void> getPdfDownload(// BuildContext context, Future<void> getPdfDownload(
String path, // BuildContext context,
String id,) async { String path,
String id,
) async {
print('getPdfDownload 1 - $path'); print('getPdfDownload 1 - $path');
// if (path.isEmpty) { // if (path.isEmpty) {
@ -344,9 +353,7 @@ class ApiService {
final contentDisp = response.headers['content-disposition']; final contentDisp = response.headers['content-disposition'];
print('getPdfDownloadcontentDisp $contentDisp'); print('getPdfDownloadcontentDisp $contentDisp');
String fileName = extractFileName(contentDisp, path String fileName = extractFileName(contentDisp, path.split('/').last);
.split('/')
.last);
print('Resolved fileName: $fileName'); print('Resolved fileName: $fileName');
final anchor = html.AnchorElement(href: blobUrl) final anchor = html.AnchorElement(href: blobUrl)
..setAttribute('download', fileName) ..setAttribute('download', fileName)
@ -357,16 +364,15 @@ class ApiService {
} else if (response.statusCode == 404) { } else if (response.statusCode == 404) {
showDialog( showDialog(
context: context, context: context,
builder: (context) => builder: (context) => AlertDialog(
AlertDialog( title: const Text('File not found.'),
title: const Text('File not found.'), actions: [
actions: [ TextButton(
TextButton( child: const Text('OK'),
child: const Text('OK'), onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pop(),
),
],
), ),
],
),
); );
} else if (response.statusCode == 403) { } else if (response.statusCode == 403) {
await clearLocalStorageAndRedirect(); await clearLocalStorageAndRedirect();
@ -450,10 +456,12 @@ class ApiService {
return response; return response;
} }
Future<Map<String, dynamic>> updateStatusMasters(id, Future<Map<String, dynamic>> updateStatusMasters(
status, id,
masterName, status,
userId,) async { masterName,
userId,
) async {
print('updateStatusMaster $id $status $masterName $userId'); print('updateStatusMaster $id $status $masterName $userId');
final Map<String, dynamic> data = { final Map<String, dynamic> data = {
"is_active": int.parse(status), "is_active": int.parse(status),
@ -499,8 +507,7 @@ class ApiService {
url = Uri.parse('${Env.apiUrl}dashboard/managerDashboard?manager_id=$id'); url = Uri.parse('${Env.apiUrl}dashboard/managerDashboard?manager_id=$id');
} else if (role == 'handler') { } else if (role == 'handler') {
url = Uri.parse( url = Uri.parse(
'${Env '${Env.apiUrl}dashboard/handlerDashboard?manager_id=$id&handler_id=$userId',
.apiUrl}dashboard/handlerDashboard?manager_id=$id&handler_id=$userId',
); );
} else if (role == 'staff') { } else if (role == 'staff') {
url = Uri.parse('${Env.apiUrl}dashboard/staffDashboard?staff_id=$userId'); url = Uri.parse('${Env.apiUrl}dashboard/staffDashboard?staff_id=$userId');
@ -687,6 +694,10 @@ class ApiService {
print('manager'); print('manager');
// url = Uri.parse('${Env.apiUrl}staff/staffList'); // url = Uri.parse('${Env.apiUrl}staff/staffList');
url = Uri.parse('${Env.apiUrl}staff/staffList?manager_id=${managerId}'); url = Uri.parse('${Env.apiUrl}staff/staffList?manager_id=${managerId}');
} else if (role == 'Accounts') {
print('manager');
// url = Uri.parse('${Env.apiUrl}staff/staffList');
url = Uri.parse('${Env.apiUrl}staff/staffList?manager_id=${managerId}');
} else { } else {
print('handler'); print('handler');
url = Uri.parse('${Env.apiUrl}staff/staffList?handler_id=${managerId}'); url = Uri.parse('${Env.apiUrl}staff/staffList?handler_id=${managerId}');
@ -721,8 +732,10 @@ class ApiService {
// ------------------------------------ SALES EXECUTIVE ----------------------------------------------------- // ------------------------------------ SALES EXECUTIVE -----------------------------------------------------
Future<Map<String, dynamic>> fetchSalesExecutiveList(int managerId, Future<Map<String, dynamic>> fetchSalesExecutiveList(
role,) async { int managerId,
role,
) async {
// print(_token); // print(_token);
print('rolemanagerId - $managerId'); print('rolemanagerId - $managerId');
@ -738,6 +751,10 @@ class ApiService {
'${Env.apiUrl}salesExecutive/executiveList?manager_id=${managerId}', '${Env.apiUrl}salesExecutive/executiveList?manager_id=${managerId}',
); );
// url = Uri.parse('${Env.apiUrl}salesExecutive/executiveList'); // url = Uri.parse('${Env.apiUrl}salesExecutive/executiveList');
} else if (role == 'Accounts') {
print('manager');
// url = Uri.parse('${Env.apiUrl}staff/staffList');
url = Uri.parse('${Env.apiUrl}staff/staffList?manager_id=${managerId}');
} else { } else {
print('handler'); print('handler');
url = Uri.parse( url = Uri.parse(
@ -807,15 +824,12 @@ class ApiService {
if (role == 'staff') { if (role == 'staff') {
url = Uri.parse( url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&enquiry_status=$selectedStatus',
''}&to_date=${toDate ?? ''}&enquiry_status=$selectedStatus',
// '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus', // '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus',
); );
} else { } else {
url = Uri.parse( url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&enquiry_status=$selectedStatus&staff_id=$selectedStaffId',
''}&to_date=${toDate ??
''}&enquiry_status=$selectedStatus&staff_id=$selectedStaffId',
// '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus&staff_id=$selectedStaffId', // '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus&staff_id=$selectedStaffId',
); );
} }
@ -844,8 +858,7 @@ class ApiService {
// } // }
final url = Uri.parse( final url = Uri.parse(
'${Env.apiUrl}staff/monthlyLoginCount?month=${month ?? '${Env.apiUrl}staff/monthlyLoginCount?month=${month ?? ''}&manager_id=$mangerId',
''}&manager_id=$mangerId',
); );
final headers = { final headers = {
@ -1017,13 +1030,14 @@ class ApiService {
// ----------------------------------- POLICY ------------------------------------------------- // ----------------------------------- POLICY -------------------------------------------------
Future<Map<String, dynamic>> fetchPolicyList(int id, Future<Map<String, dynamic>> fetchPolicyList(
role, { int id,
String? fromDate, role, {
String? toDate, String? fromDate,
String? selectedStatus, String? toDate,
String? selectedStaffId, String? selectedStatus,
}) async { String? selectedStaffId,
}) async {
// print(_token); // print(_token);
if (_token == null) { if (_token == null) {
await _initializeToken(); await _initializeToken();
@ -1047,14 +1061,11 @@ class ApiService {
if (role == 'staff') { if (role == 'staff') {
url = Uri.parse( url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus',
''}&to_date=${toDate ?? ''}&status=$selectedStatus',
); );
} else { } else {
url = Uri.parse( url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus&staff_id=$selectedStaffId',
''}&to_date=${toDate ??
''}&status=$selectedStatus&staff_id=$selectedStaffId',
); );
} }
@ -1077,13 +1088,17 @@ class ApiService {
return response; return response;
} }
Future<Map<String, dynamic>> fetchPolicyDataOnlyList(dynamic id, Future<Map<String, dynamic>> fetchPolicyDataOnlyList(
role, { managerId,
String? fromDate, dynamic id,
String? toDate, role, {
String? selectedStaffId, String? fromDate,
}) async { String? toDate,
// print(_token); String? selectedStaffId,
}) async {
print(
"fetchPolicyDataOnlyListAPI - mangerID- $managerId - id - $id - role -$role ",
);
if (_token == null) { if (_token == null) {
await _initializeToken(); await _initializeToken();
} }
@ -1093,7 +1108,11 @@ class ApiService {
final String query; final String query;
if (role == 'manager') { if (role == 'manager') {
query = 'manager_id=$id'; query = 'manager_id=$managerId';
} else if (role == 'Accounts') {
query = 'manager_id=$managerId';
} else if (role == 'Accounts') {
query = 'manager_id=$managerId';
} else if (role == 'staff') { } else if (role == 'staff') {
query = 'staff_id=$id'; query = 'staff_id=$id';
} else if (role == 'handler') { } else if (role == 'handler') {
@ -1103,9 +1122,7 @@ class ApiService {
} }
final url = Uri.parse( final url = Uri.parse(
'${Env '${Env.apiUrl}enquiry/enquiryList?$query&only_policy_data=true&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&staff_id=$selectedStaffId',
.apiUrl}enquiry/enquiryList?$query&only_policy_data=true&from_date=${fromDate ??
''}&to_date=${toDate ?? ''}&staff_id=$selectedStaffId',
); );
// if (role == 'manager') { // if (role == 'manager') {
@ -1190,6 +1207,8 @@ class ApiService {
if (role == 'manager') { if (role == 'manager') {
url = Uri.parse('${Env.apiUrl}claim/ClaimList?manager_id=$managerId'); url = Uri.parse('${Env.apiUrl}claim/ClaimList?manager_id=$managerId');
} else if (role == 'Accounts') {
url = Uri.parse('${Env.apiUrl}claim/ClaimList?manager_id=$managerId');
} else if (role == 'agent') { } else if (role == 'agent') {
url = Uri.parse('${Env.apiUrl}claim/ClaimList?agent_id=$userId'); url = Uri.parse('${Env.apiUrl}claim/ClaimList?agent_id=$userId');
} else if (role == 'handler') { } else if (role == 'handler') {
@ -1242,6 +1261,10 @@ class ApiService {
url = Uri.parse( url = Uri.parse(
'${Env.apiUrl}endorsement/endorsementList?manager_id=$managerId', '${Env.apiUrl}endorsement/endorsementList?manager_id=$managerId',
); );
} else if (role == 'Accounts') {
url = Uri.parse(
'${Env.apiUrl}endorsement/endorsementList?manager_id=$managerId',
);
} else if (role == 'agent') { } else if (role == 'agent') {
url = Uri.parse('${Env.apiUrl}endorsement/endorsementList?agent_id=$id'); url = Uri.parse('${Env.apiUrl}endorsement/endorsementList?agent_id=$id');
} else if (role == 'handler') { } else if (role == 'handler') {
@ -1439,8 +1462,10 @@ class ApiService {
} }
// Update enquiry // Update enquiry
static Future<EnquiryModel> updateEnquiry(String id, static Future<EnquiryModel> updateEnquiry(
EnquiryModel enquiry,) async { String id,
EnquiryModel enquiry,
) async {
try { try {
final response = await http.put( final response = await http.put(
Uri.parse('$_baseUrl/api/enquiries/$id'), Uri.parse('$_baseUrl/api/enquiries/$id'),
@ -1608,8 +1633,9 @@ class ApiService {
await _initializeToken(); await _initializeToken();
} }
final url = Uri.parse('${Env final url = Uri.parse(
.apiUrl}policy/PolicyFilePath?policy_id=$ID&file_type=$file_type'); '${Env.apiUrl}policy/PolicyFilePath?policy_id=$ID&file_type=$file_type',
);
final headers = { final headers = {
'Authorization': 'Bearer $_token' ?? '', 'Authorization': 'Bearer $_token' ?? '',
@ -1640,7 +1666,4 @@ class ApiService {
final response = await _makePostRequestJson(url, data, headers); final response = await _makePostRequestJson(url, data, headers);
return response; return response;
} }
} }

View File

@ -374,32 +374,32 @@ class _AppHeaderState extends ConsumerState<AppHeader> {
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
], ],
if (role != 'Accounts') ...[
// Proposal button // Proposal button
Container( Container(
width: 36, width: 36,
height: 36, height: 36,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey.shade200, width: 1), border: Border.all(color: Colors.grey.shade200, width: 1),
),
child: IconButton(
padding: EdgeInsets.zero,
icon: const Icon(Icons.quora, color: Colors.black87, size: 20),
onPressed: () {
SideDrawerPanel.show(
context: context,
title: 'Quote Creation',
child: CreateProposal_Quick(),
);
},
tooltip: 'Quick Quote',
),
), ),
child: IconButton(
padding: EdgeInsets.zero,
icon: const Icon(Icons.quora, color: Colors.black87, size: 20),
onPressed: () {
SideDrawerPanel.show(
context: context,
title: 'Quote Creation',
child: CreateProposal_Quick(),
);
},
tooltip: 'Quick Quote',
),
),
const SizedBox(width: 12),
const SizedBox(width: 12),
],
// Notifications button // Notifications button
Container( Container(
width: 36, width: 36,

View File

@ -135,7 +135,7 @@ class _AddDialogState extends State<AddDialog> {
Future.microtask(() { Future.microtask(() {
// final id = ref.read(managerIdProvider); // final id = ref.read(managerIdProvider);
// roleId = ref.read(userRoleProvider); // roleId = ref.read(userRoleProvider);
// userId = ref.read(userIdProvider); // userId = ref.read(userIdProvider);
if (widget.userId != null && widget.managerId != null) { if (widget.userId != null && widget.managerId != null) {
getStaffList(widget.managerId, widget.userId); getStaffList(widget.managerId, widget.userId);
@ -269,6 +269,7 @@ class _AddDialogState extends State<AddDialog> {
final response = await apiService.fetchPolicyDataOnlyList( final response = await apiService.fetchPolicyDataOnlyList(
managerIdStr, managerIdStr,
roleStr, roleStr,
roleStr,
fromDate: controllers['startDate']?.text ?? '', fromDate: controllers['startDate']?.text ?? '',
toDate: controllers['endDate']?.text ?? '', toDate: controllers['endDate']?.text ?? '',
selectedStaffId: widget.userId ?? '', selectedStaffId: widget.userId ?? '',

View File

@ -49,6 +49,7 @@ class StaffListState extends ConsumerState<StaffList> {
prefid = data1; prefid = data1;
role = ref.read(userRoleProvider); role = ref.read(userRoleProvider);
print("E43 => mId: $prefid"); print("E43 => mId: $prefid");
print("roleSTAFFLIST: $role");
if (prefid != null && role != null) { if (prefid != null && role != null) {
getStaffList(prefid, role); getStaffList(prefid, role);
} }

View File

@ -146,9 +146,7 @@ class _InvoiceListState extends ConsumerState<InvoiceList> {
return sortedData.sublist(startIndex, endIndex); return sortedData.sublist(startIndex, endIndex);
} }
void filterDateRange() { void filterDateRange() {}
}
void refrshfilterDateRange() { void refrshfilterDateRange() {
setState(() { setState(() {
@ -161,7 +159,7 @@ class _InvoiceListState extends ConsumerState<InvoiceList> {
// Reset the FormField validation // Reset the FormField validation
_formKey.currentState?.reset(); _formKey.currentState?.reset();
}); });
getInvoiceList(); getInvoiceList();
} }
void filterData(String query) { void filterData(String query) {
@ -171,8 +169,8 @@ class _InvoiceListState extends ConsumerState<InvoiceList> {
// final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; // final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive";
return (_formatDate(item['updated_at']) ?? '-').toLowerCase().contains( return (_formatDate(item['updated_at']) ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(_formatDate(item['invoice_date']) ?? '-').toLowerCase().contains( (_formatDate(item['invoice_date']) ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
@ -211,6 +209,7 @@ class _InvoiceListState extends ConsumerState<InvoiceList> {
return MainLayout( return MainLayout(
title: "Pay Out", title: "Pay Out",
body: Container( body: Container(
height: 30,
// color: Colors.yellow.shade50, // color: Colors.yellow.shade50,
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: Column( child: Column(
@ -228,29 +227,29 @@ class _InvoiceListState extends ConsumerState<InvoiceList> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Tooltip( // Tooltip(
message: 'Back', // message: 'Back',
child: IconButton( // child: IconButton(
icon: const Icon( // icon: const Icon(
Icons.arrow_left_sharp, // Icons.arrow_left_sharp,
size: 25, // size: 25,
color: Color(0xFF425B5B), // color: Color(0xFF425B5B),
), // ),
onPressed: () { // onPressed: () {
context.go(AppRoutes.dashboard); // context.go(AppRoutes.dashboard);
}, // },
splashRadius: 18, // splashRadius: 18,
hoverColor: Colors.black12, // hoverColor: Colors.black12,
padding: const EdgeInsets.all(4), // padding: const EdgeInsets.all(4),
constraints: const BoxConstraints(), // constraints: const BoxConstraints(),
), // ),
), // ),
const SizedBox(width: 5), // spacing between icon and text // const SizedBox(width: 5), // spacing between icon and text
Text( Text(
"Invoice", "Invoice",
style: GoogleFonts.inter( style: GoogleFonts.inter(
fontSize: 18, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w500,
), ),
), ),
], ],
@ -372,13 +371,15 @@ class _InvoiceListState extends ConsumerState<InvoiceList> {
// // ), // // ),
// Spacer(), // Spacer(),
// ], // ],
ThemedSearchField( ThemedSearchField(
hintText: 'Search', hintText: 'Search',
backgroundColor: Color(0xFFF6F8F8), // backgroundColor: Color(0xFFF6F8F8),
onChanged: filterData, onChanged: filterData,
controller: _searchStaffController, controller: _searchStaffController,
txtwidth: MediaQuery.of(context).size.width * 0.2, txtHeight: 30,
txtwidth: ResponsiveLayout.isMobile(context)
? MediaQuery.of(context).size.width * 0.7
: MediaQuery.of(context).size.width * 0.15,
), ),
SizedBox(width: 10), SizedBox(width: 10),
Tooltip( Tooltip(
@ -533,10 +534,7 @@ class _InvoiceListState extends ConsumerState<InvoiceList> {
), ),
Expanded( Expanded(
flex: 3, flex: 3,
child: Text( child: Text(item['invoice_date'] ?? '-', style: _dataBold),
item['invoice_date'] ?? '-',
style: _dataBold,
),
), ),
Expanded( Expanded(
flex: 3, flex: 3,

View File

@ -300,7 +300,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
) { ) {
if (next == true) { if (next == true) {
print('refresh triggered Quick Creation'); print('refresh triggered Quick Creation');
callRefresh(); autoRefrshfilterDateRange();
// callRefresh();
ref.read(enquiryRefreshProvider.notifier).state = false; ref.read(enquiryRefreshProvider.notifier).state = false;
} }
@ -637,9 +638,18 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
print('completedData - $completedData'); print('completedData - $completedData');
// filteredData now holds the currently displayed tab's data (without search) // filteredData now holds the currently displayed tab's data (without search)
// filteredData = (selectedIndex == 0)
// ? inProgressData
// : completedData;
// 👇 IMPORTANT: Set filteredData based on current tab
filteredData = (selectedIndex == 0) filteredData = (selectedIndex == 0)
? inProgressData ? List.from(inProgressData)
: completedData; : List.from(completedData);
print('filteredData count: ${filteredData.length}');
print('inProgressData count: ${inProgressData.length}');
print('completedData count: ${completedData.length}');
} else if (data is Map) { } else if (data is Map) {
getStaffData = [Map<String, dynamic>.from(data)]; getStaffData = [Map<String, dynamic>.from(data)];
} else { } else {
@ -662,54 +672,64 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
} }
void filterData(String query) { void filterData(String query) {
print("FilterDAta - $query"); print("FilterData - $query");
setState(() { setState(() {
// Get the correct source list based on selected tab
final sourceList = (selectedIndex == 0) ? inProgressData : completedData; final sourceList = (selectedIndex == 0) ? inProgressData : completedData;
filteredData = sourceList.where((item) { if (query.isEmpty) {
// final isActiveStatus = item['is_active'] == "1" ? "active" : "inactive"; // If search is empty, show all data for current tab
filteredData = List.from(sourceList);
return (item['agent_name'] ?? '-').toLowerCase().contains( } else {
query.toLowerCase(), // Search within the current tab's data
) || filteredData = sourceList.where((item) {
(item['agent_code'] ?? '-').toLowerCase().contains( return (item['agent_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['reg_no'] ?? '-').toLowerCase().contains( (item['agent_code'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['insurer_name'] ?? '-').toLowerCase().contains( (item['reg_no'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['enquiry_status'] ?? '-').toLowerCase().contains( (item['insurer_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['assigned_to_name'] ?? '-').toLowerCase().contains( (item['enquiry_status'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['insured_name'] ?? '-').toLowerCase().contains( (item['assigned_to_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['insurer_short_name'] ?? '-').toLowerCase().contains( (item['insured_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['premium_amount'] ?? '-').toLowerCase().contains( (item['insurer_short_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['payment_mode'] ?? '-').toLowerCase().contains( (item['premium_amount'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(_formatDate(item['created_on']) ?? '-').toLowerCase().contains( (item['payment_mode'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(_formatDate(item['updated_on']) ?? '-').toLowerCase().contains( (item['broker_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['policy_number'] ?? '-').toLowerCase().contains( (_formatDate(item['created_on']) ?? '-').toLowerCase().contains(
query.toLowerCase(), query.toLowerCase(),
) || ) ||
(item['status'] ?? '-').toLowerCase().contains(query.toLowerCase()); (_formatDate(item['updated_on']) ?? '-').toLowerCase().contains(
}).toList(); query.toLowerCase(),
) ||
(item['policy_number'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['status'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
);
}).toList();
}
}); });
} }
@ -1595,7 +1615,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
'In progress': 'In Progress', 'In progress': 'In Progress',
}; };
List<Map<String, dynamic>> get filteredDataByTab { List<Map<String, dynamic>> get filteredDataByTab1 {
if (selectedIndex == 0) { if (selectedIndex == 0) {
// Progress enquiries // Progress enquiries
final sortedData = [...inProgressData] final sortedData = [...inProgressData]
@ -1628,6 +1648,44 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
} }
} }
List<Map<String, dynamic>> get filteredDataByTab {
// Use filteredData instead of the raw source lists
final sortedData = [...filteredData]
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
if (sortedData.isEmpty) return [];
if (selectedIndex == 0) {
// Progress enquiries - return filtered in-progress items
return sortedData.where((e) {
return [
"To be assigned",
"Assigned",
"In progress",
].contains(e['enquiry_status']);
}).toList();
} else {
// Completed enquiries - apply pagination to filtered completed items
final completedFiltered = sortedData.where((e) {
return e['enquiry_status'] == "Completed";
}).toList();
// Update total pages based on filtered results
totalCompletedPages = (completedFiltered.length / completedItemsPerPage)
.ceil();
if (totalCompletedPages == 0) totalCompletedPages = 1;
// Apply pagination
final startIndex = (completedCurrentPage - 1) * completedItemsPerPage;
final endIndex = (startIndex + completedItemsPerPage).clamp(
0,
completedFiltered.length,
);
return completedFiltered.sublist(startIndex, endIndex);
}
}
// Add group enquiries by status // Add group enquiries by status
Map<String, List<Map<String, dynamic>>> get _groupedEnquiries { Map<String, List<Map<String, dynamic>>> get _groupedEnquiries {
final Map<String, List<Map<String, dynamic>>> grouped = {}; final Map<String, List<Map<String, dynamic>>> grouped = {};
@ -2770,7 +2828,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
setState(() { setState(() {
print('TAPPED TAB'); print('TAPPED TAB');
selectedIndex = index; selectedIndex = index;
filteredData = (index == 0) ? inProgressData : completedData;
if (index == 1) { if (index == 1) {
completedCurrentPage = 1; completedCurrentPage = 1;
} }

View File

@ -637,6 +637,35 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
} }
void filterData(String query) { void filterData(String query) {
final queryLC = query.toLowerCase();
String _safeStr(dynamic value) {
return value?.toString().toLowerCase() ?? '';
}
setState(() {
final sourceList = (selectedIndex == 0) ? inProgressData : completedData;
filteredData = sourceList.where((item) {
return _safeStr(item['agent_name']).contains(queryLC) ||
_safeStr(item['agent_code']).contains(queryLC) ||
_safeStr(item['reg_no']).contains(queryLC) ||
_safeStr(item['insurer_name']).contains(queryLC) ||
_safeStr(item['enquiry_status']).contains(queryLC) ||
_safeStr(item['assigned_to_name']).contains(queryLC) ||
_safeStr(item['insured_name']).contains(queryLC) ||
_safeStr(item['insurer_short_name']).contains(queryLC) ||
_safeStr(item['premium_amount']).contains(queryLC) ||
_safeStr(item['payment_mode']).contains(queryLC) ||
_safeStr(_formatDate(item['created_on'])).contains(queryLC) ||
_safeStr(_formatDate(item['updated_on'])).contains(queryLC) ||
_safeStr(item['policy_number']).contains(queryLC) ||
_safeStr(item['status']).contains(queryLC);
}).toList();
});
}
void filterData1(String query) {
print("FilterDAta - $query"); print("FilterDAta - $query");
setState(() { setState(() {
final sourceList = (selectedIndex == 0) ? inProgressData : completedData; final sourceList = (selectedIndex == 0) ? inProgressData : completedData;

View File

@ -32,6 +32,7 @@ class policylistState extends ConsumerState<policylist> {
int itemsPerPage = 10; int itemsPerPage = 10;
late ApiService apiService; late ApiService apiService;
dynamic userId; dynamic userId;
dynamic managerId;
dynamic SelectedStatus; dynamic SelectedStatus;
dynamic SelectedStaffId; dynamic SelectedStaffId;
// List<Map<String, dynamic>> dataVal = []; // List<Map<String, dynamic>> dataVal = [];
@ -58,30 +59,31 @@ class policylistState extends ConsumerState<policylist> {
} }
Future.microtask(() { Future.microtask(() {
final id = ref.read(managerIdProvider); final managerId = ref.read(managerIdProvider);
roleId = ref.read(userRoleProvider); roleId = ref.read(userRoleProvider);
userId = ref.read(userIdProvider); userId = ref.read(userIdProvider);
print("D49 => r : $roleId | mId: $id | uId: $userId "); print("D49 => r : $roleId | mId: $managerId | uId: $userId ");
if (userId != null) { if (userId != null) {
getStaffList(userId, roleId); getStaffList(managerId!, userId, roleId);
} }
}); });
} }
void refresh() { void refresh() {
final id = ref.read(managerIdProvider); managerId = ref.read(managerIdProvider);
final roleId = ref.read(userRoleProvider); final roleId = ref.read(userRoleProvider);
final userId = ref.read(userIdProvider); final userId = ref.read(userIdProvider);
print("D61 => r : $roleId | mId: $id | uId: $userId"); // print("D61 => r : $roleId | mId: $id | uId: $userId");
if (userId != null) { if (userId != null) {
getStaffList(userId, roleId); getStaffList(managerId, userId, roleId);
} }
} }
Future<void> getStaffList( Future<void> getStaffList(
int managerId, int managerId,
id,
role, { role, {
String fromDate = '', String fromDate = '',
String toDate = '', String toDate = '',
@ -114,6 +116,7 @@ class policylistState extends ConsumerState<policylist> {
try { try {
final response = await apiService.fetchPolicyDataOnlyList( final response = await apiService.fetchPolicyDataOnlyList(
managerId, managerId,
id,
role, role,
fromDate: fromDt, fromDate: fromDt,
toDate: toDt, toDate: toDt,
@ -199,7 +202,7 @@ class policylistState extends ConsumerState<policylist> {
// } // }
// Call your API // Call your API
getStaffList(userId, roleId); getStaffList(managerId, userId, roleId);
} }
void refrshfilterDateRange() { void refrshfilterDateRange() {
@ -213,7 +216,7 @@ class policylistState extends ConsumerState<policylist> {
// Reset the FormField validation // Reset the FormField validation
_formKey.currentState?.reset(); _formKey.currentState?.reset();
}); });
getStaffList(userId, roleId); getStaffList(managerId, userId, roleId);
} }
void filterData(String query) { void filterData(String query) {
@ -223,27 +226,33 @@ class policylistState extends ConsumerState<policylist> {
setState(() { setState(() {
filteredData = getStaffData.where((item) { filteredData = getStaffData.where((item) {
// Compute UI status text // Compute UI status text
final accuracyText = final accuracyText = item['is_data_accuracy_checked'] == '1'
item['is_data_accuracy_checked'] == '1'
? 'Verified' ? 'Verified'
: 'Click to Verify'; : 'Click to Verify';
return return (item['agent_name'] ?? '-').toLowerCase().contains(lowerQuery) ||
(item['agent_name'] ?? '-').toLowerCase().contains(lowerQuery) || (item['reg_no'] ?? '-').toLowerCase().contains(lowerQuery) ||
(item['reg_no'] ?? '-').toLowerCase().contains(lowerQuery) || (item['insurer_name'] ?? '-').toLowerCase().contains(lowerQuery) ||
(item['insurer_name'] ?? '-').toLowerCase().contains(lowerQuery) || (item['insurer_short_name'] ?? '-').toLowerCase().contains(
(item['insurer_short_name'] ?? '-').toLowerCase().contains(lowerQuery) || lowerQuery,
(item['assigned_to_name'] ?? '-').toLowerCase().contains(lowerQuery) || ) ||
(item['insured_name'] ?? '-').toLowerCase().contains(lowerQuery) || (item['assigned_to_name'] ?? '-').toLowerCase().contains(
(item['premium_amount'] ?? '-').toLowerCase().contains(lowerQuery) || lowerQuery,
(item['payment_mode_value'] ?? '-').toLowerCase().contains(lowerQuery) || ) ||
(_formatDate(item['updated_on']) ?? '-').toLowerCase().contains(lowerQuery) || (item['insured_name'] ?? '-').toLowerCase().contains(lowerQuery) ||
(item['policy_number'] ?? '-').toLowerCase().contains(lowerQuery) || (item['premium_amount'] ?? '-').toLowerCase().contains(
lowerQuery,
// NEW CONDITIONS for search ) ||
accuracyText.toLowerCase().contains(lowerQuery); (item['payment_mode_value'] ?? '-').toLowerCase().contains(
lowerQuery,
) ||
(_formatDate(item['updated_on']) ?? '-').toLowerCase().contains(
lowerQuery,
) ||
(item['policy_number'] ?? '-').toLowerCase().contains(lowerQuery) ||
// NEW CONDITIONS for search
accuracyText.toLowerCase().contains(lowerQuery);
}).toList(); }).toList();
}); });
} }
@ -418,11 +427,12 @@ class policylistState extends ConsumerState<policylist> {
: SizedBox.shrink(), : SizedBox.shrink(),
ThemedSearchField( ThemedSearchField(
hintText: 'Search', hintText: 'Search',
// backgroundColor: Color(0xFFF6F8F8), // backgroundColor: Color(0xFFF6F8F8),
backgroundColor: Color(0xFFFFFFFF),
txtHeight: 30,
onChanged: filterData, onChanged: filterData,
controller: _searchStaffController, controller: _searchStaffController,
backgroundColor: Color(0xFFFFFFFF),
txtHeight: 30,
txtwidth: ResponsiveLayout.isMobile(context) txtwidth: ResponsiveLayout.isMobile(context)
? MediaQuery.of(context).size.width * 0.7 ? MediaQuery.of(context).size.width * 0.7
: MediaQuery.of(context).size.width * 0.15, : MediaQuery.of(context).size.width * 0.15,
@ -737,14 +747,14 @@ class policylistState extends ConsumerState<policylist> {
message: '', message: '',
child: InkWell( child: InkWell(
onTap: () { onTap: () {
context.push( context.push(AppRoutes.policyValidation, extra: item);
AppRoutes.policyValidation,
extra: item,
);
}, },
child: Container( child: Container(
width: 110, // FIXED WIDTH Equal in both states width: 110, // FIXED WIDTH Equal in both states
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: item['is_data_accuracy_checked'] == '1' color: item['is_data_accuracy_checked'] == '1'
? const Color(0xFF2E7D6E) ? const Color(0xFF2E7D6E)
@ -752,7 +762,8 @@ class policylistState extends ConsumerState<policylist> {
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, // Center content mainAxisAlignment:
MainAxisAlignment.center, // Center content
children: [ children: [
Icon( Icon(
item['is_data_accuracy_checked'] == '1' item['is_data_accuracy_checked'] == '1'
@ -777,8 +788,7 @@ class policylistState extends ConsumerState<policylist> {
), ),
), ),
), ),
] ],
], ],
), ),
), ),
@ -1003,4 +1013,3 @@ class policylistState extends ConsumerState<policylist> {
fontSize: 12, fontSize: 12,
); );
} }

View File

@ -237,10 +237,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus name: device_info_plus
sha256: "4df8babf73058181227e18b08e6ea3520cf5fc5d796888d33b7cb0f33f984b7c" sha256: "98f28b42168cc509abc92f88518882fd58061ea372d7999aecc424345c7bff6a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "12.3.0" version: "11.5.0"
device_info_plus_platform_interface: device_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -700,26 +700,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "11.0.2" version: "10.0.9"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.10" version: "3.0.9"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@ -1217,74 +1217,74 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_flutter_core name: syncfusion_flutter_core
sha256: e1fdfcc3ed7e1f040ba95838780b2eb1857e3e5eccb817fbe94ea2b09c35eac4 sha256: "2d878bce96c4fd1092205a4f72b328f7f05d86b27c3bd55db7fd440e6017352a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_flutter_pdf: syncfusion_flutter_pdf:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_flutter_pdf name: syncfusion_flutter_pdf
sha256: "4077abff3d3dcae757317c0a85cb607b98cc6ea8f3b47c7d8488d4144ef01a9f" sha256: "95b5e01cc2305f03490b009a28c2e8753feecdb4202c87fcba27a74fbc93222c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_flutter_pdfviewer: syncfusion_flutter_pdfviewer:
dependency: "direct main" dependency: "direct main"
description: description:
name: syncfusion_flutter_pdfviewer name: syncfusion_flutter_pdfviewer
sha256: "4bc26c493a017ea615a2c232031f3aa46642ddb22d82a8d88d8c5e5ea7fe4c7d" sha256: "31ae13c02b8db657ee914dd8912ccb8eefeb86a0957d5a7315d46efe4729472f"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_flutter_signaturepad: syncfusion_flutter_signaturepad:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_flutter_signaturepad name: syncfusion_flutter_signaturepad
sha256: "56c35321879b900f59a91e0758af7ca66973447bfdaeb643fe1da0084cbc5b22" sha256: b4f229d542b29f9c3927862194d9f0b15b02f27b13a899e7dd54b04de8b50d24
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_pdfviewer_linux: syncfusion_pdfviewer_linux:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_linux name: syncfusion_pdfviewer_linux
sha256: bae7feb109b38ecf9f8be99bd032503adf98e56da048307a17af8515d0f9d2ed sha256: ef66789a0018e4fa84f17277a5e1ed3ac817aa197d19073a6b6a409256c5c131
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_pdfviewer_macos: syncfusion_pdfviewer_macos:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_macos name: syncfusion_pdfviewer_macos
sha256: "5c02ead2a430cd3f203639ede38ce2e06fb6c8aab6791b0d15c01436f882f482" sha256: "23ba6294111f72b24ddeb36f685e4c7dd02a855a3c514b628926c9b58e45a40a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_pdfviewer_platform_interface: syncfusion_pdfviewer_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_platform_interface name: syncfusion_pdfviewer_platform_interface
sha256: "65641e064385ac65253930ec96a6edc2eea781c9e15bf3d5fa15e459037817e7" sha256: d4061b838a6847cf07ab946346865dc32608691f9fa8d11b3870ac947f236222
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_pdfviewer_web: syncfusion_pdfviewer_web:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_web name: syncfusion_pdfviewer_web
sha256: c55201d9eda49f543b9ad21f539b0f5fbe45ca1a3b30081ee471eb4dff7132f4 sha256: "9acc5d3a7a056d81e2ea333fb9f42b6838263c80f54400a69aab73a845290fc2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
syncfusion_pdfviewer_windows: syncfusion_pdfviewer_windows:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_windows name: syncfusion_pdfviewer_windows
sha256: "1b706e58a95c794687d037e055cf0580370ceee27a59a8cd4e14368534161af8" sha256: "4989d32dbcda945615f3ba5730f814a468d34c0fdaab9edf4805a0f03c3ae62d"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "31.2.18" version: "31.1.19"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
@ -1297,10 +1297,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.6" version: "0.7.4"
toastification: toastification:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1417,10 +1417,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.0" version: "2.1.4"
vm_service: vm_service:
dependency: transitive dependency: transitive
description: description:
@ -1503,4 +1503,4 @@ packages:
version: "3.1.3" version: "3.1.3"
sdks: sdks:
dart: ">=3.8.1 <4.0.0" dart: ">=3.8.1 <4.0.0"
flutter: ">=3.35.1" flutter: ">=3.32.0"

View File

@ -70,7 +70,7 @@ dependencies:
fluttertoast: ^9.0.0 fluttertoast: ^9.0.0
fl_chart: ^0.70.0 fl_chart: ^0.70.0
flutter_reorderable_grid_view: ^5.5.2 flutter_reorderable_grid_view: ^5.5.2
syncfusion_flutter_pdfviewer: ^31.2.18 syncfusion_flutter_pdfviewer: ^31.1.19
pdf_render: ^1.4.12 pdf_render: ^1.4.12
# fl_chart: ^1.1.0 # fl_chart: ^1.1.0