UI_HR_Dashboard Tab Layout
This commit is contained in:
parent
745af9eb86
commit
a262d702c8
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,10 @@ import 'package:jwt_decode/jwt_decode.dart';
|
||||
import 'package:nhancepolicy/models/environment.dart';
|
||||
import 'package:nhancepolicy/responsive.dart';
|
||||
import 'package:nhancepolicy/service/api_service.dart';
|
||||
import 'package:nhancepolicy/service/hrDashboardTabs/activePolicies.dart';
|
||||
import 'package:nhancepolicy/service/hrDashboardTabs/cd.dart';
|
||||
import 'package:nhancepolicy/service/hrDashboardTabs/claims.dart';
|
||||
import 'package:nhancepolicy/service/hrDashboardTabs/preEnrollment.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'customAppBar/customAppBar.dart';
|
||||
@ -23,7 +27,8 @@ class hrDashboard extends StatefulWidget {
|
||||
State<hrDashboard> createState() => _hrDashboardState();
|
||||
}
|
||||
|
||||
class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStateMixin {
|
||||
class _hrDashboardState extends State<hrDashboard>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late ApiService apiService;
|
||||
late TabController _tabController;
|
||||
bool isLoading = false;
|
||||
@ -34,10 +39,16 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
dynamic enrollmentClient_id;
|
||||
dynamic policy_name;
|
||||
dynamic getCardArrays = [];
|
||||
List<dynamic> empAllowed_modules = [];
|
||||
|
||||
List<Widget> visibleTabs = [];
|
||||
List<Widget> tabViews = [];
|
||||
dynamic clientName;
|
||||
dynamic clientLogo;
|
||||
dynamic empClientBranchId;
|
||||
dynamic empHrId;
|
||||
List<dynamic> enrollmentAllowed_modules = [];
|
||||
List<Map<String, dynamic>> tabData = [];
|
||||
dynamic enrollmentEmpClientBranchId;
|
||||
dynamic enrollmentHrId;
|
||||
dynamic empClientId;
|
||||
@ -55,12 +66,12 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
super.initState();
|
||||
apiService = ApiService(context); // Initialize ApiService here
|
||||
_loadToken();
|
||||
_tabController = TabController(length: 4, vsync: this);
|
||||
_tabController.addListener(() {
|
||||
setState(() {
|
||||
selectedIndex = _tabController.index;
|
||||
});
|
||||
});
|
||||
// _tabController = TabController(length: 4, vsync: this);
|
||||
// _tabController.addListener(() {
|
||||
// setState(() {
|
||||
// selectedIndex = _tabController.index;
|
||||
// });
|
||||
// });
|
||||
// Future.delayed(Duration(seconds: 3), () {
|
||||
// setState(() {
|
||||
// isLoading = false;
|
||||
@ -79,45 +90,169 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
final _postToken = prefs.getString('_postToken');
|
||||
final enrollToken = prefs.getString('enrollToken');
|
||||
|
||||
|
||||
|
||||
|
||||
if (_postToken != null && _postToken.isNotEmpty) {
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(_postToken);
|
||||
empClientId = decodedToken['client_id'].toString();
|
||||
empClientBranchId = prefs.getString('empClientBranchId');
|
||||
empHrId = prefs.getString('empHrId');
|
||||
print(empClientId);
|
||||
print(empClientBranchId);
|
||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||
clientLogo = prefs.getString('clientLogo');
|
||||
clientName = prefs.getString('clientName');
|
||||
} else {
|
||||
getClientLogoAndDetails(empClientBranchId,empClientId,_postToken);
|
||||
}
|
||||
getCashDepositDetails(empClientBranchId,empClientId,empHrId,_postToken);
|
||||
} else if (enrollToken != null && enrollToken.isNotEmpty) {
|
||||
if (enrollToken != null && enrollToken.isNotEmpty) {
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(enrollToken);
|
||||
enrollmentClient_id = decodedToken['client_id'].toString();
|
||||
enrollmentEmpClientBranchId = prefs.getString('enrollmentEmpClientBranchId');
|
||||
enrollmentEmpClientBranchId =
|
||||
prefs.getString('enrollmentEmpClientBranchId');
|
||||
enrollmentHrId = prefs.getString('enrollmentHrId');
|
||||
|
||||
print("Pre decodedToken - $decodedToken");
|
||||
print("Pre enrollmentClient_id - $enrollmentClient_id");
|
||||
print("Pre enrollmentEmpClientBranchId - $enrollmentEmpClientBranchId");
|
||||
print("Pre enrollmentHrId - $enrollmentHrId");
|
||||
|
||||
String? modulesString = prefs.getString('enrollmentAllowed_modules');
|
||||
if (modulesString != null) {
|
||||
enrollmentAllowed_modules = jsonDecode(modulesString);
|
||||
print(
|
||||
"enrollmentAllowed_modules - $enrollmentAllowed_modules"); // [2, 3, 4]
|
||||
|
||||
if (enrollmentAllowed_modules.contains(1)) {
|
||||
tabData.add({
|
||||
'icon': Icons.grid_view,
|
||||
'label': 'Pre Enrollment',
|
||||
});
|
||||
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]);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||
clientLogo = prefs.getString('clientLogo');
|
||||
clientName = prefs.getString('clientName');
|
||||
} else {
|
||||
getClientLogoAndDetails(enrollmentEmpClientBranchId,enrollmentClient_id,enrollToken);
|
||||
getClientLogoAndDetails(
|
||||
enrollmentEmpClientBranchId, enrollmentClient_id, enrollToken);
|
||||
}
|
||||
getCashDepositDetails(enrollmentEmpClientBranchId,enrollmentClient_id,enrollmentHrId,enrollToken);
|
||||
} else {
|
||||
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
||||
// For now, let's navigate to the login screen
|
||||
ToastHelper.showErrorToast(context, 'Session Out');
|
||||
Navigator.pushReplacementNamed(context, 'hrLogin');
|
||||
getCashDepositDetails(enrollmentEmpClientBranchId, enrollmentClient_id,
|
||||
enrollmentHrId, enrollToken);
|
||||
}
|
||||
|
||||
if (_postToken != null && _postToken.isNotEmpty) {
|
||||
Map<String, dynamic>? postdecodedToken = Jwt.parseJwt(_postToken);
|
||||
|
||||
empClientId = postdecodedToken['client_id'].toString();
|
||||
empClientBranchId = prefs.getString('empClientBranchId');
|
||||
empHrId = prefs.getString('empHrId');
|
||||
|
||||
print('post empHrId- $empHrId');
|
||||
print('postdecodedToken- $postdecodedToken');
|
||||
print('post empClientId- $empClientId');
|
||||
print('post empClientBranchId- $empClientBranchId');
|
||||
|
||||
print('allowed_modules');
|
||||
String? modulesString = prefs.getString('empAllowed_modules');
|
||||
|
||||
String? enrollmodulesString =
|
||||
prefs.getString('enrollmentAllowed_modules');
|
||||
if (modulesString != null || enrollmodulesString != null) {
|
||||
empAllowed_modules = jsonDecode(modulesString!);
|
||||
enrollmentAllowed_modules = jsonDecode(enrollmodulesString!);
|
||||
print("empAllowed_modules - $empAllowed_modules"); // [2, 3, 4]
|
||||
print(
|
||||
"enrollmentAllowed_modules - $enrollmentAllowed_modules"); // [2, 3, 4]
|
||||
|
||||
if (empAllowed_modules.contains(2)) {
|
||||
print("visibleTabs.length2");
|
||||
print(visibleTabs.length);
|
||||
|
||||
tabData.add({
|
||||
'icon': Icons.verified_user,
|
||||
'label': 'Active Policies',
|
||||
});
|
||||
tabViews.add(
|
||||
ActivePolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (empAllowed_modules.contains(3)) {
|
||||
print("visibleTabs.length3");
|
||||
print(visibleTabs.length);
|
||||
|
||||
tabData.add({
|
||||
'icon': Icons.desktop_windows,
|
||||
'label': 'CD',
|
||||
});
|
||||
|
||||
tabViews.add(CdPolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
));
|
||||
}
|
||||
if (empAllowed_modules.contains(4)) {
|
||||
tabData.add({
|
||||
'icon': Icons.receipt_long,
|
||||
'label': 'Claims',
|
||||
});
|
||||
tabViews.add(ClaimsPolicies(
|
||||
empClientId: empClientId,
|
||||
empClientBranchId: empClientBranchId,
|
||||
empHrId: empHrId,
|
||||
));
|
||||
}
|
||||
}
|
||||
// getCashDepositDetails(
|
||||
// empClientBranchId, empClientId, empHrId, _postToken);
|
||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||
clientLogo = prefs.getString('clientLogo');
|
||||
clientName = prefs.getString('clientName');
|
||||
} else {
|
||||
getClientLogoAndDetails(empClientBranchId, empClientId, _postToken);
|
||||
}
|
||||
print("getCashDepositDetails");
|
||||
}
|
||||
|
||||
_tabController = TabController(length: tabData.length, vsync: this);
|
||||
_tabController.addListener(() {
|
||||
setState(() {
|
||||
selectedIndex = _tabController.index;
|
||||
});
|
||||
});
|
||||
|
||||
setState(() {});
|
||||
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
Future<void> getClientLogoAndDetails(clintBranchId,clintID,token) async {
|
||||
Future<void> getClientLogoAndDetails(clintBranchId, clintID, token) async {
|
||||
var url = Uri.parse(Environment.apiUrl +
|
||||
'getClientDetails?client_id=$clintID&client_branch_id=$clintBranchId');
|
||||
try {
|
||||
@ -164,10 +299,15 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getCashDepositDetails(clintBranchId,clintID,hr_id,token) async {
|
||||
Future<void> getCashDepositDetails(
|
||||
clintBranchId, clintID, hr_id, token) async {
|
||||
print('IN');
|
||||
print("clintBranchId -$clintBranchId");
|
||||
print("clintID -$clintID");
|
||||
print("hr_id -$hr_id");
|
||||
print("token -$token");
|
||||
|
||||
isLoading = true;
|
||||
// isLoading = true;
|
||||
// setState(() {
|
||||
// _isLoading = true;
|
||||
// });
|
||||
@ -175,8 +315,12 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
if (clintBranchId == null || clintID == null) {
|
||||
return;
|
||||
}
|
||||
final response =
|
||||
await apiService.getCashDepositDetailsToApi(clintID!, clintBranchId!,hr_id,token);
|
||||
final response = await apiService.getCashDepositDetailsToApi(
|
||||
clintID!, clintBranchId!, hr_id, token);
|
||||
|
||||
// final response = await apiService.getCashDepositDetailsToApi(
|
||||
// clintID!, clintBranchId!, hr_id, token);
|
||||
print('IN1');
|
||||
if (response['status'] == 'success') {
|
||||
isLoading = false;
|
||||
setState(() {
|
||||
@ -186,6 +330,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
print('getCardArrays');
|
||||
print(getCardArrays);
|
||||
});
|
||||
|
||||
print('IN2');
|
||||
} else {
|
||||
print('API request failed with status');
|
||||
}
|
||||
@ -267,6 +413,9 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
double policyHeight = MediaQuery.of(context).size.height / 4.5;
|
||||
double cardWidth = MediaQuery.of(context).size.width / 6;
|
||||
|
||||
print("visibleTabAll - $visibleTabs");
|
||||
print("tabViewsAll - $tabViews");
|
||||
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(),
|
||||
body: Stack(children: [
|
||||
@ -277,82 +426,81 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
color: Color(0xFFEFF3F6),
|
||||
child: Column(
|
||||
children: [
|
||||
Card(
|
||||
elevation: 0,
|
||||
Container(
|
||||
color: Colors.white,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 75,
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.only(
|
||||
top: 10, bottom: 10, left: 20, right: 20)
|
||||
: EdgeInsets.only(
|
||||
top: 12,
|
||||
bottom: 12,
|
||||
left: 10,
|
||||
right: 10), // Add padding to the container
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: Container(
|
||||
width: 150,
|
||||
height: 150,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Image.network(
|
||||
clientLogo ?? '',
|
||||
width: 80, // Set the width here
|
||||
height: 80, // Set the height here
|
||||
loadingBuilder: (BuildContext context,
|
||||
Widget child,
|
||||
ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
value: loadingProgress
|
||||
.expectedTotalBytes !=
|
||||
null
|
||||
? loadingProgress
|
||||
.cumulativeBytesLoaded /
|
||||
loadingProgress
|
||||
.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
errorBuilder: (BuildContext context,
|
||||
Object error, StackTrace? stackTrace) {
|
||||
return Image.asset(
|
||||
'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
),
|
||||
width: double.infinity,
|
||||
height: 75,
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.only(
|
||||
top: 10, bottom: 10, left: 20, right: 20)
|
||||
: EdgeInsets.only(
|
||||
top: 12,
|
||||
bottom: 12,
|
||||
left: 10,
|
||||
right: 10), // Add padding to the container
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: Container(
|
||||
width: 150,
|
||||
height: 150,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Image.network(
|
||||
clientLogo ?? '',
|
||||
width: 80, // Set the width here
|
||||
height: 80, // Set the height here
|
||||
loadingBuilder: (BuildContext context,
|
||||
Widget child,
|
||||
ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
value:
|
||||
loadingProgress.expectedTotalBytes !=
|
||||
null
|
||||
? loadingProgress
|
||||
.cumulativeBytesLoaded /
|
||||
loadingProgress
|
||||
.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
errorBuilder: (BuildContext context,
|
||||
Object error, StackTrace? stackTrace) {
|
||||
return Image.asset(
|
||||
'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 9,
|
||||
child: Text(
|
||||
clientName ?? '',
|
||||
textAlign: TextAlign.right,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(context) ? 20 : 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 9,
|
||||
child: Text(
|
||||
clientName ?? '',
|
||||
textAlign: TextAlign.right,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(context) ? 20 : 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFC4E3E6), // 🔹 Background behind the TabBar
|
||||
color: Color(
|
||||
0xFFC4E3E6), // 🔹 Background behind the TabBar
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.transparent),
|
||||
boxShadow: [
|
||||
@ -366,7 +514,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
isScrollable: true,
|
||||
labelPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
|
||||
labelPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 0, vertical: 0),
|
||||
// indicator: BoxDecoration(
|
||||
// color: const Color(0xFF00999E), // Selected tab background
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
@ -382,47 +531,75 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
indicatorColor: Colors.transparent,
|
||||
labelColor: Colors.white,
|
||||
unselectedLabelColor: const Color(0xFF828282),
|
||||
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),
|
||||
],
|
||||
// tabs: visibleTabs,
|
||||
tabs: List.generate(tabData.length, (index) {
|
||||
final data = tabData[index];
|
||||
return CustomTab(
|
||||
icon: data['icon'],
|
||||
label: data['label'],
|
||||
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),
|
||||
// ],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
// Expanded TabBarView
|
||||
SizedBox(
|
||||
height: 400, // Adjust height based on your layout
|
||||
height: 500, // Adjust height based on your layout
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
// Pre Enrollment Tab
|
||||
Card(
|
||||
elevation: 5,
|
||||
color: Colors.white,
|
||||
child: Container(
|
||||
child: GridView.builder(
|
||||
itemCount: getCardArrays.length,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4, // Adjust for screen size (e.g., use 2 or 3 for tablets)
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 0,
|
||||
childAspectRatio: 2,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
return buildPolicyCard(getCardArrays[index]);
|
||||
},
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
Center(child: Text("Active Policies")),
|
||||
Center(child: Text("CD")),
|
||||
Center(child: Text("Claims")),
|
||||
],
|
||||
children: tabViews,
|
||||
),
|
||||
|
||||
// child: TabBarView(
|
||||
// controller: _tabController,
|
||||
// children: [
|
||||
// // Pre Enrollment Tab
|
||||
// Card(
|
||||
// elevation: 5,
|
||||
// color: Colors.white,
|
||||
// child: Container(
|
||||
// child: GridView.builder(
|
||||
// itemCount: getCardArrays.length,
|
||||
// gridDelegate:
|
||||
// const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
// crossAxisCount:
|
||||
// 4, // Adjust for screen size (e.g., use 2 or 3 for tablets)
|
||||
// crossAxisSpacing: 16,
|
||||
// mainAxisSpacing: 0,
|
||||
// childAspectRatio: 2,
|
||||
// ),
|
||||
// itemBuilder: (context, index) {
|
||||
// return buildPolicyCard(
|
||||
// getCardArrays[index]);
|
||||
// },
|
||||
// ),
|
||||
// )),
|
||||
//
|
||||
// Center(child: Text("Active Policies")),
|
||||
// Center(child: Text("CD")),
|
||||
// Center(child: Text("Claims")),
|
||||
// ],
|
||||
// ),
|
||||
),
|
||||
// if (getCardArrays.length != 0)
|
||||
// Card(
|
||||
@ -817,39 +994,46 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
}
|
||||
|
||||
Widget buildPolicyCard(Map<String, dynamic> policy) {
|
||||
return Card(
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
policy['type'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
print("buildPolicyCard - $policy");
|
||||
return SizedBox(
|
||||
height: 50,
|
||||
child: Card(
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
policy['type'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
policy['policy_name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
policy['policy_name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildCountBox(policy['membersCountOfDraft'].toString(), "Draft"),
|
||||
_buildCountBox(policy['membersCountOfEnrolled'].toString(), "Enrolled"),
|
||||
_buildCountBox(policy['totalMembersCount'].toString(), "Total"),
|
||||
],
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildCountBox(
|
||||
policy['membersCountOfDraft'].toString(), "Draft"),
|
||||
_buildCountBox(
|
||||
policy['membersCountOfEnrolled'].toString(), "Enrolled"),
|
||||
_buildCountBox(
|
||||
policy['totalMembersCount'].toString(), "Total"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -872,11 +1056,11 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(label, style: const TextStyle(fontSize: 12, color: Colors.black87)),
|
||||
Text(label,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.black87)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CustomTab extends StatelessWidget {
|
||||
@ -915,9 +1099,12 @@ class CustomTab extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 18, color: isSelected ? Colors.white : const Color(0xFF828282)),
|
||||
Icon(icon,
|
||||
size: 18,
|
||||
color: isSelected ? Colors.white : const Color(0xFF828282)),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
@ -979,4 +1166,4 @@ class PolicyCard extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
287
lib/hrLogin.dart
287
lib/hrLogin.dart
@ -64,7 +64,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
|
||||
Map<String, dynamic> payload = isEmailFieldVisible
|
||||
? {'email': emailController.text}
|
||||
: {'mobile_no': mobileController.text};
|
||||
: {'mobile_number': mobileController.text};
|
||||
|
||||
// var enteredMobileNumber = mobileController.text;
|
||||
final response = await http.post(
|
||||
@ -81,7 +81,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
String message = data['data']['message'];
|
||||
if (userVerification) {
|
||||
final SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
await SharedPreferences.getInstance();
|
||||
// var enteredMobileNumber = mobileController.text;
|
||||
// prefs.setString('empMobileNo', enteredMobileNumber);
|
||||
if (isEmailFieldVisible) {
|
||||
@ -175,7 +175,6 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString('verificationId', _verificationId);
|
||||
|
||||
|
||||
ToastHelper.showSuccessToast(
|
||||
context, 'Verification code sent to ${enteredMobileNumber}');
|
||||
|
||||
@ -194,7 +193,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
_isLoading = false;
|
||||
});
|
||||
},
|
||||
codeAutoRetrievalTimeout: (String verificationId) async{
|
||||
codeAutoRetrievalTimeout: (String verificationId) async {
|
||||
setState(() {
|
||||
_verificationId = verificationId;
|
||||
});
|
||||
@ -221,7 +220,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
print('The provided phone number is not valid.');
|
||||
}
|
||||
},
|
||||
codeSent: (String verificationId, int? resendToken) async{
|
||||
codeSent: (String verificationId, int? resendToken) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('verificationId', verificationId);
|
||||
setState(() {
|
||||
@ -242,7 +241,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
),
|
||||
);
|
||||
},
|
||||
codeAutoRetrievalTimeout: (String verificationId) async{
|
||||
codeAutoRetrievalTimeout: (String verificationId) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('verificationId', verificationId);
|
||||
setState(() {
|
||||
@ -509,12 +508,11 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
Container(
|
||||
margin: Responsive.isDesktop(context)
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: 150)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
horizontal: 150)
|
||||
: EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
@ -535,157 +533,138 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
children: [
|
||||
isEmailFieldVisible
|
||||
? Container(
|
||||
height: 55,
|
||||
margin: Responsive
|
||||
.isDesktop(context)
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: 150)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: Colors.grey),
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
10),
|
||||
),
|
||||
child: TextFormField(
|
||||
controller:
|
||||
emailController,
|
||||
keyboardType:
|
||||
TextInputType
|
||||
.emailAddress,
|
||||
decoration:
|
||||
InputDecoration(
|
||||
border:
|
||||
InputBorder.none,
|
||||
hintText:
|
||||
"Enter your email",
|
||||
contentPadding:
|
||||
EdgeInsets
|
||||
.symmetric(
|
||||
horizontal:
|
||||
10),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null ||
|
||||
value.isEmpty) {
|
||||
return 'Please enter your email';
|
||||
}
|
||||
if (!RegExp(
|
||||
r'^[^@]+@[^@]+\.[^@]+')
|
||||
.hasMatch(value)) {
|
||||
return 'Please enter a valid email';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: 55,
|
||||
margin: Responsive
|
||||
.isDesktop(context)
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: 150)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: Colors.grey),
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
10),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 10),
|
||||
SizedBox(
|
||||
width: 40,
|
||||
child: TextField(
|
||||
controller:
|
||||
countryController,
|
||||
keyboardType:
|
||||
TextInputType
|
||||
.number,
|
||||
decoration:
|
||||
InputDecoration(
|
||||
border:
|
||||
InputBorder
|
||||
.none,
|
||||
),
|
||||
height: 55,
|
||||
margin: Responsive.isDesktop(
|
||||
context)
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: 150)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: Colors.grey),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"|",
|
||||
style: TextStyle(
|
||||
fontSize: 33,
|
||||
color:
|
||||
Colors.grey),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller:
|
||||
mobileController,
|
||||
keyboardType:
|
||||
TextInputType
|
||||
.phone,
|
||||
decoration:
|
||||
InputDecoration(
|
||||
border:
|
||||
InputBorder
|
||||
.none,
|
||||
controller: emailController,
|
||||
keyboardType: TextInputType
|
||||
.emailAddress,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText:
|
||||
"Enter your mobile number",
|
||||
"Enter your email",
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(
|
||||
horizontal: 10),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value ==
|
||||
null ||
|
||||
value
|
||||
.isEmpty) {
|
||||
return 'Please enter your mobile number';
|
||||
if (value == null ||
|
||||
value.isEmpty) {
|
||||
return 'Please enter your email';
|
||||
}
|
||||
if (value
|
||||
.length !=
|
||||
10) {
|
||||
return 'Mobile number must be 10 digits';
|
||||
if (!RegExp(
|
||||
r'^[^@]+@[^@]+\.[^@]+')
|
||||
.hasMatch(value)) {
|
||||
return 'Please enter a valid email';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(
|
||||
10),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: 55,
|
||||
margin: Responsive.isDesktop(
|
||||
context)
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: 150)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: Colors.grey),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 10),
|
||||
SizedBox(
|
||||
width: 40,
|
||||
child: TextField(
|
||||
controller:
|
||||
countryController,
|
||||
keyboardType:
|
||||
TextInputType
|
||||
.number,
|
||||
decoration:
|
||||
InputDecoration(
|
||||
border:
|
||||
InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"|",
|
||||
style: TextStyle(
|
||||
fontSize: 33,
|
||||
color: Colors.grey),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller:
|
||||
mobileController,
|
||||
keyboardType:
|
||||
TextInputType.phone,
|
||||
decoration:
|
||||
InputDecoration(
|
||||
border:
|
||||
InputBorder.none,
|
||||
hintText:
|
||||
"Enter your mobile number",
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null ||
|
||||
value.isEmpty) {
|
||||
return 'Please enter your mobile number';
|
||||
}
|
||||
if (value.length !=
|
||||
10) {
|
||||
return 'Mobile number must be 10 digits';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(
|
||||
10),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
Container(
|
||||
margin:
|
||||
Responsive.isDesktop(context)
|
||||
margin: Responsive.isDesktop(context)
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: 150)
|
||||
horizontal: 150)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
horizontal: 0),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 45,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
ElevatedButton.styleFrom(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
Color(0xFF00989E),
|
||||
shape:
|
||||
RoundedRectangleBorder(
|
||||
Color(0xFF00989E),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
10),
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
onPressed: _isLoading
|
||||
@ -693,22 +672,22 @@ class _MyPhoneState extends State<MyHrLogin> {
|
||||
: verifyMobileAndEmailNumber,
|
||||
child: _isLoading
|
||||
? CircularProgressIndicator(
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<
|
||||
Color>(
|
||||
Color(0xFF00989E),
|
||||
),
|
||||
)
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<
|
||||
Color>(
|
||||
Color(0xFF00989E),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
isEmailFieldVisible
|
||||
? "Login with Email OTP"
|
||||
: "Login with Mobile OTP",
|
||||
style: GoogleFonts
|
||||
.poppins(
|
||||
color: Color(
|
||||
0xFFFFFFFF),
|
||||
),
|
||||
),
|
||||
isEmailFieldVisible
|
||||
? "Login with Email OTP"
|
||||
: "Login with Mobile OTP",
|
||||
style:
|
||||
GoogleFonts.poppins(
|
||||
color:
|
||||
Color(0xFFFFFFFF),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -46,6 +46,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
dynamic enrollmentEmpPrimaryId;
|
||||
dynamic enrollmentGpaEmpName;
|
||||
dynamic enrollmentClient_id;
|
||||
dynamic enrollmentHrId;
|
||||
List<dynamic> enrollmentAllowed_modules = [];
|
||||
dynamic enrollmentEmp_status;
|
||||
|
||||
dynamic empClientBranchId;
|
||||
@ -53,6 +55,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
dynamic empPrimaryId;
|
||||
dynamic gpaEmpName;
|
||||
dynamic client_id;
|
||||
dynamic empHrId;
|
||||
List<dynamic> empAllowed_modules = [];
|
||||
dynamic emp_status;
|
||||
|
||||
dynamic _token;
|
||||
@ -105,7 +109,6 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
void startTimer() {
|
||||
_isTimerRunning = true;
|
||||
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
|
||||
@ -124,10 +127,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
try {
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrl + 'getVerifiedHrData'),
|
||||
body: json.encode({
|
||||
'mobile_no': mobileNumber,
|
||||
'otp_verification': otpVerifyStatus
|
||||
}),
|
||||
body: json.encode(
|
||||
{'mobile_no': mobileNumber, 'otp_verification': otpVerifyStatus}),
|
||||
headers: {
|
||||
HttpHeaders.contentTypeHeader: 'application/json',
|
||||
},
|
||||
@ -195,7 +196,7 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
||||
print('decodedToken : $decodedToken');
|
||||
print('postdecodedToken : $decodedToken');
|
||||
empClientBranchId = decodedToken['ref_id'];
|
||||
prefs.setString('empClientBranchId', empClientBranchId);
|
||||
empCodeString = decodedToken['emp_code'].toString();
|
||||
@ -206,9 +207,12 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
prefs.setString('gpaEmpName', gpaEmpName);
|
||||
client_id = decodedToken['client_id'];
|
||||
prefs.setString('client_id', client_id);
|
||||
empHrId = decodedToken['id'];
|
||||
prefs.setString('empHrId', empHrId);
|
||||
empAllowed_modules = decodedToken['allowed_modules'];
|
||||
prefs.setString('empAllowed_modules', jsonEncode(empAllowed_modules));
|
||||
emp_status = decodedToken['emp_status'];
|
||||
prefs.setString('emp_status', emp_status);
|
||||
|
||||
}
|
||||
|
||||
if (status == 'success') {
|
||||
@ -219,7 +223,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
print('decodedToken : $decodedToken');
|
||||
enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
||||
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
prefs.setString(
|
||||
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
||||
prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString);
|
||||
enrollmentEmpPrimaryId = decodedToken['id'];
|
||||
@ -228,22 +233,27 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName);
|
||||
enrollmentClient_id = decodedToken['client_id'];
|
||||
prefs.setString('enrollmentClient_id', enrollmentClient_id);
|
||||
|
||||
enrollmentHrId = decodedToken['id'];
|
||||
prefs.setString('enrollmentHrId', enrollmentHrId);
|
||||
enrollmentAllowed_modules = decodedToken['allowed_modules'];
|
||||
prefs.setString(
|
||||
'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
|
||||
// enrollmentEmp_status = decodedToken['emp_status'];
|
||||
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||
}
|
||||
}
|
||||
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final _postToken = prefs.getString('_postToken');
|
||||
|
||||
if (_postToken != null && _postToken.isNotEmpty) {
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||
// if (emp_status == 'enrolled' || emp_status == 'active') {
|
||||
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
||||
// } else {
|
||||
// Navigator.pushReplacementNamed(context, 'empDetails');
|
||||
// }
|
||||
}
|
||||
|
||||
if (_postToken != null && _postToken.isNotEmpty) {
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||
// if (emp_status == 'enrolled' || emp_status == 'active') {
|
||||
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
||||
// } else {
|
||||
// Navigator.pushReplacementNamed(context, 'empDetails');
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void enrollmentSuccessData(data) async {
|
||||
@ -252,7 +262,7 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
print('decodedToken : $decodedToken');
|
||||
print('enrolldecodedToken : $decodedToken');
|
||||
enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
||||
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
||||
@ -263,6 +273,12 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName);
|
||||
enrollmentClient_id = decodedToken['client_id'];
|
||||
prefs.setString('enrollmentClient_id', enrollmentClient_id);
|
||||
|
||||
enrollmentHrId = decodedToken['id'];
|
||||
prefs.setString('enrollmentHrId', enrollmentHrId);
|
||||
enrollmentAllowed_modules = decodedToken['allowed_modules'];
|
||||
prefs.setString(
|
||||
'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
|
||||
// enrollmentEmp_status = decodedToken['emp_status'];
|
||||
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||
|
||||
@ -271,15 +287,14 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
// Redirect to another page
|
||||
final enrollToken = prefs.getString('enrollToken');
|
||||
|
||||
if (enrollToken != null && enrollToken.isNotEmpty) {
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||
// if (emp_status == 'enrolled' || emp_status == 'active') {
|
||||
// Navigator.pushReplacementNamed(context, 'home');
|
||||
// } else {
|
||||
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
||||
// }
|
||||
}
|
||||
|
||||
if (enrollToken != null && enrollToken.isNotEmpty) {
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||
// if (emp_status == 'enrolled' || emp_status == 'active') {
|
||||
// Navigator.pushReplacementNamed(context, 'home');
|
||||
// } else {
|
||||
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void verifyOTP(String otp) async {
|
||||
@ -325,7 +340,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
ToastHelper.showErrorToast(context, 'OTP expired. Please request a new one.');
|
||||
ToastHelper.showErrorToast(
|
||||
context, 'OTP expired. Please request a new one.');
|
||||
} else if (e.code == 'invalid-verification-code') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@ -333,7 +349,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
ToastHelper.showErrorToast(context, 'Invalid OTP entered. Please try again.');
|
||||
ToastHelper.showErrorToast(
|
||||
context, 'Invalid OTP entered. Please try again.');
|
||||
} else if (e.code == 'session-expired') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@ -341,7 +358,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
ToastHelper.showErrorToast(context, 'Session expired. Try restarting the verification.');
|
||||
ToastHelper.showErrorToast(
|
||||
context, 'Session expired. Try restarting the verification.');
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@ -356,7 +374,8 @@ class _MyVerifyState extends State<MyHrVerify> {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
print('Error: $e');
|
||||
ToastHelper.showErrorToast(context, 'Failed to verify OTP. Please try again.');
|
||||
ToastHelper.showErrorToast(
|
||||
context, 'Failed to verify OTP. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -412,13 +412,17 @@ class ApiService {
|
||||
//HR API STARTS
|
||||
|
||||
Future<Map<String, dynamic>> getCashDepositDetailsToApi(
|
||||
String clintID, String empRefId,String hr_id, String token) async {
|
||||
print(token);
|
||||
String clintID, String empRefId, String hr_id, String token) async {
|
||||
print("getCashDepositDetailsToApi1");
|
||||
|
||||
if (token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
// final url = Uri.parse(
|
||||
// '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=470');
|
||||
final url = Uri.parse(
|
||||
'${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=$hr_id');
|
||||
|
||||
final headers = {
|
||||
'Authorization': 'Bearer $token' ?? '',
|
||||
};
|
||||
|
||||
195
lib/service/hrDashboardTabs/activePolicies.dart
Normal file
195
lib/service/hrDashboardTabs/activePolicies.dart
Normal file
@ -0,0 +1,195 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../api_service.dart';
|
||||
|
||||
class ActivePolicies extends StatefulWidget {
|
||||
final String empClientId;
|
||||
final String empClientBranchId;
|
||||
final String empHrId;
|
||||
|
||||
const ActivePolicies(
|
||||
{Key? key,
|
||||
required this.empClientId,
|
||||
required this.empClientBranchId,
|
||||
required this.empHrId});
|
||||
|
||||
@override
|
||||
State<ActivePolicies> createState() => _ActivePolicieState();
|
||||
}
|
||||
|
||||
class _ActivePolicieState extends State<ActivePolicies> {
|
||||
late ApiService apiService;
|
||||
dynamic getCardArrays = [];
|
||||
int selectedIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
apiService = ApiService(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
// padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade50,
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black54, // Grey shadow
|
||||
spreadRadius: 0.2,
|
||||
blurRadius: 6,
|
||||
offset: Offset(0, 1), // Horizontal, Vertical
|
||||
),
|
||||
],
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
|
||||
child: Row(
|
||||
children: [
|
||||
buildTab("Active", 0),
|
||||
const SizedBox(width: 10),
|
||||
buildTab("Expired", 1),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Container(
|
||||
// color: Colors.amber,
|
||||
// child: Card(
|
||||
// elevation: 5,
|
||||
// color: Colors.white,
|
||||
// child: GridView.builder(
|
||||
// itemCount: getCardArrays.length,
|
||||
// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
// crossAxisCount: 4,
|
||||
// crossAxisSpacing: 16,
|
||||
// mainAxisSpacing: 0,
|
||||
// childAspectRatio: 2,
|
||||
// ),
|
||||
// itemBuilder: (context, index) {
|
||||
// return buildPolicyCard(getCardArrays[index]);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTab(String title, int index) {
|
||||
final isSelected = selectedIndex == index;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 6.5, bottom: 6.0, left: 20.0, right: 20.0),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? const Color(0xFF009195) : Colors.transparent,
|
||||
boxShadow: isSelected
|
||||
? [
|
||||
BoxShadow(
|
||||
color: isSelected
|
||||
? const Color(0xFF009195)
|
||||
: Colors.transparent, // Grey shadow
|
||||
spreadRadius: 0.2,
|
||||
blurRadius: 1,
|
||||
offset: const Offset(0, 1), // Horizontal, Vertical
|
||||
),
|
||||
]
|
||||
: [],
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Text(title,
|
||||
style: GoogleFonts.poppins(
|
||||
color: isSelected ? Colors.white : Colors.black,
|
||||
fontWeight: FontWeight.w600,
|
||||
))),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildPolicyCard(Map<String, dynamic> policy) {
|
||||
return Card(
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
policy['type'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
policy['policy_name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildCountBox(
|
||||
policy['membersCountOfDraft'].toString(), "Draft"),
|
||||
_buildCountBox(
|
||||
policy['membersCountOfEnrolled'].toString(), "Enrolled"),
|
||||
_buildCountBox(policy['totalMembersCount'].toString(), "Total"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCountBox(String count, String label) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 40,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFDFF1F3),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
count,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(label,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.black87)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
29
lib/service/hrDashboardTabs/cd.dart
Normal file
29
lib/service/hrDashboardTabs/cd.dart
Normal file
@ -0,0 +1,29 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class CdPolicies extends StatefulWidget {
|
||||
final String empClientId;
|
||||
final String empClientBranchId;
|
||||
final String empHrId;
|
||||
const CdPolicies(
|
||||
{Key? key,
|
||||
required this.empClientId,
|
||||
required this.empClientBranchId,
|
||||
required this.empHrId});
|
||||
|
||||
@override
|
||||
State<CdPolicies> createState() => _CdPolicieState();
|
||||
}
|
||||
|
||||
class _CdPolicieState extends State<CdPolicies> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Container(
|
||||
child: Text("Cd policy data"),
|
||||
);
|
||||
}
|
||||
}
|
||||
30
lib/service/hrDashboardTabs/claims.dart
Normal file
30
lib/service/hrDashboardTabs/claims.dart
Normal file
@ -0,0 +1,30 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class ClaimsPolicies extends StatefulWidget {
|
||||
final String empClientId;
|
||||
final String empClientBranchId;
|
||||
final String empHrId;
|
||||
|
||||
const ClaimsPolicies(
|
||||
{Key? key,
|
||||
required this.empClientId,
|
||||
required this.empClientBranchId,
|
||||
required this.empHrId});
|
||||
|
||||
@override
|
||||
State<ClaimsPolicies> createState() => _ClaimsPolicieState();
|
||||
}
|
||||
|
||||
class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Container(
|
||||
child: Text("Claims policy data"),
|
||||
);
|
||||
}
|
||||
}
|
||||
225
lib/service/hrDashboardTabs/preEnrollment.dart
Normal file
225
lib/service/hrDashboardTabs/preEnrollment.dart
Normal file
@ -0,0 +1,225 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../api_service.dart';
|
||||
|
||||
class PreEnrollment extends StatefulWidget {
|
||||
final String enrollmentClientId;
|
||||
final String enrollmentClientBranchId;
|
||||
final String enrollmentHrId;
|
||||
final String enrollToken;
|
||||
|
||||
const PreEnrollment(
|
||||
{Key? key,
|
||||
required this.enrollmentClientId,
|
||||
required this.enrollmentClientBranchId,
|
||||
required this.enrollmentHrId,
|
||||
required this.enrollToken});
|
||||
|
||||
@override
|
||||
State<PreEnrollment> createState() => _PreEnrollmentState();
|
||||
}
|
||||
|
||||
class _PreEnrollmentState extends State<PreEnrollment> {
|
||||
late ApiService apiService;
|
||||
dynamic getCardArrays = [];
|
||||
int selectedIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
apiService = ApiService(context);
|
||||
_loadData();
|
||||
|
||||
print("_PreEnrollmentState 1");
|
||||
}
|
||||
|
||||
Future<void> _loadData() async {
|
||||
await getCashDepositDetails(widget.enrollmentClientBranchId,
|
||||
widget.enrollmentClientId, widget.enrollmentHrId, widget.enrollToken);
|
||||
}
|
||||
|
||||
Future<void> getCashDepositDetails(
|
||||
clintBranchId, clintID, hr_id, token) async {
|
||||
print("_PreEnrollmentState 2");
|
||||
print('IN');
|
||||
print("clintBranchId -$clintBranchId");
|
||||
print("clintID -$clintID");
|
||||
print("hr_id -$hr_id");
|
||||
print("token -$token");
|
||||
|
||||
// isLoading = true;
|
||||
// setState(() {
|
||||
// _isLoading = true;
|
||||
// });
|
||||
try {
|
||||
if (clintBranchId == null || clintID == null) {
|
||||
return;
|
||||
}
|
||||
final response = await apiService.getCashDepositDetailsToApi(
|
||||
clintID!, clintBranchId!, hr_id, token);
|
||||
|
||||
// final response = await apiService.getCashDepositDetailsToApi(
|
||||
// clintID!, clintBranchId!, hr_id, token);
|
||||
print('IN1');
|
||||
if (response['status'] == 'success') {
|
||||
// isLoading = false;
|
||||
setState(() {
|
||||
print('response');
|
||||
print(response['data']);
|
||||
|
||||
print("_PreEnrollmentState 3");
|
||||
getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
||||
print('getCardArrays');
|
||||
print(getCardArrays);
|
||||
});
|
||||
|
||||
print('IN2');
|
||||
} else {
|
||||
print('API request failed with status');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("_PreEnrollmentState 4");
|
||||
// TODO: implement build
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
// height: 400,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.white,
|
||||
child: SizedBox(
|
||||
height: 400,
|
||||
child: GridView.builder(
|
||||
itemCount: getCardArrays.length,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 0,
|
||||
childAspectRatio: 2,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
return buildPolicyCard(getCardArrays[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTab(String title, int index) {
|
||||
final isSelected = selectedIndex == index;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 6.5, bottom: 6.0, left: 20.0, right: 20.0),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? const Color(0xFF009195) : Colors.transparent,
|
||||
boxShadow: isSelected
|
||||
? [
|
||||
BoxShadow(
|
||||
color: isSelected
|
||||
? const Color(0xFF009195)
|
||||
: Colors.transparent, // Grey shadow
|
||||
spreadRadius: 0.2,
|
||||
blurRadius: 1,
|
||||
offset: const Offset(0, 1), // Horizontal, Vertical
|
||||
),
|
||||
]
|
||||
: [],
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Text(title,
|
||||
style: GoogleFonts.poppins(
|
||||
color: isSelected ? Colors.white : Colors.black,
|
||||
fontWeight: FontWeight.w600,
|
||||
))),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildPolicyCard(Map<String, dynamic> policy) {
|
||||
return Card(
|
||||
color: Colors.white,
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
policy['type'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontFamily: "Inter",
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
policy['policy_name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildCountBox(
|
||||
policy['membersCountOfDraft'].toString(), "Draft"),
|
||||
_buildCountBox(
|
||||
policy['membersCountOfEnrolled'].toString(), "Enrolled"),
|
||||
_buildCountBox(policy['totalMembersCount'].toString(), "Total"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCountBox(String count, String label) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 70,
|
||||
height: 40,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFDFF1F3),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
count,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(label,
|
||||
style: const TextStyle(fontSize: 10, color: Color(0xFF848484))),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import file_picker
|
||||
import firebase_auth
|
||||
import firebase_core
|
||||
import google_sign_in_ios
|
||||
@ -14,6 +15,7 @@ import smart_auth
|
||||
import url_launcher_macos
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
|
||||
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
|
||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user