UI_HR_Dashboard Tab Layout

This commit is contained in:
venbaittech 2025-07-02 09:24:49 +05:30
parent 745af9eb86
commit a262d702c8
10 changed files with 1491 additions and 814 deletions

View File

@ -46,6 +46,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
dynamic enrollmentGpaEmpName;
dynamic enrollmentClient_id;
dynamic enrollmentHrId;
List<dynamic> enrollmentAllowed_modules = [];
dynamic enrollmentEmp_status;
dynamic empCodeString;
@ -54,6 +55,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
dynamic gpaEmpName;
dynamic empClientId;
dynamic empHrId;
List<dynamic> empAllowed_modules = [];
dynamic _token;
dynamic _postToken;
dynamic clientName;
@ -81,8 +83,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
super.dispose();
}
void startTimer() {
_isTimerRunning = true;
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
@ -101,8 +101,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
try {
final response = await http.post(
Uri.parse(Environment.apiUrl + 'getVerifiedHrData'),
body:
json.encode({'email': widget.email, 'otp': _otpController.text}),
body: json.encode({'email': widget.email, 'otp': _otpController.text}),
headers: {
HttpHeaders.contentTypeHeader: 'application/json',
},
@ -170,7 +169,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
// 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();
@ -183,6 +182,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
prefs.setString('empClientId', empClientId);
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);
// getClientLogoAndDetails();
@ -198,9 +199,10 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
// Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
print('decodedToken : $decodedToken');
print('postenrolldecodedToken : $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'];
@ -211,6 +213,9 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
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);
}
@ -230,14 +235,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
}
}
void enrollmentSuccessData(data) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('enrollToken', data['data']);
// 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();
@ -250,9 +254,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
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);
getClientLogoAndDetails(enrollmentClient_id,enrollmentEmpClientBranchId,data['data']);
getClientLogoAndDetails(
enrollmentClient_id, enrollmentEmpClientBranchId, data['data']);
print('Successfully Login');
// Redirect to another page
@ -266,7 +274,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
Navigator.pushReplacementNamed(context, 'hrDashboard');
// }
}
}
void _resendOTP() {
@ -631,7 +638,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
..onTap = () {
// Navigate to the page where the user can change the phone number
Navigator.pushNamed(
context, 'hrLogin');
context,
'hrLogin');
},
),
],
@ -887,7 +895,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
),
),
),
],
),
],

View File

@ -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,42 +90,166 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
final _postToken = prefs.getString('_postToken');
final enrollToken = prefs.getString('enrollToken');
if (enrollToken != null && enrollToken.isNotEmpty) {
Map<String, dynamic>? decodedToken = Jwt.parseJwt(enrollToken);
enrollmentClient_id = decodedToken['client_id'].toString();
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);
}
getCashDepositDetails(enrollmentEmpClientBranchId, enrollmentClient_id,
enrollmentHrId, enrollToken);
}
if (_postToken != null && _postToken.isNotEmpty) {
Map<String, dynamic>? decodedToken = Jwt.parseJwt(_postToken);
empClientId = decodedToken['client_id'].toString();
Map<String, dynamic>? postdecodedToken = Jwt.parseJwt(_postToken);
empClientId = postdecodedToken['client_id'].toString();
empClientBranchId = prefs.getString('empClientBranchId');
empHrId = prefs.getString('empHrId');
print(empClientId);
print(empClientBranchId);
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);
}
getCashDepositDetails(empClientBranchId,empClientId,empHrId,_postToken);
} else if (enrollToken != null && enrollToken.isNotEmpty) {
Map<String, dynamic>? decodedToken = Jwt.parseJwt(enrollToken);
enrollmentClient_id = decodedToken['client_id'].toString();
enrollmentEmpClientBranchId = prefs.getString('enrollmentEmpClientBranchId');
enrollmentHrId = prefs.getString('enrollmentHrId');
print("getCashDepositDetails");
}
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
clientLogo = prefs.getString('clientLogo');
clientName = prefs.getString('clientName');
} else {
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');
}
_tabController = TabController(length: tabData.length, vsync: this);
_tabController.addListener(() {
setState(() {
selectedIndex = _tabController.index;
});
});
setState(() {});
isLoading = false;
}
Future<void> getClientLogoAndDetails(clintBranchId, clintID, token) async {
@ -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,10 +426,8 @@ 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)
@ -309,8 +456,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress
.expectedTotalBytes !=
value:
loadingProgress.expectedTotalBytes !=
null
? loadingProgress
.cumulativeBytesLoaded /
@ -347,12 +494,13 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
],
),
),
),
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]);
},
),
)
children: tabViews,
),
Center(child: Text("Active Policies")),
Center(child: Text("CD")),
Center(child: Text("Claims")),
],
),
// 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,7 +994,10 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
}
Widget buildPolicyCard(Map<String, dynamic> policy) {
return Card(
print("buildPolicyCard - $policy");
return SizedBox(
height: 50,
child: Card(
elevation: 3,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
@ -844,14 +1024,18 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_buildCountBox(policy['membersCountOfDraft'].toString(), "Draft"),
_buildCountBox(policy['membersCountOfEnrolled'].toString(), "Enrolled"),
_buildCountBox(policy['totalMembersCount'].toString(), "Total"),
_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,

View File

@ -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(
@ -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}');
@ -510,8 +509,7 @@ class _MyPhoneState extends State<MyHrLogin> {
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(
horizontal: 0),
: EdgeInsets.symmetric(horizontal: 0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
@ -536,8 +534,8 @@ class _MyPhoneState extends State<MyHrLogin> {
isEmailFieldVisible
? Container(
height: 55,
margin: Responsive
.isDesktop(context)
margin: Responsive.isDesktop(
context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(
@ -547,26 +545,19 @@ class _MyPhoneState extends State<MyHrLogin> {
width: 1,
color: Colors.grey),
borderRadius:
BorderRadius.circular(
10),
BorderRadius.circular(10),
),
child: TextFormField(
controller:
emailController,
keyboardType:
TextInputType
controller: emailController,
keyboardType: TextInputType
.emailAddress,
decoration:
InputDecoration(
border:
InputBorder.none,
decoration: InputDecoration(
border: InputBorder.none,
hintText:
"Enter your email",
contentPadding:
EdgeInsets
.symmetric(
horizontal:
10),
EdgeInsets.symmetric(
horizontal: 10),
),
validator: (value) {
if (value == null ||
@ -584,8 +575,8 @@ class _MyPhoneState extends State<MyHrLogin> {
)
: Container(
height: 55,
margin: Responsive
.isDesktop(context)
margin: Responsive.isDesktop(
context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(
@ -595,8 +586,7 @@ class _MyPhoneState extends State<MyHrLogin> {
width: 1,
color: Colors.grey),
borderRadius:
BorderRadius.circular(
10),
BorderRadius.circular(10),
),
child: Row(
children: [
@ -612,8 +602,7 @@ class _MyPhoneState extends State<MyHrLogin> {
decoration:
InputDecoration(
border:
InputBorder
.none,
InputBorder.none,
),
),
),
@ -621,8 +610,7 @@ class _MyPhoneState extends State<MyHrLogin> {
"|",
style: TextStyle(
fontSize: 33,
color:
Colors.grey),
color: Colors.grey),
),
SizedBox(width: 10),
Expanded(
@ -630,25 +618,20 @@ class _MyPhoneState extends State<MyHrLogin> {
controller:
mobileController,
keyboardType:
TextInputType
.phone,
TextInputType.phone,
decoration:
InputDecoration(
border:
InputBorder
.none,
InputBorder.none,
hintText:
"Enter your mobile number",
),
validator: (value) {
if (value ==
null ||
value
.isEmpty) {
if (value == null ||
value.isEmpty) {
return 'Please enter your mobile number';
}
if (value
.length !=
if (value.length !=
10) {
return 'Mobile number must be 10 digits';
}
@ -667,8 +650,7 @@ class _MyPhoneState extends State<MyHrLogin> {
),
SizedBox(height: 15),
Container(
margin:
Responsive.isDesktop(context)
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(
@ -677,15 +659,12 @@ class _MyPhoneState extends State<MyHrLogin> {
width: double.infinity,
height: 45,
child: ElevatedButton(
style:
ElevatedButton.styleFrom(
style: ElevatedButton.styleFrom(
backgroundColor:
Color(0xFF00989E),
shape:
RoundedRectangleBorder(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(
10),
BorderRadius.circular(10),
),
),
onPressed: _isLoading
@ -703,10 +682,10 @@ class _MyPhoneState extends State<MyHrLogin> {
isEmailFieldVisible
? "Login with Email OTP"
: "Login with Mobile OTP",
style: GoogleFonts
.poppins(
color: Color(
0xFFFFFFFF),
style:
GoogleFonts.poppins(
color:
Color(0xFFFFFFFF),
),
),
),

View File

@ -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,6 +233,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);
}
@ -243,7 +254,6 @@ class _MyVerifyState extends State<MyHrVerify> {
// 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);
@ -279,7 +295,6 @@ class _MyVerifyState extends State<MyHrVerify> {
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.');
}
}

View File

@ -413,12 +413,16 @@ class ApiService {
Future<Map<String, dynamic>> getCashDepositDetailsToApi(
String clintID, String empRefId, String hr_id, String token) async {
print(token);
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' ?? '',
};

View 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)),
],
);
}
}

View 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"),
);
}
}

View 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"),
);
}
}

View 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))),
],
);
}
}

View File

@ -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"))