From 096fd98c0eb8970060f34d984b7f568a658c7053 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Tue, 8 Jul 2025 12:11:17 +0530 Subject: [PATCH] UI_HR_LOADER UI_EMPCODE_SEARCH --- lib/hrDashboard.dart | 57 +++- lib/hrPolicyDetails.dart | 18 +- lib/main.dart | 20 +- lib/service/hrDashboardTabs/cd.dart | 262 +++++++++--------- lib/service/hrDashboardTabs/claims.dart | 43 ++- .../hrDashboardTabs/preEnrollment.dart | 6 +- 6 files changed, 248 insertions(+), 158 deletions(-) diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart index 86e52c6..07f628b 100755 --- a/lib/hrDashboard.dart +++ b/lib/hrDashboard.dart @@ -21,7 +21,16 @@ import 'package:universal_html/html.dart' as html; import 'package:intl/intl.dart'; class hrDashboard extends StatefulWidget { - const hrDashboard({Key? key}) : super(key: key); + final int selectedIndex; + late final int isHrcode; + final String empCodeFromHrPolicy; + + hrDashboard({ + Key? key, + required this.selectedIndex, + required this.isHrcode, + required this.empCodeFromHrPolicy, + }) : super(key: key); @override State createState() => _hrDashboardState(); @@ -32,6 +41,7 @@ class _hrDashboardState extends State late ApiService apiService; late TabController _tabController; bool isLoading = false; + int isHrcode = 0; late String _token; dynamic getPolicyNo; // bool _isLoading = false; @@ -52,6 +62,8 @@ class _hrDashboardState extends State dynamic enrollmentEmpClientBranchId; dynamic enrollmentHrId; dynamic empClientId; + String empCodeFromHrPolcy = ''; + final List cardColors = [ Color(0xFFFFE3D9), Color(0xFFFFD9EE), @@ -66,6 +78,8 @@ class _hrDashboardState extends State super.initState(); apiService = ApiService(context); // Initialize ApiService here _loadToken(); + empCodeFromHrPolcy = widget.empCodeFromHrPolicy; + // _tabController = TabController(length: 4, vsync: this); // _tabController.addListener(() { // setState(() { @@ -219,17 +233,22 @@ class _hrDashboardState extends State postToken: _postToken, )); } + print('333'); if (empAllowed_modules.contains(4)) { tabData.add({ 'icon': Icons.receipt_long, 'label': 'Claims', }); tabViews.add(ClaimsPolicies( - empClientId: empClientId, - empClientBranchId: empClientBranchId, - empHrId: empHrId, - postToken: _postToken, - )); + empClientId: empClientId, + empClientBranchId: empClientBranchId, + empHrId: empHrId, + postToken: _postToken, + isHrcode: widget.isHrcode == 1 ? 1 : 0, + empCodeHrPolicy: empCodeFromHrPolcy + // empCodeHrPolicy: widget.empCodeFromHrPolicy + + )); } } // getCashDepositDetails( @@ -244,9 +263,35 @@ class _hrDashboardState extends State } _tabController = TabController(length: tabData.length, vsync: this); + + print('selectedIndex ${widget.selectedIndex}'); + // var isHrcode; + print('111'); + if (widget.selectedIndex == 3) { + print("Process1"); + _tabController.index = 3; + setState(() { + selectedIndex = 3; + isHrcode = 1; + empCodeFromHrPolcy = widget.empCodeFromHrPolicy; + }); + print("tabIndexConti11- $selectedIndex - ${_tabController.index}"); + // print("tabIndexCode11- $isHrcode - ${widget.isHrempcode}"); + } + + print('222'); _tabController.addListener(() { setState(() { selectedIndex = _tabController.index; + if (widget.selectedIndex == 3) { + isHrcode = 1; + } else { + isHrcode = 0; + } + empCodeFromHrPolcy = ''; + print("Process2"); + print("tabIndexConti- $selectedIndex - ${_tabController.index}"); + // print("tabIndexCode11- $isHrcode "); }); }); diff --git a/lib/hrPolicyDetails.dart b/lib/hrPolicyDetails.dart index a124366..a276c23 100755 --- a/lib/hrPolicyDetails.dart +++ b/lib/hrPolicyDetails.dart @@ -5,6 +5,7 @@ import 'package:nhancepolicy/customAppBar/enrollmentAppBar.dart'; import 'package:nhancepolicy/excel_verification.dart'; import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/service/api_service.dart'; +import 'package:nhancepolicy/service/hrDashboardTabs/claims.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:jwt_decode/jwt_decode.dart'; import 'dart:convert'; @@ -22,6 +23,7 @@ import 'package:path/path.dart' as path; import 'package:collection/collection.dart'; import 'package:url_launcher/url_launcher.dart'; import 'customAppBar/customFooter.dart'; +import 'hrDashboard.dart'; class hrPolicyDetails extends StatefulWidget { final String ClientId; @@ -822,7 +824,21 @@ class _HrPolicyDetailsState extends State width: 10, ), GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + print("policytabdata - ${item['emp_code']!}"); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => hrDashboard( + selectedIndex: 3, + empCodeFromHrPolicy: + item['emp_code']!, + isHrcode: 1), + ), + ); + }); + }, child: Container( height: 35, width: 35, diff --git a/lib/main.dart b/lib/main.dart index aa237b3..31f5330 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -82,15 +82,19 @@ Future main() async { 'empDetails': (context) => empDetails(), 'addOnsDetails': (context) => addOnsDetails(), 'empReviewDetails': (context) => empReviewDetails(), - 'hrDashboard': (context) => hrDashboard(), + 'hrDashboard': (context) => hrDashboard( + selectedIndex: 0, + isHrcode: 0, + empCodeFromHrPolicy: '', + ), 'cdTransactionDetails': (context) => cdTransactionDetails( - insurerName: '', - cdMasterAccountNo: '', - insurerId: '', - cd_ac_pk: '', - empClientId: '', - postToken: '', - ), + insurerName: '', + cdMasterAccountNo: '', + insurerId: '', + cd_ac_pk: '', + empClientId: '', + postToken: '', + ), 'hrPolicyDetails': (context) => hrPolicyDetails( ClientId: '', ClientPoliyId: '', diff --git a/lib/service/hrDashboardTabs/cd.dart b/lib/service/hrDashboardTabs/cd.dart index 2848ead..766bc9a 100644 --- a/lib/service/hrDashboardTabs/cd.dart +++ b/lib/service/hrDashboardTabs/cd.dart @@ -280,13 +280,7 @@ class _CdPolicieState extends State { ), ) : Expanded( - child: Row( - children: [ - SingleChildScrollView( - child: _buildCDDataTable(context), - ), - ], - ), + child: _buildCDDataTable(context), ) ], ), @@ -303,129 +297,131 @@ class _CdPolicieState extends State { ); } - // 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 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); - 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( - 'Insurer Name', - style: GoogleFonts.poppins( - color: Colors.white, fontWeight: FontWeight.bold), - ), - ), - Expanded( - flex: 3, - child: Text( - 'CD Account number', - style: GoogleFonts.poppins( - color: Colors.white, fontWeight: FontWeight.bold), - ), - ), - Expanded( - flex: 2, - child: Text( - 'Current Balance', - style: GoogleFonts.poppins( - color: Colors.white, fontWeight: FontWeight.bold), - ), - ), - Expanded( - flex: 1, - child: Text( - 'Action', - textAlign: TextAlign.center, - style: GoogleFonts.poppins( - color: Colors.white, fontWeight: FontWeight.bold), - ), - ), - ], - ), - ), - - const SizedBox(height: 6), - - // Table body rows - ..._paginatedData.mapIndexed((index, item) { - return Container( - margin: const EdgeInsets.only(bottom: 8), - padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 16), - decoration: BoxDecoration( - color: index % 2 == 0 ? Color(0xFFE6FAFB) : Colors.white, - borderRadius: BorderRadius.circular(6), - ), - child: Row( - children: [ - Expanded( - flex: 4, - child: Text( - item['insurer_name'] ?? '-', - style: GoogleFonts.poppins(color: Color(0xFF000000)), - ), - ), - Expanded( - flex: 3, - child: Text( - item['cd_master_account_no'] ?? '-', - style: GoogleFonts.poppins(color: Color(0xFF000000)), - ), - ), - Expanded( - flex: 2, - child: Text( - "₹${item['balance'] ?? '0'}", - style: GoogleFonts.poppins(color: Color(0xFF000000)), - ), - ), - Expanded( - flex: 1, - child: Center( - child: IconButton( - icon: const Icon(Icons.remove_red_eye_outlined), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => cdTransactionDetails( - insurerName: item['insurer_name'], - cdMasterAccountNo: item['cd_master_account_no'], - insurerId: item['insurer_id'], - cd_ac_pk: item['cd_ac_pk'], - empClientId: widget.empClientId, - postToken: widget.postToken), - ), - ); - }, - ), - ), - ), - ], - ), - ); - }).toList(), - ], + 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( + // 'Insurer Name', + // style: GoogleFonts.poppins( + // color: Colors.white, fontWeight: FontWeight.bold), + // ), + // ), + // Expanded( + // flex: 3, + // child: Text( + // 'CD Account number', + // style: GoogleFonts.poppins( + // color: Colors.white, fontWeight: FontWeight.bold), + // ), + // ), + // Expanded( + // flex: 2, + // child: Text( + // 'Current Balance', + // style: GoogleFonts.poppins( + // color: Colors.white, fontWeight: FontWeight.bold), + // ), + // ), + // Expanded( + // flex: 1, + // child: Text( + // 'Action', + // textAlign: TextAlign.center, + // style: GoogleFonts.poppins( + // color: Colors.white, fontWeight: FontWeight.bold), + // ), + // ), + // ], + // ), + // ), + // + // const SizedBox(height: 6), + // + // // Table body rows + // ..._paginatedData.mapIndexed((index, item) { + // return Container( + // margin: const EdgeInsets.only(bottom: 8), + // padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 16), + // decoration: BoxDecoration( + // color: index % 2 == 0 ? Color(0xFFE6FAFB) : Colors.white, + // borderRadius: BorderRadius.circular(6), + // ), + // child: Row( + // children: [ + // Expanded( + // flex: 4, + // child: Text( + // item['insurer_name'] ?? '-', + // style: GoogleFonts.poppins(color: Color(0xFF000000)), + // ), + // ), + // Expanded( + // flex: 3, + // child: Text( + // item['cd_master_account_no'] ?? '-', + // style: GoogleFonts.poppins(color: Color(0xFF000000)), + // ), + // ), + // Expanded( + // flex: 2, + // child: Text( + // "₹${item['balance'] ?? '0'}", + // style: GoogleFonts.poppins(color: Color(0xFF000000)), + // ), + // ), + // Expanded( + // flex: 1, + // child: Center( + // child: IconButton( + // icon: const Icon(Icons.remove_red_eye_outlined), + // onPressed: () { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => cdTransactionDetails( + // insurerName: item['insurer_name'], + // cdMasterAccountNo: item['cd_master_account_no'], + // insurerId: item['insurer_id'], + // cd_ac_pk: item['cd_ac_pk'], + // empClientId: widget.empClientId, + // postToken: widget.postToken), + // ), + // ); + // }, + // ), + // ), + // ), + // ], + // ), + // ); + // }).toList(), + // + // + // ], + // ); } Widget _buildDataRow(Map item) { @@ -451,7 +447,7 @@ class _CdPolicieState extends State { ), ), Expanded( - flex: 4, + flex: 3, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -460,7 +456,7 @@ class _CdPolicieState extends State { ), ), Expanded( - flex: 3, + flex: 2, child: Text("₹${item['balance'] ?? '0'}", style: _dataBold), ), Expanded( @@ -501,10 +497,10 @@ class _CdPolicieState extends State { children: [ Expanded(flex: 4, child: Text('Insurer Name', style: _headerStyle)), Expanded( - flex: 4, child: Text('CD Account number', style: _headerStyle)), + flex: 3, child: Text('CD Account number', style: _headerStyle)), Expanded( - flex: 4, child: Text('Current Balance', style: _headerStyle)), - Expanded(flex: 4, child: Text('Actions', style: _headerStyle)), + flex: 2, child: Text('Current Balance', style: _headerStyle)), + Expanded(flex: 1, child: Text('Actions', style: _headerStyle)), ], ), ); diff --git a/lib/service/hrDashboardTabs/claims.dart b/lib/service/hrDashboardTabs/claims.dart index f6591fa..49071ab 100644 --- a/lib/service/hrDashboardTabs/claims.dart +++ b/lib/service/hrDashboardTabs/claims.dart @@ -17,13 +17,18 @@ class ClaimsPolicies extends StatefulWidget { final String empClientBranchId; final String empHrId; final String postToken; + final String empCodeHrPolicy; + + final int isHrcode; const ClaimsPolicies( {Key? key, required this.empClientId, required this.empClientBranchId, required this.empHrId, - required this.postToken}); + required this.postToken, + required this.empCodeHrPolicy, + required this.isHrcode}); @override State createState() => _ClaimsPolicieState(); @@ -86,18 +91,40 @@ class _ClaimsPolicieState extends State { super.initState(); apiService = ApiService(context); - if (widget.postToken != null && widget.postToken.isNotEmpty) { - Map? postdecodedToken = Jwt.parseJwt(widget.postToken); - - empClientId = postdecodedToken['client_id'].toString(); - getClaimList(); - } for (String field in tabHeader) { controllers[field] = TextEditingController(); } print("TextCXOnte - $controllers"); + if (widget.postToken != null && widget.postToken.isNotEmpty) { + Map? postdecodedToken = Jwt.parseJwt(widget.postToken); + + empClientId = postdecodedToken['client_id'].toString(); + + print("Empcoed1- ${widget.empCodeHrPolicy}"); + print("EmpisHrcode- ${widget.isHrcode}"); + if (widget.empCodeHrPolicy != '') { + print("Empcoedbool- ${widget.isHrcode}"); + controllers['empCode']!.text = widget.empCodeHrPolicy; + // if (widget.isHrcode == 0) { + // controllers['empCode']?.clear(); + // } else { + // controllers['empCode']!.text = widget.empCodeHrPolicy; + // } + + print("Empcoed- ${widget.empCodeHrPolicy}"); + } + + // if (widget.empCodeHrPolicy != '' && widget.isHrcode) { + // print("Empcoedbool- ${widget.isHrcode}"); + // controllers['empCode']!.text = widget.empCodeHrPolicy; + // print("Empcoed- ${widget.empCodeHrPolicy}"); + // } + + getClaimList(); + } + getClaimsPoliciesDetails(); // getApiData(); } @@ -107,6 +134,7 @@ class _ClaimsPolicieState extends State { for (var controller in controllers.values) { controller.dispose(); } + controllers['empCode']?.clear(); super.dispose(); } @@ -187,6 +215,7 @@ class _ClaimsPolicieState extends State { } void applyFilter() { + print("Filtersss"); final data = claim_Detials(); print("data -- $data"); getClaimList(); diff --git a/lib/service/hrDashboardTabs/preEnrollment.dart b/lib/service/hrDashboardTabs/preEnrollment.dart index 8c970af..9025c4a 100644 --- a/lib/service/hrDashboardTabs/preEnrollment.dart +++ b/lib/service/hrDashboardTabs/preEnrollment.dart @@ -139,10 +139,10 @@ class _PreEnrollmentState extends State { final totalSpacing = (crossAxisCount - 1) * spacing; final itemWidth = (screenWidth - totalSpacing) / crossAxisCount; -// Example: target card height + // Example: target card height final itemHeight = screenHeight * 0.2; -// Dynamic aspect ratio: + // Dynamic aspect ratio: final aspectRatio = screenWidth / screenHeight; print("_PreEnrollmentState 4"); @@ -176,7 +176,7 @@ class _PreEnrollmentState extends State { // color: Colors.redAccent.shade100, // color: Colors.white, // color: Colors.white, - padding: EdgeInsets.symmetric(horizontal: 16.0), + // padding: EdgeInsets.symmetric(horizontal: 16.0), height: MediaQuery.of(context).size.height * 0.45, // height: 400,