UI_HR_CLAIMS_MODULE_FILTER

This commit is contained in:
venbaittech 2025-07-05 18:10:57 +05:30
parent 4e85d3d73f
commit dda99d9948
4 changed files with 784 additions and 435 deletions

BIN
assets/claimHistory.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

View File

@ -500,7 +500,7 @@ class _hrDashboardState extends State<hrDashboard>
SizedBox(height: 8),
Container(
padding: const EdgeInsets.all(5),
// padding: const EdgeInsets.all(5),
// height: MediaQuery.of(context).size.height * 0.08,
decoration: BoxDecoration(
color:
@ -515,11 +515,16 @@ class _hrDashboardState extends State<hrDashboard>
),
],
),
child: TabBar(
child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// mainAxisSize: MainAxisSize.min,
children: [
TabBar(
controller: _tabController,
isScrollable: true,
labelPadding: const EdgeInsets.symmetric(
horizontal: 0, vertical: 0),
labelPadding: EdgeInsets.zero,
// labelPadding: const EdgeInsets.symmetric(
// horizontal: 0, vertical: 0),
// indicator: BoxDecoration(
// color: const Color(0xFF00999E), // Selected tab background
// borderRadius: BorderRadius.circular(12),
@ -533,6 +538,7 @@ class _hrDashboardState extends State<hrDashboard>
// ),
dividerColor: Colors.transparent,
indicatorColor: Colors.transparent,
indicatorPadding: EdgeInsets.zero,
labelColor: Colors.white,
unselectedLabelColor: const Color(0xFF828282),
// tabs: visibleTabs,
@ -564,6 +570,8 @@ class _hrDashboardState extends State<hrDashboard>
// isSelected: selectedIndex == 3),
// ],
),
],
),
),
SizedBox(height: 16),
// Expanded TabBarView
@ -695,7 +703,8 @@ class CustomTab extends StatelessWidget {
Widget build(BuildContext context) {
return Tab(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 6),
// margin: const EdgeInsets.symmetric(horizontal: 6),
margin: const EdgeInsets.only(right: 6),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration(
color: isSelected ? const Color(0xFF00999E) : Colors.white,
@ -716,8 +725,8 @@ class CustomTab extends StatelessWidget {
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon,
size: 18,

View File

@ -46,9 +46,11 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
Map<String, TextEditingController> controllers = {};
List<dynamic> reversedDataPolicy = [];
List<Map<String, dynamic>> originalData = [];
String? selectedPolicyType;
// int? selectedPolicyType;
String? selectedClaimStatus;
String? selectedPolicyTypeName;
String? selectedClaimStatusName;
int? selectedPolicyType;
int? selectedClaimStatus;
dynamic empClientId;
List<Map<String, dynamic>> getClaimPolicies = [];
Map<String, dynamic> getClaimPoliciesApi = {};
@ -95,7 +97,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
print("TextCXOnte - $controllers");
getCDPoliciesDetails();
getClaimsPoliciesDetails();
// getApiData();
}
@ -107,7 +109,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
super.dispose();
}
Future<void> getCDPoliciesDetails() async {
Future<void> getClaimsPoliciesDetails() async {
print('9');
setState(() {
isLoading = true;
@ -168,6 +170,10 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
print('originalData - $getClaimPolicies');
});
} else {
getClaimPolicies = [];
originalData = getClaimPolicies;
filteredData = List.from(originalData);
print('originalData - $getClaimPolicies');
print('Request failed: ${response['code']}');
}
} catch (e) {
@ -182,6 +188,26 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
void applyFilter() {
final data = claim_Detials();
print("data -- $data");
getClaimList();
}
void reset() {
setState(() {
controllers.forEach((key, controller) {
controller.clear();
});
selectedPolicyType = null;
selectedPolicyTypeName = null;
selectedClaimStatus = null;
selectedClaimStatusName = null;
_currentPage = 1;
getClaimList();
});
final data = claim_Detials();
print("restdata -- $data");
}
@override
@ -189,6 +215,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
// TODO: implement build
return Container(
decoration: BoxDecoration(
// color: Colors.red.shade50,
color: Colors.white,
borderRadius: BorderRadius.circular(10), // 👈 set your desired radius
),
@ -199,19 +226,24 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
SizedBox(
height: 10,
),
Expanded(
child: Container(
child: Column(
children: [
// Text("DAer"),
// _buildClaimsDataTable(context),
SingleChildScrollView(
child: _buildClaimsDataTable(context),
),
],
),
),
),
// Expanded(
// child: Container(
// child: Column(
// children: [
// // Text("DAer"),
// // _buildClaimsDataTable(context),
// SingleChildScrollView(
// scrollDirection: Axis.vertical,
// child: _buildClaimsDataTable(context),
// ),
// ],
// ),
// ),
// ),
],
),
);
@ -254,203 +286,410 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header row
Container(
return ListView.builder(
itemCount: _paginatedData.length + 2, // +1 for header, +1 for pagination
itemBuilder: (context, index) {
if (index == 0) return _buildHeader();
if (index == _paginatedData.length + 1)
return _buildPagination(context);
final item = _paginatedData[index - 1];
return _buildDataRow(item);
},
);
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// // Header row
// Container(
// decoration: BoxDecoration(
// color: Color(0xFF00A6A6),
// borderRadius: BorderRadius.circular(6),
// ),
// padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
// child: Row(
// children: [
// Expanded(
// flex: 4,
// child: Text(
// 'Name',
// style: GoogleFonts.poppins(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// Expanded(
// flex: 4,
// child: Text(
// 'Policy Name',
// style: GoogleFonts.poppins(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// Expanded(
// flex: 3,
// child: Text(
// 'Claim Number',
// style: GoogleFonts.poppins(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// Expanded(
// flex: 2,
// child: Text(
// 'Status',
// style: GoogleFonts.poppins(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// Expanded(
// flex: 3,
// child: Text(
// 'Claim Amount',
// style: GoogleFonts.poppins(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// Expanded(
// flex: 3,
// child: Text(
// 'Record Date',
// style: GoogleFonts.poppins(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// Expanded(
// flex: 2,
// child: Text(
// 'Action',
// textAlign: TextAlign.center,
// style: GoogleFonts.poppins(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// ],
// ),
// ),
//
// const SizedBox(height: 6),
//
// SingleChildScrollView(
// scrollDirection: Axis.vertical,
// child: Column(
// children: _paginatedData.mapIndexed((index, item) {
// return Container(
// // margin: const EdgeInsets.only(bottom: 8),
// padding:
// const EdgeInsets.symmetric(vertical: 5, horizontal: 16),
// decoration: BoxDecoration(
// color: Colors.white,
// border: Border(
// bottom: BorderSide(
// // color: Color(0xFFA1A1A1),
// color: Color(0xFFD7E9EB),
// width: 1,
// ),
// ),
// // color: index % 2 == 0 ? Color(0xFFE6FAFB) : Colors.white,
// borderRadius: BorderRadius.circular(6),
// ),
// child: Row(
// children: [
// Expanded(
// flex: 4,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// item['emp_name'] ?? '-',
// style: GoogleFonts.poppins(
// color: Color(0xFF000000),
// fontWeight: FontWeight.w400,
// fontSize: 12),
// ),
// Text(
// item['emp_code'] ?? '-',
// style: GoogleFonts.poppins(
// color: Color(0xFF585757),
// fontWeight: FontWeight.w300,
// fontSize: 10),
// ),
// ],
// ),
// ),
// Expanded(
// flex: 4,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// item['emp_name'] ?? '-',
// style: GoogleFonts.poppins(
// color: Color(0xFF000000),
// fontWeight: FontWeight.w400,
// fontSize: 12),
// ),
// Text(
// item['policy_no'] ?? '-',
// style: GoogleFonts.poppins(
// color: Color(0xFF585757),
// fontWeight: FontWeight.w300,
// fontSize: 10),
// ),
// ],
// ),
// ),
// Expanded(
// flex: 3,
// child: Text(
// "${item['claim_no'] ?? ''}",
// style: GoogleFonts.poppins(
// color: Color(0xFF000000),
// fontWeight: FontWeight.w400,
// fontSize: 12),
// ),
// ),
// Expanded(
// flex: 2,
// child: Container(
// padding: const EdgeInsets.symmetric(
// horizontal: 4, vertical: 4),
// decoration: BoxDecoration(
// color: Color(0xFF7BD9B6),
// // color: (item['emp_is_active'] == "1")
// // ? Color(0xFF7BD9B6)
// // : Color(0xFFFFA6A6),
// borderRadius: BorderRadius.circular(6),
// ),
// child: Align(
// alignment: Alignment.center,
// child: Text(
// "${item['status'] ?? ''}",
// style: GoogleFonts.poppins(
// color: Color(0xFF000000),
// fontWeight: FontWeight.w500,
// fontSize: 12,
// ),
// ),
// ),
// ),
// ),
// Expanded(
// flex: 3,
// child: Text(
// "${item['claim_amount'] ?? ''}",
// style: GoogleFonts.poppins(
// color: Color(0xFF000000),
// fontWeight: FontWeight.w400,
// fontSize: 12),
// ),
// ),
// Expanded(
// flex: 3,
// child: Text(
// "${item['ticket_created_date'] ?? ''}",
// style: GoogleFonts.poppins(
// color: Color(0xFF000000),
// fontWeight: FontWeight.w400,
// fontSize: 12),
// ),
// ),
// Expanded(
// flex: 2,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// GestureDetector(
// onTap: () {},
// child: Container(
// height: 30,
// width: 30,
// decoration: BoxDecoration(
// color: Color(0xFFE6F5F6),
// borderRadius: BorderRadius.circular(12)),
// child: Icon(Icons.credit_card,
// color: Color(0xFF3D3D3D)),
// // child: Image.asset(
// // 'assets/ecard.jpg',
// // height: 20,
// // fit: BoxFit.cover,
// // ),
// ),
// ),
// ],
// ),
// ),
// ],
// ),
// );
// }).toList(),
// ),
// ),
//
// Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// Padding(
// padding: const EdgeInsets.symmetric(vertical: 12),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// DropdownButton<int>(
// value: _rowsPerPage,
// items: [5, 10, 15, 20, 50].map((int value) {
// return DropdownMenuItem<int>(
// value: value,
// child: Text(
// ' $value ',
// style: GoogleFonts.poppins(fontSize: 15),
// ),
// );
// }).toList(),
// onChanged: (newValue) {
// setState(() {
// _rowsPerPage = newValue!;
// _currentPage =
// 1; // Reset to first page when rows per page changes
// });
// },
// ),
// IconButton(
// onPressed: _currentPage > 1
// ? () {
// setState(() {
// _currentPage--;
// });
// }
// : null,
// icon: Icon(Icons.chevron_left),
// ),
// for (int i = 1;
// i <= (filteredData.length / _rowsPerPage).ceil();
// i++)
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 4),
// child: ElevatedButton(
// style: ElevatedButton.styleFrom(
// backgroundColor: _currentPage == i
// ? Color(0xFF00A6A6)
// : Colors.grey[300],
// foregroundColor:
// _currentPage == i ? Colors.white : Colors.black,
// minimumSize: Size(36, 36),
// padding: EdgeInsets.zero,
// ),
// onPressed: () {
// setState(() {
// _currentPage = i;
// });
// },
// child: Text(i.toString()),
// ),
// ),
// IconButton(
// onPressed: _currentPage <
// (filteredData.length / _rowsPerPage).ceil()
// ? () {
// setState(() {
// _currentPage++;
// });
// }
// : null,
// icon: Icon(Icons.chevron_right),
// ),
// ],
// ),
// ),
// ],
// ),
// ],
// );
}
Widget _buildHeader() {
return Container(
decoration: BoxDecoration(
color: Color(0xFF00A6A6),
borderRadius: BorderRadius.circular(6),
),
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
child: Row(
child: const Row(
children: [
Expanded(
flex: 4,
child: Text(
'Name',
style: GoogleFonts.poppins(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(
flex: 4,
child: Text(
'Policy Name',
style: GoogleFonts.poppins(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(
flex: 3,
child: Text(
'Claim Number',
style: GoogleFonts.poppins(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(flex: 4, child: Text('Name', style: _headerStyle)),
Expanded(flex: 4, child: Text('Policy Name', style: _headerStyle)),
Expanded(flex: 3, child: Text('Claim Number', style: _headerStyle)),
Expanded(flex: 4, child: Text('Status', style: _headerStyle)),
Expanded(flex: 3, child: Text('Claim Amount', style: _headerStyle)),
Expanded(flex: 3, child: Text('Record Date', style: _headerStyle)),
Expanded(
flex: 2,
child: Text(
'Status',
style: GoogleFonts.poppins(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(
flex: 3,
child: Text(
'Claim Amount',
style: GoogleFonts.poppins(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(
flex: 3,
child: Text(
'Record Date',
style: GoogleFonts.poppins(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(
flex: 2,
child: Text(
'Action',
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
child: Text('Action',
textAlign: TextAlign.center, style: _headerStyle)),
],
),
),
);
}
const SizedBox(height: 6),
SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: _paginatedData.mapIndexed((index, item) {
Widget _buildDataRow(Map<String, dynamic> item) {
return Container(
// margin: const EdgeInsets.only(bottom: 8),
padding:
const EdgeInsets.symmetric(vertical: 5, horizontal: 16),
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 16),
margin: const EdgeInsets.only(top: 10),
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
// color: Color(0xFFA1A1A1),
color: Color(0xFFD7E9EB),
width: 1,
color: Color(0xFFE0F7F9),
border: const Border(
bottom: BorderSide(color: Color(0xFFD7E9EB), width: 1),
),
),
// color: index % 2 == 0 ? Color(0xFFE6FAFB) : Colors.white,
borderRadius: BorderRadius.circular(6),
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Expanded(
flex: 4,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item['emp_name'] ?? '-',
style: GoogleFonts.poppins(
color: Color(0xFF000000),
fontWeight: FontWeight.w400,
fontSize: 12),
),
Text(
item['emp_code'] ?? '-',
style: GoogleFonts.poppins(
color: Color(0xFF585757),
fontWeight: FontWeight.w300,
fontSize: 10),
),
Text(item['emp_name'] ?? '-', style: _dataBold),
Text(item['emp_code'] ?? '-', style: _dataSub),
],
),
),
Expanded(
flex: 4,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item['emp_name'] ?? '-',
style: GoogleFonts.poppins(
color: Color(0xFF000000),
fontWeight: FontWeight.w400,
fontSize: 12),
),
Text(
item['policy_no'] ?? '-',
style: GoogleFonts.poppins(
color: Color(0xFF585757),
fontWeight: FontWeight.w300,
fontSize: 10),
),
Text(item['policy_type'] ?? '-', style: _dataBold),
Text(item['client_policy_no'] ?? '-', style: _dataSub),
],
),
),
Expanded(
flex: 3,
child: Text(
"${item['claim_no'] ?? ''}",
style: GoogleFonts.poppins(
color: Color(0xFF000000),
fontWeight: FontWeight.w400,
fontSize: 12),
),
child: Text(item['claim_no'] ?? '-', style: _dataBold),
),
Expanded(
flex: 2,
flex: 4,
child: Align(
alignment: Alignment.bottomLeft,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 4, vertical: 4),
padding:
const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
decoration: BoxDecoration(
color: Color(0xFF7BD9B6),
// color: (item['emp_is_active'] == "1")
// ? Color(0xFF7BD9B6)
// : Color(0xFFFFA6A6),
borderRadius: BorderRadius.circular(6),
),
child: Align(
alignment: Alignment.center,
child: Text(
"${item['status'] ?? ''}",
style: GoogleFonts.poppins(
color: Color(0xFF000000),
fontWeight: FontWeight.w500,
fontSize: 12,
),
),
),
),
),
Expanded(
flex: 3,
child: Text(
"${item['claim_amount'] ?? ''}",
style: GoogleFonts.poppins(
color: Color(0xFF000000),
fontWeight: FontWeight.w400,
fontSize: 12),
child: Text(item['status'] ?? '-', style: _dataBold)),
),
),
Expanded(
flex: 3,
child: Text(
"${item['ticket_created_date'] ?? ''}",
style: GoogleFonts.poppins(
color: Color(0xFF000000),
fontWeight: FontWeight.w400,
fontSize: 12),
child: Text(item['claim_amount'] ?? '-', style: _dataBold),
),
Expanded(
flex: 3,
child: Text(item['ticket_created_date'] ?? '-', style: _dataBold),
),
Expanded(
flex: 2,
@ -463,15 +702,16 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
height: 30,
width: 30,
decoration: BoxDecoration(
color: Color(0xFFE6F5F6),
borderRadius: BorderRadius.circular(12)),
child: Icon(Icons.credit_card,
color: Color(0xFF3D3D3D)),
// child: Image.asset(
// 'assets/ecard.jpg',
// height: 20,
// fit: BoxFit.cover,
// ),
color: Color(0xFF86D1D4),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: EdgeInsets.all(6), // You can adjust this value
child: Image.asset(
'assets/claimHistory.png',
fit: BoxFit.contain,
),
),
),
),
],
@ -480,13 +720,27 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
],
),
);
}).toList(),
),
),
}
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
static final _dataBold = GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
);
static final _dataSub = GoogleFonts.poppins(
fontSize: 10,
fontWeight: FontWeight.w300,
color: Color(0xFF585757),
);
static const _headerStyle = TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
);
Widget _buildPagination(BuildContext context) {
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Row(
@ -545,8 +799,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
),
),
IconButton(
onPressed: _currentPage <
(filteredData.length / _rowsPerPage).ceil()
onPressed:
_currentPage < (filteredData.length / _rowsPerPage).ceil()
? () {
setState(() {
_currentPage++;
@ -558,10 +812,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
],
),
),
],
),
],
);
]);
}
Widget _buildName(BuildContext context) {
@ -808,6 +1059,39 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
Widget _buildPolicyType(BuildContext context) {
List<dynamic> ticketTypeList = getClaimPoliciesApi['ticket_type'] ?? [];
// Get type_name from ticket_type id
String? getTypeNameById(int? id) {
if (id == null) return null;
final match = ticketTypeList.firstWhere(
(e) => e['ticket_type'] == id,
orElse: () => null,
);
return match != null ? match['type_name'] : null;
}
// Get id from type_name
int? getIdByTypeName(String? typeName) {
print("getIdByTypeName");
print("getIdByTypeName - $typeName");
final match = ticketTypeList.firstWhere(
(e) => e['type_name'] == typeName,
orElse: () => null,
);
print("match - $match");
if (match != null && match is Map) {
final map = match as Map;
final id = map['ticket_type'];
print("Returning ticket_type: $id");
return id is int ? id : int.tryParse(id.toString());
}
print("no match or invalid map");
return null;
}
return Container(
width: MediaQuery.of(context).size.width * 0.22,
child: Column(
@ -821,32 +1105,21 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
SizedBox(
height: 40,
child: DropdownSearch<String>(
selectedItem: selectedPolicyType,
selectedItem: selectedPolicyTypeName,
items: (String? filter, _) {
List<String> allItems = ticketTypeList
return ticketTypeList
.map<String>((item) => item['type_name'].toString())
.toList();
if (filter == null || filter.isEmpty) return allItems;
return allItems
.where((element) =>
element.toLowerCase().contains(filter.toLowerCase()))
.toList();
},
onChanged: (value) {
setState(() {
// Find corresponding ticket_type ID
var selectedItem = ticketTypeList.firstWhere(
(e) => e['type_name'] == value,
orElse: () => null,
);
if (selectedItem != null) {
print(
"Selected ticket_type: ${selectedItem['ticket_type']}");
selectedPolicyType = selectedItem['ticket_type'];
}
selectedPolicyTypeName = value;
selectedPolicyType = getIdByTypeName(value);
});
print(
"Selected selectedPolicyTypeName: $selectedPolicyTypeName");
print("Selected selectedPolicyType: $selectedPolicyType");
},
decoratorProps: DropDownDecoratorProps(
decoration: InputDecoration(
@ -871,7 +1144,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
EdgeInsets.symmetric(horizontal: 12, vertical: 10),
),
),
popupProps: PopupProps.menu(
popupProps: const PopupProps.menu(
showSearchBox: true,
searchFieldProps: TextFieldProps(
decoration: InputDecoration(
@ -891,12 +1164,46 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
Widget _buildClaimStatus(BuildContext context) {
List<dynamic> claimStatusList = getClaimPoliciesApi['claim_status'] ?? [];
// Get type_name from ticket_type id
String? getTypeNameById(int? id) {
if (id == null) return null;
final match = claimStatusList.firstWhere(
(e) => e['id'] == id,
orElse: () => null,
);
return match != null ? match['claim_status'] : null;
}
// Get id from type_name
int? getIdByTypeName(String? typeName) {
print("getIdByTypeName");
print("getIdByTypeName - $typeName");
final match = claimStatusList.firstWhere(
(e) => e['claim_status'] == typeName,
orElse: () => null,
);
print("match - $match");
if (match != null && match is Map) {
final map = match as Map;
final id = map['id'];
print("Returning id: $id");
return id is int ? id : int.tryParse(id.toString());
}
print("no match or invalid map");
return null;
}
return Container(
width: MediaQuery.of(context).size.width * 0.22,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
const Text(
"Claim Status",
style: TextStyle(fontSize: 12),
),
@ -906,33 +1213,55 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
SizedBox(
height: 40,
child: DropdownSearch<String>(
selectedItem: selectedClaimStatus,
selectedItem: selectedClaimStatusName,
items: (String? filter, _) {
List<String> allItems = claimStatusList
return claimStatusList
.map<String>((item) => item['claim_status'].toString())
.toList();
if (filter == null || filter.isEmpty) return allItems;
return allItems
.where((element) =>
element.toLowerCase().contains(filter.toLowerCase()))
.toList();
},
onChanged: (value) {
setState(() {
// Find corresponding ticket_type ID
var selectedItem = claimStatusList.firstWhere(
(e) => e['claim_status'] == value,
orElse: () => null,
);
if (selectedItem != null) {
print(
"Selected ticket_type: ${selectedItem['ticket_type']}");
selectedClaimStatus = selectedItem['ticket_type'];
}
selectedClaimStatusName = value;
selectedClaimStatus = getIdByTypeName(value);
});
print(
"Selected selectedClaimStatusName: $selectedClaimStatusName");
print("Selected selectedClaimStatus: $selectedClaimStatus");
},
// selectedItem: selectedClaimStatus,
// selectedItem: getTypeNameById(selectedClaimStatus),
// items: (String? filter, _) {
// List<String> allItems = claimStatusList
// .map<String>((item) => item['claim_status'].toString())
// .toList();
//
// if (filter == null || filter.isEmpty) return allItems;
//
// return allItems
// .where((element) =>
// element.toLowerCase().contains(filter.toLowerCase()))
// .toList();
// },
//
// onChanged: (value) {
// if (!mounted) return;
// print("Selected ticket_type11: $value");
//
// final id = getIdByTypeName(value);
// print("getIdByTypeName returned: $id");
//
// if (id != null) {
// setState(() {
// selectedClaimStatus = id;
// });
// } else {
// print("No match found for $value");
// }
// },
decoratorProps: DropDownDecoratorProps(
decoration: InputDecoration(
constraints: BoxConstraints(maxHeight: 200),
@ -1032,7 +1361,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
ElevatedButton.icon(
Expanded(
child: ElevatedButton.icon(
onPressed: () {
applyFilter();
},
@ -1053,8 +1383,15 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
),
),
),
ElevatedButton.icon(
onPressed: () {},
),
SizedBox(
width: 10,
),
Expanded(
child: ElevatedButton.icon(
onPressed: () {
reset();
},
icon: const Icon(Icons.refresh_outlined,
color: Colors.white, size: 18),
label: const Text(
@ -1072,6 +1409,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
),
),
),
),
],
),
);

View File

@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation
import file_picker
import firebase_auth
import firebase_core
import google_sign_in_ios
@ -14,6 +15,7 @@ import smart_auth
import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))