FIX_EMPCODE_RESET_CLAIMS
This commit is contained in:
parent
d734836efe
commit
5088f4f275
@ -42,6 +42,9 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
late TabController _tabController;
|
||||
bool isLoading = false;
|
||||
int isHrcode = 0;
|
||||
|
||||
String? enrollToken = '';
|
||||
String? _postToken = '';
|
||||
late String _token;
|
||||
dynamic getPolicyNo;
|
||||
// bool _isLoading = false;
|
||||
@ -101,11 +104,11 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final _postToken = prefs.getString('_postToken');
|
||||
final enrollToken = prefs.getString('enrollToken');
|
||||
_postToken = prefs.getString('_postToken');
|
||||
enrollToken = prefs.getString('enrollToken');
|
||||
|
||||
if (enrollToken != null && enrollToken.isNotEmpty) {
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(enrollToken);
|
||||
if (enrollToken != null && enrollToken!.isNotEmpty) {
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(enrollToken!);
|
||||
enrollmentClient_id = decodedToken['client_id'].toString();
|
||||
enrollmentEmpClientBranchId =
|
||||
prefs.getString('enrollmentEmpClientBranchId');
|
||||
@ -129,39 +132,14 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
});
|
||||
print("getCardArrays.length = ${getCardArrays.length}");
|
||||
|
||||
tabViews.add(
|
||||
PreEnrollment(
|
||||
enrollmentClientId: enrollmentClient_id,
|
||||
enrollmentClientBranchId: enrollmentEmpClientBranchId,
|
||||
enrollmentHrId: enrollmentHrId,
|
||||
enrollToken: enrollToken,
|
||||
),
|
||||
// SizedBox(
|
||||
// height: 400,
|
||||
// child: Card(
|
||||
// elevation: 5,
|
||||
// color: Colors.white,
|
||||
// child: SizedBox(
|
||||
// height: 100,
|
||||
// child: GridView.builder(
|
||||
// itemCount: getCardArrays.length,
|
||||
// gridDelegate:
|
||||
// const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
// crossAxisCount: 4,
|
||||
// crossAxisSpacing: 16,
|
||||
// mainAxisSpacing: 0,
|
||||
// childAspectRatio: 2,
|
||||
// ),
|
||||
// itemBuilder: (context, index) {
|
||||
// print("tabIndc- $index");
|
||||
// print("getCardArraystabIndc- $getCardArrays[index]");
|
||||
// return buildPolicyCard(getCardArrays[index]);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
);
|
||||
// tabViews.add(
|
||||
// PreEnrollment(
|
||||
// enrollmentClientId: enrollmentClient_id,
|
||||
// enrollmentClientBranchId: enrollmentEmpClientBranchId,
|
||||
// enrollmentHrId: enrollmentHrId,
|
||||
// enrollToken: enrollToken,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,8 +154,8 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
enrollmentHrId, enrollToken);
|
||||
}
|
||||
|
||||
if (_postToken != null && _postToken.isNotEmpty) {
|
||||
Map<String, dynamic>? postdecodedToken = Jwt.parseJwt(_postToken);
|
||||
if (_postToken != null && _postToken!.isNotEmpty) {
|
||||
Map<String, dynamic>? postdecodedToken = Jwt.parseJwt(_postToken!);
|
||||
|
||||
empClientId = postdecodedToken['client_id'].toString();
|
||||
empClientBranchId = prefs.getString('empClientBranchId');
|
||||
@ -208,14 +186,14 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
'icon': Icons.verified_user,
|
||||
'label': 'Active Policies',
|
||||
});
|
||||
tabViews.add(
|
||||
ActivePolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
postToken: _postToken,
|
||||
),
|
||||
);
|
||||
// tabViews.add(
|
||||
// ActivePolicies(
|
||||
// empClientId: empClientId,
|
||||
// empClientBranchId: empClientBranchId,
|
||||
// empHrId: empHrId,
|
||||
// postToken: _postToken,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
if (empAllowed_modules.contains(3)) {
|
||||
print("visibleTabs.length3");
|
||||
@ -226,12 +204,12 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
'label': 'CD',
|
||||
});
|
||||
|
||||
tabViews.add(CdPolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
postToken: _postToken,
|
||||
));
|
||||
// tabViews.add(CdPolicies(
|
||||
// empClientId: empClientId,
|
||||
// empClientBranchId: empClientBranchId,
|
||||
// empHrId: empHrId,
|
||||
// postToken: _postToken,
|
||||
// ));
|
||||
}
|
||||
print('333');
|
||||
if (empAllowed_modules.contains(4)) {
|
||||
@ -239,16 +217,15 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
'icon': Icons.receipt_long,
|
||||
'label': 'Claims',
|
||||
});
|
||||
tabViews.add(ClaimsPolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
postToken: _postToken,
|
||||
isHrcode: widget.isHrcode == 1 ? 1 : 0,
|
||||
empCodeHrPolicy: empCodeFromHrPolcy
|
||||
// empCodeHrPolicy: widget.empCodeFromHrPolicy
|
||||
|
||||
));
|
||||
// tabViews.add(ClaimsPolicies(
|
||||
// empClientId: empClientId,
|
||||
// empClientBranchId: empClientBranchId,
|
||||
// empHrId: empHrId,
|
||||
// postToken: _postToken,
|
||||
// isHrcode: widget.isHrcode == 1 ? 1 : 0,
|
||||
// empCodeHrPolicy: empCodeFromHrPolcy
|
||||
// // empCodeHrPolicy: widget.empCodeFromHrPolicy
|
||||
// ));
|
||||
}
|
||||
}
|
||||
// getCashDepositDetails(
|
||||
@ -281,16 +258,20 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
|
||||
print('222');
|
||||
_tabController.addListener(() {
|
||||
int newIndex = _tabController.index;
|
||||
|
||||
setState(() {
|
||||
selectedIndex = _tabController.index;
|
||||
if (widget.selectedIndex == 3) {
|
||||
isHrcode = 1;
|
||||
} else {
|
||||
isHrcode = 0;
|
||||
selectedIndex = newIndex;
|
||||
if (newIndex != 3 && empCodeFromHrPolcy.isNotEmpty) {
|
||||
empCodeFromHrPolcy = ''; // ✅ clear only once
|
||||
}
|
||||
empCodeFromHrPolcy = '';
|
||||
|
||||
// selectedIndex = _tabController.index;
|
||||
// empCodeFromHrPolcy = '';
|
||||
|
||||
print("Process2");
|
||||
print("tabIndexConti- $selectedIndex - ${_tabController.index}");
|
||||
|
||||
// print("tabIndexCode11- $isHrcode ");
|
||||
});
|
||||
});
|
||||
@ -300,6 +281,47 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
List<Widget> getTabViews() {
|
||||
return tabData.map((tab) {
|
||||
final label = tab['label'];
|
||||
|
||||
switch (label) {
|
||||
case 'Claims':
|
||||
return ClaimsPolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
postToken: _postToken!,
|
||||
isHrcode: widget.isHrcode == 1 ? 1 : 0,
|
||||
empCodeHrPolicy: empCodeFromHrPolcy,
|
||||
);
|
||||
case 'CD':
|
||||
return CdPolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
postToken: _postToken!,
|
||||
);
|
||||
case 'Active Policies':
|
||||
return ActivePolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
postToken: _postToken!,
|
||||
);
|
||||
case 'Pre Enrollment':
|
||||
return PreEnrollment(
|
||||
enrollmentClientId: enrollmentClient_id,
|
||||
enrollmentClientBranchId: enrollmentEmpClientBranchId,
|
||||
enrollmentHrId: enrollmentHrId,
|
||||
enrollToken: enrollToken!,
|
||||
);
|
||||
default:
|
||||
return Center(child: Text('Unknown tab'));
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
|
||||
Future<void> getClientLogoAndDetails(clintBranchId, clintID, token) async {
|
||||
var url = Uri.parse(Environment.apiUrl +
|
||||
'getClientDetails?client_id=$clintID&client_branch_id=$clintBranchId');
|
||||
@ -568,19 +590,6 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
controller: _tabController,
|
||||
isScrollable: true,
|
||||
labelPadding: EdgeInsets.zero,
|
||||
// labelPadding: const EdgeInsets.symmetric(
|
||||
// horizontal: 0, vertical: 0),
|
||||
// indicator: BoxDecoration(
|
||||
// color: const Color(0xFF00999E), // Selected tab background
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Colors.black.withOpacity(0.2),
|
||||
// blurRadius: 4,
|
||||
// offset: const Offset(0, 2),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
dividerColor: Colors.transparent,
|
||||
indicatorColor: Colors.transparent,
|
||||
indicatorPadding: EdgeInsets.zero,
|
||||
@ -595,25 +604,6 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
isSelected: selectedIndex == index,
|
||||
);
|
||||
}),
|
||||
|
||||
// tabs: [
|
||||
// CustomTab(
|
||||
// icon: Icons.grid_view,
|
||||
// label: 'Pre Enrollment',
|
||||
// isSelected: selectedIndex == 0),
|
||||
// CustomTab(
|
||||
// icon: Icons.verified_user,
|
||||
// label: 'Active Policies',
|
||||
// isSelected: selectedIndex == 1),
|
||||
// CustomTab(
|
||||
// icon: Icons.desktop_windows,
|
||||
// label: 'CD',
|
||||
// isSelected: selectedIndex == 2),
|
||||
// CustomTab(
|
||||
// icon: Icons.receipt_long,
|
||||
// label: 'Claims',
|
||||
// isSelected: selectedIndex == 3),
|
||||
// ],
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -625,19 +615,11 @@ class _hrDashboardState extends State<hrDashboard>
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: tabViews,
|
||||
children: getTabViews(),
|
||||
// children: tabViews,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// SizedBox(
|
||||
// height: MediaQuery.of(context).size.height * 0.55,
|
||||
// // height: 500, // Adjust height based on your layout
|
||||
// child: TabBarView(
|
||||
// controller: _tabController,
|
||||
// children: tabViews,
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -60,6 +60,7 @@ class hrPolicyDetails extends StatefulWidget {
|
||||
class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
with TickerProviderStateMixin {
|
||||
Uint8List? fileBytes;
|
||||
String empCodeFromHrPolcy = '';
|
||||
late String _token;
|
||||
List<Map<String, dynamic>> getEmpDependenceByClintId = [];
|
||||
List<Map<String, dynamic>> getCDPolicies = [];
|
||||
@ -831,10 +832,10 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => hrDashboard(
|
||||
selectedIndex: 3,
|
||||
empCodeFromHrPolicy:
|
||||
item['emp_code']!,
|
||||
isHrcode: 1),
|
||||
selectedIndex: 3,
|
||||
empCodeFromHrPolicy: item['emp_code']!,
|
||||
isHrcode: 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user