From 48e338be0a1b275aa94582b63ee1e18e7448a780 Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Mon, 15 Dec 2025 14:30:38 +0530 Subject: [PATCH] .env changes --- .env.development | 4 -- .env.production | 4 -- .env.test | 4 -- .env.uat | 4 -- build_web_dev.sh | 42 -------------------- build_web_production.sh | 42 -------------------- build_web_test.sh | 42 -------------------- build_web_uat.sh | 42 -------------------- lib/addons.dart | 1 - lib/cdTransactionDetails.dart | 1 - lib/config/environment.dart | 47 ++++++++++++++++++++++ lib/config/main_dev.dart | 9 +++++ lib/config/main_prod.dart | 10 +++++ lib/config/main_prod1.dart | 10 +++++ lib/config/main_uat.dart | 10 +++++ lib/customAppBar/toastHelper.dart | 52 +++++++++++++++++++++++++ lib/email_verify.dart | 9 +++-- lib/empDetails.dart | 3 +- lib/empReview.dart | 1 - lib/excel_verification.dart | 6 ++- lib/home.dart | 11 +++++- lib/hrDashboard.dart | 4 +- lib/hrHome.dart | 9 ++++- lib/hrLogin.dart | 3 +- lib/hrPolicyDetails.dart | 1 - lib/main.dart | 6 +-- lib/models/environment.dart | 42 -------------------- lib/oldPolicy.dart | 2 +- lib/phone.dart | 4 +- lib/postFileUpload.dart | 4 +- lib/service/api_service.dart | 7 +++- lib/service/hrDashboardTabs/cd.dart | 1 - lib/service/hrDashboardTabs/claims.dart | 1 - lib/verify.dart | 6 ++- pubspec.yaml | 5 --- web/index.html | 6 +-- 36 files changed, 196 insertions(+), 259 deletions(-) delete mode 100755 .env.development delete mode 100644 .env.production delete mode 100644 .env.test delete mode 100644 .env.uat delete mode 100755 build_web_dev.sh delete mode 100755 build_web_production.sh delete mode 100644 build_web_test.sh delete mode 100644 build_web_uat.sh create mode 100644 lib/config/environment.dart create mode 100644 lib/config/main_dev.dart create mode 100644 lib/config/main_prod.dart create mode 100644 lib/config/main_prod1.dart create mode 100644 lib/config/main_uat.dart delete mode 100644 lib/models/environment.dart diff --git a/.env.development b/.env.development deleted file mode 100755 index e1b2169..0000000 --- a/.env.development +++ /dev/null @@ -1,4 +0,0 @@ -API_URL=https://venbait.in/enrollment/employeeRest/ -API_URL_POST=https://venbait.in/nhance/dev/employeeRest/ -BASE_HREF=/nhance/hr/dev/ -ENV=development \ No newline at end of file diff --git a/.env.production b/.env.production deleted file mode 100644 index 9bcc9dc..0000000 --- a/.env.production +++ /dev/null @@ -1,4 +0,0 @@ -API_URL=https://app.nhanceindia.in/enrolment/employeeRest/ -API_URL_POST=https://app.nhanceindia.in/zenith/employeeRest/ -BASE_HREF=/hr/ -ENV=production \ No newline at end of file diff --git a/.env.test b/.env.test deleted file mode 100644 index 9bcc9dc..0000000 --- a/.env.test +++ /dev/null @@ -1,4 +0,0 @@ -API_URL=https://app.nhanceindia.in/enrolment/employeeRest/ -API_URL_POST=https://app.nhanceindia.in/zenith/employeeRest/ -BASE_HREF=/hr/ -ENV=production \ No newline at end of file diff --git a/.env.uat b/.env.uat deleted file mode 100644 index 9bcc9dc..0000000 --- a/.env.uat +++ /dev/null @@ -1,4 +0,0 @@ -API_URL=https://app.nhanceindia.in/enrolment/employeeRest/ -API_URL_POST=https://app.nhanceindia.in/zenith/employeeRest/ -BASE_HREF=/hr/ -ENV=production \ No newline at end of file diff --git a/build_web_dev.sh b/build_web_dev.sh deleted file mode 100755 index 3df3c30..0000000 --- a/build_web_dev.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Define the path to the .env.development file -ENV_FILE_PATH=".env.development" - -# Check if the .env.development file exists -if [ ! -f $ENV_FILE_PATH ]; then - echo "$ENV_FILE_PATH does not exist" - exit 1 -fi - -# Copy the .env.development file to .env -cp $ENV_FILE_PATH .env -echo "Copied $ENV_FILE_PATH to .env" - -# Verify .env file contains correct values -source .env - -if [ -z "$BASE_HREF" ]; then - echo "BASE_HREF value is empty" - exit 1 -fi - -if [ -z "$API_URL" ]; then - echo "API_URL value is empty" - exit 1 -fi - -# Print loaded values for verification -echo "Loaded BASE_HREF: $BASE_HREF" -echo "Loaded API_URL: $API_URL" - -# Build the web app for development with base href -flutter build web --release --base-href "$BASE_HREF" --dart-define=ENV=development - -# Check if the build was successful -if [ $? -ne 0 ]; then - echo "Flutter dev build failed" - exit 1 -fi - -echo "Flutter dev build succeeded" diff --git a/build_web_production.sh b/build_web_production.sh deleted file mode 100755 index d30cd90..0000000 --- a/build_web_production.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Define the path to the .env.production file -ENV_FILE_PATH=".env.production" - -# Check if the .env.production file exists -if [ ! -f $ENV_FILE_PATH ]; then - echo "$ENV_FILE_PATH does not exist" - exit 1 -fi - -# Copy the .env.production file to .env -cp $ENV_FILE_PATH .env -echo "Copied $ENV_FILE_PATH to .env" - -# Verify .env file contains correct values -source .env - -if [ -z "$BASE_HREF" ]; then - echo "BASE_HREF value is empty" - exit 1 -fi - -if [ -z "$API_URL" ]; then - echo "API_URL value is empty" - exit 1 -fi - -# Print loaded values for verification -echo "Loaded BASE_HREF: $BASE_HREF" -echo "Loaded API_URL: $API_URL" - -# Build the web app for production with base href -flutter build web --release --base-href "$BASE_HREF" --dart-define=ENV=production - -# Check if the build was successful -if [ $? -ne 0 ]; then - echo "Flutter production build failed" - exit 1 -fi - -echo "Flutter production build succeeded" diff --git a/build_web_test.sh b/build_web_test.sh deleted file mode 100644 index e41b84f..0000000 --- a/build_web_test.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Define the path to the .env.test file -ENV_FILE_PATH=".env.test" - -# Check if the .env.test file exists -if [ ! -f $ENV_FILE_PATH ]; then - echo "$ENV_FILE_PATH does not exist" - exit 1 -fi - -# Copy the .env.test file to .env -cp $ENV_FILE_PATH .env -echo "Copied $ENV_FILE_PATH to .env" - -# Verify .env file contains correct values -source .env - -if [ -z "$BASE_HREF" ]; then - echo "BASE_HREF value is empty" - exit 1 -fi - -if [ -z "$API_URL" ]; then - echo "API_URL value is empty" - exit 1 -fi - -# Print loaded values for verification -echo "Loaded BASE_HREF: $BASE_HREF" -echo "Loaded API_URL: $API_URL" - -# Build the web app for the test environment with base href -flutter build web --release --base-href "$BASE_HREF" --dart-define=ENV=test - -# Check if the build was successful -if [ $? -ne 0 ]; then - echo "Flutter test build failed" - exit 1 -fi - -echo "Flutter test build succeeded" diff --git a/build_web_uat.sh b/build_web_uat.sh deleted file mode 100644 index 04e38fa..0000000 --- a/build_web_uat.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Define the path to the .env.uat file -ENV_FILE_PATH=".env.uat" - -# Check if the .env.uat file exists -if [ ! -f $ENV_FILE_PATH ]; then - echo "$ENV_FILE_PATH does not exist" - exit 1 -fi - -# Copy the .env.uat file to .env -cp $ENV_FILE_PATH .env -echo "Copied $ENV_FILE_PATH to .env" - -# Verify .env file contains correct values -source .env - -if [ -z "$BASE_HREF" ]; then - echo "BASE_HREF value is empty" - exit 1 -fi - -if [ -z "$API_URL" ]; ]; then - echo "API_URL value is empty" - exit 1 -fi - -# Print loaded values for verification -echo "Loaded BASE_HREF: $BASE_HREF" -echo "Loaded API_URL: $API_URL" - -# Build the web app for UAT with base href -flutter build web --release --base-href "$BASE_HREF" --dart-define=ENV=uat - -# Check if the build was successful -if [ $? -ne 0 ]; then - echo "Flutter UAT build failed" - exit 1 -fi - -echo "Flutter UAT build succeeded" diff --git a/lib/addons.dart b/lib/addons.dart index 557511a..7b6e60f 100644 --- a/lib/addons.dart +++ b/lib/addons.dart @@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/responsive.dart'; import 'package:nhancepolicy/service/api_service.dart'; import 'package:shared_preferences/shared_preferences.dart'; diff --git a/lib/cdTransactionDetails.dart b/lib/cdTransactionDetails.dart index 753eb71..8646cf6 100644 --- a/lib/cdTransactionDetails.dart +++ b/lib/cdTransactionDetails.dart @@ -12,7 +12,6 @@ import 'package:nhancepolicy/service/api_service.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:universal_html/html.dart' as html; -import '../../models/environment.dart'; import 'package:collection/collection.dart'; import 'customAppBar/customAppBar.dart'; diff --git a/lib/config/environment.dart b/lib/config/environment.dart new file mode 100644 index 0000000..648d6bb --- /dev/null +++ b/lib/config/environment.dart @@ -0,0 +1,47 @@ +// lib/environment.dart +enum Flavor { dev, uat, prod, prod1} + +class Environment { + static Flavor flavor = Flavor.dev; // overwritten by each main_*.dart + + static bool get isProd => flavor == Flavor.prod || flavor == Flavor.prod1; + + static String get apiUrl { + switch (flavor) { + case Flavor.dev: + return "https://venbait.in/enrollment/employeeRest/"; + case Flavor.uat: + return "https://appstage.nhanceindia.in/apex/employeeRest/"; + case Flavor.prod: + return "https://app.nhanceindia.in/enrolment/employeeRest/"; + case Flavor.prod1: + return "https://app.nhanceindia.in/enrolment/employeeRest/"; + } + } + + static String get apiUrlPost { + switch (flavor) { + case Flavor.dev: + return "https://venbait.in/nhance/dev/employeeRest/"; + case Flavor.uat: + return "https://appstage.nhanceindia.in/nexus/employeeRest/"; + case Flavor.prod: + return "https://app.nhanceindia.in/zenith/employeeRest/"; + case Flavor.prod1: + return "https://app.nhanceindia.in/zenith/employeeRest/"; + } + } + + static String get baseHref { + switch (flavor) { + case Flavor.dev: + return "/nhance/hr/dev/"; + case Flavor.uat: + return "/"; + case Flavor.prod: + return "/hr/"; + case Flavor.prod1: + return "/"; + } + } +} diff --git a/lib/config/main_dev.dart b/lib/config/main_dev.dart new file mode 100644 index 0000000..19e2474 --- /dev/null +++ b/lib/config/main_dev.dart @@ -0,0 +1,9 @@ + +import '../main.dart'; +import 'environment.dart'; + +Future main() async { + Environment.flavor = Flavor.dev; + await startApp(); +} + diff --git a/lib/config/main_prod.dart b/lib/config/main_prod.dart new file mode 100644 index 0000000..44580d0 --- /dev/null +++ b/lib/config/main_prod.dart @@ -0,0 +1,10 @@ + + +import '../main.dart'; +import 'environment.dart'; + +Future main() async { + Environment.flavor = Flavor.prod; + await startApp(); +} + diff --git a/lib/config/main_prod1.dart b/lib/config/main_prod1.dart new file mode 100644 index 0000000..f2eae0f --- /dev/null +++ b/lib/config/main_prod1.dart @@ -0,0 +1,10 @@ + + +import '../main.dart'; +import 'environment.dart'; + +Future main() async { + Environment.flavor = Flavor.prod1; + await startApp(); +} + diff --git a/lib/config/main_uat.dart b/lib/config/main_uat.dart new file mode 100644 index 0000000..1d0484a --- /dev/null +++ b/lib/config/main_uat.dart @@ -0,0 +1,10 @@ + + +import '../main.dart'; +import 'environment.dart'; + +Future main() async { + Environment.flavor = Flavor.uat; + await startApp(); +} + diff --git a/lib/customAppBar/toastHelper.dart b/lib/customAppBar/toastHelper.dart index 8221dd8..926cac8 100644 --- a/lib/customAppBar/toastHelper.dart +++ b/lib/customAppBar/toastHelper.dart @@ -157,6 +157,58 @@ class ToastHelper { // _showToast(context, message, Colors.red); } + static void showErrorToast2(BuildContext context, String message,String decmessage) { + toastification.show( + context: context, + type: ToastificationType.error, + style: ToastificationStyle.flatColored, + autoCloseDuration: const Duration(seconds: 2), + title: Text(message), + // you can also use RichText widget for title and description parameters + description: RichText( + text: TextSpan(text: decmessage)), + alignment: Alignment.topRight, + direction: TextDirection.ltr, + animationDuration: const Duration(milliseconds: 100), + animationBuilder: (context, animation, alignment, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + icon: const Icon(Icons.error), + primaryColor: Colors.redAccent, + backgroundColor: Colors.white, + foregroundColor: Colors.black, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 16, + offset: Offset(0, 16), + spreadRadius: 0, + ) + ], + showProgressBar: true, + closeButtonShowType: CloseButtonShowType.onHover, + closeOnClick: false, + pauseOnHover: true, + dragToClose: true, + applyBlurEffect: true, + callbacks: ToastificationCallbacks( + onTap: (toastItem) => print('Toast ${toastItem.id} tapped'), + onCloseButtonTap: (toastItem) => + print('Toast ${toastItem.id} close button tapped'), + onAutoCompleteCompleted: (toastItem) => + print('Toast ${toastItem.id} auto complete completed'), + onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'), + ), + ); + // _showToast(context, message, Colors.red); + } + static void showInfoToast(BuildContext context, String message) { toastification.show( context: context, diff --git a/lib/email_verify.dart b/lib/email_verify.dart index 2f8c0e4..6ea648a 100644 --- a/lib/email_verify.dart +++ b/lib/email_verify.dart @@ -15,10 +15,10 @@ import 'package:shared_preferences/shared_preferences.dart'; 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'; import 'branch/branch_selection_page.dart'; +import 'config/environment.dart'; // import 'dart:html' as html; @@ -106,6 +106,7 @@ class _MyEmailVerifyState extends State { Uri.parse(Environment.apiUrl + 'getVerifiedHrData'), body: json.encode(payload), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', HttpHeaders.contentTypeHeader: 'application/json', }, ); @@ -263,7 +264,7 @@ class _MyEmailVerifyState extends State { final _postToken = prefs.getString('_postToken'); if (_postToken != null && _postToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); + ToastHelper.showSuccessToast(context, 'Successfully Logged In'); // if (emp_status == 'enrolled' || emp_status == 'active') { Navigator.pushReplacementNamed(context, 'hrDashboard'); // } else { @@ -304,7 +305,7 @@ class _MyEmailVerifyState extends State { final enrollToken = prefs.getString('enrollToken'); if (enrollToken != null && enrollToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); + ToastHelper.showSuccessToast(context, 'Successfully Logged In'); // if (emp_status == 'enrolled' || emp_status == 'active') { // Navigator.pushReplacementNamed(context, 'home'); // } else { @@ -337,6 +338,7 @@ class _MyEmailVerifyState extends State { Uri.parse(apiEndpoint), body: json.encode(payload), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', HttpHeaders.contentTypeHeader: 'application/json', }, ); @@ -369,6 +371,7 @@ class _MyEmailVerifyState extends State { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $token', // Add token to the Authorization header }, diff --git a/lib/empDetails.dart b/lib/empDetails.dart index ccc14cb..5957079 100644 --- a/lib/empDetails.dart +++ b/lib/empDetails.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:nhancepolicy/customAppBar/customAppBar.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/service/api_service.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -18,6 +17,7 @@ import 'dart:async'; import 'package:nhancepolicy/responsive.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'config/environment.dart'; import 'customAppBar/customFooter.dart'; class empDetails extends StatefulWidget { @@ -161,6 +161,7 @@ class _empDetailsState extends State { 'employee_id': empID }), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', HttpHeaders.contentTypeHeader: 'application/json', }, ); diff --git a/lib/empReview.dart b/lib/empReview.dart index 93a4ce2..7640e97 100644 --- a/lib/empReview.dart +++ b/lib/empReview.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:intl/intl.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/responsive.dart'; import 'package:nhancepolicy/service/api_service.dart'; import 'package:shared_preferences/shared_preferences.dart'; diff --git a/lib/excel_verification.dart b/lib/excel_verification.dart index 4200bad..4efad7a 100644 --- a/lib/excel_verification.dart +++ b/lib/excel_verification.dart @@ -9,7 +9,6 @@ import 'dart:async'; import 'package:http/http.dart' as http; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/hrPolicyDetails.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/service/api_service.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:universal_html/html.dart' as html; @@ -22,6 +21,7 @@ import 'package:csv/csv.dart'; import 'package:spreadsheet_decoder/spreadsheet_decoder.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'config/environment.dart'; import 'customAppBar/customFooter.dart'; class excelVerify extends StatefulWidget { @@ -448,6 +448,7 @@ class _excelVerifyState extends State { print('else'); // Attach the file to the request // Set authorization token in headers + request.headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; request.headers['Authorization'] = 'Bearer $_token'; // request.files.add(http.MultipartFile.fromBytes('file', fileBytes, // filename: fileName)); @@ -499,7 +500,8 @@ class _excelVerifyState extends State { setState(() { isLoading = false; }); - ToastHelper.showErrorToast(context, data['message']); + ToastHelper.showErrorToast2(context,"",data['message']); + // ToastHelper.showErrorToast(context, data['message']); print('Table'); setState(() { diff --git a/lib/home.dart b/lib/home.dart index 4d5b3d1..85a58a1 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -4,7 +4,6 @@ import 'package:flutter/widgets.dart'; import 'package:nhancepolicy/customAppBar/customAppBar.dart'; import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; -import 'package:nhancepolicy/models/environment.dart'; import 'dart:convert'; import 'dart:io'; import 'package:nhancepolicy/responsive.dart'; @@ -13,6 +12,8 @@ import 'package:jwt_decode/jwt_decode.dart'; // import 'package:fluttertoast/fluttertoast.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'config/environment.dart'; + // void main() { // runApp(MaterialApp( // home: MyApp(), @@ -135,6 +136,7 @@ class _MyAppState extends State { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', // Add token to the Authorization header }, @@ -211,6 +213,7 @@ class _MyAppState extends State { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', // Add token to the Authorization header }, @@ -474,6 +477,7 @@ class _MyAppState extends State { url, body: jsonEncode(requestBody), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Content-Type': 'application/json', // Add authorization header if needed 'Authorization': 'Bearer $_token', @@ -504,6 +508,7 @@ class _MyAppState extends State { final response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', // Add token to the Authorization header }, @@ -555,6 +560,7 @@ class _MyAppState extends State { final response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Content-Type': 'application/json', 'Authorization': 'Bearer $_token', // Add token to the Authorization header // Add your authorization token here @@ -627,6 +633,7 @@ class _MyAppState extends State { url, body: jsonEncode(updatedNewData), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Content-Type': 'application/json', 'Authorization': 'Bearer $_token', // Add token to the Authorization header @@ -686,6 +693,7 @@ class _MyAppState extends State { url, body: jsonEncode(jsonData), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Content-Type': 'application/json', 'Authorization': 'Bearer $_token', // Add token to the Authorization header @@ -768,6 +776,7 @@ class _MyAppState extends State { url, body: jsonEncode(jsonData), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Content-Type': 'application/json', 'Authorization': 'Bearer $_token', // Add token to the Authorization header diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart index 5fc1f13..6c7f5cc 100644 --- a/lib/hrDashboard.dart +++ b/lib/hrDashboard.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:google_fonts/google_fonts.dart'; 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'; @@ -15,6 +14,7 @@ import 'package:nhancepolicy/service/hrDashboardTabs/preEnrollment.dart'; import 'package:nhancepolicy/service/token_storage_service.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:http/http.dart' as http; +import 'config/environment.dart'; import 'customAppBar/customAppBar.dart'; import 'customAppBar/customFooter.dart'; import 'customAppBar/toastHelper.dart'; @@ -370,6 +370,7 @@ class _hrDashboardState extends State var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $token', // Add token to the Authorization header }, @@ -461,6 +462,7 @@ class _hrDashboardState extends State var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', }, ); diff --git a/lib/hrHome.dart b/lib/hrHome.dart index e03469c..ad6de60 100644 --- a/lib/hrHome.dart +++ b/lib/hrHome.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:nhancepolicy/customAppBar/customAppBar.dart'; import 'package:nhancepolicy/excel_verification.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:jwt_decode/jwt_decode.dart'; import 'dart:convert'; @@ -18,6 +17,8 @@ import 'package:excel/excel.dart'; import 'package:path_provider/path_provider.dart'; import 'package:path/path.dart' as path; +import 'config/environment.dart'; + class MyHrHome extends StatefulWidget { const MyHrHome({Key? key}) : super(key: key); @@ -94,6 +95,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', }, ); @@ -171,6 +173,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', }, ); @@ -214,6 +217,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', }, ); @@ -255,6 +259,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', }, ); @@ -298,6 +303,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { url, headers: { 'Authorization': 'Bearer $_token', + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', }, ); if (response.statusCode == 200) { @@ -437,6 +443,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', }, ); diff --git a/lib/hrLogin.dart b/lib/hrLogin.dart index 6d9acd9..8662031 100644 --- a/lib/hrLogin.dart +++ b/lib/hrLogin.dart @@ -6,7 +6,6 @@ import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/hrVerify.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'dart:convert'; import 'dart:io'; import 'package:nhancepolicy/responsive.dart'; @@ -14,6 +13,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:flutter_animated_button/flutter_animated_button.dart'; +import 'config/environment.dart'; import 'email_verify.dart'; class MyHrLogin extends StatefulWidget { @@ -105,6 +105,7 @@ class _MyPhoneState extends State { Uri.parse(apiEndpoint), body: json.encode(payload), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', HttpHeaders.contentTypeHeader: 'application/json', }, ); diff --git a/lib/hrPolicyDetails.dart b/lib/hrPolicyDetails.dart index 32ab476..235ace5 100644 --- a/lib/hrPolicyDetails.dart +++ b/lib/hrPolicyDetails.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:nhancepolicy/customAppBar/customAppBar.dart'; import 'package:nhancepolicy/excel_verification.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/postFileUpload.dart'; import 'package:nhancepolicy/service/api_service.dart'; import 'package:nhancepolicy/service/hrDashboardTabs/claims.dart'; diff --git a/lib/main.dart b/lib/main.dart index 2c225b7..3a26bb2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,7 +8,6 @@ import 'package:nhancepolicy/empDetails.dart'; import 'package:nhancepolicy/excel_verification.dart'; import 'package:nhancepolicy/hrHome.dart'; import 'package:nhancepolicy/hrVerify.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/phone.dart'; import 'package:nhancepolicy/postFileUpload.dart'; import 'package:nhancepolicy/service/token_storage_service.dart'; @@ -22,9 +21,10 @@ import 'package:nhancepolicy/oldPolicy.dart'; import 'package:firebase_core/firebase_core.dart'; import 'cdTransactionDetails.dart'; +import 'config/environment.dart'; import 'email_verify.dart'; -Future main() async { +Future startApp() async { // html.window.onBeforeUnload.listen((event) { // print('Local Storage cleared by window'); // html.window.localStorage.clear(); @@ -52,7 +52,7 @@ Future main() async { appId: '1:1084115316849:web:ce28f12a426f285d6c6bd0', messagingSenderId: '1084115316849', projectId: 'nhance-ee8d1')); - await dotenv.load(fileName: Environment.fileName); + // await dotenv.load(fileName: Environment.fileName); runApp(MaterialApp( initialRoute: 'hrLogin', diff --git a/lib/models/environment.dart b/lib/models/environment.dart deleted file mode 100644 index 9ddaeec..0000000 --- a/lib/models/environment.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; - -import '../home.dart'; - -class Environment { - static String get fileName { - const String env = - String.fromEnvironment('ENV', defaultValue: 'development'); - switch (env) { - case 'test': - return '.env.test'; - case 'uat': - return '.env.uat'; - case 'production': - return '.env.production'; - default: - return '.env.development'; - } - } - - static String get apiUrl { - return dotenv.env['API_URL'] ?? 'API_URL not found!'; - } - - static String get apiUrlPost { - return dotenv.env['API_URL_POST'] ?? 'API_URL not found!'; - } - - static String get baseHref { - return dotenv.env['BASE_HREF'] ?? 'BASE_HREF not found!'; - } - - static String get env { - return dotenv.env['ENV'] ?? 'ENV not found!'; - } -} - -Future main() async { - await dotenv.load(fileName: Environment.fileName); - runApp(MyApp()); -} diff --git a/lib/oldPolicy.dart b/lib/oldPolicy.dart index 6a3ce3b..87e41ba 100644 --- a/lib/oldPolicy.dart +++ b/lib/oldPolicy.dart @@ -5,10 +5,10 @@ import 'package:flutter/widgets.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:intl/intl.dart'; import 'package:jwt_decode/jwt_decode.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/responsive.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:http/http.dart' as http; +import 'config/environment.dart'; import 'customAppBar/customAppBar.dart'; import 'customAppBar/toastHelper.dart'; diff --git a/lib/phone.dart b/lib/phone.dart index bcf62dd..fb8a2d3 100644 --- a/lib/phone.dart +++ b/lib/phone.dart @@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; -import 'package:nhancepolicy/models/environment.dart'; import 'dart:convert'; import 'dart:io'; import 'package:nhancepolicy/responsive.dart'; @@ -13,6 +12,8 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_animated_button/flutter_animated_button.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'config/environment.dart'; + class MyPhone extends StatefulWidget { const MyPhone({Key? key}); @@ -61,6 +62,7 @@ class _MyPhoneState extends State { Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'), body: json.encode({'mobile_number': enteredMobileNumber}), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', HttpHeaders.contentTypeHeader: 'application/json', }, ); diff --git a/lib/postFileUpload.dart b/lib/postFileUpload.dart index a0881a9..3aa7ae7 100644 --- a/lib/postFileUpload.dart +++ b/lib/postFileUpload.dart @@ -9,7 +9,6 @@ import 'dart:async'; import 'package:http/http.dart' as http; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/hrPolicyDetails.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/service/api_service.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:universal_html/html.dart' as html; @@ -21,6 +20,7 @@ import 'package:csv/csv.dart'; import 'package:spreadsheet_decoder/spreadsheet_decoder.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'config/environment.dart'; import 'customAppBar/customFooter.dart'; class postFileUpload extends StatefulWidget { @@ -244,6 +244,7 @@ class _postFileUploadState extends State { final response = await http.get( Uri.parse(url), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $token', 'Content-Type': 'application/json', // 'app-signature': 'ts-traveltool-2025-signature-123456', @@ -389,6 +390,7 @@ class _postFileUploadState extends State { print('else'); // Attach the file to the request // Set authorization token in headers + request.headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; request.headers['Authorization'] = 'Bearer $_token'; // request.files.add(http.MultipartFile.fromBytes('file', fileBytes, // filename: fileName)); diff --git a/lib/service/api_service.dart b/lib/service/api_service.dart index 2b6a85d..ad0feef 100644 --- a/lib/service/api_service.dart +++ b/lib/service/api_service.dart @@ -3,8 +3,8 @@ import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; import 'dart:convert'; +import '../config/environment.dart'; import '../customAppBar/toastHelper.dart'; -import '../models/environment.dart'; class ApiService { final BuildContext context; @@ -595,6 +595,7 @@ class ApiService { final url = Uri.parse('${Environment.apiUrlPost}claimsSearch'); final headers = { + 'APP-SIGNATURE' :'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $token', 'Content-Type': 'application/json', }; @@ -779,19 +780,21 @@ class ApiService { Future> _makePostRequestWithoutFormData( Uri url, String body, Map headers) async { - + headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; final response = await http.post(url, headers: headers, body: body); return _handleResponse(response); } Future> _makeGetRequest( Uri url, Map headers) async { + headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; final response = await http.get(url, headers: headers); return _handleResponse(response); } Future> _makePostRequest( Uri url, String body, Map headers) async { + headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y'; final response = await http.post(url, headers: headers, body: body); return _handleResponse(response); } diff --git a/lib/service/hrDashboardTabs/cd.dart b/lib/service/hrDashboardTabs/cd.dart index 120db63..c159a1d 100644 --- a/lib/service/hrDashboardTabs/cd.dart +++ b/lib/service/hrDashboardTabs/cd.dart @@ -11,7 +11,6 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:universal_html/html.dart' as html; import '../../cdTransactionDetails.dart'; -import '../../models/environment.dart'; import '../api_service.dart'; import 'package:collection/collection.dart'; diff --git a/lib/service/hrDashboardTabs/claims.dart b/lib/service/hrDashboardTabs/claims.dart index dc559f9..af237cd 100644 --- a/lib/service/hrDashboardTabs/claims.dart +++ b/lib/service/hrDashboardTabs/claims.dart @@ -9,7 +9,6 @@ import 'package:collection/collection.dart'; import 'package:jwt_decode/jwt_decode.dart'; import '../../claimshistory.dart'; -import '../../models/environment.dart'; import '../api_service.dart'; class ClaimsPolicies extends StatefulWidget { diff --git a/lib/verify.dart b/lib/verify.dart index e0b3f54..767f1ee 100644 --- a/lib/verify.dart +++ b/lib/verify.dart @@ -1,7 +1,6 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:nhancepolicy/models/environment.dart'; import 'package:pinput/pinput.dart'; import 'dart:async'; import 'package:flutter/gestures.dart'; @@ -13,6 +12,8 @@ import 'package:nhancepolicy/responsive.dart'; import 'package:jwt_decode/jwt_decode.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'config/environment.dart'; + class MyVerify extends StatefulWidget { final String verificationId; final String mobileNumber; @@ -111,6 +112,7 @@ class _MyVerifyState extends State { Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'), body: json.encode({'mobile_number': mobileNumber}), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', HttpHeaders.contentTypeHeader: 'application/json', }, ); @@ -142,6 +144,7 @@ class _MyVerifyState extends State { 'otp_verification': otpVerifyStatus }), headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', HttpHeaders.contentTypeHeader: 'application/json', }, ); @@ -257,6 +260,7 @@ class _MyVerifyState extends State { var response = await http.get( url, headers: { + 'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y', 'Authorization': 'Bearer $_token', // Add token to the Authorization header }, diff --git a/pubspec.yaml b/pubspec.yaml index 2567081..d73478e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -90,11 +90,6 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/ - - .env - - .env.development - - .env.production - - .env.uat - - .env.test # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg diff --git a/web/index.html b/web/index.html index c1eb5a8..fa17c60 100644 --- a/web/index.html +++ b/web/index.html @@ -18,18 +18,18 @@ - + - + - nhancepolicy + Nhance HR