From ad396fefb0b0e55582bb48ad929d06fbb9499f13 Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Fri, 20 Feb 2026 11:20:45 +0530 Subject: [PATCH] UAT bug fix --- lib/presentation/RaiseClaimForm.dart | 41 +++- lib/presentation/cdTransactionDetails.dart | 6 +- lib/presentation/claims.dart | 9 +- lib/presentation/hrPolicyDetails.dart | 211 +++++++++++---------- lib/presentation/preFileUpload.dart | 30 ++- 5 files changed, 187 insertions(+), 110 deletions(-) diff --git a/lib/presentation/RaiseClaimForm.dart b/lib/presentation/RaiseClaimForm.dart index b541f5a..27a3eb4 100644 --- a/lib/presentation/RaiseClaimForm.dart +++ b/lib/presentation/RaiseClaimForm.dart @@ -144,6 +144,7 @@ class _RaiseClaimDialogState extends State { bool isIntimationDateValid = true; bool isAdmitDateValid = true; bool isDischargeDateValid = true; + bool isAccidentService = false; @override void initState() { @@ -395,6 +396,8 @@ class _RaiseClaimDialogState extends State { // ☠ Accident / Death final isAccident = [2, 3, 4].contains(serviceId); + isAccidentService = isAccident ? true : false; + isAccidentDateValid = !isAccident || accidentDate != null; isIntimationDateValid = !isAccident || intimationDate != null; }); @@ -1129,12 +1132,33 @@ class _RaiseClaimDialogState extends State { value: selectedValue, hint: const Text('Select'), icon: const Icon(Icons.keyboard_arrow_down), + + /// ✅ This controls selected value (closed state) + selectedItemBuilder: (context) { + return itemsList.map((item) { + return Align( + alignment: Alignment.centerLeft, + child: Text( + item[displayField] ?? '', + maxLines: 1, + overflow: TextOverflow.ellipsis, + softWrap: false, + ), + ); + }).toList(); + }, + + /// ✅ This controls dropdown list (open state) items: itemsList.map>((item) { return DropdownMenuItem( value: item['id'], - child: Text(item[displayField]), + child: Text( + item[displayField] ?? '', + style: const TextStyle(fontSize: 13), + ), // FULL TEXT here ); }).toList(), + onChanged: onChanged, ), ), @@ -1146,6 +1170,7 @@ class _RaiseClaimDialogState extends State { + Widget buildDropdownFieldSearch( String label, void Function(int?) onChanged, @@ -1215,7 +1240,16 @@ class _RaiseClaimDialogState extends State { ), ), searchMatchFn: (item, searchValue) { - final text = item.child.toString().toLowerCase(); + final matchedItem = itemsList.firstWhere( + (e) => e['id'] == item.value, + orElse: () => {}, + ); + + final text = matchedItem[displayField] + ?.toString() + .toLowerCase() ?? + ''; + return text.contains(searchValue.toLowerCase()); }, ), @@ -1229,7 +1263,8 @@ class _RaiseClaimDialogState extends State { return DropdownMenuItem( value: item['id'], child: Text( - item[displayField], + item[displayField] ?? '', + style: const TextStyle(fontSize: 12), overflow: TextOverflow.ellipsis, ), ); diff --git a/lib/presentation/cdTransactionDetails.dart b/lib/presentation/cdTransactionDetails.dart index c73b8d0..e45c9c6 100755 --- a/lib/presentation/cdTransactionDetails.dart +++ b/lib/presentation/cdTransactionDetails.dart @@ -387,9 +387,9 @@ class _cdTransactionDetailsState extends State { : '-', item['endorsement_no'] ?? '', item['sub_type_text'] ?? '', - item['transaction_type'] == 'Credit' ? '₹${item['amount']}' : '-', - item['transaction_type'] == 'Debit' ? '₹${item['amount']}' : '-', - '₹${item['balance'] ?? '0'}', + item['transaction_type'] == 'Credit' ? '₹${formatAmount(item['amount'])}' : '-', + item['transaction_type'] == 'Debit' ? '₹${formatAmount(item['amount'])}' : '-', + '₹${formatAmount(item['balance']) ?? '0'}', item['description'] ?? '', item['username'] ?? '', ]); diff --git a/lib/presentation/claims.dart b/lib/presentation/claims.dart index b7df781..5114d91 100755 --- a/lib/presentation/claims.dart +++ b/lib/presentation/claims.dart @@ -1527,7 +1527,12 @@ class _ClaimsPolicieState extends State { ), ), searchMatchFn: (item, searchValue) { - final text = item.child.toString().toLowerCase(); + final matchedItem = itemsList.firstWhere( + (e) => e['id'] == item.value, + orElse: () => {}, + ); + + final text = matchedItem['name']?.toString().toLowerCase() ?? ''; return text.contains(searchValue.toLowerCase()); }, ), @@ -1542,7 +1547,7 @@ class _ClaimsPolicieState extends State { return DropdownMenuItem( value: item['id'], child: Text( - item[displayField], + item[displayField] ?? '', style: const TextStyle(fontSize: 12), overflow: TextOverflow.ellipsis, ), diff --git a/lib/presentation/hrPolicyDetails.dart b/lib/presentation/hrPolicyDetails.dart index fd0bc36..072019c 100755 --- a/lib/presentation/hrPolicyDetails.dart +++ b/lib/presentation/hrPolicyDetails.dart @@ -350,58 +350,62 @@ class _HrPolicyDetailsState extends State } void search(String query) { - print(query); - // Check if the query is empty - if (query.isEmpty) { - // If search query is empty, show all data + final lowerQuery = query.toLowerCase().trim(); + + if (lowerQuery.isEmpty) { setState(() { filteredData = List.from(originalData); }); } else { - // Filter the original data based on the search query setState(() { filteredData = originalData.where((row) { - final empStatus = row['emp_is_active'] == 1 ? 'active' : 'Inactive'; - // Implement your filter logic here - // For example, check if any field in the row contains the query - // Adjust this logic based on your data structure + + final status = + row['status']?.toString().toLowerCase().trim() ?? ''; + + bool statusMatch; + + if (lowerQuery == 'active' || lowerQuery == 'inactive') { + // ✅ Exact match for these two + statusMatch = status == lowerQuery; + } else { + // ✅ Partial match for others + statusMatch = status.contains(lowerQuery); + } + return row['name'] - .toString() - .toLowerCase() - .contains(query.toLowerCase()) || + ?.toString() + .toLowerCase() + .contains(lowerQuery) == true || row['uhid'] - .toString() + ?.toString() .toLowerCase() - .contains(query.toLowerCase()) || + .contains(lowerQuery) == true || row['relationship'] - .toString() + ?.toString() .toLowerCase() - .contains(query.toLowerCase()) || - row['formatted_dob'].replaceAll("/", "-") - .toString() + .contains(lowerQuery) == true || + row['formatted_dob'] + ?.toString() + .replaceAll("/", "-") .toLowerCase() - .contains(query.toLowerCase()) || + .contains(lowerQuery) == true || row['gender'] - .toString() + ?.toString() .toLowerCase() - .contains(query.toLowerCase()) || + .contains(lowerQuery) == true || row['mobile'] - .toString() + ?.toString() .toLowerCase() - .contains(query.toLowerCase()) || + .contains(lowerQuery) == true || row['email_corporate'] - .toString() + ?.toString() .toLowerCase() - .contains(query.toLowerCase()) || - row['status'] - .toString() - .toLowerCase() - .contains(query.toLowerCase()) || - empStatus.contains(query.toLowerCase()); + .contains(lowerQuery) == true || + statusMatch; }).toList(); }); } - print(filteredData.length); } // emp_is_active @@ -1578,81 +1582,96 @@ class _HrPolicyDetailsState extends State return SizedBox(); // No icon to show } - return Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // --- eCard Button --- - if (showEcard) - Tooltip( - message: 'Download e-Card', - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - getEcardDownload( - item['emp_code'], - item['employee_id'], - item['client_policy_id'], - item['policy_no']); - }, - child: Container( - height: 40, - width: 40, - decoration: BoxDecoration( - color: Color(0xFFE6F5F6), - borderRadius: BorderRadius.circular(8), - ), - child: Padding( - padding: EdgeInsets.all(4), - child: Image.asset( - 'assets/credit_card.png', - fit: BoxFit.contain, - ), - ), - ), - ), - ), - ), + return SizedBox( + height: 40, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ - if (showEcard && showClaim) SizedBox(width: 8), - - // --- Claim Button --- - if (showClaim) - Tooltip( - message: 'View Claims', - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ClaimsPolicies( - empCode: item['emp_code']!, + /// --- eCard Button (Fixed Space) --- + SizedBox( + width: 40, + height: 40, + child: Visibility( + visible: showEcard, + maintainSize: true, + maintainAnimation: true, + maintainState: true, + child: Tooltip( + message: 'Download e-Card', + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + getEcardDownload( + item['emp_code'], + item['employee_id'], + item['client_policy_id'], + item['policy_no'], + ); + }, + child: Container( + decoration: BoxDecoration( + color: const Color(0xFFE6F5F6), + borderRadius: BorderRadius.circular(8), + ), + padding: const EdgeInsets.all(6), + child: Image.asset( + 'assets/credit_card.png', + fit: BoxFit.contain, ), ), - ); - }, - child: Container( - height: 40, - width: 40, - decoration: BoxDecoration( - color: Color(0xFFE6F5F6), - borderRadius: BorderRadius.circular(8), ), - child: Padding( - padding: EdgeInsets.all(4), - child: Image.asset( - 'assets/claim.png', - fit: BoxFit.contain, + ), + ), + ), + ), + + const SizedBox(width: 8), + + /// --- Claim Button (Fixed Space) --- + SizedBox( + width: 40, + height: 40, + child: Visibility( + visible: showClaim, + maintainSize: true, + maintainAnimation: true, + maintainState: true, + child: Tooltip( + message: 'View Claims', + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ClaimsPolicies( + empCode: item['emp_code']!, + ), + ), + ); + }, + child: Container( + decoration: BoxDecoration( + color: const Color(0xFFE6F5F6), + borderRadius: BorderRadius.circular(8), + ), + padding: const EdgeInsets.all(6), + child: Image.asset( + 'assets/claim.png', + fit: BoxFit.contain, + ), ), ), ), ), ), ), - ], + ], + ), ); }, ), diff --git a/lib/presentation/preFileUpload.dart b/lib/presentation/preFileUpload.dart index 3469d36..665eaf1 100755 --- a/lib/presentation/preFileUpload.dart +++ b/lib/presentation/preFileUpload.dart @@ -520,7 +520,7 @@ class _excelVerifyState extends State { isLoading = false; Map data = json.decode(responseString); if (data['status'] == false) { - ToastHelper.showSuccessToast(context, data['message']); + ToastHelper.showErrorToast(context, data['message']); print('Table'); setState(() { @@ -787,13 +787,21 @@ class _excelVerifyState extends State { final picked = await showDatePicker( context: context, firstDate: DateTime(2000), - lastDate: DateTime(2100), + lastDate: DateTime.now(), initialDate: DateTime.now(), ); if (picked != null) { - openDateController.text = - DateFormat('dd-MM-yyyy').format(picked); + final formatted = + DateFormat('dd-MM-yyyy').format(picked); + + // ✅ If open date changed, clear close date + if (openDateController.text != formatted) { + closeDateController.clear(); + } + + openDateController.text = formatted; } + }, ), ), @@ -804,12 +812,22 @@ class _excelVerifyState extends State { label: 'Enrolment Close Date', controller: closeDateController, onTap: () async { + + if (openDateController.text.isEmpty) { + ToastHelper.showErrorToast(context, 'Please select Enrolment Open Date first'); + return; + } + + final openDate = DateFormat('dd-MM-yyyy') + .parse(openDateController.text); + final picked = await showDatePicker( context: context, - firstDate: DateTime(2000), + firstDate: openDate, // ✅ Cannot select before open date lastDate: DateTime(2100), - initialDate: DateTime.now(), + initialDate: openDate, ); + if (picked != null) { closeDateController.text = DateFormat('dd-MM-yyyy').format(picked);