From a262d702c8c49a5365c06ae1b4f8030613c2fdb7 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Wed, 2 Jul 2025 09:24:49 +0530 Subject: [PATCH] UI_HR_Dashboard Tab Layout --- lib/email_verify.dart | 909 +++++++++--------- lib/hrDashboard.dart | 537 +++++++---- lib/hrLogin.dart | 287 +++--- lib/hrVerify.dart | 83 +- lib/service/api_service.dart | 8 +- .../hrDashboardTabs/activePolicies.dart | 195 ++++ lib/service/hrDashboardTabs/cd.dart | 29 + lib/service/hrDashboardTabs/claims.dart | 30 + .../hrDashboardTabs/preEnrollment.dart | 225 +++++ macos/Flutter/GeneratedPluginRegistrant.swift | 2 + 10 files changed, 1491 insertions(+), 814 deletions(-) create mode 100644 lib/service/hrDashboardTabs/activePolicies.dart create mode 100644 lib/service/hrDashboardTabs/cd.dart create mode 100644 lib/service/hrDashboardTabs/claims.dart create mode 100644 lib/service/hrDashboardTabs/preEnrollment.dart diff --git a/lib/email_verify.dart b/lib/email_verify.dart index 1a3dfe2..853b7a3 100644 --- a/lib/email_verify.dart +++ b/lib/email_verify.dart @@ -16,7 +16,7 @@ import 'package:jwt_decode/jwt_decode.dart'; import '../customAppBar/toastHelper.dart'; import '../models/environment.dart'; import '../models/platform_helper_mobile.dart' -if (dart.library.html) '../models/platform_helper_other.dart'; + if (dart.library.html) '../models/platform_helper_other.dart'; // import 'dart:html' as html; @@ -46,6 +46,7 @@ class _MyEmailVerifyState extends State { dynamic enrollmentGpaEmpName; dynamic enrollmentClient_id; dynamic enrollmentHrId; + List enrollmentAllowed_modules = []; dynamic enrollmentEmp_status; dynamic empCodeString; @@ -54,6 +55,7 @@ class _MyEmailVerifyState extends State { dynamic gpaEmpName; dynamic empClientId; dynamic empHrId; + List empAllowed_modules = []; dynamic _token; dynamic _postToken; dynamic clientName; @@ -81,8 +83,6 @@ class _MyEmailVerifyState extends State { super.dispose(); } - - void startTimer() { _isTimerRunning = true; _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { @@ -101,8 +101,7 @@ class _MyEmailVerifyState extends State { 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 { // Decode the JWT token received from the API response Map? 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 { 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 { // Decode the JWT token received from the API response Map? 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,33 +213,35 @@ class _MyEmailVerifyState extends State { 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(empClientId,empClientBranchId,post['data']); + getClientLogoAndDetails(empClientId, empClientBranchId, post['data']); final SharedPreferences prefs = await SharedPreferences.getInstance(); final _postToken = prefs.getString('_postToken'); - if (_postToken != null && _postToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); - // if (emp_status == 'enrolled' || emp_status == 'active') { - Navigator.pushReplacementNamed(context, 'hrDashboard'); - // } else { - // Navigator.pushReplacementNamed(context, 'empDetails'); - // } - } + if (_postToken != null && _postToken.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + // if (emp_status == 'enrolled' || emp_status == 'active') { + Navigator.pushReplacementNamed(context, 'hrDashboard'); + // } else { + // Navigator.pushReplacementNamed(context, 'empDetails'); + // } + } } - void enrollmentSuccessData(data) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('enrollToken', data['data']); // Decode the JWT token received from the API response Map? 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,23 +254,26 @@ class _MyEmailVerifyState extends State { 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 final enrollToken = prefs.getString('enrollToken'); - if (enrollToken != null && enrollToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); - // if (emp_status == 'enrolled' || emp_status == 'active') { - // Navigator.pushReplacementNamed(context, 'home'); - // } else { - Navigator.pushReplacementNamed(context, 'hrDashboard'); - // } - } - + if (enrollToken != null && enrollToken.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + // if (emp_status == 'enrolled' || emp_status == 'active') { + // Navigator.pushReplacementNamed(context, 'home'); + // } else { + Navigator.pushReplacementNamed(context, 'hrDashboard'); + // } + } } void _resendOTP() { @@ -310,7 +317,7 @@ class _MyEmailVerifyState extends State { } } - Future getClientLogoAndDetails(client_id,empRefId,token) async { + Future getClientLogoAndDetails(client_id, empRefId, token) async { var url = Uri.parse(Environment.apiUrl + 'getClientDetails?client_id=$client_id&client_branch_id=$empRefId'); try { @@ -318,7 +325,7 @@ class _MyEmailVerifyState extends State { url, headers: { 'Authorization': - 'Bearer $token', // Add token to the Authorization header + 'Bearer $token', // Add token to the Authorization header }, ); if (response.statusCode == 200) { @@ -418,485 +425,485 @@ class _MyEmailVerifyState extends State { }, child: Scaffold( body: SingleChildScrollView( - keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, - child: Container( - height: _size.height, - color: Colors.white, - child: Stack( - children: [ - Visibility( - visible: _size.width <= 1100, - child: ClipRRect( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(30), - bottomRight: Radius.circular(30), - ), - child: Container( - height: _size.height / 3, - width: double.infinity, - color: Color(0xFFFFFCE5), - child: Stack( + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + child: Container( + height: _size.height, + color: Colors.white, + child: Stack( + children: [ + Visibility( + visible: _size.width <= 1100, + child: ClipRRect( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(30), + bottomRight: Radius.circular(30), + ), + child: Container( + height: _size.height / 3, + width: double.infinity, + color: Color(0xFFFFFCE5), + child: Stack( + children: [ + Column( children: [ - Column( + SizedBox( + height: _size.height / + 6.4), // Adjust the spacing between the rows + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align to the center children: [ - SizedBox( - height: _size.height / - 6.4), // Adjust the spacing between the rows - Row( - mainAxisAlignment: MainAxisAlignment - .center, // Align to the center - children: [ - Expanded( - flex: Responsive.isDesktop(context) - ? 10 - : 12, - child: Align( - alignment: Responsive.isDesktop(context) - ? Alignment.centerLeft - : Alignment.bottomCenter, - child: Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, + Expanded( + flex: Responsive.isDesktop(context) + ? 10 + : 12, + child: Align( + alignment: Responsive.isDesktop(context) + ? Alignment.centerLeft + : Alignment.bottomCenter, + child: Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ), + ), + ), + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Expanded( + flex: 2, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align to the end (right) + children: [ + Text( + 'HR Login', + style: GoogleFonts.poppins( + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed + ), + ), + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), + ], ), ), ), - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Expanded( - flex: 2, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'hrLogin'); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align to the end (right) - children: [ - Text( - 'HR Login', - style: GoogleFonts.poppins( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], - ), - ), - ), - ), - ], - ), + ), ], ), ], ), - ), + ], ), ), - Container( - margin: marginInsets, - alignment: Alignment.bottomCenter, - child: SingleChildScrollView( - child: Form( - key: _formKey, - child: Column( + ), + ), + Container( + margin: marginInsets, + alignment: Alignment.bottomCenter, + child: SingleChildScrollView( + child: Form( + key: _formKey, + child: Column( + children: [ + Row( children: [ - Row( - children: [ - if (_size.width > 1100) - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints constraints) { - if (constraints.maxWidth > 600) { - return Image.asset( - 'assets/hrLogin.jpg', - height: _size.height, - fit: BoxFit.cover, - ); - } else { - return SizedBox(); - } - }, - ), - ), - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: Container( - margin: _size.width > 1100 - ? EdgeInsets.only(left: 20, right: 20) - : EdgeInsets.only(left: 0, right: 0), - child: Column( - mainAxisAlignment: + if (_size.width > 1100) + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: LayoutBuilder( + builder: (BuildContext context, + BoxConstraints constraints) { + if (constraints.maxWidth > 600) { + return Image.asset( + 'assets/hrLogin.jpg', + height: _size.height, + fit: BoxFit.cover, + ); + } else { + return SizedBox(); + } + }, + ), + ), + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: Container( + margin: _size.width > 1100 + ? EdgeInsets.only(left: 20, right: 20) + : EdgeInsets.only(left: 0, right: 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Row( - children: [ - Expanded( - flex: 10, - child: Align( - alignment: Responsive + children: [ + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Row( + children: [ + Expanded( + flex: 10, + child: Align( + alignment: Responsive .isDesktop(context) - ? Alignment.centerLeft - : Alignment + ? Alignment.centerLeft + : Alignment .bottomCenter, // Align to the start - child: _size.width <= 1100 + child: _size.width <= 1100 + ? Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) + : _size.width > 1100 ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) - : _size.width > 1100 - ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) : Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), - )), - ], - ), - SizedBox(height: 10), - // SizedBox( - // height: Responsive.isDesktop(context) - // ? _size.height * 0.1 - // : 10, - // ), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ), + )), + ], + ), + SizedBox(height: 10), + // SizedBox( + // height: Responsive.isDesktop(context) + // ? _size.height * 0.1 + // : 10, + // ), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( horizontal: 150) - : EdgeInsets.symmetric( + : EdgeInsets.symmetric( horizontal: 0), - child: Row( - mainAxisAlignment: + child: Row( + mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Welcome to Nhance", - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - ], + children: [ + Text( + "Welcome to Nhance", + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.bold, + ), ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( horizontal: 150) - : EdgeInsets.symmetric( + : EdgeInsets.symmetric( horizontal: 0), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: "Please enter the one-time usage code sent to your mobile number ${widget.email}", + style: TextStyle( + fontSize: 12, + height: 1.5, + color: Color(0xFF000000)), + children: [ + TextSpan( + text: " (Change Email)", style: TextStyle( fontSize: 12, - height: 1.5, - color: Color(0xFF000000)), - children: [ - TextSpan( - text: " (Change Email)", - style: TextStyle( - fontSize: 12, - color: Color( - 0xFFE26728)), // Change color as desired - recognizer: + color: Color( + 0xFFE26728)), // Change color as desired + recognizer: TapGestureRecognizer() ..onTap = () { // Navigate to the page where the user can change the phone number Navigator.pushNamed( - context, 'hrLogin'); + context, + 'hrLogin'); }, - ), - ], ), - ), + ], ), - SizedBox(height: 15), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( + ), + ), + SizedBox(height: 15), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( horizontal: 150) - : EdgeInsets.symmetric( + : EdgeInsets.symmetric( horizontal: 0), - child: Pinput( - length: 6, - // defaultPinTheme: defaultPinTheme, - // focusedPinTheme: focusedPinTheme, - // submittedPinTheme: submittedPinTheme, - showCursor: true, - controller: _otpController, - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( + child: Pinput( + length: 6, + // defaultPinTheme: defaultPinTheme, + // focusedPinTheme: focusedPinTheme, + // submittedPinTheme: submittedPinTheme, + showCursor: true, + controller: _otpController, + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( horizontal: 150) - : EdgeInsets.symmetric( + : EdgeInsets.symmetric( horizontal: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align text to the right - children: [ - _isTimerRunning - ? Text( - "Resend OTP in $_secondsRemaining seconds", - style: - GoogleFonts.poppins( - color: - Colors.black), - ) - : InkWell( - onTap: () { - _resendOTP(); - }, - child: Text( - "Resend OTP", + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align text to the right + children: [ + _isTimerRunning + ? Text( + "Resend OTP in $_secondsRemaining seconds", style: - GoogleFonts.poppins( - color: Colors - .blue), + GoogleFonts.poppins( + color: + Colors.black), + ) + : InkWell( + onTap: () { + _resendOTP(); + }, + child: Text( + "Resend OTP", + style: + GoogleFonts.poppins( + color: Colors + .blue), + ), ), - ), - ], - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( horizontal: 150) - : EdgeInsets.symmetric( + : EdgeInsets.symmetric( horizontal: 0), - child: SizedBox( - width: double.infinity, - height: 45, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: + child: SizedBox( + width: double.infinity, + height: 45, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF00989E), - shape: RoundedRectangleBorder( - borderRadius: + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), - ), - ), - onPressed: () { - if (_formKey.currentState! - .validate()) { - _formKey.currentState! - .save(); // Save form fields before calling verifyOTP - verifyOTP( - _otpController.text); - } - }, - child: Text( - "Submit", - style: GoogleFonts.poppins( - color: Color(0xFFFFFFFF)), - ), ), ), + onPressed: () { + if (_formKey.currentState! + .validate()) { + _formKey.currentState! + .save(); // Save form fields before calling verifyOTP + verifyOTP( + _otpController.text); + } + }, + child: Text( + "Submit", + style: GoogleFonts.poppins( + color: Color(0xFFFFFFFF)), + ), ), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Column( - // children: [ - // SizedBox(height: 20), - // Text( - // "Benefits of Login", - // style: - // GoogleFonts.poppins( - // fontSize: 20, - // fontWeight: - // FontWeight.bold, - // ), - // ), - // SizedBox(height: 15), - // ], - // )) - // : SizedBox(), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.center, - // children: [ - // Expanded( - // flex: 6, - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: 8), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment - // .center, - // children: [ - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // decoration: - // BoxDecoration( - // border: - // Border( - // right: - // BorderSide( - // width: 1, - // color: Colors - // .black, - // ), - // ), - // ), - // child: Column( - // children: [ - // Icon( - // Icons - // .policy, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "View Policy", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // child: Column( - // children: [ - // Icon( - // Icons - // .edit, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "Manage Claims", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // ], - // ), - // ) - // : SizedBox( - // height: Responsive.isDesktop( - // context) - // ? _size.height * 0.1 - // : _size.height * 0.2, - // ), - SizedBox( - height: Responsive.isDesktop(context) - ? _size.height * 0.3 - : _size.height * 0.2, - ), - // SizedBox( - // height: _size.height * 0.1, - // ), - Container( - alignment: Alignment.bottomCenter, - padding: + ), + ), + // _size.width > 1100 + // ? Container( + // margin: EdgeInsets.symmetric( + // horizontal: 150), + // child: Column( + // children: [ + // SizedBox(height: 20), + // Text( + // "Benefits of Login", + // style: + // GoogleFonts.poppins( + // fontSize: 20, + // fontWeight: + // FontWeight.bold, + // ), + // ), + // SizedBox(height: 15), + // ], + // )) + // : SizedBox(), + // _size.width > 1100 + // ? Container( + // margin: EdgeInsets.symmetric( + // horizontal: 150), + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment.center, + // children: [ + // Expanded( + // flex: 6, + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: 8), + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment + // .center, + // children: [ + // Expanded( + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: + // 12), + // decoration: + // BoxDecoration( + // border: + // Border( + // right: + // BorderSide( + // width: 1, + // color: Colors + // .black, + // ), + // ), + // ), + // child: Column( + // children: [ + // Icon( + // Icons + // .policy, + // color: Color( + // 0xFFE26728)), + // SizedBox( + // height: + // 10), + // Text( + // "View Policy", + // style: GoogleFonts + // .poppins()), + // ], + // ), + // ), + // ), + // Expanded( + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: + // 12), + // child: Column( + // children: [ + // Icon( + // Icons + // .edit, + // color: Color( + // 0xFFE26728)), + // SizedBox( + // height: + // 10), + // Text( + // "Manage Claims", + // style: GoogleFonts + // .poppins()), + // ], + // ), + // ), + // ), + // ], + // ), + // ), + // ), + // ], + // ), + // ) + // : SizedBox( + // height: Responsive.isDesktop( + // context) + // ? _size.height * 0.1 + // : _size.height * 0.2, + // ), + SizedBox( + height: Responsive.isDesktop(context) + ? _size.height * 0.3 + : _size.height * 0.2, + ), + // SizedBox( + // height: _size.height * 0.1, + // ), + Container( + alignment: Alignment.bottomCenter, + padding: EdgeInsets.symmetric(vertical: 8), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: 'By continuing, you agree with our ', + style: GoogleFonts.poppins( + color: Colors.black, + fontSize: 9, + ), + children: [ + TextSpan( + text: 'privacy policy ', + style: GoogleFonts.poppins( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + TextSpan( + text: 'and ', style: GoogleFonts.poppins( color: Colors.black, fontSize: 9, ), - children: [ - TextSpan( - text: 'privacy policy ', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - TextSpan( - text: 'and ', - style: GoogleFonts.poppins( - color: Colors.black, - fontSize: 9, - ), - ), - TextSpan( - text: 'terms of use', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - ], ), - ), + TextSpan( + text: 'terms of use', + style: GoogleFonts.poppins( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + ], ), - ], + ), ), - ), + ], ), - - ], + ), ), ], ), - ), + ], ), ), - ], - )), - ))); + ), + ), + ], + )), + ))); } } diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart index 1271820..045a3a3 100755 --- a/lib/hrDashboard.dart +++ b/lib/hrDashboard.dart @@ -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 createState() => _hrDashboardState(); } -class _hrDashboardState extends State with SingleTickerProviderStateMixin { +class _hrDashboardState extends State + with SingleTickerProviderStateMixin { late ApiService apiService; late TabController _tabController; bool isLoading = false; @@ -34,10 +39,16 @@ class _hrDashboardState extends State with SingleTickerProviderStat dynamic enrollmentClient_id; dynamic policy_name; dynamic getCardArrays = []; + List empAllowed_modules = []; + + List visibleTabs = []; + List tabViews = []; dynamic clientName; dynamic clientLogo; dynamic empClientBranchId; dynamic empHrId; + List enrollmentAllowed_modules = []; + List> tabData = []; dynamic enrollmentEmpClientBranchId; dynamic enrollmentHrId; dynamic empClientId; @@ -55,12 +66,12 @@ class _hrDashboardState extends State with SingleTickerProviderStat super.initState(); apiService = ApiService(context); // Initialize ApiService here _loadToken(); - _tabController = TabController(length: 4, vsync: this); - _tabController.addListener(() { - setState(() { - selectedIndex = _tabController.index; - }); - }); + // _tabController = TabController(length: 4, vsync: this); + // _tabController.addListener(() { + // setState(() { + // selectedIndex = _tabController.index; + // }); + // }); // Future.delayed(Duration(seconds: 3), () { // setState(() { // isLoading = false; @@ -79,45 +90,169 @@ class _hrDashboardState extends State with SingleTickerProviderStat final _postToken = prefs.getString('_postToken'); final enrollToken = prefs.getString('enrollToken'); - - - - if (_postToken != null && _postToken.isNotEmpty) { - Map? decodedToken = Jwt.parseJwt(_postToken); - empClientId = decodedToken['client_id'].toString(); - empClientBranchId = prefs.getString('empClientBranchId'); - empHrId = prefs.getString('empHrId'); - print(empClientId); - print(empClientBranchId); - if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { - clientLogo = prefs.getString('clientLogo'); - clientName = prefs.getString('clientName'); - } else { - getClientLogoAndDetails(empClientBranchId,empClientId,_postToken); - } - getCashDepositDetails(empClientBranchId,empClientId,empHrId,_postToken); - } else if (enrollToken != null && enrollToken.isNotEmpty) { + if (enrollToken != null && enrollToken.isNotEmpty) { Map? decodedToken = Jwt.parseJwt(enrollToken); enrollmentClient_id = decodedToken['client_id'].toString(); - enrollmentEmpClientBranchId = prefs.getString('enrollmentEmpClientBranchId'); + enrollmentEmpClientBranchId = + prefs.getString('enrollmentEmpClientBranchId'); enrollmentHrId = prefs.getString('enrollmentHrId'); + print("Pre decodedToken - $decodedToken"); + print("Pre enrollmentClient_id - $enrollmentClient_id"); + print("Pre enrollmentEmpClientBranchId - $enrollmentEmpClientBranchId"); + print("Pre enrollmentHrId - $enrollmentHrId"); + + String? modulesString = prefs.getString('enrollmentAllowed_modules'); + if (modulesString != null) { + enrollmentAllowed_modules = jsonDecode(modulesString); + print( + "enrollmentAllowed_modules - $enrollmentAllowed_modules"); // [2, 3, 4] + + if (enrollmentAllowed_modules.contains(1)) { + tabData.add({ + 'icon': Icons.grid_view, + 'label': 'Pre Enrollment', + }); + print("getCardArrays.length = ${getCardArrays.length}"); + + tabViews.add( + PreEnrollment( + enrollmentClientId: enrollmentClient_id, + enrollmentClientBranchId: enrollmentEmpClientBranchId, + enrollmentHrId: enrollmentHrId, + enrollToken: enrollToken, + ), + // SizedBox( + // height: 400, + // child: Card( + // elevation: 5, + // color: Colors.white, + // child: SizedBox( + // height: 100, + // child: GridView.builder( + // itemCount: getCardArrays.length, + // gridDelegate: + // const SliverGridDelegateWithFixedCrossAxisCount( + // crossAxisCount: 4, + // crossAxisSpacing: 16, + // mainAxisSpacing: 0, + // childAspectRatio: 2, + // ), + // itemBuilder: (context, index) { + // print("tabIndc- $index"); + // print("getCardArraystabIndc- $getCardArrays[index]"); + // return buildPolicyCard(getCardArrays[index]); + // }, + // ), + // ), + // ), + // ), + ); + } + } + if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { clientLogo = prefs.getString('clientLogo'); clientName = prefs.getString('clientName'); } else { - getClientLogoAndDetails(enrollmentEmpClientBranchId,enrollmentClient_id,enrollToken); + getClientLogoAndDetails( + enrollmentEmpClientBranchId, enrollmentClient_id, enrollToken); } - getCashDepositDetails(enrollmentEmpClientBranchId,enrollmentClient_id,enrollmentHrId,enrollToken); - } else { - // Token is empty or null, handle accordingly (e.g., navigate to login screen) - // For now, let's navigate to the login screen - ToastHelper.showErrorToast(context, 'Session Out'); - Navigator.pushReplacementNamed(context, 'hrLogin'); + getCashDepositDetails(enrollmentEmpClientBranchId, enrollmentClient_id, + enrollmentHrId, enrollToken); } + + if (_postToken != null && _postToken.isNotEmpty) { + Map? postdecodedToken = Jwt.parseJwt(_postToken); + + empClientId = postdecodedToken['client_id'].toString(); + empClientBranchId = prefs.getString('empClientBranchId'); + empHrId = prefs.getString('empHrId'); + + print('post empHrId- $empHrId'); + print('postdecodedToken- $postdecodedToken'); + print('post empClientId- $empClientId'); + print('post empClientBranchId- $empClientBranchId'); + + print('allowed_modules'); + String? modulesString = prefs.getString('empAllowed_modules'); + + String? enrollmodulesString = + prefs.getString('enrollmentAllowed_modules'); + if (modulesString != null || enrollmodulesString != null) { + empAllowed_modules = jsonDecode(modulesString!); + enrollmentAllowed_modules = jsonDecode(enrollmodulesString!); + print("empAllowed_modules - $empAllowed_modules"); // [2, 3, 4] + print( + "enrollmentAllowed_modules - $enrollmentAllowed_modules"); // [2, 3, 4] + + if (empAllowed_modules.contains(2)) { + print("visibleTabs.length2"); + print(visibleTabs.length); + + tabData.add({ + 'icon': Icons.verified_user, + 'label': 'Active Policies', + }); + tabViews.add( + ActivePolicies( + empClientId: empClientId, + empClientBranchId: empClientBranchId, + empHrId: empHrId, + ), + ); + } + if (empAllowed_modules.contains(3)) { + print("visibleTabs.length3"); + print(visibleTabs.length); + + tabData.add({ + 'icon': Icons.desktop_windows, + 'label': 'CD', + }); + + tabViews.add(CdPolicies( + empClientId: empClientId, + empClientBranchId: empClientBranchId, + empHrId: empHrId, + )); + } + if (empAllowed_modules.contains(4)) { + tabData.add({ + 'icon': Icons.receipt_long, + 'label': 'Claims', + }); + tabViews.add(ClaimsPolicies( + empClientId: empClientId, + empClientBranchId: empClientBranchId, + empHrId: empHrId, + )); + } + } + // getCashDepositDetails( + // empClientBranchId, empClientId, empHrId, _postToken); + if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { + clientLogo = prefs.getString('clientLogo'); + clientName = prefs.getString('clientName'); + } else { + getClientLogoAndDetails(empClientBranchId, empClientId, _postToken); + } + print("getCashDepositDetails"); + } + + _tabController = TabController(length: tabData.length, vsync: this); + _tabController.addListener(() { + setState(() { + selectedIndex = _tabController.index; + }); + }); + + setState(() {}); + + isLoading = false; } - Future getClientLogoAndDetails(clintBranchId,clintID,token) async { + Future getClientLogoAndDetails(clintBranchId, clintID, token) async { var url = Uri.parse(Environment.apiUrl + 'getClientDetails?client_id=$clintID&client_branch_id=$clintBranchId'); try { @@ -164,10 +299,15 @@ class _hrDashboardState extends State with SingleTickerProviderStat } } - Future getCashDepositDetails(clintBranchId,clintID,hr_id,token) async { + Future 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 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 with SingleTickerProviderStat print('getCardArrays'); print(getCardArrays); }); + + print('IN2'); } else { print('API request failed with status'); } @@ -267,6 +413,9 @@ class _hrDashboardState extends State with SingleTickerProviderStat double policyHeight = MediaQuery.of(context).size.height / 4.5; double cardWidth = MediaQuery.of(context).size.width / 6; + print("visibleTabAll - $visibleTabs"); + print("tabViewsAll - $tabViews"); + return Scaffold( appBar: CustomAppBar(), body: Stack(children: [ @@ -277,82 +426,81 @@ class _hrDashboardState extends State with SingleTickerProviderStat color: Color(0xFFEFF3F6), child: Column( children: [ - Card( - elevation: 0, + Container( color: Colors.white, - child: Container( - width: double.infinity, - height: 75, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 10, bottom: 10, left: 20, right: 20) - : EdgeInsets.only( - top: 12, - bottom: 12, - left: 10, - right: 10), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: Image.network( - clientLogo ?? '', - width: 80, // Set the width here - height: 80, // Set the height here - loadingBuilder: (BuildContext context, - Widget child, - ImageChunkEvent? loadingProgress) { - if (loadingProgress == null) return child; - return Center( - child: CircularProgressIndicator( - value: loadingProgress - .expectedTotalBytes != - null - ? loadingProgress - .cumulativeBytesLoaded / - loadingProgress - .expectedTotalBytes! - : null, - ), - ); - }, - errorBuilder: (BuildContext context, - Object error, StackTrace? stackTrace) { - return Image.asset( - 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path - width: 80, - height: 80, - fit: BoxFit.cover, - ); - }, - ), + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 10, bottom: 10, left: 20, right: 20) + : EdgeInsets.only( + top: 12, + bottom: 12, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo ?? '', + width: 80, // Set the width here + height: 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: + loadingProgress.expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress + .expectedTotalBytes! + : null, + ), + ); + }, + errorBuilder: (BuildContext context, + Object error, StackTrace? stackTrace) { + return Image.asset( + 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path + width: 80, + height: 80, + fit: BoxFit.cover, + ); + }, ), ), - Expanded( - flex: 9, - child: Text( - clientName ?? '', - textAlign: TextAlign.right, - style: GoogleFonts.poppins( - fontSize: - Responsive.isDesktop(context) ? 20 : 18, - fontWeight: FontWeight.w600, - ), + ), + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, ), - ) - ], - ), + ), + ) + ], ), ), + SizedBox(height: 16), Container( padding: const EdgeInsets.all(5), decoration: BoxDecoration( - color: Color(0xFFC4E3E6), // 🔹 Background behind the TabBar + color: Color( + 0xFFC4E3E6), // 🔹 Background behind the TabBar borderRadius: BorderRadius.circular(12), border: Border.all(color: Colors.transparent), boxShadow: [ @@ -366,7 +514,8 @@ class _hrDashboardState extends State 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 with SingleTickerProviderStat indicatorColor: Colors.transparent, labelColor: Colors.white, unselectedLabelColor: const Color(0xFF828282), - tabs: [ - CustomTab(icon: Icons.grid_view, label: 'Pre Enrollment', isSelected: selectedIndex == 0), - CustomTab(icon: Icons.verified_user, label: 'Active Policies', isSelected: selectedIndex == 1), - CustomTab(icon: Icons.desktop_windows, label: 'CD', isSelected: selectedIndex == 2), - CustomTab(icon: Icons.receipt_long, label: 'Claims', isSelected: selectedIndex == 3), - ], + // tabs: visibleTabs, + tabs: List.generate(tabData.length, (index) { + final data = tabData[index]; + return CustomTab( + icon: data['icon'], + label: data['label'], + isSelected: selectedIndex == index, + ); + }), + + // tabs: [ + // CustomTab( + // icon: Icons.grid_view, + // label: 'Pre Enrollment', + // isSelected: selectedIndex == 0), + // CustomTab( + // icon: Icons.verified_user, + // label: 'Active Policies', + // isSelected: selectedIndex == 1), + // CustomTab( + // icon: Icons.desktop_windows, + // label: 'CD', + // isSelected: selectedIndex == 2), + // CustomTab( + // icon: Icons.receipt_long, + // label: 'Claims', + // isSelected: selectedIndex == 3), + // ], ), ), - - + SizedBox(height: 16), // Expanded TabBarView SizedBox( - height: 400, // Adjust height based on your layout + height: 500, // Adjust height based on your layout child: TabBarView( controller: _tabController, - children: [ - // Pre Enrollment Tab - Card( - elevation: 5, - color: Colors.white, - child: Container( - child: GridView.builder( - itemCount: getCardArrays.length, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 4, // Adjust for screen size (e.g., use 2 or 3 for tablets) - crossAxisSpacing: 16, - mainAxisSpacing: 0, - childAspectRatio: 2, - ), - itemBuilder: (context, index) { - return buildPolicyCard(getCardArrays[index]); - }, - ), - ) - ), - - Center(child: Text("Active Policies")), - Center(child: Text("CD")), - Center(child: Text("Claims")), - ], + children: tabViews, ), + + // child: TabBarView( + // controller: _tabController, + // children: [ + // // Pre Enrollment Tab + // Card( + // elevation: 5, + // color: Colors.white, + // child: Container( + // child: GridView.builder( + // itemCount: getCardArrays.length, + // gridDelegate: + // const SliverGridDelegateWithFixedCrossAxisCount( + // crossAxisCount: + // 4, // Adjust for screen size (e.g., use 2 or 3 for tablets) + // crossAxisSpacing: 16, + // mainAxisSpacing: 0, + // childAspectRatio: 2, + // ), + // itemBuilder: (context, index) { + // return buildPolicyCard( + // getCardArrays[index]); + // }, + // ), + // )), + // + // Center(child: Text("Active Policies")), + // Center(child: Text("CD")), + // Center(child: Text("Claims")), + // ], + // ), ), // if (getCardArrays.length != 0) // Card( @@ -817,39 +994,46 @@ class _hrDashboardState extends State with SingleTickerProviderStat } Widget buildPolicyCard(Map policy) { - return Card( - elevation: 3, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), - child: Padding( - padding: const EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - policy['type'] ?? '', - style: const TextStyle( - fontWeight: FontWeight.w600, - fontSize: 14, + print("buildPolicyCard - $policy"); + return SizedBox( + height: 50, + child: Card( + elevation: 3, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + child: Padding( + padding: const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + policy['type'] ?? '', + style: const TextStyle( + fontWeight: FontWeight.w600, + fontSize: 14, + ), ), - ), - const SizedBox(height: 4), - Text( - policy['policy_name'] ?? '', - style: const TextStyle( - fontSize: 12, - color: Colors.grey, + const SizedBox(height: 4), + Text( + policy['policy_name'] ?? '', + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + ), ), - ), - const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - _buildCountBox(policy['membersCountOfDraft'].toString(), "Draft"), - _buildCountBox(policy['membersCountOfEnrolled'].toString(), "Enrolled"), - _buildCountBox(policy['totalMembersCount'].toString(), "Total"), - ], - ), - ], + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _buildCountBox( + policy['membersCountOfDraft'].toString(), "Draft"), + _buildCountBox( + policy['membersCountOfEnrolled'].toString(), "Enrolled"), + _buildCountBox( + policy['totalMembersCount'].toString(), "Total"), + ], + ), + ], + ), ), ), ); @@ -872,11 +1056,11 @@ class _hrDashboardState extends State with SingleTickerProviderStat ), ), const SizedBox(height: 6), - Text(label, style: const TextStyle(fontSize: 12, color: Colors.black87)), + Text(label, + style: const TextStyle(fontSize: 12, color: Colors.black87)), ], ); } - } class CustomTab extends StatelessWidget { @@ -915,9 +1099,12 @@ class CustomTab extends StatelessWidget { ], ), child: Row( - mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + // mainAxisSize: MainAxisSize.min, children: [ - Icon(icon, size: 18, color: isSelected ? Colors.white : const Color(0xFF828282)), + Icon(icon, + size: 18, + color: isSelected ? Colors.white : const Color(0xFF828282)), const SizedBox(width: 6), Text( label, @@ -979,4 +1166,4 @@ class PolicyCard extends StatelessWidget { ], ); } -} \ No newline at end of file +} diff --git a/lib/hrLogin.dart b/lib/hrLogin.dart index fc373a8..2da9539 100755 --- a/lib/hrLogin.dart +++ b/lib/hrLogin.dart @@ -64,7 +64,7 @@ class _MyPhoneState extends State { Map payload = isEmailFieldVisible ? {'email': emailController.text} - : {'mobile_no': mobileController.text}; + : {'mobile_number': mobileController.text}; // var enteredMobileNumber = mobileController.text; final response = await http.post( @@ -81,7 +81,7 @@ class _MyPhoneState extends State { String message = data['data']['message']; if (userVerification) { final SharedPreferences prefs = - await SharedPreferences.getInstance(); + await SharedPreferences.getInstance(); // var enteredMobileNumber = mobileController.text; // prefs.setString('empMobileNo', enteredMobileNumber); if (isEmailFieldVisible) { @@ -175,7 +175,6 @@ class _MyPhoneState extends State { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('verificationId', _verificationId); - ToastHelper.showSuccessToast( context, 'Verification code sent to ${enteredMobileNumber}'); @@ -194,7 +193,7 @@ class _MyPhoneState extends State { _isLoading = false; }); }, - codeAutoRetrievalTimeout: (String verificationId) async{ + codeAutoRetrievalTimeout: (String verificationId) async { setState(() { _verificationId = verificationId; }); @@ -221,7 +220,7 @@ class _MyPhoneState extends State { print('The provided phone number is not valid.'); } }, - codeSent: (String verificationId, int? resendToken) async{ + codeSent: (String verificationId, int? resendToken) async { final prefs = await SharedPreferences.getInstance(); await prefs.setString('verificationId', verificationId); setState(() { @@ -242,7 +241,7 @@ class _MyPhoneState extends State { ), ); }, - codeAutoRetrievalTimeout: (String verificationId) async{ + codeAutoRetrievalTimeout: (String verificationId) async { final prefs = await SharedPreferences.getInstance(); await prefs.setString('verificationId', verificationId); setState(() { @@ -509,12 +508,11 @@ class _MyPhoneState extends State { Container( margin: Responsive.isDesktop(context) ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), child: Row( mainAxisAlignment: - MainAxisAlignment.center, + MainAxisAlignment.center, children: [ Expanded( child: Text( @@ -535,157 +533,138 @@ class _MyPhoneState extends State { children: [ isEmailFieldVisible ? Container( - height: 55, - margin: Responsive - .isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - decoration: BoxDecoration( - border: Border.all( - width: 1, - color: Colors.grey), - borderRadius: - BorderRadius.circular( - 10), - ), - child: TextFormField( - controller: - emailController, - keyboardType: - TextInputType - .emailAddress, - decoration: - InputDecoration( - border: - InputBorder.none, - hintText: - "Enter your email", - contentPadding: - EdgeInsets - .symmetric( - horizontal: - 10), - ), - validator: (value) { - if (value == null || - value.isEmpty) { - return 'Please enter your email'; - } - if (!RegExp( - r'^[^@]+@[^@]+\.[^@]+') - .hasMatch(value)) { - return 'Please enter a valid email'; - } - return null; - }, - ), - ) - : Container( - height: 55, - margin: Responsive - .isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - decoration: BoxDecoration( - border: Border.all( - width: 1, - color: Colors.grey), - borderRadius: - BorderRadius.circular( - 10), - ), - child: Row( - children: [ - SizedBox(width: 10), - SizedBox( - width: 40, - child: TextField( - controller: - countryController, - keyboardType: - TextInputType - .number, - decoration: - InputDecoration( - border: - InputBorder - .none, - ), + height: 55, + margin: Responsive.isDesktop( + context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + decoration: BoxDecoration( + border: Border.all( + width: 1, + color: Colors.grey), + borderRadius: + BorderRadius.circular(10), ), - ), - Text( - "|", - style: TextStyle( - fontSize: 33, - color: - Colors.grey), - ), - SizedBox(width: 10), - Expanded( child: TextFormField( - controller: - mobileController, - keyboardType: - TextInputType - .phone, - decoration: - InputDecoration( - border: - InputBorder - .none, + controller: emailController, + keyboardType: TextInputType + .emailAddress, + decoration: InputDecoration( + border: InputBorder.none, hintText: - "Enter your mobile number", + "Enter your email", + contentPadding: + EdgeInsets.symmetric( + horizontal: 10), ), validator: (value) { - if (value == - null || - value - .isEmpty) { - return 'Please enter your mobile number'; + if (value == null || + value.isEmpty) { + return 'Please enter your email'; } - if (value - .length != - 10) { - return 'Mobile number must be 10 digits'; + if (!RegExp( + r'^[^@]+@[^@]+\.[^@]+') + .hasMatch(value)) { + return 'Please enter a valid email'; } return null; }, - inputFormatters: [ - FilteringTextInputFormatter - .digitsOnly, - LengthLimitingTextInputFormatter( - 10), + ), + ) + : Container( + height: 55, + margin: Responsive.isDesktop( + context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + decoration: BoxDecoration( + border: Border.all( + width: 1, + color: Colors.grey), + borderRadius: + BorderRadius.circular(10), + ), + child: Row( + children: [ + SizedBox(width: 10), + SizedBox( + width: 40, + child: TextField( + controller: + countryController, + keyboardType: + TextInputType + .number, + decoration: + InputDecoration( + border: + InputBorder.none, + ), + ), + ), + Text( + "|", + style: TextStyle( + fontSize: 33, + color: Colors.grey), + ), + SizedBox(width: 10), + Expanded( + child: TextFormField( + controller: + mobileController, + keyboardType: + TextInputType.phone, + decoration: + InputDecoration( + border: + InputBorder.none, + hintText: + "Enter your mobile number", + ), + validator: (value) { + if (value == null || + value.isEmpty) { + return 'Please enter your mobile number'; + } + if (value.length != + 10) { + return 'Mobile number must be 10 digits'; + } + return null; + }, + inputFormatters: [ + FilteringTextInputFormatter + .digitsOnly, + LengthLimitingTextInputFormatter( + 10), + ], + ), + ), ], ), ), - ], - ), - ), SizedBox(height: 15), Container( - margin: - Responsive.isDesktop(context) + margin: Responsive.isDesktop(context) ? EdgeInsets.symmetric( - horizontal: 150) + horizontal: 150) : EdgeInsets.symmetric( - horizontal: 0), + horizontal: 0), child: SizedBox( width: double.infinity, height: 45, child: ElevatedButton( - style: - ElevatedButton.styleFrom( + style: ElevatedButton.styleFrom( backgroundColor: - Color(0xFF00989E), - shape: - RoundedRectangleBorder( + Color(0xFF00989E), + shape: RoundedRectangleBorder( borderRadius: - BorderRadius.circular( - 10), + BorderRadius.circular(10), ), ), onPressed: _isLoading @@ -693,22 +672,22 @@ class _MyPhoneState extends State { : verifyMobileAndEmailNumber, child: _isLoading ? CircularProgressIndicator( - valueColor: - AlwaysStoppedAnimation< - Color>( - Color(0xFF00989E), - ), - ) + valueColor: + AlwaysStoppedAnimation< + Color>( + Color(0xFF00989E), + ), + ) : Text( - isEmailFieldVisible - ? "Login with Email OTP" - : "Login with Mobile OTP", - style: GoogleFonts - .poppins( - color: Color( - 0xFFFFFFFF), - ), - ), + isEmailFieldVisible + ? "Login with Email OTP" + : "Login with Mobile OTP", + style: + GoogleFonts.poppins( + color: + Color(0xFFFFFFFF), + ), + ), ), ), ), diff --git a/lib/hrVerify.dart b/lib/hrVerify.dart index b65fa6e..4e041df 100755 --- a/lib/hrVerify.dart +++ b/lib/hrVerify.dart @@ -46,6 +46,8 @@ class _MyVerifyState extends State { dynamic enrollmentEmpPrimaryId; dynamic enrollmentGpaEmpName; dynamic enrollmentClient_id; + dynamic enrollmentHrId; + List enrollmentAllowed_modules = []; dynamic enrollmentEmp_status; dynamic empClientBranchId; @@ -53,6 +55,8 @@ class _MyVerifyState extends State { dynamic empPrimaryId; dynamic gpaEmpName; dynamic client_id; + dynamic empHrId; + List empAllowed_modules = []; dynamic emp_status; dynamic _token; @@ -105,7 +109,6 @@ class _MyVerifyState extends State { super.dispose(); } - void startTimer() { _isTimerRunning = true; _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { @@ -124,10 +127,8 @@ class _MyVerifyState extends State { 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 { // Decode the JWT token received from the API response Map? 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 { 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 { Map? decodedToken = Jwt.parseJwt(data['data']); print('decodedToken : $decodedToken'); enrollmentEmpClientBranchId = decodedToken['ref_id']; - prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); + prefs.setString( + 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); enrollmentEmpCodeString = decodedToken['emp_code'].toString(); prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString); enrollmentEmpPrimaryId = decodedToken['id']; @@ -228,22 +233,27 @@ class _MyVerifyState extends State { prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); enrollmentClient_id = decodedToken['client_id']; prefs.setString('enrollmentClient_id', enrollmentClient_id); + + enrollmentHrId = decodedToken['id']; + prefs.setString('enrollmentHrId', enrollmentHrId); + enrollmentAllowed_modules = decodedToken['allowed_modules']; + prefs.setString( + 'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules)); // enrollmentEmp_status = decodedToken['emp_status']; // prefs.setString('enrollmentEmp_status', enrollmentEmp_status); - } + } final SharedPreferences prefs = await SharedPreferences.getInstance(); final _postToken = prefs.getString('_postToken'); - if (_postToken != null && _postToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); - // if (emp_status == 'enrolled' || emp_status == 'active') { - Navigator.pushReplacementNamed(context, 'hrDashboard'); - // } else { - // Navigator.pushReplacementNamed(context, 'empDetails'); - // } - } - + if (_postToken != null && _postToken.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + // if (emp_status == 'enrolled' || emp_status == 'active') { + Navigator.pushReplacementNamed(context, 'hrDashboard'); + // } else { + // Navigator.pushReplacementNamed(context, 'empDetails'); + // } + } } void enrollmentSuccessData(data) async { @@ -252,7 +262,7 @@ class _MyVerifyState extends State { // Decode the JWT token received from the API response Map? 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 { prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); enrollmentClient_id = decodedToken['client_id']; prefs.setString('enrollmentClient_id', enrollmentClient_id); + + enrollmentHrId = decodedToken['id']; + prefs.setString('enrollmentHrId', enrollmentHrId); + enrollmentAllowed_modules = decodedToken['allowed_modules']; + prefs.setString( + 'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules)); // enrollmentEmp_status = decodedToken['emp_status']; // prefs.setString('enrollmentEmp_status', enrollmentEmp_status); @@ -271,15 +287,14 @@ class _MyVerifyState extends State { // Redirect to another page final enrollToken = prefs.getString('enrollToken'); - if (enrollToken != null && enrollToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); - // if (emp_status == 'enrolled' || emp_status == 'active') { - // Navigator.pushReplacementNamed(context, 'home'); - // } else { - Navigator.pushReplacementNamed(context, 'hrDashboard'); - // } - } - + if (enrollToken != null && enrollToken.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + // if (emp_status == 'enrolled' || emp_status == 'active') { + // Navigator.pushReplacementNamed(context, 'home'); + // } else { + Navigator.pushReplacementNamed(context, 'hrDashboard'); + // } + } } void verifyOTP(String otp) async { @@ -325,7 +340,8 @@ class _MyVerifyState extends State { 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 { 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 { 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 { // _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.'); } } diff --git a/lib/service/api_service.dart b/lib/service/api_service.dart index c5e9714..91b602a 100755 --- a/lib/service/api_service.dart +++ b/lib/service/api_service.dart @@ -412,13 +412,17 @@ class ApiService { //HR API STARTS Future> getCashDepositDetailsToApi( - String clintID, String empRefId,String hr_id, String token) async { - print(token); + String clintID, String empRefId, String hr_id, String token) async { + print("getCashDepositDetailsToApi1"); + if (token == null) { await _initializeToken(); } + // final url = Uri.parse( + // '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=470'); final url = Uri.parse( '${Environment.apiUrl}getPolicyLevelEmployeeSummaryData?client_id=$clintID&client_branch_id=$empRefId&hr_id=$hr_id'); + final headers = { 'Authorization': 'Bearer $token' ?? '', }; diff --git a/lib/service/hrDashboardTabs/activePolicies.dart b/lib/service/hrDashboardTabs/activePolicies.dart new file mode 100644 index 0000000..26bfb07 --- /dev/null +++ b/lib/service/hrDashboardTabs/activePolicies.dart @@ -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 createState() => _ActivePolicieState(); +} + +class _ActivePolicieState extends State { + 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 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)), + ], + ); + } +} diff --git a/lib/service/hrDashboardTabs/cd.dart b/lib/service/hrDashboardTabs/cd.dart new file mode 100644 index 0000000..5545d9b --- /dev/null +++ b/lib/service/hrDashboardTabs/cd.dart @@ -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 createState() => _CdPolicieState(); +} + +class _CdPolicieState extends State { + @override + Widget build(BuildContext context) { + // TODO: implement build + return Container( + child: Text("Cd policy data"), + ); + } +} diff --git a/lib/service/hrDashboardTabs/claims.dart b/lib/service/hrDashboardTabs/claims.dart new file mode 100644 index 0000000..87d8a73 --- /dev/null +++ b/lib/service/hrDashboardTabs/claims.dart @@ -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 createState() => _ClaimsPolicieState(); +} + +class _ClaimsPolicieState extends State { + @override + Widget build(BuildContext context) { + // TODO: implement build + return Container( + child: Text("Claims policy data"), + ); + } +} diff --git a/lib/service/hrDashboardTabs/preEnrollment.dart b/lib/service/hrDashboardTabs/preEnrollment.dart new file mode 100644 index 0000000..71aeb03 --- /dev/null +++ b/lib/service/hrDashboardTabs/preEnrollment.dart @@ -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 createState() => _PreEnrollmentState(); +} + +class _PreEnrollmentState extends State { + late ApiService apiService; + dynamic getCardArrays = []; + int selectedIndex = 0; + + @override + void initState() { + super.initState(); + apiService = ApiService(context); + _loadData(); + + print("_PreEnrollmentState 1"); + } + + Future _loadData() async { + await getCashDepositDetails(widget.enrollmentClientBranchId, + widget.enrollmentClientId, widget.enrollmentHrId, widget.enrollToken); + } + + Future 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>.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 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))), + ], + ); + } +} diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 2ce5852..ff40429 100755 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -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"))