From c7d8b9504e1e0d47f4a479766fe724dea3cc30f2 Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Mon, 16 Mar 2026 14:32:47 +0530 Subject: [PATCH 1/2] api status code added --- lib/pages/changePassword.dart | 35 +- lib/pages/email_verify.dart | 125 +- lib/pages/enrollment/service/api_service.dart | 15 +- lib/pages/login.dart | 67 +- lib/pages/postEnrollment/claims.dart | 4 +- lib/pages/postEnrollment/planclaimsform.dart | 1389 +++++++++-------- .../postEnrollment/service/api_service.dart | 50 +- lib/pages/session/SetPinBiometric.dart | 48 +- lib/pages/session/changePin.dart | 26 +- .../session/settingUpPinAndBiometric.dart | 24 +- lib/pages/setPassword.dart | 35 +- 11 files changed, 1027 insertions(+), 791 deletions(-) diff --git a/lib/pages/changePassword.dart b/lib/pages/changePassword.dart index c66c339..3b0439a 100755 --- a/lib/pages/changePassword.dart +++ b/lib/pages/changePassword.dart @@ -116,12 +116,43 @@ class _changesPasswordState extends State { ToastHelper.showErrorToast(context, message!); print('Invalid mobile number'); } + } else if (response.statusCode == 401) { + setState(() { + _isLoading = false; + }); + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 403) { + setState(() { + _isLoading = false; + }); + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 451) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); } else { setState(() { _isLoading = false; }); - ToastHelper.showErrorToast(context, 'Something went wrong'); - throw Exception('Failed to verify mobile number'); + throw Exception('Failed to load data'); } } } catch (e) { diff --git a/lib/pages/email_verify.dart b/lib/pages/email_verify.dart index 6ed1791..6a54549 100755 --- a/lib/pages/email_verify.dart +++ b/lib/pages/email_verify.dart @@ -268,13 +268,18 @@ class _MyEmailVerifyState extends State { String status = data['status']; // Directly access the post_enrollment data - Map post = data['post_enrollment']; + Map? post; + + if (data['post_enrollment'] != null && + data['post_enrollment'] is Map) { + post = data['post_enrollment']; + } + print('post: $post'); _postToken = postToken; - String postStatus = post['status']; - if (postStatus == 'success') { + if (post != null && post['status'] == 'success') { setState(() { _isOtpVerified = true; // ✅ LOCK }); @@ -291,11 +296,43 @@ class _MyEmailVerifyState extends State { // Show a Snackbar if the OTP is invalid print('OTP verification failed. Please try again.'); } + } else if (response.statusCode == 401) { + setState(() { + _isLoading = false; + }); + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 403) { + setState(() { + _isLoading = false; + }); + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 451) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); } else { - final SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.clear(); - ToastHelper.showWarningToast(context, 'Something went wrong'); - throw Exception('Failed to verify OTP'); + setState(() { + _isLoading = false; + }); + throw Exception('Failed to load data'); } } catch (e) { final SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -882,42 +919,6 @@ class _MyEmailVerifyState extends State { ), ), ), - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Expanded( - flex: 2, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - context.go('/hrLogin'); - // Navigator.pushNamed( - // context, 'hrLogin'); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align to the end (right) - children: [ - Text( - 'HR Login', - style: GoogleFonts.poppins( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], - ), - ), - ), - ), ], ), ], @@ -948,38 +949,40 @@ class _MyEmailVerifyState extends State { MainAxisAlignment.center, children: [ if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) + !Responsive.isTablet(context))...[ Row( children: [ Expanded( flex: 10, child: Align( alignment: Responsive - .isDesktop(context) + .isDesktop(context) ? Alignment.center : Alignment - .bottomCenter, // Align to the start + .bottomCenter, // Align to the start child: _size.width <= 1100 ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) : _size.width > 1100 - ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) - : Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), + ? Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) + : Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ), )), ], ), - SizedBox(height: 10), + SizedBox(height: 10), + ], + // SizedBox( // height: Responsive.isDesktop(context) // ? _size.height * 0.1 diff --git a/lib/pages/enrollment/service/api_service.dart b/lib/pages/enrollment/service/api_service.dart index 5fb12a1..e6f750e 100755 --- a/lib/pages/enrollment/service/api_service.dart +++ b/lib/pages/enrollment/service/api_service.dart @@ -503,13 +503,18 @@ class ApiService { if (response.statusCode == 200) { return jsonDecode(response.body); } else if (response.statusCode == 401) { - if (!_isSessionOutToastShown) { - _isSessionOutToastShown = true; - await _clearLocalStorageAndRedirect(); - } + await _clearLocalStorageAndRedirect(); + return {}; + } else if (response.statusCode == 403) { + await _clearLocalStorageAndRedirect(); + return {}; + } else if (response.statusCode == 451) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); return {}; } else if (response.statusCode == 429) { - final body = jsonDecode(response.body); + final body = jsonDecode(response.body); final message = body['message']; ToastHelper.showWarningToast(context, message); return {}; diff --git a/lib/pages/login.dart b/lib/pages/login.dart index 4d794a1..3949ed1 100755 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -172,9 +172,35 @@ class _loginState extends State { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.clear(); } + } else if (response.statusCode == 401) { + setState(() { + _isLoading = false; + }); + ToastHelper.showErrorToast(context, 'Session Out'); + } else if (response.statusCode == 403) { + setState(() { + _isLoading = false; + }); + ToastHelper.showErrorToast(context, 'Session Out'); + } else if (response.statusCode == 451) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); } else { - ToastHelper.showErrorToast(context, 'Something went wrong'); - throw Exception('Failed to verify pin number'); + setState(() { + _isLoading = false; + }); + throw Exception('Failed to load data'); } } catch (e) { // ToastHelper.showErrorToast(context, 'Something went wrong'); @@ -1072,43 +1098,6 @@ class _loginState extends State { height: 100, )), ), - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Expanded( - flex: 2, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'hrLogin'); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align to the end (right) - children: [ - Text( - 'HR Login', - style: TextStyle( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], - ), - ), - ), - ), ], ), ], diff --git a/lib/pages/postEnrollment/claims.dart b/lib/pages/postEnrollment/claims.dart index 8f97935..1383301 100755 --- a/lib/pages/postEnrollment/claims.dart +++ b/lib/pages/postEnrollment/claims.dart @@ -1262,8 +1262,8 @@ class _claimsState extends State { message: claimsSubject, // Full text shown on hover child: Text( - claimsSubject.length > 30 - ? '${claimsSubject.substring(0, 30)}...' + claimsSubject.length > 20 + ? '${claimsSubject.substring(0, 20)}...' : claimsSubject, textAlign: TextAlign.left, style: GoogleFonts.poppins( diff --git a/lib/pages/postEnrollment/planclaimsform.dart b/lib/pages/postEnrollment/planclaimsform.dart index f82d69b..8440823 100755 --- a/lib/pages/postEnrollment/planclaimsform.dart +++ b/lib/pages/postEnrollment/planclaimsform.dart @@ -80,6 +80,11 @@ class _planclaimsformState extends State { final fileService = FileUploadService(); bool isSubmitting = false; + Map claimTypeMap = {}; + List> claimTypeList = []; + int? claimTypeId; + bool isClaimTypeValid = true; + // Declare subjectController and bodyController as instance variables late TextEditingController subjectController; @@ -206,16 +211,20 @@ class _planclaimsformState extends State { print('fromClaimsPage $fromClaimsPage'); } if (fromClaimsPage == 0) { - claimSubject = claimsDetails['claim_subject']; - print('claimSubject $claimSubject'); - claimsDepartmentId = claimsDetails['ticket_type_id']; - rawPolicyStartDate = claimsDetails['policy_start_date']; - print('rawPolicyStartDate $rawPolicyStartDate'); - rawPolicyEndDate = claimsDetails['claims_grace_date']; - print('rawpolicyEndDate $rawPolicyEndDate'); - print('claimsDepartmentId $claimsDepartmentId'); - claimsPolicyNo = claimsDetails['policy_no']; - client_policy_id = claimsDetails['client_policy_id']; + setState(() { + claimSubject = claimsDetails['claim_subject']; + print('claimSubject $claimSubject'); + claimsDepartmentId = claimsDetails['ticket_type_id']; + rawPolicyStartDate = claimsDetails['policy_start_date']; + print('rawPolicyStartDate $rawPolicyStartDate'); + rawPolicyEndDate = claimsDetails['claims_grace_date']; + print('rawpolicyEndDate $rawPolicyEndDate'); + print('claimsDepartmentId $claimsDepartmentId'); + claimsPolicyNo = claimsDetails['policy_no']; + client_policy_id = claimsDetails['client_policy_id']; + print('Current Client ID : ${client_policy_id}'); + }); + // employeePolicyList = claimsDetails['EmployeePolicy']; // print('employeePolicyList : $employeePolicyList'); List empList = claimsDetails['EmployeePolicy']; @@ -285,11 +294,11 @@ class _planclaimsformState extends State { try { // Call both APIs final responseActive = await apiService.getActiveAndInactivePolicyDetails( - client_id!, empCodeString!, 'Active', client_branch_id,mobileNo,emailId + client_id!, empCodeString!, 'Active', client_branch_id,mobileNo,emailId ); final responseInactive = await apiService.getActiveAndInactivePolicyDetails( - client_id!, empCodeString!, 'Inactive', client_branch_id,mobileNo,emailId + client_id!, empCodeString!, 'Inactive', client_branch_id,mobileNo,emailId ); final bool isActiveSuccess = responseActive['status'] == 'success' && responseActive['data'] != null; @@ -367,11 +376,23 @@ class _planclaimsformState extends State { // 'private': department['private'], }; }).toList(); + + claimTypeMap = Map.from(response['claim_type']); isLoading = false; }); + // ✅ AUTO SELECT SERVICE = 1 (GMC) + if (fromClaimsPage == 1 && departmentList.isNotEmpty) { + serviceId = 1; + loadClaimTypes(serviceId); + } + if (fromClaimsPage == 0) { setInitialServiceId(departmentList); + loadClaimTypes(claimsDepartmentId); } + // if (fromClaimsPage == 0) { + // setInitialServiceId(departmentList); + // } } else { throw Exception('Failed to fetch department list'); } @@ -380,6 +401,35 @@ class _planclaimsformState extends State { } } + void loadClaimTypes(int? serviceId) { + if (serviceId == null) return; + + String key = serviceId.toString(); + + if (claimTypeMap.containsKey(key)) { + Map types = + Map.from(claimTypeMap[key]); + + claimTypeList = types.entries.map((entry) { + return { + 'id': int.parse(entry.key), + 'name': entry.value, + }; + }).toList(); + + // // ✅ AUTO SELECT FIRST CLAIM TYPE + // if (claimTypeList.isNotEmpty) { + // claimTypeId = claimTypeList.first['id']; + // } + + setState(() {}); + } else { + claimTypeList = []; + claimTypeId = null; + setState(() {}); + } + } + void fetchPoliciesBasedOnService(int? serviceId) { if (policyList.isEmpty) { print('Policy list is empty. Ensure data is fetched before filtering.'); @@ -388,7 +438,7 @@ class _planclaimsformState extends State { setState(() { policyNumberId = null; policyTypeCondition = null; - client_policy_id = null; + // client_policy_id = null; }); print('1111 serviceId : $serviceId'); if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4 || serviceId == 72) { @@ -425,7 +475,7 @@ class _planclaimsformState extends State { if (fromClaimsPage == 0) { // Find the object where 'policy_no' matches 'claimsPolicyNo' final matchingPolicy = policyNumberList.firstWhere( - (item) => item['policy_no'] == claimsPolicyNo, + (item) => item['policy_no'] == claimsPolicyNo, orElse: () => {}); // Set policyNumberId to the matching policy's ID @@ -445,7 +495,7 @@ class _planclaimsformState extends State { }); policyTypeCondition = filteredPolicies[0]['ticket_type_id']; - client_policy_id = filteredPolicies[0]['client_policy_id']; + // client_policy_id = filteredPolicies[0]['client_policy_id']; print('Output : $policyTypeCondition'); // Output: GMC }); } else { @@ -496,7 +546,7 @@ class _planclaimsformState extends State { print('Filtered matching policy_no: $filteredPoliciesList'); - client_policy_id = filteredPoliciesList[0]['client_policy_id']; + // client_policy_id = filteredPoliciesList[0]['client_policy_id']; subjectController.text = filteredPoliciesList[0]['claim_subject']; @@ -554,6 +604,7 @@ class _planclaimsformState extends State { isHospitalPincodeValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || hospitalPinCodeController.text.trim().isNotEmpty; isHospitalPhoneNoValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || hospitalPhoneNoController.text.trim().isNotEmpty; // isAdmitDischargeValid = policyTypeCondition != 1 || (admitDate != null && dischargeDate != null); + isClaimTypeValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || claimTypeId != null; isAdmitDateValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || admitDate != null; isDischargeDateValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || dischargeDate != null; isClaimAmountValid = serviceId != 1 || claimAmountController.text.trim().isNotEmpty; @@ -562,6 +613,7 @@ class _planclaimsformState extends State { }); if (isServiceValid && + isClaimTypeValid && isPolicyValid && isMemberValid && isSubjectValid && @@ -618,8 +670,8 @@ class _planclaimsformState extends State { 'policy_name': serviceId == 1 ? null : (fromClaimsPage == 0 - ? claimsDetails['policy_name'] - : filteredPoliciesList[0]['policy_name']), + ? claimsDetails['policy_name'] + : filteredPoliciesList[0]['policy_name']), }; @@ -627,6 +679,7 @@ class _planclaimsformState extends State { if (policyTypeCondition == 1 || policyTypeCondition == 72) { String formattedAdmitDate = DateFormat('yyyy-MM-dd').format(admitDate!); String formattedDischargeDate = DateFormat('yyyy-MM-dd').format(dischargeDate!); + fields['claim_type'] = claimTypeId; fields['hospital_name'] = hospitalNameController.text; fields['hospital_address'] = hospitalAddressController.text; fields['hospital_city'] = hospitalCityController.text; @@ -641,11 +694,11 @@ class _planclaimsformState extends State { fields['insured_emp_id'] = selectedMemberId; } else { String formattedAccidentDate = - DateFormat('yyyy-MM-dd').format(accidentDate!); + DateFormat('yyyy-MM-dd').format(accidentDate!); String formattedDeathDate = DateFormat('yyyy-MM-dd').format(deathDate!); String formattedBirthDate = DateFormat('yyyy-MM-dd').format(birthDate!); String formattedIntimationDate = - DateFormat('yyyy-MM-dd').format(intimationDate!); + DateFormat('yyyy-MM-dd').format(intimationDate!); fields['date_of_accident'] = formattedAccidentDate; fields['dob'] = formattedBirthDate; fields['date_of_intimat'] = formattedIntimationDate; @@ -662,6 +715,7 @@ class _planclaimsformState extends State { request.headers['Authorization'] = 'Bearer $_token'; request.headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; final stringFields = fields.map((key, value) => MapEntry(key, value?.toString() ?? '')); + print("📁 stringFields: ${stringFields}"); request.fields.addAll(stringFields); // get uploaded files @@ -882,653 +936,682 @@ class _planclaimsformState extends State { context.go('/$route'); }, child: Scaffold( - backgroundColor: Colors.white, - appBar: CustomAppBar(), - body: Stack(children: [ - SingleChildScrollView( - child: Container( - padding: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width * - 0.2, // 30% of screen width as horizontal padding - vertical: MediaQuery.of(context).size.height * - 0.05, // 5% of screen height as vertical padding - ) - : EdgeInsets.all(10), - color: Colors.white, - child: Column(children: [ - Card( - elevation: 5, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(15.0), // Set border radius here - ), - child: Container( - decoration: BoxDecoration( - color: Colors.white, // Set background color to white - borderRadius: BorderRadius.circular( - 15.0), // Set border radius for Container - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15) - : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - color: Color( - 0xFFFFFCE5), // Set background color for the container - borderRadius: BorderRadius.circular( - 10), // Set border radius for the container - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 20, - bottom: 20, - left: 0, - right: 0) - : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - final route = fromClaimsPage == 0 ? 'claims' : 'help'; - context.go('/$route'); - }, - child: Icon( - Icons - .chevron_left, // Replace with your desired icon - color: Color(0xFF000000), - size: 30, - ), - ), + backgroundColor: Colors.white, + appBar: CustomAppBar(), + body: Stack(children: [ + SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.05, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Colors.white, + child: Column(children: [ + Card( + elevation: 5, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(15.0), // Set border radius here + ), + child: Container( + decoration: BoxDecoration( + color: Colors.white, // Set background color to white + borderRadius: BorderRadius.circular( + 15.0), // Set border radius for Container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFFCE5), // Set background color for the container + borderRadius: BorderRadius.circular( + 10), // Set border radius for the container ), - Expanded( - flex: 11, - child: Row( - mainAxisAlignment: - Responsive.isDesktop(context) - ? MainAxisAlignment.center - : MainAxisAlignment.start, - children: [ - Text( - fromClaimsPage == 0 - ? claimsDetails[ + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, + bottom: 20, + left: 0, + right: 0) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + final route = fromClaimsPage == 0 ? 'claims' : 'help'; + context.go('/$route'); + }, + child: Icon( + Icons + .chevron_left, // Replace with your desired icon + color: Color(0xFF000000), + size: 30, + ), + ), + ), + Expanded( + flex: 11, + child: Row( + mainAxisAlignment: + Responsive.isDesktop(context) + ? MainAxisAlignment.center + : MainAxisAlignment.start, + children: [ + Text( + fromClaimsPage == 0 + ? claimsDetails[ 'policy_name'] - : 'Raise a Request', - textAlign: TextAlign.start, - style: GoogleFonts.poppins( - fontSize: - Responsive.isDesktop( + : 'Raise a Request', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( context) - ? 20 - : 16, - fontWeight: FontWeight.w600, - color: Color(0xFF000000), - ), - ) - ], - ), - ) - ], - ), // Space between rows - // Add more rows as needed - ], - ), - ), - SizedBox(height: 15), - Container( - child: Column( - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Form( - key: formKey, - child: Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildDropdownField( - 'Service', - (value) { - setState(() { - serviceId = value; - selectedServiceName = departmentList.firstWhere( - (serList) => serList['id'] == value, - orElse: () => {'name': ''}, - )['name']; - policyNumberId = null; - if (fromClaimsPage == 1) { - fetchPoliciesBasedOnService(serviceId); - } - isServiceValid = true; - }); - }, - fromClaimsPage == 0, - departmentList, - 'name', - serviceId, + ? 20 + : 16, + fontWeight: FontWeight.w600, + color: Color(0xFF000000), ), - if (!isServiceValid) - Text('Please select a service', style: TextStyle(color: Colors.red)), - ], - ), - - // buildDropdownField( - // 'Service', - // (value) { - // setState(() { - // serviceId = value; - // selectedServiceName = - // departmentList - // .firstWhere( - // (serList) => - // serList[ - // 'id'] == - // value, - // orElse: () => - // {'name': ''}, - // )['name']; - // policyNumberId = - // null; - // if (fromClaimsPage == - // 1) { - // fetchPoliciesBasedOnService( - // serviceId); - // } - // }); - // }, - // fromClaimsPage == 0, - // departmentList, - // 'name', - // serviceId, // Pass current serviceId as selectedValue - // ), - SizedBox(height: 15), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildDropdownField( - 'Select Policy', - (value) { - setState(() { - policyNumberId = value; - selectedMemberId = null; - String? selectedPolicyNo = policyNumberList.firstWhere( - (item) => item['id'] == value, - orElse: () => {'policy_no': ''}, - )['policy_no']; - if (selectedPolicyNo != null && fromClaimsPage == 1) { - fetchMemberBasedOnPolicy(selectedPolicyNo); - } - isPolicyValid = true; - }); - }, - fromClaimsPage == 0, - policyNumberList, - 'policy_no', - policyNumberId, - ), - if (!isPolicyValid) - Text('Please select a policy', style: TextStyle(color: Colors.red)), - ], - ), - - // // if (fromClaimsPage == 1) - // buildDropdownField( - // 'Select Policy', - // (value) { - // setState(() { - // policyNumberId = - // value; - // selectedMemberId = - // null; - // String? - // selectedPolicyNo = - // policyNumberList - // .firstWhere( - // (item) => - // item['id'] == - // value, - // orElse: () => - // { - // 'policy_no': '' - // })['policy_no']; - // - // if (selectedPolicyNo != - // null && - // fromClaimsPage == - // 1) { - // fetchMemberBasedOnPolicy( - // selectedPolicyNo); - // } - // }); - // }, - // fromClaimsPage == 0, - // policyNumberList, - // 'policy_no', - // policyNumberId, // Pass current policyNumberId as selectedValue - // ), - SizedBox(height: 15), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildDropdownField( - 'Member Name', - (value) { - setState(() { - selectedMemberId = value; - selectedMemberName = employeePolicyList.firstWhere( - (member) => member['id'] == value, - orElse: () => {'name': ''}, - )['name']; - isMemberValid = true; - }); - }, - false, - employeePolicyList, - 'name', - selectedMemberId, - ), - if (!isMemberValid) - Text('Please select a member', style: TextStyle(color: Colors.red)), - ], - ), -SizedBox(height: 15), - // buildDropdownField( - // 'Member Name', - // (value) { - // setState(() { - // selectedMemberId = - // value; - // selectedMemberName = - // employeePolicyList - // .firstWhere( - // (member) => - // member[ - // 'id'] == - // value, - // orElse: () => - // {'name': ''}, - // )['name']; - // }); - // }, - // false, - // employeePolicyList, - // 'name', - // selectedMemberId, // Pass current selectedMemberId as selectedValue - // ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // buildTextField('Subject', - // subjectController), - // if (!isSubjectValid) - // Text('Please enter the Subject', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextAreaField( - 'Message', - messageController), - SizedBox(height: 15), - // if (policyTypeCondition == - // 3) - // buildTextField( - // 'Accident Details', - // accidentDetailsController), - SizedBox(height: 15), - if (policyTypeCondition == 1 || policyTypeCondition == 72) ...[ - buildTextField('Hospital Name', hospitalNameController), - if (!isHospitalNameValid) - Text('Please enter the Hospital Name', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextAreaField('Hospital Address',hospitalAddressController), - if (!isHospitalAddressValid) - Text('Please enter the Hospital Address', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital City', hospitalCityController), - if (!isHospitalCityValid) - Text('Please enter the Hospital City', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital State', hospitalStateController), - if (!isHospitalStateValid) - Text('Please enter the Hospital State', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital Pincode', hospitalPinCodeController,keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - LengthLimitingTextInputFormatter(6), // optional - ]), - if (!isHospitalPincodeValid) - Text('Please enter the Hospital Pincode', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital Phone No', hospitalPhoneNoController,keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - LengthLimitingTextInputFormatter(10), // optional - ]), - if (!isHospitalPhoneNoValid) - Text('Please enter the Hospital Phone No', style: TextStyle(color: Colors.red)), + ) ], - SizedBox(height: 15), - if (serviceId == 2 || - serviceId == 3 || - serviceId == 4) ...[ - buildDatePickerField( - label: - 'Date of Birth', - selectedDate: - birthDate, - allowFuture: false, - onDateSelected: - (selectedDate) { - setState(() { - birthDate = - selectedDate; - }); - }, - ), - SizedBox(height: 15), - buildDatePickerField( - label: 'Accident Date', - selectedDate: accidentDate, - allowFuture: false, - minDate: parsedPolicyStartDate, - maxDate: parsedPolicyEndDate, - onDateSelected: (selectedDate) { - setState(() { - if (deathDate != null) deathDate = null; - if (intimationDate != null) intimationDate = null; - accidentDate = selectedDate; - }); - }, - ), - if (!isAccidentDateValid) - Text('Please select the Accident Date', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildDatePickerField( - label: - 'Date of Death', - selectedDate: - deathDate, - allowFuture: false, - minDate: accidentDate ?? parsedPolicyStartDate, - maxDate: parsedPolicyEndDate, - onDateSelected: - (selectedDate) { - setState(() { - deathDate = - selectedDate; - }); - }, - ), - SizedBox(height: 15), - buildDatePickerField( - label: 'Date of Intimation', - selectedDate: intimationDate, - allowFuture: false, - minDate: accidentDate ?? deathDate ?? parsedPolicyStartDate, - maxDate: parsedPolicyEndDate, - onDateSelected: (selectedDate) { - setState(() { - intimationDate = selectedDate; - }); - }, - ), - if (!isIntimationDateValid) - Text('Please select the Intimation Date', style: TextStyle(color: Colors.red)), - ], - SizedBox(height: 15), - // buildTextAreaField( - // 'Accident Details', - // accidentDetailsController), - // SizedBox(height: 15), - if (policyTypeCondition == 1 || policyTypeCondition == 72) ...[ - // 🟡 Admit Date — no future allowed - buildDatePickerField( - label: 'Admit Date', - selectedDate: admitDate, - allowFuture: false, - onDateSelected: (selectedDate) { - setState(() { - admitDate = selectedDate; - dischargeDate = null; // reset discharge when admit changes - }); - }, - ), - if (!isAdmitDateValid) - const Text('Please select the Admit Date', style: TextStyle(color: Colors.red)), - const SizedBox(height: 20), - - // 🟢 Discharge Date — must be after Admit Date - buildDatePickerField( - label: 'Discharge Date', - selectedDate: dischargeDate, - allowFuture: true, - minDate: admitDate != null - ? admitDate!.add(const Duration(days: 1)) - : DateTime.now().add(const Duration(days: 1)), - maxDate: null, - onDateSelected: (selectedDate) { - setState(() { - dischargeDate = selectedDate; - }); - }, - ), - if (!isDischargeDateValid) - const Text('Please select the Discharge Date', style: TextStyle(color: Colors.red)), - ], - - - SizedBox(height: 15), - if (serviceId == 1) ...[ - buildTextField('Claims Amount', claimAmountController, keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ]), - if (!isClaimAmountValid) - Text('Please enter the Claims Amount', style: TextStyle(color: Colors.red)), - ], - - SizedBox(height: 15), - if (serviceId == 2 || - serviceId == 3 || - serviceId == 4) - buildTextField( - 'Sum Insured', - sumInsuredController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - ), - ] - ), - SizedBox(height: 15), - // ThemedUploadField( - // hintText: "Upload Documents", - // txtwidth: MediaQuery.of(context).size.width < 600 - // ? MediaQuery.of(context).size.width // Full width on mobile - // : MediaQuery.of(context).size.width * 0.26, // 26% on desktop - // txtheight: 45, - // onFilesSelected: (files) { - // print("Picked files: ${files.map((f) => f.name).toList()}"); - // setState(() { - // uploadedFiles = files; // store all selected files - // }); - // }, - // ), - Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - const MultiFileUploadWidget(), - ], - ), - ), - ], - ), - ), - ], - ), + ), + ) + ], + ), // Space between rows + // Add more rows as needed + ], ), - ], - ), - SizedBox(height: 15), - Row( - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: () { - sendFormDataToApi(); - }, - child: isSubmitting - ? SizedBox( - height: 22, - width: 22, - child: CircularProgressIndicator( - strokeWidth: 2, - color: Colors.white, + ), + SizedBox(height: 15), + Container( + child: Column( + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Form( + key: formKey, + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildDropdownField( + 'Service', + (value) { + setState(() { + serviceId = value; + selectedServiceName = departmentList.firstWhere( + (serList) => serList['id'] == value, + orElse: () => {'name': ''}, + )['name']; + policyNumberId = null; + + loadClaimTypes(serviceId); // ✅ LOAD CLAIM TYPES + isServiceValid = true; + if (fromClaimsPage == 1) { + fetchPoliciesBasedOnService(serviceId); + } + }); + }, + fromClaimsPage == 0, + departmentList, + 'name', + serviceId, + ), + if (!isServiceValid) + Text('Please select a service', style: TextStyle(color: Colors.red)), + ], + ), + + // buildDropdownField( + // 'Service', + // (value) { + // setState(() { + // serviceId = value; + // selectedServiceName = + // departmentList + // .firstWhere( + // (serList) => + // serList[ + // 'id'] == + // value, + // orElse: () => + // {'name': ''}, + // )['name']; + // policyNumberId = + // null; + // if (fromClaimsPage == + // 1) { + // fetchPoliciesBasedOnService( + // serviceId); + // } + // }); + // }, + // fromClaimsPage == 0, + // departmentList, + // 'name', + // serviceId, // Pass current serviceId as selectedValue + // ), + SizedBox(height: 15), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildDropdownField( + 'Select Policy', + (value) { + setState(() { + policyNumberId = value; + selectedMemberId = null; + String? selectedPolicyNo = policyNumberList.firstWhere( + (item) => item['id'] == value, + orElse: () => {'policy_no': ''}, + )['policy_no']; + if (selectedPolicyNo != null && fromClaimsPage == 1) { + fetchMemberBasedOnPolicy(selectedPolicyNo); + } + isPolicyValid = true; + }); + }, + fromClaimsPage == 0, + policyNumberList, + 'policy_no', + policyNumberId, + ), + if (!isPolicyValid) + Text('Please select a policy', style: TextStyle(color: Colors.red)), + ], + ), + + SizedBox(height: 15), + + if (policyTypeCondition == 1 || policyTypeCondition == 72) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildDropdownField( + 'Select Claim Type', + (value) { + setState(() { + claimTypeId = value; + isClaimTypeValid = true; + }); + }, + false, + claimTypeList, + 'name', + claimTypeId, + ), + if (!isClaimTypeValid) + Text( + 'Please select a claim type', + style: TextStyle(color: Colors.red), + ), + ], + ), + + // // if (fromClaimsPage == 1) + // buildDropdownField( + // 'Select Policy', + // (value) { + // setState(() { + // policyNumberId = + // value; + // selectedMemberId = + // null; + // String? + // selectedPolicyNo = + // policyNumberList + // .firstWhere( + // (item) => + // item['id'] == + // value, + // orElse: () => + // { + // 'policy_no': '' + // })['policy_no']; + // + // if (selectedPolicyNo != + // null && + // fromClaimsPage == + // 1) { + // fetchMemberBasedOnPolicy( + // selectedPolicyNo); + // } + // }); + // }, + // fromClaimsPage == 0, + // policyNumberList, + // 'policy_no', + // policyNumberId, // Pass current policyNumberId as selectedValue + // ), + SizedBox(height: 15), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildDropdownField( + 'Member Name', + (value) { + setState(() { + selectedMemberId = value; + selectedMemberName = employeePolicyList.firstWhere( + (member) => member['id'] == value, + orElse: () => {'name': ''}, + )['name']; + isMemberValid = true; + }); + }, + false, + employeePolicyList, + 'name', + selectedMemberId, + ), + if (!isMemberValid) + Text('Please select a member', style: TextStyle(color: Colors.red)), + ], + ), + SizedBox(height: 15), + // buildDropdownField( + // 'Member Name', + // (value) { + // setState(() { + // selectedMemberId = + // value; + // selectedMemberName = + // employeePolicyList + // .firstWhere( + // (member) => + // member[ + // 'id'] == + // value, + // orElse: () => + // {'name': ''}, + // )['name']; + // }); + // }, + // false, + // employeePolicyList, + // 'name', + // selectedMemberId, // Pass current selectedMemberId as selectedValue + // ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // buildTextField('Subject', + // subjectController), + // if (!isSubjectValid) + // Text('Please enter the Subject', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildTextAreaField( + 'Message', + messageController), + SizedBox(height: 15), + // if (policyTypeCondition == + // 3) + // buildTextField( + // 'Accident Details', + // accidentDetailsController), + SizedBox(height: 15), + if (policyTypeCondition == 1 || policyTypeCondition == 72) ...[ + buildTextField('Hospital Name', hospitalNameController), + if (!isHospitalNameValid) + Text('Please enter the Hospital Name', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildTextAreaField('Hospital Address',hospitalAddressController), + if (!isHospitalAddressValid) + Text('Please enter the Hospital Address', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildTextField('Hospital City', hospitalCityController), + if (!isHospitalCityValid) + Text('Please enter the Hospital City', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildTextField('Hospital State', hospitalStateController), + if (!isHospitalStateValid) + Text('Please enter the Hospital State', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildTextField('Hospital Pincode', hospitalPinCodeController,keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(6), // optional + ]), + if (!isHospitalPincodeValid) + Text('Please enter the Hospital Pincode', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildTextField('Hospital Phone No', hospitalPhoneNoController,keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(10), // optional + ]), + if (!isHospitalPhoneNoValid) + Text('Please enter the Hospital Phone No', style: TextStyle(color: Colors.red)), + ], + SizedBox(height: 15), + if (serviceId == 2 || + serviceId == 3 || + serviceId == 4) ...[ + buildDatePickerField( + label: + 'Date of Birth', + selectedDate: + birthDate, + allowFuture: false, + onDateSelected: + (selectedDate) { + setState(() { + birthDate = + selectedDate; + }); + }, + ), + SizedBox(height: 15), + buildDatePickerField( + label: 'Accident Date', + selectedDate: accidentDate, + allowFuture: false, + minDate: parsedPolicyStartDate, + maxDate: parsedPolicyEndDate, + onDateSelected: (selectedDate) { + setState(() { + if (deathDate != null) deathDate = null; + if (intimationDate != null) intimationDate = null; + accidentDate = selectedDate; + }); + }, + ), + if (!isAccidentDateValid) + Text('Please select the Accident Date', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildDatePickerField( + label: + 'Date of Death', + selectedDate: + deathDate, + allowFuture: false, + minDate: accidentDate ?? parsedPolicyStartDate, + maxDate: parsedPolicyEndDate, + onDateSelected: + (selectedDate) { + setState(() { + deathDate = + selectedDate; + }); + }, + ), + SizedBox(height: 15), + buildDatePickerField( + label: 'Date of Intimation', + selectedDate: intimationDate, + allowFuture: false, + minDate: accidentDate ?? deathDate ?? parsedPolicyStartDate, + maxDate: parsedPolicyEndDate, + onDateSelected: (selectedDate) { + setState(() { + intimationDate = selectedDate; + }); + }, + ), + if (!isIntimationDateValid) + Text('Please select the Intimation Date', style: TextStyle(color: Colors.red)), + ], + SizedBox(height: 15), + // buildTextAreaField( + // 'Accident Details', + // accidentDetailsController), + // SizedBox(height: 15), + if (policyTypeCondition == 1 || policyTypeCondition == 72) ...[ + // 🟡 Admit Date — no future allowed + buildDatePickerField( + label: 'Admit Date', + selectedDate: admitDate, + allowFuture: false, + onDateSelected: (selectedDate) { + setState(() { + admitDate = selectedDate; + dischargeDate = null; // reset discharge when admit changes + }); + }, + ), + if (!isAdmitDateValid) + const Text('Please select the Admit Date', style: TextStyle(color: Colors.red)), + const SizedBox(height: 20), + + // 🟢 Discharge Date — must be after Admit Date + buildDatePickerField( + label: 'Discharge Date', + selectedDate: dischargeDate, + allowFuture: true, + minDate: admitDate != null + ? admitDate!.add(const Duration(days: 1)) + : DateTime.now().add(const Duration(days: 1)), + maxDate: null, + onDateSelected: (selectedDate) { + setState(() { + dischargeDate = selectedDate; + }); + }, + ), + if (!isDischargeDateValid) + const Text('Please select the Discharge Date', style: TextStyle(color: Colors.red)), + ], + + + SizedBox(height: 15), + if (serviceId == 1) ...[ + buildTextField('Claims Amount', claimAmountController, keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ]), + if (!isClaimAmountValid) + Text('Please enter the Claims Amount', style: TextStyle(color: Colors.red)), + ], + + SizedBox(height: 15), + if (serviceId == 2 || + serviceId == 3 || + serviceId == 4) + buildTextField( + 'Sum Insured', + sumInsuredController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + ), + ] + ), + SizedBox(height: 15), + // ThemedUploadField( + // hintText: "Upload Documents", + // txtwidth: MediaQuery.of(context).size.width < 600 + // ? MediaQuery.of(context).size.width // Full width on mobile + // : MediaQuery.of(context).size.width * 0.26, // 26% on desktop + // txtheight: 45, + // onFilesSelected: (files) { + // print("Picked files: ${files.map((f) => f.name).toList()}"); + // setState(() { + // uploadedFiles = files; // store all selected files + // }); + // }, + // ), + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + const MultiFileUploadWidget(), + ], + ), + ), + ], + ), + ), + ], + ), ), - ) - : Text( - 'Send', - style: GoogleFonts.poppins( - color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: - Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular( - 5), - ), - ), + ], ), - ), + SizedBox(height: 15), + Row( + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + sendFormDataToApi(); + }, + child: isSubmitting + ? SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator( + strokeWidth: 2, + color: Colors.white, + ), + ) + : Text( + 'Send', + style: GoogleFonts.poppins( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 5), + ), + ), + ), + ), + ), + ], + ), + ], ), - ], - ), - ], - ), - ), - ], - ))), - ], - ), - ), - ), - SizedBox(height: Responsive.isDesktop(context) ? 40 : 60), - ]), - )), - if (isLoading) - Container( - color: Color(0x98FFFCE5), // Semi-transparent background - child: Center( - child: // Your GIF loader widget + ), + ], + ))), + ], + ), + ), + ), + SizedBox(height: Responsive.isDesktop(context) ? 40 : 60), + ]), + )), + if (isLoading) + Container( + color: Color(0x98FFFCE5), // Semi-transparent background + child: Center( + child: // Your GIF loader widget Image.asset( height: 60, width: 60, 'assets/nhance-loader.gif'), // Adjust path to your GIF loader - ), + ), + ), + if (Responsive.isDesktop(context)) + Align( + alignment: Alignment.bottomCenter, + child: Container( + width: double.infinity, // Make the footer full width + child: CustomFooter(), + ), + ), + ]), + // floatingActionButton: Responsive.isDesktop(context) + // ? null + // : FloatingActionButton( + // onPressed: () { + // Navigator.pushNamed(context, 'chatbot'); + // }, + // child: Icon(Icons.chat), + // ), + floatingActionButtonLocation: Responsive.isDesktop(context) + ? null + : FloatingActionButtonLocation.miniEndFloat, + bottomNavigationBar: Responsive.isDesktop(context) + ? null + : CustomBottomNavigationBar( + onTabChanged: (index) { + // Add your navigation logic here + // repositionBotman(); + if (index == 0) { + context.push('/home'); + } else if (index == 1) { + context.push('/claims'); + } else if (index == 2) { + context.push('/faqs'); + } else if (index == 3) { + context.push('/profile'); + } else if (index == 4) { + context.push('/help'); + } + // else if (index == 4) { + // // context.push('/wellness'); + // // Wellness tab clicked → show popup + // if(!isRetailLoggedIn) + // PopupHelper.showRedirectPopup( + // context: context, + // apiService: apiService, + // empPrimaryId: session.empPrimaryId, + // ); + // } + }, + icons: [ + Icons.home_outlined, + Icons.sticky_note_2_outlined, + Icons.question_answer_outlined, + Icons.person_outline_outlined, + Icons.headset_mic_outlined, + ], + labels: ["Home", "Claims", "FAQs", "Profile","Help"], + initialIndex: 0, // Initial index of the bottom navigation bar ), - if (Responsive.isDesktop(context)) - Align( - alignment: Alignment.bottomCenter, - child: Container( - width: double.infinity, // Make the footer full width - child: CustomFooter(), - ), - ), - ]), - // floatingActionButton: Responsive.isDesktop(context) - // ? null - // : FloatingActionButton( - // onPressed: () { - // Navigator.pushNamed(context, 'chatbot'); - // }, - // child: Icon(Icons.chat), - // ), - floatingActionButtonLocation: Responsive.isDesktop(context) - ? null - : FloatingActionButtonLocation.miniEndFloat, - bottomNavigationBar: Responsive.isDesktop(context) - ? null - : CustomBottomNavigationBar( - onTabChanged: (index) { - // Add your navigation logic here - // repositionBotman(); - if (index == 0) { - context.push('/home'); - } else if (index == 1) { - context.push('/claims'); - } else if (index == 2) { - context.push('/faqs'); - } else if (index == 3) { - context.push('/profile'); - } else if (index == 4) { - context.push('/help'); - } - // else if (index == 4) { - // // context.push('/wellness'); - // // Wellness tab clicked → show popup - // if(!isRetailLoggedIn) - // PopupHelper.showRedirectPopup( - // context: context, - // apiService: apiService, - // empPrimaryId: session.empPrimaryId, - // ); - // } - }, - icons: [ - Icons.home_outlined, - Icons.sticky_note_2_outlined, - Icons.question_answer_outlined, - Icons.person_outline_outlined, - Icons.headset_mic_outlined, - ], - labels: ["Home", "Claims", "FAQs", "Profile","Help"], - initialIndex: 0, // Initial index of the bottom navigation bar - ), - ) + ) ); } diff --git a/lib/pages/postEnrollment/service/api_service.dart b/lib/pages/postEnrollment/service/api_service.dart index d4a4d47..037457f 100755 --- a/lib/pages/postEnrollment/service/api_service.dart +++ b/lib/pages/postEnrollment/service/api_service.dart @@ -17,7 +17,7 @@ class ApiService { } Future _initializeToken() async { - _postToken = await TokenService.getPostToken(); + _postToken = await TokenService.getPostToken(); } Future> getActiveAndInactivePolicyDetails( @@ -25,7 +25,8 @@ class ApiService { String? empCode, String? status, String? branchID, - String? mobileNo,String? emailId) async { + String? mobileNo, + String? emailId) async { print(_postToken); if (_postToken == null) { await _initializeToken(); @@ -61,7 +62,8 @@ class ApiService { if (_postToken == null) { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}getAdvertisementImage?client_id=$clientID'); + final url = Uri.parse( + '${Environment.apiUrl}getAdvertisementImage?client_id=$clientID'); final headers = { 'Authorization': 'Bearer $_postToken' ?? '', }; @@ -110,7 +112,8 @@ class ApiService { return response; } - Future> getTrackClaimsList(String empPrimaryId,mobileNo,emailID) async { + Future> getTrackClaimsList( + String empPrimaryId, mobileNo, emailID) async { print(_postToken); if (_postToken == null) { await _initializeToken(); @@ -158,12 +161,14 @@ class ApiService { return response; } - Future> getWellnessLink(empPrimaryId,client_policy_id) async { + Future> getWellnessLink( + empPrimaryId, client_policy_id) async { print(_postToken); if (_postToken == null) { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}getWellnessURL?emp_id=$empPrimaryId'); + final url = + Uri.parse('${Environment.apiUrl}getWellnessURL?emp_id=$empPrimaryId'); // final url = Uri.parse('${Environment.apiUrl}getWellnessURL?emp_id=$empPrimaryId&client_policy_id=$client_policy_id'); final headers = { 'Authorization': 'Bearer $_postToken' ?? '', @@ -184,7 +189,8 @@ class ApiService { }; final jsonBody = jsonEncode(eCardParam); // Send formDataJson as the body - final response = await _makePostRequestWithoutFormData(url,jsonBody, headers); + final response = + await _makePostRequestWithoutFormData(url, jsonBody, headers); return response; } @@ -200,7 +206,8 @@ class ApiService { }; final jsonBody = jsonEncode(formData); // Send formDataJson as the body - final response = await _makePostRequestWithoutFormData(url,jsonBody, headers); + final response = + await _makePostRequestWithoutFormData(url, jsonBody, headers); return response; } @@ -227,7 +234,6 @@ class ApiService { return response['status'] == 'success'; } - Future> fetchPolicyTypeAndInsurer() async { print(_postToken); if (_postToken == null) { @@ -241,12 +247,14 @@ class ApiService { return response; } - Future> fetchDepartmentList(String clientId, String empCode) async { + Future> fetchDepartmentList( + String clientId, String empCode) async { print(_postToken); if (_postToken == null) { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}get_ticket_type?client_id=$clientId&emp_code=$empCode'); + final url = Uri.parse( + '${Environment.apiUrl}get_ticket_type?client_id=$clientId&emp_code=$empCode'); final headers = { 'Authorization': 'Bearer $_postToken' ?? '', }; @@ -378,7 +386,8 @@ class ApiService { Future> _makeGetRequest( Uri url, Map headers) async { // Add global APP_SIGNATURE header - headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; + headers['APP-SIGNATURE'] = + 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; final response = await http.get(url, headers: headers); return _handleResponse(response); } @@ -386,7 +395,8 @@ class ApiService { Future> _makePostRequest( Uri url, Map body, Map headers) async { // Add global APP_SIGNATURE header - headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; + headers['APP-SIGNATURE'] = + 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; final response = await http.post(url, headers: headers, body: body); return _handleResponse(response); } @@ -394,20 +404,28 @@ class ApiService { Future> _makePostRequestWithoutFormData( Uri url, String body, Map headers) async { // Add global APP_SIGNATURE header - headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; + headers['APP-SIGNATURE'] = + 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; final response = await http.post(url, headers: headers, body: body); return _handleResponse(response); } - Future> _handleResponse(http.Response response) async { if (response.statusCode == 200) { return jsonDecode(response.body); } else if (response.statusCode == 401) { await _clearLocalStorageAndRedirect(); return {}; + } else if (response.statusCode == 403) { + await _clearLocalStorageAndRedirect(); + return {}; + } else if (response.statusCode == 451) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + return {}; } else if (response.statusCode == 429) { - final body = jsonDecode(response.body); + final body = jsonDecode(response.body); final message = body['message']; ToastHelper.showWarningToast(context, message); return {}; diff --git a/lib/pages/session/SetPinBiometric.dart b/lib/pages/session/SetPinBiometric.dart index 212cf86..90e808c 100755 --- a/lib/pages/session/SetPinBiometric.dart +++ b/lib/pages/session/SetPinBiometric.dart @@ -207,10 +207,28 @@ ToastHelper.showErrorToast(context, 'Invalid Pin Number'); print('Invalid Pin Number'); } - } else { - ToastHelper.showErrorToast(context, 'Something went wrong'); + } else if (response.statusCode == 401) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; context.go('/login'); - throw Exception('Failed to verify pin number'); + + } else if (response.statusCode == 403) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 451) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else { + throw Exception('Failed to load data'); } } catch (e) { ToastHelper.showErrorToast(context, 'Something went wrong'); @@ -425,9 +443,28 @@ // } } + } else if (response.statusCode == 401) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 403) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 451) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); } else { - ToastHelper.showErrorToast(context, 'Something went wrong'); - throw Exception('Failed to verify pin number'); + throw Exception('Failed to load data'); } } catch (e) { // ToastHelper.showErrorToast(context, 'Something went wrong'); @@ -580,6 +617,7 @@ child: Column( // crossAxisAlignment: CrossAxisAlignment.center, children: [ + SizedBox(height: 8), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ diff --git a/lib/pages/session/changePin.dart b/lib/pages/session/changePin.dart index e659017..b5e0927 100755 --- a/lib/pages/session/changePin.dart +++ b/lib/pages/session/changePin.dart @@ -12,6 +12,7 @@ import '../../config/environment.dart'; import '../../customAppBar/responsive.dart'; import '../../customAppBar/toastHelper.dart'; import '../postEnrollment/service/svg_service.dart'; +import '../service/SessionManager.dart'; import 'authenticationService.dart'; class changePin extends StatefulWidget { @@ -107,11 +108,28 @@ class _changePinState extends State { ToastHelper.showErrorToast(context, message); print('Invalid Pin Number'); } + } else if (response.statusCode == 401) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 403) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 451) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); } else { - Map data = json.decode(response.body); - String message = data['data']['message']; - ToastHelper.showErrorToast(context, message); - throw Exception('Failed to verify mobile number'); + throw Exception('Failed to load data'); } } } catch (e) { diff --git a/lib/pages/session/settingUpPinAndBiometric.dart b/lib/pages/session/settingUpPinAndBiometric.dart index d41e6a9..e3572f1 100755 --- a/lib/pages/session/settingUpPinAndBiometric.dart +++ b/lib/pages/session/settingUpPinAndBiometric.dart @@ -166,9 +166,28 @@ class _pinSettingPageState extends State { ToastHelper.showErrorToast(context, message); print('Invalid Pin Number'); } + } else if (response.statusCode == 401) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 403) { + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 451) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); } else { - ToastHelper.showErrorToast(context, 'Something went wrong'); - throw Exception('Failed to verify mobile number'); + throw Exception('Failed to load data'); } // } } catch (e) { @@ -319,6 +338,7 @@ class _pinSettingPageState extends State { child: Column( // crossAxisAlignment: CrossAxisAlignment.center, children: [ + SizedBox(height: 8), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ diff --git a/lib/pages/setPassword.dart b/lib/pages/setPassword.dart index 0692b18..1bc30e7 100755 --- a/lib/pages/setPassword.dart +++ b/lib/pages/setPassword.dart @@ -110,12 +110,43 @@ class _setPasswordState extends State { ToastHelper.showErrorToast(context, message!); print('Invalid mobile number'); } + } else if (response.statusCode == 401) { + setState(() { + _isLoading = false; + }); + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 403) { + setState(() { + _isLoading = false; + }); + await SessionManager().clear(); + ToastHelper.showErrorToast(context, 'Session Out'); + if (!context.mounted) return; + context.go('/login'); + + } else if (response.statusCode == 451) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); + } else if (response.statusCode == 429) { + setState(() { + _isLoading = false; + }); + final body = jsonDecode(response.body); + final message = body['message']; + ToastHelper.showWarningToast(context, message); } else { setState(() { _isLoading = false; }); - ToastHelper.showErrorToast(context, 'Something went wrong'); - throw Exception('Failed to verify mobile number'); + throw Exception('Failed to load data'); } } } catch (e) { From 724768e240ff4c7f56ed8bdb8bd54a2fdb791d3b Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Tue, 17 Mar 2026 10:53:55 +0530 Subject: [PATCH 2/2] claim form --- android/app/build.gradle | 4 +- lib/pages/postEnrollment/planclaimsform.dart | 567 ++---------------- .../postEnrollment/service/api_service.dart | 9 +- pubspec.yaml | 4 +- 4 files changed, 67 insertions(+), 517 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index a11a274..88942a4 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -19,12 +19,12 @@ if (project.hasProperty('google-services.json')) { def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { - flutterVersionCode = '54' + flutterVersionCode = '55' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { - flutterVersionName = '2.0.16' + flutterVersionName = '2.0.17' } def keystoreProperties = new Properties() diff --git a/lib/pages/postEnrollment/planclaimsform.dart b/lib/pages/postEnrollment/planclaimsform.dart index f9f2077..b7c0d46 100755 --- a/lib/pages/postEnrollment/planclaimsform.dart +++ b/lib/pages/postEnrollment/planclaimsform.dart @@ -85,7 +85,6 @@ class _planclaimsformState extends State { int? claimTypeId; bool isClaimTypeValid = true; - // Declare subjectController and bodyController as instance variables late TextEditingController subjectController; late TextEditingController messageController; @@ -946,14 +945,14 @@ class _planclaimsformState extends State { vertical: MediaQuery.of(context).size.height * 0.05, // 5% of screen height as vertical padding ) - : EdgeInsets.all(10), - color: Colors.white, + : EdgeInsets.all(10), + color: Colors.white, child: Column(children: [ Card( elevation: 5, shape: RoundedRectangleBorder( borderRadius: - BorderRadius.circular(15.0), // Set border radius here + BorderRadius.circular(15.0), // Set border radius here ), child: Container( decoration: BoxDecoration( @@ -964,10 +963,10 @@ class _planclaimsformState extends State { padding: Responsive.isDesktop(context) ? EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15) : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), // Add padding to the container + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container child: Row( children: [ Expanded( @@ -987,22 +986,22 @@ class _planclaimsformState extends State { ), padding: Responsive.isDesktop(context) ? EdgeInsets.only( - top: 20, - bottom: 20, - left: 0, - right: 0) + top: 20, + bottom: 20, + left: 0, + right: 0) : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), + top: 10, + bottom: 10, + left: 10, + right: 10), child: Column( crossAxisAlignment: - CrossAxisAlignment.center, + CrossAxisAlignment.center, children: [ Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ Expanded( flex: 1, @@ -1018,40 +1017,6 @@ class _planclaimsformState extends State { ), ), ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 20, - bottom: 20, - left: 0, - right: 0) - : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - final route = fromClaimsPage == 0 ? 'claims' : 'help'; - context.go('/$route'); - }, - child: Icon( - Icons - .chevron_left, // Replace with your desired icon - color: Color(0xFF000000), - size: 30, - ), - ), - ), Expanded( flex: 11, child: Row( @@ -1070,8 +1035,8 @@ class _planclaimsformState extends State { fontSize: Responsive.isDesktop( context) - ? 20 - : 16, + ? 20 + : 16, fontWeight: FontWeight.w600, color: Color(0xFF000000), ), @@ -1091,16 +1056,16 @@ class _planclaimsformState extends State { children: [ Column( crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Container( width: double.infinity, alignment: Alignment.centerLeft, child: Column( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Form( key: formKey, @@ -1193,6 +1158,32 @@ class _planclaimsformState extends State { Text('Please select a policy', style: TextStyle(color: Colors.red)), ], ), + SizedBox(height: 15), + + if (policyTypeCondition == 1 || policyTypeCondition == 72) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildDropdownField( + 'Select Claim Type', + (value) { + setState(() { + claimTypeId = value; + isClaimTypeValid = true; + }); + }, + false, + claimTypeList, + 'name', + claimTypeId, + ), + if (!isClaimTypeValid) + Text( + 'Please select a claim type', + style: TextStyle(color: Colors.red), + ), + ], + ), // // if (fromClaimsPage == 1) // buildDropdownField( @@ -1254,7 +1245,7 @@ class _planclaimsformState extends State { Text('Please select a member', style: TextStyle(color: Colors.red)), ], ), -SizedBox(height: 15), + SizedBox(height: 15), // buildDropdownField( // 'Member Name', // (value) { @@ -1278,7 +1269,7 @@ SizedBox(height: 15), // 'name', // selectedMemberId, // Pass current selectedMemberId as selectedValue // ), - Column( + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // buildTextField('Subject', @@ -1322,12 +1313,12 @@ SizedBox(height: 15), Text('Please enter the Hospital Pincode', style: TextStyle(color: Colors.red)), SizedBox(height: 15), buildTextField('Hospital Phone No', hospitalPhoneNoController, - isRequired: true, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - LengthLimitingTextInputFormatter(10), - ],minLength: 10,), + isRequired: true, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(10), + ],minLength: 10,), if (!isHospitalPhoneNoValid) Text( hospitalPhoneNoController.text.trim().isEmpty @@ -1454,9 +1445,9 @@ SizedBox(height: 15), SizedBox(height: 15), if (serviceId == 1) ...[ buildTextField('Claims Amount', claimAmountController, isRequired: true, keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ]), + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ]), if (!isClaimAmountValid) Text('Please enter the Claims Amount', style: TextStyle(color: Colors.red)), ], @@ -1475,7 +1466,7 @@ SizedBox(height: 15), ], ), ] - ), + ), SizedBox(height: 15), // ThemedUploadField( // hintText: "Upload Documents", @@ -1504,442 +1495,6 @@ SizedBox(height: 15), ], ), ), - ), - SizedBox(height: 15), - Container( - child: Column( - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Form( - key: formKey, - child: Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildDropdownField( - 'Service', - (value) { - setState(() { - serviceId = value; - selectedServiceName = departmentList.firstWhere( - (serList) => serList['id'] == value, - orElse: () => {'name': ''}, - )['name']; - policyNumberId = null; - - loadClaimTypes(serviceId); // ✅ LOAD CLAIM TYPES - isServiceValid = true; - if (fromClaimsPage == 1) { - fetchPoliciesBasedOnService(serviceId); - } - }); - }, - fromClaimsPage == 0, - departmentList, - 'name', - serviceId, - ), - if (!isServiceValid) - Text('Please select a service', style: TextStyle(color: Colors.red)), - ], - ), - - // buildDropdownField( - // 'Service', - // (value) { - // setState(() { - // serviceId = value; - // selectedServiceName = - // departmentList - // .firstWhere( - // (serList) => - // serList[ - // 'id'] == - // value, - // orElse: () => - // {'name': ''}, - // )['name']; - // policyNumberId = - // null; - // if (fromClaimsPage == - // 1) { - // fetchPoliciesBasedOnService( - // serviceId); - // } - // }); - // }, - // fromClaimsPage == 0, - // departmentList, - // 'name', - // serviceId, // Pass current serviceId as selectedValue - // ), - SizedBox(height: 15), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildDropdownField( - 'Select Policy', - (value) { - setState(() { - policyNumberId = value; - selectedMemberId = null; - String? selectedPolicyNo = policyNumberList.firstWhere( - (item) => item['id'] == value, - orElse: () => {'policy_no': ''}, - )['policy_no']; - if (selectedPolicyNo != null && fromClaimsPage == 1) { - fetchMemberBasedOnPolicy(selectedPolicyNo); - } - isPolicyValid = true; - }); - }, - fromClaimsPage == 0, - policyNumberList, - 'policy_no', - policyNumberId, - ), - if (!isPolicyValid) - Text('Please select a policy', style: TextStyle(color: Colors.red)), - ], - ), - - SizedBox(height: 15), - - if (policyTypeCondition == 1 || policyTypeCondition == 72) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildDropdownField( - 'Select Claim Type', - (value) { - setState(() { - claimTypeId = value; - isClaimTypeValid = true; - }); - }, - false, - claimTypeList, - 'name', - claimTypeId, - ), - if (!isClaimTypeValid) - Text( - 'Please select a claim type', - style: TextStyle(color: Colors.red), - ), - ], - ), - - // // if (fromClaimsPage == 1) - // buildDropdownField( - // 'Select Policy', - // (value) { - // setState(() { - // policyNumberId = - // value; - // selectedMemberId = - // null; - // String? - // selectedPolicyNo = - // policyNumberList - // .firstWhere( - // (item) => - // item['id'] == - // value, - // orElse: () => - // { - // 'policy_no': '' - // })['policy_no']; - // - // if (selectedPolicyNo != - // null && - // fromClaimsPage == - // 1) { - // fetchMemberBasedOnPolicy( - // selectedPolicyNo); - // } - // }); - // }, - // fromClaimsPage == 0, - // policyNumberList, - // 'policy_no', - // policyNumberId, // Pass current policyNumberId as selectedValue - // ), - SizedBox(height: 15), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildDropdownField( - 'Member Name', - (value) { - setState(() { - selectedMemberId = value; - selectedMemberName = employeePolicyList.firstWhere( - (member) => member['id'] == value, - orElse: () => {'name': ''}, - )['name']; - isMemberValid = true; - }); - }, - false, - employeePolicyList, - 'name', - selectedMemberId, - ), - if (!isMemberValid) - Text('Please select a member', style: TextStyle(color: Colors.red)), - ], - ), - SizedBox(height: 15), - // buildDropdownField( - // 'Member Name', - // (value) { - // setState(() { - // selectedMemberId = - // value; - // selectedMemberName = - // employeePolicyList - // .firstWhere( - // (member) => - // member[ - // 'id'] == - // value, - // orElse: () => - // {'name': ''}, - // )['name']; - // }); - // }, - // false, - // employeePolicyList, - // 'name', - // selectedMemberId, // Pass current selectedMemberId as selectedValue - // ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // buildTextField('Subject', - // subjectController), - // if (!isSubjectValid) - // Text('Please enter the Subject', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextAreaField( - 'Message', - messageController), - SizedBox(height: 15), - // if (policyTypeCondition == - // 3) - // buildTextField( - // 'Accident Details', - // accidentDetailsController), - SizedBox(height: 15), - if (policyTypeCondition == 1 || policyTypeCondition == 72) ...[ - buildTextField('Hospital Name', hospitalNameController), - if (!isHospitalNameValid) - Text('Please enter the Hospital Name', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextAreaField('Hospital Address',hospitalAddressController), - if (!isHospitalAddressValid) - Text('Please enter the Hospital Address', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital City', hospitalCityController), - if (!isHospitalCityValid) - Text('Please enter the Hospital City', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital State', hospitalStateController), - if (!isHospitalStateValid) - Text('Please enter the Hospital State', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital Pincode', hospitalPinCodeController,keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - LengthLimitingTextInputFormatter(6), // optional - ]), - if (!isHospitalPincodeValid) - Text('Please enter the Hospital Pincode', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildTextField('Hospital Phone No', hospitalPhoneNoController,keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - LengthLimitingTextInputFormatter(10), // optional - ]), - if (!isHospitalPhoneNoValid) - Text('Please enter the Hospital Phone No', style: TextStyle(color: Colors.red)), - ], - SizedBox(height: 15), - if (serviceId == 2 || - serviceId == 3 || - serviceId == 4) ...[ - buildDatePickerField( - label: - 'Date of Birth', - selectedDate: - birthDate, - allowFuture: false, - onDateSelected: - (selectedDate) { - setState(() { - birthDate = - selectedDate; - }); - }, - ), - SizedBox(height: 15), - buildDatePickerField( - label: 'Accident Date', - selectedDate: accidentDate, - allowFuture: false, - minDate: parsedPolicyStartDate, - maxDate: parsedPolicyEndDate, - onDateSelected: (selectedDate) { - setState(() { - if (deathDate != null) deathDate = null; - if (intimationDate != null) intimationDate = null; - accidentDate = selectedDate; - }); - }, - ), - if (!isAccidentDateValid) - Text('Please select the Accident Date', style: TextStyle(color: Colors.red)), - SizedBox(height: 15), - buildDatePickerField( - label: - 'Date of Death', - selectedDate: - deathDate, - allowFuture: false, - minDate: accidentDate ?? parsedPolicyStartDate, - maxDate: parsedPolicyEndDate, - onDateSelected: - (selectedDate) { - setState(() { - deathDate = - selectedDate; - }); - }, - ), - SizedBox(height: 15), - buildDatePickerField( - label: 'Date of Intimation', - selectedDate: intimationDate, - allowFuture: false, - minDate: accidentDate ?? deathDate ?? parsedPolicyStartDate, - maxDate: parsedPolicyEndDate, - onDateSelected: (selectedDate) { - setState(() { - intimationDate = selectedDate; - }); - }, - ), - if (!isIntimationDateValid) - Text('Please select the Intimation Date', style: TextStyle(color: Colors.red)), - ], - SizedBox(height: 15), - // buildTextAreaField( - // 'Accident Details', - // accidentDetailsController), - // SizedBox(height: 15), - if (policyTypeCondition == 1 || policyTypeCondition == 72) ...[ - // 🟡 Admit Date — no future allowed - buildDatePickerField( - label: 'Admit Date', - selectedDate: admitDate, - allowFuture: false, - onDateSelected: (selectedDate) { - setState(() { - admitDate = selectedDate; - dischargeDate = null; // reset discharge when admit changes - }); - }, - ), - if (!isAdmitDateValid) - const Text('Please select the Admit Date', style: TextStyle(color: Colors.red)), - const SizedBox(height: 20), - - // 🟢 Discharge Date — must be after Admit Date - buildDatePickerField( - label: 'Discharge Date', - selectedDate: dischargeDate, - allowFuture: true, - minDate: admitDate != null - ? admitDate!.add(const Duration(days: 1)) - : DateTime.now().add(const Duration(days: 1)), - maxDate: null, - onDateSelected: (selectedDate) { - setState(() { - dischargeDate = selectedDate; - }); - }, - ), - if (!isDischargeDateValid) - const Text('Please select the Discharge Date', style: TextStyle(color: Colors.red)), - ], - - - SizedBox(height: 15), - if (serviceId == 1) ...[ - buildTextField('Claims Amount', claimAmountController, keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ]), - if (!isClaimAmountValid) - Text('Please enter the Claims Amount', style: TextStyle(color: Colors.red)), - ], - - SizedBox(height: 15), - if (serviceId == 2 || - serviceId == 3 || - serviceId == 4) - buildTextField( - 'Sum Insured', - sumInsuredController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - ), - ] - ), - SizedBox(height: 15), - // ThemedUploadField( - // hintText: "Upload Documents", - // txtwidth: MediaQuery.of(context).size.width < 600 - // ? MediaQuery.of(context).size.width // Full width on mobile - // : MediaQuery.of(context).size.width * 0.26, // 26% on desktop - // txtheight: 45, - // onFilesSelected: (files) { - // print("Picked files: ${files.map((f) => f.name).toList()}"); - // setState(() { - // uploadedFiles = files; // store all selected files - // }); - // }, - // ), - Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - const MultiFileUploadWidget(), - ], - ), - ), - ], - ), - ), - ], - ), - ), ], ), SizedBox(height: 15), @@ -2185,7 +1740,7 @@ SizedBox(height: 15), List> itemsList, String displayField, int? selectedValue, // Added selectedValue parameter - {bool isRequired = false,} + {bool isRequired = false,} ) { return DropdownButtonFormField( value: selectedValue, diff --git a/lib/pages/postEnrollment/service/api_service.dart b/lib/pages/postEnrollment/service/api_service.dart index ccb4317..29a3ddc 100755 --- a/lib/pages/postEnrollment/service/api_service.dart +++ b/lib/pages/postEnrollment/service/api_service.dart @@ -421,13 +421,8 @@ class ApiService { ToastHelper.showWarningToast(context, message); return {}; } else if (response.statusCode == 429) { -<<<<<<< HEAD - final body = jsonDecode(response.body); -======= - if (!context.mounted) return {}; - final body = jsonDecode(response.body); ->>>>>>> 24f532f750daddbb5d414d9056a4e1c4c760a2c4 - final message = body['message']; + final body = jsonDecode(response.body); + final message = body['message']; ToastHelper.showWarningToast(context, message); return {}; } else { diff --git a/pubspec.yaml b/pubspec.yaml index 4ed2211..01ef878 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,8 +17,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. #version: 1.0.32+32 -version: 1.0.29+34 -#version: 2.0.16+54 +version: 1.0.30+35 +#version: 2.0.17+55 environment: sdk: '>=3.3.3 <4.0.0'