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 enrollmentGpaEmpName;
dynamic enrollmentClient_id; dynamic enrollmentClient_id;
dynamic enrollmentHrId; dynamic enrollmentHrId;
List<dynamic> enrollmentAllowed_modules = [];
dynamic enrollmentEmp_status; dynamic enrollmentEmp_status;
dynamic empCodeString; dynamic empCodeString;
@ -54,6 +55,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
dynamic gpaEmpName; dynamic gpaEmpName;
dynamic empClientId; dynamic empClientId;
dynamic empHrId; dynamic empHrId;
List<dynamic> empAllowed_modules = [];
dynamic _token; dynamic _token;
dynamic _postToken; dynamic _postToken;
dynamic clientName; dynamic clientName;
@ -81,8 +83,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
super.dispose(); super.dispose();
} }
void startTimer() { void startTimer() {
_isTimerRunning = true; _isTimerRunning = true;
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
@ -101,8 +101,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
try { try {
final response = await http.post( final response = await http.post(
Uri.parse(Environment.apiUrl + 'getVerifiedHrData'), Uri.parse(Environment.apiUrl + 'getVerifiedHrData'),
body: body: json.encode({'email': widget.email, 'otp': _otpController.text}),
json.encode({'email': widget.email, 'otp': _otpController.text}),
headers: { headers: {
HttpHeaders.contentTypeHeader: 'application/json', HttpHeaders.contentTypeHeader: 'application/json',
}, },
@ -170,7 +169,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
// Decode the JWT token received from the API response // Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']); Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
print('decodedToken : $decodedToken'); print('postdecodedToken : $decodedToken');
empClientBranchId = decodedToken['ref_id']; empClientBranchId = decodedToken['ref_id'];
prefs.setString('empClientBranchId', empClientBranchId); prefs.setString('empClientBranchId', empClientBranchId);
empCodeString = decodedToken['emp_code'].toString(); empCodeString = decodedToken['emp_code'].toString();
@ -183,6 +182,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
prefs.setString('empClientId', empClientId); prefs.setString('empClientId', empClientId);
empHrId = decodedToken['id']; empHrId = decodedToken['id'];
prefs.setString('empHrId', empHrId); prefs.setString('empHrId', empHrId);
empAllowed_modules = decodedToken['allowed_modules'];
prefs.setString('empAllowed_modules', jsonEncode(empAllowed_modules));
// emp_status = decodedToken['emp_status']; // emp_status = decodedToken['emp_status'];
// prefs.setString('emp_status', emp_status); // prefs.setString('emp_status', emp_status);
// getClientLogoAndDetails(); // getClientLogoAndDetails();
@ -198,9 +199,10 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
// Decode the JWT token received from the API response // Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']); Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
print('decodedToken : $decodedToken'); print('postenrolldecodedToken : $decodedToken');
enrollmentEmpClientBranchId = decodedToken['ref_id']; enrollmentEmpClientBranchId = decodedToken['ref_id'];
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); prefs.setString(
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
enrollmentEmpCodeString = decodedToken['emp_code'].toString(); enrollmentEmpCodeString = decodedToken['emp_code'].toString();
prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString); prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString);
enrollmentEmpPrimaryId = decodedToken['id']; enrollmentEmpPrimaryId = decodedToken['id'];
@ -211,6 +213,9 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
prefs.setString('enrollmentClient_id', enrollmentClient_id); prefs.setString('enrollmentClient_id', enrollmentClient_id);
enrollmentHrId = decodedToken['id']; enrollmentHrId = decodedToken['id'];
prefs.setString('enrollmentHrId', enrollmentHrId); prefs.setString('enrollmentHrId', enrollmentHrId);
enrollmentAllowed_modules = decodedToken['allowed_modules'];
prefs.setString(
'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
// enrollmentEmp_status = decodedToken['emp_status']; // enrollmentEmp_status = decodedToken['emp_status'];
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status); // prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
} }
@ -230,14 +235,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
} }
} }
void enrollmentSuccessData(data) async { void enrollmentSuccessData(data) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('enrollToken', data['data']); prefs.setString('enrollToken', data['data']);
// Decode the JWT token received from the API response // Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']); Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
print('decodedToken : $decodedToken'); print('enrolldecodedToken : $decodedToken');
enrollmentEmpClientBranchId = decodedToken['ref_id']; enrollmentEmpClientBranchId = decodedToken['ref_id'];
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
enrollmentEmpCodeString = decodedToken['emp_code'].toString(); enrollmentEmpCodeString = decodedToken['emp_code'].toString();
@ -250,9 +254,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
prefs.setString('enrollmentClient_id', enrollmentClient_id); prefs.setString('enrollmentClient_id', enrollmentClient_id);
enrollmentHrId = decodedToken['id']; enrollmentHrId = decodedToken['id'];
prefs.setString('enrollmentHrId', enrollmentHrId); prefs.setString('enrollmentHrId', enrollmentHrId);
enrollmentAllowed_modules = decodedToken['allowed_modules'];
prefs.setString(
'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
// enrollmentEmp_status = decodedToken['emp_status']; // enrollmentEmp_status = decodedToken['emp_status'];
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status); // prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
getClientLogoAndDetails(enrollmentClient_id,enrollmentEmpClientBranchId,data['data']); getClientLogoAndDetails(
enrollmentClient_id, enrollmentEmpClientBranchId, data['data']);
print('Successfully Login'); print('Successfully Login');
// Redirect to another page // Redirect to another page
@ -266,7 +274,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
Navigator.pushReplacementNamed(context, 'hrDashboard'); Navigator.pushReplacementNamed(context, 'hrDashboard');
// } // }
} }
} }
void _resendOTP() { void _resendOTP() {
@ -631,7 +638,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
..onTap = () { ..onTap = () {
// Navigate to the page where the user can change the phone number // Navigate to the page where the user can change the phone number
Navigator.pushNamed( 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/models/environment.dart';
import 'package:nhancepolicy/responsive.dart'; import 'package:nhancepolicy/responsive.dart';
import 'package:nhancepolicy/service/api_service.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:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'customAppBar/customAppBar.dart'; import 'customAppBar/customAppBar.dart';
@ -23,7 +27,8 @@ class hrDashboard extends StatefulWidget {
State<hrDashboard> createState() => _hrDashboardState(); State<hrDashboard> createState() => _hrDashboardState();
} }
class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStateMixin { class _hrDashboardState extends State<hrDashboard>
with SingleTickerProviderStateMixin {
late ApiService apiService; late ApiService apiService;
late TabController _tabController; late TabController _tabController;
bool isLoading = false; bool isLoading = false;
@ -34,10 +39,16 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
dynamic enrollmentClient_id; dynamic enrollmentClient_id;
dynamic policy_name; dynamic policy_name;
dynamic getCardArrays = []; dynamic getCardArrays = [];
List<dynamic> empAllowed_modules = [];
List<Widget> visibleTabs = [];
List<Widget> tabViews = [];
dynamic clientName; dynamic clientName;
dynamic clientLogo; dynamic clientLogo;
dynamic empClientBranchId; dynamic empClientBranchId;
dynamic empHrId; dynamic empHrId;
List<dynamic> enrollmentAllowed_modules = [];
List<Map<String, dynamic>> tabData = [];
dynamic enrollmentEmpClientBranchId; dynamic enrollmentEmpClientBranchId;
dynamic enrollmentHrId; dynamic enrollmentHrId;
dynamic empClientId; dynamic empClientId;
@ -55,12 +66,12 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
super.initState(); super.initState();
apiService = ApiService(context); // Initialize ApiService here apiService = ApiService(context); // Initialize ApiService here
_loadToken(); _loadToken();
_tabController = TabController(length: 4, vsync: this); // _tabController = TabController(length: 4, vsync: this);
_tabController.addListener(() { // _tabController.addListener(() {
setState(() { // setState(() {
selectedIndex = _tabController.index; // selectedIndex = _tabController.index;
}); // });
}); // });
// Future.delayed(Duration(seconds: 3), () { // Future.delayed(Duration(seconds: 3), () {
// setState(() { // setState(() {
// isLoading = false; // isLoading = false;
@ -79,42 +90,166 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
final _postToken = prefs.getString('_postToken'); final _postToken = prefs.getString('_postToken');
final enrollToken = prefs.getString('enrollToken'); 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) { if (_postToken != null && _postToken.isNotEmpty) {
Map<String, dynamic>? decodedToken = Jwt.parseJwt(_postToken); Map<String, dynamic>? postdecodedToken = Jwt.parseJwt(_postToken);
empClientId = decodedToken['client_id'].toString();
empClientId = postdecodedToken['client_id'].toString();
empClientBranchId = prefs.getString('empClientBranchId'); empClientBranchId = prefs.getString('empClientBranchId');
empHrId = prefs.getString('empHrId'); 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')) { if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
clientLogo = prefs.getString('clientLogo'); clientLogo = prefs.getString('clientLogo');
clientName = prefs.getString('clientName'); clientName = prefs.getString('clientName');
} else { } else {
getClientLogoAndDetails(empClientBranchId, empClientId, _postToken); getClientLogoAndDetails(empClientBranchId, empClientId, _postToken);
} }
getCashDepositDetails(empClientBranchId,empClientId,empHrId,_postToken); print("getCashDepositDetails");
} 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');
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { _tabController = TabController(length: tabData.length, vsync: this);
clientLogo = prefs.getString('clientLogo'); _tabController.addListener(() {
clientName = prefs.getString('clientName'); setState(() {
} else { selectedIndex = _tabController.index;
getClientLogoAndDetails(enrollmentEmpClientBranchId,enrollmentClient_id,enrollToken); });
} });
getCashDepositDetails(enrollmentEmpClientBranchId,enrollmentClient_id,enrollmentHrId,enrollToken);
} else { setState(() {});
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen isLoading = false;
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'hrLogin');
}
} }
Future<void> getClientLogoAndDetails(clintBranchId, clintID, token) async { 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('IN');
print("clintBranchId -$clintBranchId");
print("clintID -$clintID");
print("hr_id -$hr_id");
print("token -$token");
isLoading = true; // isLoading = true;
// setState(() { // setState(() {
// _isLoading = true; // _isLoading = true;
// }); // });
@ -175,8 +315,12 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
if (clintBranchId == null || clintID == null) { if (clintBranchId == null || clintID == null) {
return; return;
} }
final response = final response = await apiService.getCashDepositDetailsToApi(
await apiService.getCashDepositDetailsToApi(clintID!, clintBranchId!,hr_id,token); clintID!, clintBranchId!, hr_id, token);
// final response = await apiService.getCashDepositDetailsToApi(
// clintID!, clintBranchId!, hr_id, token);
print('IN1');
if (response['status'] == 'success') { if (response['status'] == 'success') {
isLoading = false; isLoading = false;
setState(() { setState(() {
@ -186,6 +330,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
print('getCardArrays'); print('getCardArrays');
print(getCardArrays); print(getCardArrays);
}); });
print('IN2');
} else { } else {
print('API request failed with status'); 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 policyHeight = MediaQuery.of(context).size.height / 4.5;
double cardWidth = MediaQuery.of(context).size.width / 6; double cardWidth = MediaQuery.of(context).size.width / 6;
print("visibleTabAll - $visibleTabs");
print("tabViewsAll - $tabViews");
return Scaffold( return Scaffold(
appBar: CustomAppBar(), appBar: CustomAppBar(),
body: Stack(children: [ body: Stack(children: [
@ -277,10 +426,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
color: Color(0xFFEFF3F6), color: Color(0xFFEFF3F6),
child: Column( child: Column(
children: [ children: [
Card( Container(
elevation: 0,
color: Colors.white, color: Colors.white,
child: Container(
width: double.infinity, width: double.infinity,
height: 75, height: 75,
padding: Responsive.isDesktop(context) padding: Responsive.isDesktop(context)
@ -309,8 +456,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
if (loadingProgress == null) return child; if (loadingProgress == null) return child;
return Center( return Center(
child: CircularProgressIndicator( child: CircularProgressIndicator(
value: loadingProgress value:
.expectedTotalBytes != loadingProgress.expectedTotalBytes !=
null null
? loadingProgress ? loadingProgress
.cumulativeBytesLoaded / .cumulativeBytesLoaded /
@ -347,12 +494,13 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
], ],
), ),
), ),
),
SizedBox(height: 16), SizedBox(height: 16),
Container( Container(
padding: const EdgeInsets.all(5), padding: const EdgeInsets.all(5),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFC4E3E6), // 🔹 Background behind the TabBar color: Color(
0xFFC4E3E6), // 🔹 Background behind the TabBar
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.transparent), border: Border.all(color: Colors.transparent),
boxShadow: [ boxShadow: [
@ -366,7 +514,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
child: TabBar( child: TabBar(
controller: _tabController, controller: _tabController,
isScrollable: true, isScrollable: true,
labelPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0), labelPadding: const EdgeInsets.symmetric(
horizontal: 0, vertical: 0),
// indicator: BoxDecoration( // indicator: BoxDecoration(
// color: const Color(0xFF00999E), // Selected tab background // color: const Color(0xFF00999E), // Selected tab background
// borderRadius: BorderRadius.circular(12), // borderRadius: BorderRadius.circular(12),
@ -382,47 +531,75 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
indicatorColor: Colors.transparent, indicatorColor: Colors.transparent,
labelColor: Colors.white, labelColor: Colors.white,
unselectedLabelColor: const Color(0xFF828282), unselectedLabelColor: const Color(0xFF828282),
tabs: [ // tabs: visibleTabs,
CustomTab(icon: Icons.grid_view, label: 'Pre Enrollment', isSelected: selectedIndex == 0), tabs: List.generate(tabData.length, (index) {
CustomTab(icon: Icons.verified_user, label: 'Active Policies', isSelected: selectedIndex == 1), final data = tabData[index];
CustomTab(icon: Icons.desktop_windows, label: 'CD', isSelected: selectedIndex == 2), return CustomTab(
CustomTab(icon: Icons.receipt_long, label: 'Claims', isSelected: selectedIndex == 3), 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 // Expanded TabBarView
SizedBox( SizedBox(
height: 400, // Adjust height based on your layout height: 500, // Adjust height based on your layout
child: TabBarView( child: TabBarView(
controller: _tabController, controller: _tabController,
children: [ children: tabViews,
// 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")), // child: TabBarView(
Center(child: Text("CD")), // controller: _tabController,
Center(child: Text("Claims")), // 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) // if (getCardArrays.length != 0)
// Card( // Card(
@ -817,7 +994,10 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
} }
Widget buildPolicyCard(Map<String, dynamic> policy) { Widget buildPolicyCard(Map<String, dynamic> policy) {
return Card( print("buildPolicyCard - $policy");
return SizedBox(
height: 50,
child: Card(
elevation: 3, elevation: 3,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding( child: Padding(
@ -844,14 +1024,18 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
_buildCountBox(policy['membersCountOfDraft'].toString(), "Draft"), _buildCountBox(
_buildCountBox(policy['membersCountOfEnrolled'].toString(), "Enrolled"), policy['membersCountOfDraft'].toString(), "Draft"),
_buildCountBox(policy['totalMembersCount'].toString(), "Total"), _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), 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 { class CustomTab extends StatelessWidget {
@ -915,9 +1099,12 @@ class CustomTab extends StatelessWidget {
], ],
), ),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
children: [ 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), const SizedBox(width: 6),
Text( Text(
label, label,

View File

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

View File

@ -46,6 +46,8 @@ class _MyVerifyState extends State<MyHrVerify> {
dynamic enrollmentEmpPrimaryId; dynamic enrollmentEmpPrimaryId;
dynamic enrollmentGpaEmpName; dynamic enrollmentGpaEmpName;
dynamic enrollmentClient_id; dynamic enrollmentClient_id;
dynamic enrollmentHrId;
List<dynamic> enrollmentAllowed_modules = [];
dynamic enrollmentEmp_status; dynamic enrollmentEmp_status;
dynamic empClientBranchId; dynamic empClientBranchId;
@ -53,6 +55,8 @@ class _MyVerifyState extends State<MyHrVerify> {
dynamic empPrimaryId; dynamic empPrimaryId;
dynamic gpaEmpName; dynamic gpaEmpName;
dynamic client_id; dynamic client_id;
dynamic empHrId;
List<dynamic> empAllowed_modules = [];
dynamic emp_status; dynamic emp_status;
dynamic _token; dynamic _token;
@ -105,7 +109,6 @@ class _MyVerifyState extends State<MyHrVerify> {
super.dispose(); super.dispose();
} }
void startTimer() { void startTimer() {
_isTimerRunning = true; _isTimerRunning = true;
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
@ -124,10 +127,8 @@ class _MyVerifyState extends State<MyHrVerify> {
try { try {
final response = await http.post( final response = await http.post(
Uri.parse(Environment.apiUrl + 'getVerifiedHrData'), Uri.parse(Environment.apiUrl + 'getVerifiedHrData'),
body: json.encode({ body: json.encode(
'mobile_no': mobileNumber, {'mobile_no': mobileNumber, 'otp_verification': otpVerifyStatus}),
'otp_verification': otpVerifyStatus
}),
headers: { headers: {
HttpHeaders.contentTypeHeader: 'application/json', HttpHeaders.contentTypeHeader: 'application/json',
}, },
@ -195,7 +196,7 @@ class _MyVerifyState extends State<MyHrVerify> {
// Decode the JWT token received from the API response // Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']); Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
print('decodedToken : $decodedToken'); print('postdecodedToken : $decodedToken');
empClientBranchId = decodedToken['ref_id']; empClientBranchId = decodedToken['ref_id'];
prefs.setString('empClientBranchId', empClientBranchId); prefs.setString('empClientBranchId', empClientBranchId);
empCodeString = decodedToken['emp_code'].toString(); empCodeString = decodedToken['emp_code'].toString();
@ -206,9 +207,12 @@ class _MyVerifyState extends State<MyHrVerify> {
prefs.setString('gpaEmpName', gpaEmpName); prefs.setString('gpaEmpName', gpaEmpName);
client_id = decodedToken['client_id']; client_id = decodedToken['client_id'];
prefs.setString('client_id', 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']; emp_status = decodedToken['emp_status'];
prefs.setString('emp_status', emp_status); prefs.setString('emp_status', emp_status);
} }
if (status == 'success') { if (status == 'success') {
@ -219,7 +223,8 @@ class _MyVerifyState extends State<MyHrVerify> {
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']); Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
print('decodedToken : $decodedToken'); print('decodedToken : $decodedToken');
enrollmentEmpClientBranchId = decodedToken['ref_id']; enrollmentEmpClientBranchId = decodedToken['ref_id'];
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); prefs.setString(
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
enrollmentEmpCodeString = decodedToken['emp_code'].toString(); enrollmentEmpCodeString = decodedToken['emp_code'].toString();
prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString); prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString);
enrollmentEmpPrimaryId = decodedToken['id']; enrollmentEmpPrimaryId = decodedToken['id'];
@ -228,6 +233,12 @@ class _MyVerifyState extends State<MyHrVerify> {
prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName);
enrollmentClient_id = decodedToken['client_id']; enrollmentClient_id = decodedToken['client_id'];
prefs.setString('enrollmentClient_id', enrollmentClient_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']; // enrollmentEmp_status = decodedToken['emp_status'];
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status); // prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
} }
@ -243,7 +254,6 @@ class _MyVerifyState extends State<MyHrVerify> {
// Navigator.pushReplacementNamed(context, 'empDetails'); // Navigator.pushReplacementNamed(context, 'empDetails');
// } // }
} }
} }
void enrollmentSuccessData(data) async { void enrollmentSuccessData(data) async {
@ -252,7 +262,7 @@ class _MyVerifyState extends State<MyHrVerify> {
// Decode the JWT token received from the API response // Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']); Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
print('decodedToken : $decodedToken'); print('enrolldecodedToken : $decodedToken');
enrollmentEmpClientBranchId = decodedToken['ref_id']; enrollmentEmpClientBranchId = decodedToken['ref_id'];
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
enrollmentEmpCodeString = decodedToken['emp_code'].toString(); enrollmentEmpCodeString = decodedToken['emp_code'].toString();
@ -263,6 +273,12 @@ class _MyVerifyState extends State<MyHrVerify> {
prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName);
enrollmentClient_id = decodedToken['client_id']; enrollmentClient_id = decodedToken['client_id'];
prefs.setString('enrollmentClient_id', enrollmentClient_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']; // enrollmentEmp_status = decodedToken['emp_status'];
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status); // prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
@ -279,7 +295,6 @@ class _MyVerifyState extends State<MyHrVerify> {
Navigator.pushReplacementNamed(context, 'hrDashboard'); Navigator.pushReplacementNamed(context, 'hrDashboard');
// } // }
} }
} }
void verifyOTP(String otp) async { void verifyOTP(String otp) async {
@ -325,7 +340,8 @@ class _MyVerifyState extends State<MyHrVerify> {
duration: Duration(seconds: 2), 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') { } else if (e.code == 'invalid-verification-code') {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
@ -333,7 +349,8 @@ class _MyVerifyState extends State<MyHrVerify> {
duration: Duration(seconds: 2), 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') { } else if (e.code == 'session-expired') {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
@ -341,7 +358,8 @@ class _MyVerifyState extends State<MyHrVerify> {
duration: Duration(seconds: 2), duration: Duration(seconds: 2),
), ),
); );
ToastHelper.showErrorToast(context, 'Session expired. Try restarting the verification.'); ToastHelper.showErrorToast(
context, 'Session expired. Try restarting the verification.');
} else { } else {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
@ -356,7 +374,8 @@ class _MyVerifyState extends State<MyHrVerify> {
// _isLoading = false; // _isLoading = false;
// }); // });
print('Error: $e'); 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( Future<Map<String, dynamic>> getCashDepositDetailsToApi(
String clintID, String empRefId, String hr_id, String token) async { String clintID, String empRefId, String hr_id, String token) async {
print(token); print("getCashDepositDetailsToApi1");
if (token == null) { if (token == null) {
await _initializeToken(); await _initializeToken();
} }
// final url = Uri.parse(
// '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=470');
final url = Uri.parse( final url = Uri.parse(
'${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=$hr_id'); '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=$hr_id');
final headers = { final headers = {
'Authorization': 'Bearer $token' ?? '', '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 FlutterMacOS
import Foundation import Foundation
import file_picker
import firebase_auth import firebase_auth
import firebase_core import firebase_core
import google_sign_in_ios import google_sign_in_ios
@ -14,6 +15,7 @@ import smart_auth
import url_launcher_macos import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin")) FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))