From 77435a82a6dc9eaf17b6105a94a7c983a0d3478a Mon Sep 17 00:00:00 2001 From: venbaittech Date: Mon, 17 Feb 2025 17:08:23 +0530 Subject: [PATCH] new added --- .env | 1 + .env.development | 4 +- .env.production | 1 + .env.test | 9 +- .env.uat | 9 +- android/app/src/main/AndroidManifest.xml | 1 + build_web_dev.sh | 1 + lib/main.dart | 18 +- lib/models/environment.dart | 6 +- lib/pages/email_verify.dart | 855 ++++++++++++++++++ lib/pages/enrollment/addons.dart | 455 +++++++++- lib/pages/enrollment/empDetails.dart | 463 +++++++++- lib/pages/enrollment/empReview.dart | 519 ++++++++++- lib/pages/enrollment/service/api_service.dart | 55 +- lib/pages/login.dart | 354 +++++--- lib/pages/postEnrollment/chatbot.dart | 34 +- lib/pages/postEnrollment/policies.dart | 144 +-- 17 files changed, 2698 insertions(+), 231 deletions(-) create mode 100644 lib/pages/email_verify.dart diff --git a/.env b/.env index 267d625..c86ec85 100644 --- a/.env +++ b/.env @@ -1,4 +1,5 @@ API_URL=https://venbait.in/nhance/dev/employeeRest/ TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api +ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH BASE_HREF=/nhance/employee/dev/ ENV=development \ No newline at end of file diff --git a/.env.development b/.env.development index 267d625..64506c5 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,6 @@ API_URL=https://venbait.in/nhance/dev/employeeRest/ +API_URL_Enrollment=https://venbait.in/enrollment/employeeRest/ TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api +ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH BASE_HREF=/nhance/employee/dev/ -ENV=development \ No newline at end of file +ENV=development diff --git a/.env.production b/.env.production index dc81ca7..1df8c98 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,5 @@ API_URL=https://app.nhanceindia.in/zenith/employeeRest/ TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api +ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH BASE_HREF=/app/ ENV=production \ No newline at end of file diff --git a/.env.test b/.env.test index 96bf094..1df8c98 100644 --- a/.env.test +++ b/.env.test @@ -1,4 +1,5 @@ -API_URL=https://venbait.in/nhance/test/employeeRest/ -TICKET_API_URL=https://venbait.in/nhance/helpdesk/test/api -BASE_HREF=/nhance/employee/test/ -ENV=test \ No newline at end of file +API_URL=https://app.nhanceindia.in/zenith/employeeRest/ +TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api +ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH +BASE_HREF=/app/ +ENV=production \ No newline at end of file diff --git a/.env.uat b/.env.uat index 5ea1d81..1df8c98 100644 --- a/.env.uat +++ b/.env.uat @@ -1,4 +1,5 @@ -API_URL=https://dev.venbait.in/nhance/uat/employeeRest/ -TICKET_API_URL=https://dev.venbait.in/nhance/helpdesk/uat/api -BASE_HREF=/nhance/employee/uat/ -ENV=uat \ No newline at end of file +API_URL=https://app.nhanceindia.in/zenith/employeeRest/ +TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api +ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH +BASE_HREF=/app/ +ENV=production \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 717732d..2bb9022 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ + main() async { + clearLocalStorageOnAppStart(); WidgetsFlutterBinding.ensureInitialized(); - + // final SharedPreferences prefs = await SharedPreferences.getInstance(); + // prefs.clear(); await Firebase.initializeApp( options: const FirebaseOptions( apiKey: 'AIzaSyC4yHbCX4mQu0jO81pJrDwxKLQlTQWofrc', @@ -52,6 +65,9 @@ class MyApp extends StatelessWidget { routes: { 'splash': (context) => SplashScreen(), 'login': (context) => login(), + 'mailVerify': (context) => MyEmailVerify( + email: '', + ), 'verify': (context) => MyVerify( verificationId: '', mobileNumber: '', diff --git a/lib/models/environment.dart b/lib/models/environment.dart index 8a90e5d..f93a3e1 100644 --- a/lib/models/environment.dart +++ b/lib/models/environment.dart @@ -21,6 +21,10 @@ class Environment { return dotenv.env['API_URL'] ?? 'API_URL not found!'; } + static String get apiUrlEnrollment { + return dotenv.env['API_URL_Enrollment'] ?? 'API_URL not found!'; + } + static String get baseHref { return dotenv.env['BASE_HREF'] ?? 'BASE_HREF not found!'; } @@ -35,7 +39,7 @@ class Environment { //Live static String get ticketToken { - return '3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH'; + return dotenv.env['ticketToken'] ?? 'TICKET_API_URL not found!'; } //Dev // static String get ticketToken { diff --git a/lib/pages/email_verify.dart b/lib/pages/email_verify.dart new file mode 100644 index 0000000..2f323f1 --- /dev/null +++ b/lib/pages/email_verify.dart @@ -0,0 +1,855 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:firebase_messaging/firebase_messaging.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart'; +import 'package:pinput/pinput.dart'; +import 'dart:async'; +import 'package:flutter/gestures.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; +import 'dart:io'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:jwt_decode/jwt_decode.dart'; + +import '../customAppBar/responsive.dart'; +import '../customAppBar/toastHelper.dart'; +import '../models/environment.dart'; +import '../models/platform_helper_mobile.dart' + if (dart.library.html) '../models/platform_helper_other.dart'; + +class MyEmailVerify extends StatefulWidget { + final String email; + + const MyEmailVerify({ + Key? key, + required this.email, + }) : super(key: key); + + @override + State createState() => _MyEmailVerifyState(); +} + +class _MyEmailVerifyState extends State { + late ApiService apiService; + TextEditingController _otpController = TextEditingController(); + final _formKey = GlobalKey(); + late Timer _timer; + int _secondsRemaining = 60; + bool _isTimerRunning = false; + dynamic empCodeString; + dynamic empClientBranchId; + dynamic empPrimaryId; + dynamic gpaEmpName; + dynamic client_id; + dynamic _token; + dynamic clientName; + dynamic clientLogo; + dynamic emp_status; + dynamic fCMToken; + late String verificationId; + final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; + final FirebaseAuth _auth = FirebaseAuth.instance; + bool _isLoading = false; + + late String _verificationId; + + @override + void initState() { + super.initState(); + apiService = ApiService(context); + startTimer(); + } + + @override + void dispose() { + _timer.cancel(); + super.dispose(); + } + + Future initNotification() async { + await _firebaseMessaging.requestPermission(); + fCMToken = await _firebaseMessaging.getToken(); + print('Token : $fCMToken'); + sendDeviceToken(fCMToken); + FirebaseMessaging.onBackgroundMessage(handleBackgroundMessage); + } + + Future handleBackgroundMessage(RemoteMessage message) async { + print('Title ${message.notification?.title}'); + print('Body ${message.notification?.body}'); + print('Playload ${message.data}'); + } + + void sendDeviceToken(deviceToken) async { + // Retrieve the passed mobile number value + + try { + final response = await http.post( + Uri.parse(Environment.apiUrl + 'storeFireBase'), + body: json + .encode({'email_id': widget.email, 'firebase_token': deviceToken}), + headers: { + HttpHeaders.contentTypeHeader: 'application/json', + 'Authorization': 'Bearer $_token', + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + print('data: $data'); + String status = data['status']; + print(status); + if (status == 'success') { + print('Token Store Successfully'); + } else { + print('Please try again'); + } + } else { + throw Exception('Failed to store'); + } + } catch (e) { + print('Error: $e'); + } + } + + void startTimer() { + _isTimerRunning = true; + _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { + setState(() { + if (_secondsRemaining > 0) { + _secondsRemaining--; + } else { + _isTimerRunning = false; + _timer.cancel(); + } + }); + }); + } + + void verifyOTP(String otp) async { + try { + final response = await http.post( + Uri.parse(Environment.apiUrl + 'getVerifiedUserData'), + body: + json.encode({'email_id': widget.email, 'otp': _otpController.text}), + headers: { + HttpHeaders.contentTypeHeader: 'application/json', + }, + ); + + if (response.statusCode == 200) { + setState(() { + _isLoading = false; + }); + Map data = json.decode(response.body); + print('data: $data'); + _token = data['data']; + String status = data['status']; + print(status); + if (status == 'success') { + setState(() { + _isLoading = false; + }); + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('token', data['data']); + + // Decode the JWT token received from the API response + Map? decodedToken = Jwt.parseJwt(data['data']); + print('decodedToken : $decodedToken'); + empClientBranchId = decodedToken['client_branch_id']; + prefs.setString('empClientBranchId', empClientBranchId); + empCodeString = decodedToken['emp_code'].toString(); + prefs.setString('empCode', empCodeString); + empPrimaryId = decodedToken['id']; + prefs.setString('empPrimaryId', empPrimaryId); + gpaEmpName = decodedToken['name'].toString(); + prefs.setString('gpaEmpName', gpaEmpName); + client_id = decodedToken['client_id']; + prefs.setString('client_id', client_id); + emp_status = decodedToken['emp_status']; + prefs.setString('emp_status', emp_status); + getClientLogoAndDetails(); + + print('Successfully Login'); + + // Redirect to another page + final token = prefs.getString('token'); + // int skipStatus = prefs.getInt('skipStatus') ?? 1; + // final mpinText = prefs.getString('mpinText'); + print(isMobilePlatform()); + if (isMobilePlatform()) { + // if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') { + if (token != null && token.isNotEmpty) { + await initNotification(); + Navigator.pushReplacementNamed(context, 'pinSettingPage'); + } + // } + } else { + if (token != null && token.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + if (emp_status == 'enrolled' || emp_status == 'active') { + Navigator.pushReplacementNamed(context, 'home'); + } else { + Navigator.pushReplacementNamed(context, 'empDetails'); + } + } + } + } else { + setState(() { + _isLoading = false; + }); + ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); + // Show a Snackbar if the OTP is invalid + print('Invalid OTP. Please try again'); + } + } else { + setState(() { + _isLoading = false; + }); + ToastHelper.showWarningToast(context, 'Something went wrong'); + throw Exception('Failed to verify OTP'); + } + } catch (e) { + setState(() { + _isLoading = false; + }); + print('Error: $e'); + ToastHelper.showWarningToast(context, 'Something went wrong'); + // Show a Snackbar if there's an error while verifying OTP + print('Failed to verify OTP. Please try again.'); + } + } + + void _resendOTP() { + setState(() { + _secondsRemaining = 60; + _isTimerRunning = true; + }); + startTimer(); + verifyMobileAndEmailNumber(); + } + + Future verifyMobileAndEmailNumber() async { + try { + // var enteredMobileNumber = mobileController.text; + final response = await http.post( + Uri.parse(Environment.apiUrl + 'verifyEmployeeEmailId'), + body: json.encode({'email': widget.email}), + headers: { + HttpHeaders.contentTypeHeader: 'application/json', + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + bool userVerification = data['data']['user_verification']; + String message = data['data']['message']; + if (userVerification) { + ToastHelper.showSuccessToast( + context, 'Verification code sent to ${widget.email}'); + } else { + ToastHelper.showErrorToast(context, message); + print('Invalid mobile number'); + } + } else { + ToastHelper.showErrorToast(context, 'Something went wrong'); + throw Exception('Failed to verify mobile number'); + } + } catch (e) { + ToastHelper.showErrorToast(context, 'Something went wrong'); + print('Error: $e'); + } + } + + Future getClientLogoAndDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + // print('response.statusCode == 200'); + Map data = json.decode(response.body); + // print(data); + + if (data.containsKey('data')) { + dynamic clientDetails = data['data']; + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('clientLogo', clientDetails['client']['client_logo']); + prefs.setString('clientName', clientDetails['client']['client_name']); + prefs.setString( + 'addon_subheading', clientDetails['client']['addon_subheading']); + setState(() { + // dynamic clientDetails = data['data']; + // print(clientDetails); + clientName = clientDetails['client']['client_name']; + print(clientName); + clientLogo = clientDetails['client']['client_logo']; + print(clientLogo); + }); + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + @override + Widget build(BuildContext context) { + // Retrieve the passed mobile number value + // final String mobileNumber = + // ModalRoute.of(context)!.settings.arguments as String; + Size _size = MediaQuery.of(context).size; + EdgeInsets marginInsets = EdgeInsets.zero; + if (Responsive.isDesktop(context)) { + marginInsets = const EdgeInsets.only( + left: 0, + right: 0, + bottom: 0, + top: 0, + ); + } else if (Responsive.isMobile(context)) { + marginInsets = const EdgeInsets.only( + left: 25, // Example value for mobile + right: 25, // Example value for mobile + bottom: 0, // Example value for mobile + top: 0, // Example value for mobile + ); + } else if (Responsive.isTablet(context)) { + marginInsets = const EdgeInsets.only( + left: 25, // Example value for mobile + right: 25, // Example value for mobile + bottom: 0, // Example value for mobile + top: 0, // Example value for mobile + ); + } + final defaultPinTheme = PinTheme( + width: 56, + height: 56, + textStyle: TextStyle( + fontSize: 20, + color: Color.fromRGBO(30, 60, 87, 1), + fontWeight: FontWeight.w600, + ), + decoration: BoxDecoration( + border: Border.all(color: Color.fromRGBO(234, 239, 243, 1)), + borderRadius: BorderRadius.circular(20), + ), + ); + + final focusedPinTheme = defaultPinTheme.copyDecorationWith( + border: Border.all(color: Color.fromRGBO(114, 178, 238, 1)), + borderRadius: BorderRadius.circular(8), + ); + + final submittedPinTheme = defaultPinTheme.copyWith( + decoration: defaultPinTheme.decoration?.copyWith( + color: Color.fromRGBO(234, 239, 243, 1), + ), + ); + + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed(context, 'login'); + return false; + }, + 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( + children: [ + Column( + 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, + ), + ), + ), + 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( + children: [ + Row( + children: [ + 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 + .isDesktop(context) + ? Alignment.centerLeft + : Alignment + .bottomCenter, // Align to the start + 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, + ) + : 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( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + "Welcome to Nhance", + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + 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, + 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, 'login'); + }, + ), + ], + ), + ), + ), + SizedBox(height: 15), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : 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( + horizontal: 150) + : 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", + style: + GoogleFonts.poppins( + color: Colors + .blue), + ), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: SizedBox( + width: double.infinity, + height: 45, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFF00989E), + 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)), + ), + ), + ), + ), + // _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: + '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, + ), + ), + TextSpan( + text: 'terms of use', + style: GoogleFonts.poppins( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + 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/login_web.jpg', + height: _size.height, + fit: BoxFit.cover, + ); + } else { + return SizedBox(); + } + }, + ), + ), + ], + ), + ], + ), + ), + ), + ), + ], + )), + ))); + } +} diff --git a/lib/pages/enrollment/addons.dart b/lib/pages/enrollment/addons.dart index 57548e4..92e233a 100644 --- a/lib/pages/enrollment/addons.dart +++ b/lib/pages/enrollment/addons.dart @@ -58,6 +58,13 @@ class _addOnsDetailsState extends State { dynamic gpaSelfRelationship; dynamic gpaSelfDetails; dynamic gpaECardDownload; + dynamic gpaGstValue; + dynamic gpaSiPremiumValue; + dynamic gpaTotalableValue; + dynamic gmcGstValue; + dynamic gmcSiPremiumValue; + dynamic gmcTotalableValue; + late bool gmcIsValueValid; dynamic gmcECardDownload; dynamic gmcClintPolicyId; dynamic gmcMappedFamilyFloaters; @@ -219,7 +226,7 @@ class _addOnsDetailsState extends State { } else { // Token is empty or null, handle accordingly (e.g., navigate to login screen) ToastHelper.showErrorToast(context, 'Session Out'); - Navigator.pushReplacementNamed(context, 'phone'); + Navigator.pushReplacementNamed(context, 'login'); } } @@ -4392,6 +4399,11 @@ class _addOnsDetailsState extends State { gmcFloaterTextDescription = item['floter_text_description']; gmcNotes = item['notes']; gmcECardDownload = item['eCardDownload']; + gmcGstValue = item['family_floaters_of_dependent_and_gst_value']; + gmcSiPremiumValue = + item['family_floaters_of_dependent_and_si_premium_value']; + gmcTotalableValue = gmcGstValue + gmcSiPremiumValue; + gmcIsValueValid = (gmcSiPremiumValue != 0 && gmcGstValue != 0); // gmcSumInsured = item['Policy_Terms']['sum_insured']; gmcMappedFamilyFloaters = item['mapped_family_floaters']; dynamic getTrueObjects = gmcMappedFamilyFloaters @@ -4559,6 +4571,230 @@ class _addOnsDetailsState extends State { }).toList(), ), ), + if (Responsive.isDesktop(context) && gmcIsValueValid) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && gmcIsValueValid) + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcSiPremiumValue ?? '') + .toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcTotalableValue ?? '') + .toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) ], ), )) @@ -4578,6 +4814,10 @@ class _addOnsDetailsState extends State { String? gpaPolicyType = item['type']; String? gpaECardDownload = item['eCardDownload']; String? gpaSumInsured; + gpaGstValue = item['si_gst_value']; + gpaSiPremiumValue = item['si_premium_value']; + gpaTotalableValue = gpaSiPremiumValue + gpaGstValue; + bool isValueValid = (gpaSiPremiumValue != 0 && gpaGstValue != 0); List gpaMappedFamilyFloaters = []; if (item['mapped_family_floaters'] != null) { @@ -4747,6 +4987,219 @@ class _addOnsDetailsState extends State { Column( children: familyFloaterContainers, ), + if (Responsive.isDesktop(context) && isValueValid) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && isValueValid) + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) ], ), ), diff --git a/lib/pages/enrollment/empDetails.dart b/lib/pages/enrollment/empDetails.dart index 4c4174f..fda4ca5 100644 --- a/lib/pages/enrollment/empDetails.dart +++ b/lib/pages/enrollment/empDetails.dart @@ -46,7 +46,14 @@ class _empDetailsState extends State { dynamic gpaOpenForEnrollment; dynamic gpaECardDownload; dynamic gpaSumInsured; + dynamic gpaGstValue; + dynamic gpaSiPremiumValue; + dynamic gpaTotalableValue; dynamic gmcECardDownload; + dynamic gmcGstValue; + dynamic gmcSiPremiumValue; + dynamic gmcTotalableValue; + late bool gmcIsValueValid; int gmcOpenForEnrollment = 0; dynamic gmcPolicies; dynamic gmcSlabRates = []; @@ -152,7 +159,7 @@ class _empDetailsState extends State { } else { // Token is empty or null, handle accordingly (e.g., navigate to login screen) ToastHelper.showErrorToast(context, 'Session Out'); - Navigator.pushReplacementNamed(context, 'phone'); + Navigator.pushReplacementNamed(context, 'login'); } } @@ -1553,7 +1560,12 @@ class _empDetailsState extends State { String? gpaPolicyName = item['Policy_Name']; String? gpaPolicyType = item['type']; String? gpaECardDownload = item['eCardDownload']; - String? gpaSumInsured; + String? gpaSumInsured = item['si_value']; + gpaGstValue = item['si_gst_value']; + gpaSiPremiumValue = item['si_premium_value']; + gpaTotalableValue = gpaSiPremiumValue + gpaGstValue; + bool isValueValid = (gpaSiPremiumValue != 0 && gpaGstValue != 0); + List gpaMappedFamilyFloaters = []; if (item['mapped_family_floaters'] != null) { @@ -1564,11 +1576,11 @@ class _empDetailsState extends State { .where((element) => element['is_value_exist'] == true) .toList(); - if (getTrueObjects.length > 0) { - gpaSumInsured = getTrueObjects[0]["data"]["basic_cover_si"]; - } else { - gpaSumInsured = item['Policy_Terms']['sumInsured2']; - } + // if (getTrueObjects.length > 0) { + // gpaSumInsured = getTrueObjects[0]["data"]["basic_cover_si"]; + // } else { + // gpaSumInsured = item['Policy_Terms']['sumInsured2']; + // } int gpaOpenForEnrollment = int.parse(item['OpenForEnrollment']); List familyFloaterContainers = []; @@ -1800,6 +1812,219 @@ class _empDetailsState extends State { Column( children: familyFloaterContainers, ), + if (Responsive.isDesktop(context) && isValueValid) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && isValueValid) + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) ], ), ), @@ -1824,6 +2049,11 @@ class _empDetailsState extends State { gmcFloaterTextDescription = item['floter_text_description']; gmcNotes = item['notes']; gmcECardDownload = item['eCardDownload']; + gmcGstValue = item['family_floaters_of_dependent_and_gst_value']; + gmcSiPremiumValue = + item['family_floaters_of_dependent_and_si_premium_value']; + gmcTotalableValue = gmcGstValue + gmcSiPremiumValue; + gmcIsValueValid = (gmcSiPremiumValue != 0 && gmcGstValue != 0); gmcMappedFamilyFloaters = item['mapped_family_floaters']; dynamic getTrueObjects = gmcMappedFamilyFloaters @@ -2263,6 +2493,225 @@ class _empDetailsState extends State { Column( children: familyFloaterContainers, ), + if (Responsive.isDesktop(context) && gmcIsValueValid) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && gmcIsValueValid) + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) ], ), )); diff --git a/lib/pages/enrollment/empReview.dart b/lib/pages/enrollment/empReview.dart index 74da7dc..30e39d4 100644 --- a/lib/pages/enrollment/empReview.dart +++ b/lib/pages/enrollment/empReview.dart @@ -58,6 +58,14 @@ class _empReviewDetailsState extends State { dynamic gpaSelfRelationship; dynamic gpaSelfDetails; dynamic gpaECardDownload; + dynamic gpaGstValue; + dynamic gpaSiPremiumValue; + dynamic gpaTotalableValue; + late bool isValueValid; + dynamic gmcGstValue; + dynamic gmcSiPremiumValue; + dynamic gmcTotalableValue; + late bool gmcIsValueValid; dynamic gmcECardDownload; dynamic gmcDisclaimer; dynamic gmcClintPolicyId = 0; @@ -212,7 +220,7 @@ class _empReviewDetailsState extends State { } else { // Token is empty or null, handle accordingly (e.g., navigate to login screen) ToastHelper.showErrorToast(context, 'Session Out'); - Navigator.pushReplacementNamed(context, 'phone'); + Navigator.pushReplacementNamed(context, 'login'); } } @@ -2111,6 +2119,8 @@ class _empReviewDetailsState extends State { ), ], ), + ...buildPolicyRows( + gpaPolicies, context), if (activeSiData == 1) TableRow( children: [ @@ -2721,6 +2731,10 @@ class _empReviewDetailsState extends State { String? gpaPolicyName = item['Policy_Name']; String? gpaPolicyType = item['type']; String? gpaECardDownload = item['eCardDownload']; + gpaGstValue = item['si_gst_value']; + gpaSiPremiumValue = item['si_premium_value']; + gpaTotalableValue = gpaSiPremiumValue + gpaGstValue; + isValueValid = (gpaSiPremiumValue != 0 && gpaGstValue != 0); String? gpaSumInsured; print('GPA Disclaimer $allDisclaimer'); setState(() { @@ -2895,6 +2909,219 @@ class _empReviewDetailsState extends State { Column( children: familyFloaterContainers, ), + if (Responsive.isDesktop(context) && isValueValid) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gpaTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && isValueValid) + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gpaTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) ], ), ), @@ -2917,6 +3144,11 @@ class _empReviewDetailsState extends State { gmcFloaterTextDescription = item['floter_text_description']; gmcNotes = item['notes']; gmcECardDownload = item['eCardDownload']; + gmcGstValue = item['family_floaters_of_dependent_and_gst_value']; + gmcSiPremiumValue = + item['family_floaters_of_dependent_and_si_premium_value']; + gmcTotalableValue = gmcGstValue + gmcSiPremiumValue; + gmcIsValueValid = (gmcSiPremiumValue != 0 && gmcGstValue != 0); // gmcSumInsured = item['Policy_Terms']['sum_insured']; gmcMappedFamilyFloaters = item['mapped_family_floaters']; // allDisclaimer = allDisclaimer.toSet().toList(); @@ -3094,6 +3326,230 @@ class _empReviewDetailsState extends State { }).toList(), ), ), + if (Responsive.isDesktop(context) && gmcIsValueValid) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcSiPremiumValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + Text( + (gmcTotalableValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && gmcIsValueValid) + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcSiPremiumValue ?? '') + .toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcGstValue ?? '').toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + (gmcTotalableValue ?? '') + .toString(), + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) ], ), )) @@ -3104,4 +3560,65 @@ class _empReviewDetailsState extends State { return cards; } + + List buildPolicyRows( + List> policies, BuildContext context) { + return policies.where((policy) { + var siGstValue = policy["si_gst_value"] ?? 0; + var siPremiumValue = policy["si_premium_value"] ?? 0; + return siGstValue != 0 && + siPremiumValue != 0; // Filter out invalid policies + }).map((policy) { + return TableRow( + children: [ + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + Responsive.isDesktop(context) + ? (policy["Policy_Name"] ?? 'Default Policy Name') + : policy['type'], + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 14 : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + '₹${policy["si_premium_value"]}/Year', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 14 : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + '₹${policy["si_gst_value"]}/-', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 14 : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + '₹${(policy["si_premium_value"] ?? 0) + (policy["si_gst_value"] ?? 0)}/-', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 14 : 12), + ), + ), + ), + ], + ); + }).toList(); + } } diff --git a/lib/pages/enrollment/service/api_service.dart b/lib/pages/enrollment/service/api_service.dart index 76db60b..a180ce6 100644 --- a/lib/pages/enrollment/service/api_service.dart +++ b/lib/pages/enrollment/service/api_service.dart @@ -30,7 +30,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getClientDetails?client_id=$clientId&emp_code=$empCode&client_branch_id=$branchID'); + '${Environment.apiUrlEnrollment}getClientDetails?client_id=$clientId&emp_code=$empCode&client_branch_id=$branchID'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -45,7 +45,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getEmployeeProfile?emp_code=$empCode&client_id=$clientId&client_branch_id=$branchID'); + '${Environment.apiUrlEnrollment}getEmployeeProfile?emp_code=$empCode&client_id=$clientId&client_branch_id=$branchID'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -58,7 +58,7 @@ class ApiService { if (_token == null) { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}relationshipList'); + final url = Uri.parse('${Environment.apiUrlEnrollment}relationshipList'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -73,7 +73,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID'); + '${Environment.apiUrlEnrollment}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -88,7 +88,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID'); + '${Environment.apiUrlEnrollment}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -103,7 +103,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID'); + '${Environment.apiUrlEnrollment}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -118,7 +118,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID'); + '${Environment.apiUrlEnrollment}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -133,7 +133,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID'); + '${Environment.apiUrlEnrollment}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -148,7 +148,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$addOnsDependentClientPolicyId'); + '${Environment.apiUrlEnrollment}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$addOnsDependentClientPolicyId'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -163,7 +163,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpClientPolicyId'); + '${Environment.apiUrlEnrollment}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpClientPolicyId'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -178,7 +178,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpParentClientPolicyId'); + '${Environment.apiUrlEnrollment}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpParentClientPolicyId'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -191,7 +191,8 @@ class ApiService { if (_token == null) { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}deleteDependence?id=$id'); + final url = + Uri.parse('${Environment.apiUrlEnrollment}deleteDependence?id=$id'); final headers = { 'Authorization': 'Bearer $_token' ?? '', }; @@ -206,7 +207,8 @@ class ApiService { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}addEmployeeAndDependence'); + final url = + Uri.parse('${Environment.apiUrlEnrollment}addEmployeeAndDependence'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -227,7 +229,8 @@ class ApiService { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}addEmployeeAndDependence'); + final url = + Uri.parse('${Environment.apiUrlEnrollment}addEmployeeAndDependence'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -248,8 +251,8 @@ class ApiService { await _initializeToken(); } - final url = - Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount'); + final url = Uri.parse( + '${Environment.apiUrlEnrollment}createOrUpdateEmployeePolicySiAmount'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -270,8 +273,8 @@ class ApiService { await _initializeToken(); } - final url = - Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount'); + final url = Uri.parse( + '${Environment.apiUrlEnrollment}createOrUpdateEmployeePolicySiAmount'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -292,8 +295,8 @@ class ApiService { await _initializeToken(); } - final url = - Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount'); + final url = Uri.parse( + '${Environment.apiUrlEnrollment}createOrUpdateEmployeePolicySiAmount'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -314,7 +317,7 @@ class ApiService { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}iAgreeForAddOn'); + final url = Uri.parse('${Environment.apiUrlEnrollment}iAgreeForAddOn'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -334,7 +337,7 @@ class ApiService { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}calculatePremium'); + final url = Uri.parse('${Environment.apiUrlEnrollment}calculatePremium'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -355,7 +358,7 @@ class ApiService { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}calculatePremium'); + final url = Uri.parse('${Environment.apiUrlEnrollment}calculatePremium'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -376,7 +379,7 @@ class ApiService { await _initializeToken(); } - final url = Uri.parse('${Environment.apiUrl}calculatePremium'); + final url = Uri.parse('${Environment.apiUrlEnrollment}calculatePremium'); final headers = { 'Authorization': 'Bearer $_token' ?? '', 'Content-Type': 'application/json', // Ensure content type is JSON @@ -399,7 +402,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getCashDepositData?client_id=$clintID&client_branch_id=$empRefId'); + '${Environment.apiUrlEnrollment}getCashDepositData?client_id=$clintID&client_branch_id=$empRefId'); final headers = { 'Authorization': 'Bearer $_hrtoken' ?? '', }; @@ -414,7 +417,7 @@ class ApiService { await _initializeToken(); } final url = Uri.parse( - '${Environment.apiUrl}getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo&client_branch_id=$empRefId'); + '${Environment.apiUrlEnrollment}getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo&client_branch_id=$empRefId'); final headers = { 'Authorization': 'Bearer $_hrtoken' ?? '', }; diff --git a/lib/pages/login.dart b/lib/pages/login.dart index b44bc4f..57f7843 100644 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; +import 'package:nhance_app_pwa/pages/email_verify.dart'; import 'package:nhance_app_pwa/pages/verify.dart'; import 'dart:convert'; import 'dart:io'; @@ -22,6 +23,7 @@ class login extends StatefulWidget { } class _loginState extends State { + final TextEditingController emailController = TextEditingController(); TextEditingController countryController = TextEditingController(); TextEditingController mobileController = TextEditingController(); final _formKey = GlobalKey(); @@ -33,6 +35,7 @@ class _loginState extends State { late String _verificationId; int? _resendToken; bool _isLoading = false; + bool isEmailFieldVisible = false; @override void initState() { @@ -80,16 +83,32 @@ class _loginState extends State { } } - Future verifyMobileNumber() async { + void toggleField() { + setState(() { + isEmailFieldVisible = !isEmailFieldVisible; + }); + } + + Future verifyMobileAndEmailNumber() async { try { if (_formKey.currentState!.validate()) { setState(() { _isLoading = true; }); - var enteredMobileNumber = mobileController.text; + + // Determine the API and the payload based on the visible field + String apiEndpoint = isEmailFieldVisible + ? Environment.apiUrl + 'verifyEmployeeEmailId' + : Environment.apiUrl + 'verifyEmployeeNumber'; + + Map payload = isEmailFieldVisible + ? {'email': emailController.text} + : {'mobile_number': mobileController.text}; + + // var enteredMobileNumber = mobileController.text; final response = await http.post( - Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'), - body: json.encode({'mobile_number': enteredMobileNumber}), + Uri.parse(apiEndpoint), + body: json.encode(payload), headers: { HttpHeaders.contentTypeHeader: 'application/json', }, @@ -102,10 +121,26 @@ class _loginState extends State { if (userVerification) { final SharedPreferences prefs = await SharedPreferences.getInstance(); - var enteredMobileNumber = mobileController.text; - prefs.setString('empMobileNo', enteredMobileNumber); - - _verifyPhoneNumber(); + // var enteredMobileNumber = mobileController.text; + // prefs.setString('empMobileNo', enteredMobileNumber); + if (isEmailFieldVisible) { + print('isEmailFieldVisible $isEmailFieldVisible'); + prefs.setString('empEmail', emailController.text); + print('${emailController.text}'); + ToastHelper.showSuccessToast( + context, 'Verification code sent to ${emailController.text}'); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => MyEmailVerify( + email: emailController.text, // Pass the phone number + ), + ), + ); + } else { + prefs.setString('empMobileNo', mobileController.text); + _verifyPhoneNumber(); + } // ToastHelper.showSuccessToast(context, message); } else { @@ -446,7 +481,7 @@ class _loginState extends State { children: [ Expanded( child: Text( - "Login with your mobile number and OTP to review and enroll for exciting health benefits for you and your family", + "Login with your ${isEmailFieldVisible ? 'email' : 'mobile number'} and OTP to review and enroll for exciting health benefits for you and your family", style: GoogleFonts.poppins( fontSize: 12, color: Color(0xFF000000)), @@ -459,118 +494,203 @@ class _loginState extends State { SizedBox( height: 20, ), - 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( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - SizedBox( - width: 10, - ), - SizedBox( - width: 40, - child: TextField( - controller: countryController, - keyboardType: - TextInputType.number, - decoration: InputDecoration( - border: InputBorder.none, + Column( + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: toggleField, + child: Text( + isEmailFieldVisible + ? "Login with Mobile No" + : "Login with Email", + style: TextStyle( + color: Color(0xFF00989E), ), ), ), - 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: 20, - ), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: SizedBox( - width: double.infinity, - height: 45, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: - Color(0xFF00989E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), - ), - ), - onPressed: _isLoading - ? null - : verifyMobileNumber, - child: _isLoading - ? CircularProgressIndicator( - valueColor: - AlwaysStoppedAnimation< - Color>( - Color( - 0xFF00989E)), - ) - : Text( - "Login With OTP", - style: - GoogleFonts.poppins( - color: Color( - 0xFFFFFFFF)), - ), ), - ), + SizedBox(height: 15), + 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, + ), + ), + ), + 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) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: SizedBox( + width: double.infinity, + height: 45, + child: ElevatedButton( + style: + ElevatedButton.styleFrom( + backgroundColor: + Color(0xFF00989E), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 10), + ), + ), + onPressed: _isLoading + ? null + : verifyMobileAndEmailNumber, + child: _isLoading + ? CircularProgressIndicator( + valueColor: + AlwaysStoppedAnimation< + Color>( + Color(0xFF00989E), + ), + ) + : Text( + isEmailFieldVisible + ? "Login with Email OTP" + : "Login with Mobile OTP", + style: GoogleFonts + .poppins( + color: Color( + 0xFFFFFFFF), + ), + ), + ), + ), + ), + ], ), SizedBox( height: _size.width <= 1100 ? 0 : 0, diff --git a/lib/pages/postEnrollment/chatbot.dart b/lib/pages/postEnrollment/chatbot.dart index 9802d8a..ad3e996 100644 --- a/lib/pages/postEnrollment/chatbot.dart +++ b/lib/pages/postEnrollment/chatbot.dart @@ -397,26 +397,36 @@ class _chatbotState extends State { } void _openDialPad(String phoneNumber) async { - final url = 'tel:$phoneNumber'; - if (await canLaunch(url)) { - await launch(url); + final Uri dialUri = Uri( + scheme: 'tel', + path: phoneNumber, + ); + + print('Trying to open dial pad: $dialUri'); + + if (await canLaunchUrl(dialUri)) { + await launchUrl(dialUri); } else { - throw 'Could not open dial pad for $phoneNumber'; + print('Could not open dial pad for $phoneNumber'); } } void _openEmail(String email) async { - final Uri params = Uri( + final Uri emailUri = Uri( scheme: 'mailto', path: email, - query: - 'subject=Your Subject&body=Hello', // Add default subject and body here + query: Uri.encodeFull( + 'subject=Your Subject&body=Hello'), // Add default subject and body ); - var url = params.toString(); - if (await canLaunch(url)) { - await launch(url); - } else { - throw 'Could not open email client for $email'; + + try { + if (await canLaunchUrl(emailUri)) { + await launchUrl(emailUri); + } else { + print('Could not open email client for $email'); + } + } catch (e) { + print('Error: $e'); } } diff --git a/lib/pages/postEnrollment/policies.dart b/lib/pages/postEnrollment/policies.dart index add5c11..66ae648 100644 --- a/lib/pages/postEnrollment/policies.dart +++ b/lib/pages/postEnrollment/policies.dart @@ -113,6 +113,16 @@ class _policiesState extends State { } } + void _openUrl(String url) async { + if (url.isNotEmpty && await canLaunch(url)) { + await launch(url, + webOnlyWindowName: '_blank'); // Opens in a new tab (web only) + } else { + // Handle invalid or null URL + print('Could not launch URL'); + } + } + @override Widget build(BuildContext context) { dynamic arguments = ModalRoute.of(context)!.settings.arguments; @@ -865,67 +875,88 @@ class _policiesState extends State { ), ])), SizedBox(height: 10), - Card( - elevation: 0, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Color(0xFFD9D9D9), // Set the border color here - width: 1.0, // Set the border width here - ), - borderRadius: BorderRadius.circular( - 8.0), // Set the border radius here - ), - child: Column(children: [ - Container( - decoration: BoxDecoration( - color: Colors - .white, // Set background color for the container + if (argumentsData['network_hospitals_url'] != null) + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + final String? url = + argumentsData['network_hospitals_url']; + if (url != null && url.isNotEmpty) { + _openUrl(url); + } else { + print('No URL provided'); + } + }, + child: Card( + elevation: 0, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Color(0xFFD9D9D9), + width: 1.0, + ), + borderRadius: BorderRadius.circular(8.0), ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 15, bottom: 15, left: 15, right: 15) - : EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + child: Column( children: [ - Expanded( - flex: 11, + Container( + decoration: BoxDecoration( + color: Colors.white, + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, + bottom: 15, + left: 15, + right: 15) + : EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), child: Row( - mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - SvgPicture.string( - SvgService.getSvg('cashLess'), - width: 25, - height: 25, - ), - SizedBox( - width: - 10), // Adjust space between icon and text - Text( - 'Cashless Hospitals', - textAlign: TextAlign.center, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 18 - : 12, - fontWeight: FontWeight.w400, - color: Color(0xFF404040), + Expanded( + flex: 11, + child: Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + SvgPicture.string( + SvgService.getSvg('cashLess'), + width: 25, + height: 25, + ), + SizedBox(width: 10), + Text( + 'Cashless Hospitals', + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 12, + fontWeight: FontWeight.w400, + color: Color(0xFF404040), + ), + ), + ], ), ), - ], - ), - ), - Expanded( - flex: 1, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Icon( - Icons - .chevron_right, // Replace with your desired icon - color: Color(0xFFE26728), - size: 20, + Expanded( + flex: 1, + child: Row( + mainAxisAlignment: + MainAxisAlignment.end, + children: [ + Icon( + Icons.chevron_right, + color: Color(0xFFE26728), + size: 20, + ), + ], + ), ), ], ), @@ -933,7 +964,8 @@ class _policiesState extends State { ], ), ), - ])), + ), + ), SizedBox(height: Responsive.isDesktop(context) ? 40 : 70), ], ),