This commit is contained in:
Venba 2024-07-04 15:02:22 +05:30
parent fd4ab0ec68
commit 44e94898b7
38 changed files with 13182 additions and 1585 deletions

2
.env
View File

@ -1,4 +1,4 @@
API_URL=https://venbait.in/nhance/dev/employeeRest/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api
BASE_HREF=/nhance/employee/dev/
ENV=development

View File

@ -1,4 +1,4 @@
API_URL=https://venbait.in/nhance/dev/employeeRest/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api
BASE_HREF=/nhance/employee/dev/
ENV=development

View File

@ -1,4 +1,4 @@
API_URL=https://venbait.in/nhance/uat/employeeRest/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/uat/api/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/uat/api
BASE_HREF=/nhance/employee/uat/
ENV=production

View File

@ -1,4 +1,4 @@
API_URL=https://venbait.in/nhance/test/employeeRest/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/test/api/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/test/api
BASE_HREF=/nhance/employee/test/
ENV=test

View File

@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:usesCleartextTraffic="true"
android:label="nhance_app_pwa"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

View File

@ -11,24 +11,29 @@ fi
# Copy the .env.development file to .env
cp $ENV_FILE_PATH .env
echo "Copied $ENV_FILE_PATH to .env"
# Check if the BASE_HREF variable exists in the .env file
if ! grep -q BASE_HREF .env; then
echo "BASE_HREF not found in .env file"
# Source the .env file to load the environment variables
source .env
# Check if the required variables are set
if [ -z "$BASE_HREF" ] || [ -z "$API_URL" ] || [ -z "$TICKET_API_URL" ]; then
echo "Environment variables not set correctly in .env"
exit 1
fi
# Extract the BASE_HREF value
BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2)
# Check if the BASE_HREF value is empty
if [ -z "$BASE_HREF" ]; then
echo "BASE_HREF value is empty"
exit 1
fi
# Print the loaded variables for verification
echo "Loaded BASE_HREF: $BASE_HREF"
echo "Loaded API_URL: $API_URL"
echo "Loaded TICKET_API_URL: $TICKET_API_URL"
# Build the web app for development with base href
flutter build web --release --base-href "$BASE_HREF"
# Optionally, remove the .env file after the build
# rm .env
# Check if the build was successful
if [ $? -ne 0 ]; then
echo "Flutter dev build failed"
exit 1
fi
echo "Flutter dev build succeeded"

View File

@ -1,34 +1,39 @@
#!/bin/bash
# Define the path to the .env file for production
# Define the path to the .env.production file
ENV_FILE_PATH=".env.production"
# Check if the .env file exists
# 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 file for production to .env
# Copy the .env.production file to .env
cp $ENV_FILE_PATH .env
echo "Copied $ENV_FILE_PATH to .env"
# Check if the BASE_HREF variable exists in the .env file
if ! grep -q BASE_HREF .env; then
echo "BASE_HREF not found in .env file"
# Source the .env file to load the environment variables
source .env
# Check if the required variables are set
if [ -z "$BASE_HREF" ] || [ -z "$API_URL" ] || [ -z "$TICKET_API_URL" ]; then
echo "Environment variables not set correctly in .env"
exit 1
fi
# Extract the BASE_HREF value
BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2)
# Print the loaded variables for verification
echo "Loaded BASE_HREF: $BASE_HREF"
echo "Loaded API_URL: $API_URL"
echo "Loaded TICKET_API_URL: $TICKET_API_URL"
# Check if the BASE_HREF value is empty
if [ -z "$BASE_HREF" ]; then
echo "BASE_HREF value is empty"
exit 1
fi
# Build the web app for production environment with base href
# Build the web app for production with base href
flutter build web --release --base-href "$BASE_HREF"
# Optionally, remove the .env file after the build
# rm .env
# Check if the build was successful
if [ $? -ne 0 ]; then
echo "Flutter prod build failed"
exit 1
fi
echo "Flutter prod build succeeded"

View File

@ -1,34 +1,39 @@
#!/bin/bash
# Define the path to the .env file for testing
# Define the path to the .env.test file
ENV_FILE_PATH=".env.test"
# Check if the .env file exists
# 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 file for testing to .env
# Copy the .env.test file to .env
cp $ENV_FILE_PATH .env
echo "Copied $ENV_FILE_PATH to .env"
# Check if the BASE_HREF variable exists in the .env file
if ! grep -q BASE_HREF .env; then
echo "BASE_HREF not found in .env file"
# Source the .env file to load the environment variables
source .env
# Check if the required variables are set
if [ -z "$BASE_HREF" ] || [ -z "$API_URL" ] || [ -z "$TICKET_API_URL" ]; then
echo "Environment variables not set correctly in .env"
exit 1
fi
# Extract the BASE_HREF value
BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2)
# Print the loaded variables for verification
echo "Loaded BASE_HREF: $BASE_HREF"
echo "Loaded API_URL: $API_URL"
echo "Loaded TICKET_API_URL: $TICKET_API_URL"
# Check if the BASE_HREF value is empty
if [ -z "$BASE_HREF" ]; then
echo "BASE_HREF value is empty"
exit 1
fi
# Build the web app for test environment with base href
# Build the web app for the test environment with base href
flutter build web --release --base-href "$BASE_HREF"
# Optionally, remove the .env file after the build
# rm .env
# Check if the build was successful
if [ $? -ne 0 ]; then
echo "Flutter test build failed"
exit 1
fi
echo "Flutter test build succeeded"

View File

@ -9,36 +9,28 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
Future<void> logout(BuildContext context) async {
final prefs = await SharedPreferences.getInstance();
final String? hrtoken = prefs.getString('hrtoken');
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
if (hrtoken != null && hrtoken.isNotEmpty) {
prefs.remove('token');
Navigator.pushNamed(context, 'hrDashboard');
} else {
await prefs.clear();
Navigator.pushNamed(context, 'phone');
}
} else if (hrtoken != null && hrtoken.isNotEmpty) {
await prefs.clear();
Navigator.pushNamed(context, 'hrLogin');
Navigator.pushNamed(context, 'phone');
}
}
@override
Widget build(BuildContext context) {
final sw = MediaQuery.of(context).size.width;
final isPoliciesPage = Uri.base.fragment == 'policies';
return ClipRRect(
borderRadius: Responsive.isDesktop(context)
borderRadius: Responsive.isDesktop(context) || isPoliciesPage
? BorderRadius.zero
: BorderRadius.only(
bottomLeft: Radius.circular(32.0),
bottomRight: Radius.circular(32.0),
),
child: AppBar(
backgroundColor: Color(0xFFFFFBDE), // Set background color for AppBar
backgroundColor: const Color(0xFFFFFBDE),
elevation: 0, // Set background color for AppBar
toolbarHeight: kToolbarHeight,
titleSpacing: 0.0,
automaticallyImplyLeading: false,
@ -76,7 +68,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
flex: Responsive.isDesktop(context) ? 9 : 3,
child: AdaptiveNavBar(
screenWidth: sw,
backgroundColor: Color(0xFFFFFBDE),
backgroundColor: const Color(0xFFFFFBDE),
leading:
Container(), // Set an empty container as we have the logo separately
title: Text(''),

View File

@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
import 'package:adaptive_navbar/adaptive_navbar.dart';
import 'package:nhance_app_pwa/customAppBar/responsive.dart';
import 'package:shared_preferences/shared_preferences.dart';
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
@override
_CustomAppBarState createState() => _CustomAppBarState();
@override
Size get preferredSize => Size.fromHeight(kToolbarHeight);
}
class _CustomAppBarState extends State<CustomAppBar> {
bool showBackToHR = true;
bool hideInactiveStatus = true;
@override
void initState() {
super.initState();
}
Future<void> logout(BuildContext context) async {
final prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
await prefs.clear();
Navigator.pushNamed(context, 'login');
}
}
@override
Widget build(BuildContext context) {
final sw = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: Color(0xFFFFFCE5), // Set background color for AppBar
appBar: PreferredSize(
preferredSize: widget.preferredSize,
child: SafeArea(
child: Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(horizontal: 16.0)
: EdgeInsets.symmetric(horizontal: 0),
child: Row(
children: [
// Logo Column
Expanded(
flex: Responsive.isDesktop(context) ? 3 : 9,
child: Row(
mainAxisAlignment: Responsive.isDesktop(context)
? MainAxisAlignment.spaceEvenly
: MainAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(top: 10, bottom: 10),
width: 230,
height: 230,
child: Image.asset(
'assets/nhance_client_logo.png',
fit: BoxFit.contain,
),
),
],
),
),
// AdaptiveNavBar Column
Expanded(
flex: Responsive.isDesktop(context) ? 9 : 3,
child: AdaptiveNavBar(
screenWidth: sw,
backgroundColor: Color(0xFFFFFCE5),
leading:
Container(), // Set an empty container as we have the logo separately
title: Text(''),
navBarItems: [
if (Responsive.isDesktop(context))
NavBarItem(
text: "Inactive Policy",
onTap: () {
Navigator.pushNamed(context, 'oldPolicy');
},
),
NavBarItem(
text: "Logout",
onTap: () async {
logout(context);
},
),
],
),
),
],
),
),
),
),
);
}
}

View File

@ -1,17 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:nhance_app_pwa/pages/claimprocess.dart';
import 'package:nhance_app_pwa/pages/claims.dart';
import 'package:nhance_app_pwa/pages/claimtracklist.dart';
import 'package:nhance_app_pwa/pages/generalexclusionsdeductibles.dart';
import 'package:nhance_app_pwa/pages/help.dart';
import 'package:nhance_app_pwa/pages/home.dart';
import 'package:nhance_app_pwa/pages/enrollment/addons.dart';
import 'package:nhance_app_pwa/pages/enrollment/empDetails.dart';
import 'package:nhance_app_pwa/pages/enrollment/empReview.dart';
import 'package:nhance_app_pwa/pages/login.dart';
import 'package:nhance_app_pwa/pages/planclaimsform.dart';
import 'package:nhance_app_pwa/pages/policies.dart';
import 'package:nhance_app_pwa/pages/privacypolicy.dart';
import 'package:nhance_app_pwa/pages/profile.dart';
import 'package:nhance_app_pwa/pages/termsofuse.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/chatbot.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/claimprocess.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/claims.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/claimtracklist.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/generalexclusionsdeductibles.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/help.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/home.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/planclaimsform.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/policies.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/privacypolicy.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/profile.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/termsofuse.dart';
import 'package:nhance_app_pwa/pages/verify.dart';
import 'models/environment.dart';
@ -35,8 +41,12 @@ Future<void> main() async {
'claimtracklist': (context) => claimtracklist(),
'privacypolicy': (context) => privacypolicy(),
'termsofuse': (context) => termsofuse(),
'chatbot': (context) => chatbot(),
'generalExclusionsDeductibles': (context) =>
generalExclusionsDeductibles(),
'empDetails': (context) => empDetails(),
'addOnsDetails': (context) => addOnsDetails(),
'empReviewDetails': (context) => empReviewDetails(),
},
));
}

View File

@ -1,12 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import '../pages/postEnrollment/home.dart';
class Environment {
static String get fileName {
const bool isProduction =
bool.fromEnvironment('dart.vm.product', defaultValue: false);
const bool isTest =
bool.fromEnvironment('dart.vm.environment', defaultValue: false);
const bool isTest = bool.fromEnvironment('ENV', defaultValue: false);
if (isProduction) {
return '.env.production';
@ -37,3 +39,38 @@ class Environment {
return 'uncp8FvG310bEyYdV9MmStlo7KDRZ65fLWTeXCI2JzwPrNHjBqQhUiAgxsaO';
}
}
Future<void> main() async {
await dotenv.load(fileName: Environment.fileName);
runApp(MyApp());
}
// class Environment {
// static String get fileName {
// if (kReleaseMode) {
// return '.env.production';
// } else {
// return '.env.development';
// }
// }
//
// static String get apiUrl {
// return dotenv.env['API_URL'] ?? '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!';
// }
//
// static String get apiUrlTicket {
// return dotenv.env['TICKET_API_URL'] ?? 'API_URL not found!';
// }
//
// static String get ticketToken {
// return 'uncp8FvG310bEyYdV9MmStlo7KDRZ65fLWTeXCI2JzwPrNHjBqQhUiAgxsaO';
// }
// }

View File

@ -1,512 +0,0 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
class claimtracklist extends StatefulWidget {
const claimtracklist({Key? key}) : super(key: key);
@override
State<claimtracklist> createState() => _claimtracklistformState();
}
class _claimtracklistformState extends State<claimtracklist> {
late ApiService apiService;
dynamic _token;
dynamic empCodeString;
dynamic empPrimaryId;
dynamic client_id;
dynamic policyList;
dynamic policyDataIsEmpty = 1;
dynamic policyHeading;
dynamic policyName;
dynamic EmployeePolicy;
List<Map<String, String>> employeeDetails = [];
dynamic argumentsData;
dynamic decodedToken;
dynamic claimTrackMsgList;
dynamic empName;
dynamic ticketID;
late TextEditingController messageController;
// Create a unique form key for each accordion section
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
@override
void initState() {
super.initState();
apiService = ApiService(context); // Initialize ApiService here
_loadToken();
messageController = TextEditingController();
}
@override
void dispose() {
super.dispose();
messageController.dispose();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
dynamic arguments = ModalRoute.of(context)!.settings.arguments;
if (arguments != null && arguments is Map<String, dynamic>) {
argumentsData = arguments;
print('argumentsData');
print(argumentsData);
ticketID = argumentsData['id'];
claimTrackMsgList = argumentsData['message_list'];
print(claimTrackMsgList);
}
}
Future<void> _loadToken() async {
print('_loadToken');
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
setState(() {
_token = token;
});
// Decode the JWT token received from the API response
decodedToken = Jwt.parseJwt(token);
print(decodedToken);
empName = decodedToken['name'];
empCodeString = prefs.getString('empCode');
print(empCodeString); // Check if emp_code is correct
empPrimaryId = prefs.getString('empPrimaryId');
client_id = prefs.getString('client_id');
print(client_id);
} else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'login');
}
}
void sendClaimsMessage(Map<String, dynamic> formData) async {
try {
formData = formData.map((key, value) => MapEntry(key, value.toString()));
final response = await apiService.sendClaimsMessageToApi(formData);
if (response['success'] == 1) {
messageController.clear();
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
messageController.clear();
Navigator.pushNamed(context, 'claims', arguments: 0);
print('Form data sent successfully.');
} else {
print('Failed to submit form data: ${response['status']}');
}
} catch (e) {
print('Error submitting form data: $e');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
child: Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width *
0.2, // 30% of screen width as horizontal padding
vertical: MediaQuery.of(context).size.height *
0.03, // 5% of screen height as vertical padding
)
: EdgeInsets.all(10),
color: Colors.white,
child: Column(children: [
Card(
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(15.0), // Set border radius here
),
child: Container(
decoration: BoxDecoration(
color: Colors.white, // Set background color to white
borderRadius: BorderRadius.circular(
15.0), // Set border radius for Container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10), // Add padding to the container
child: Row(
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 0, bottom: 0, left: 0, right: 0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: InkWell(
onTap: () {
Navigator.pushNamed(
context, 'claims');
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
if (!Responsive.isDesktop(
context))
Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
SizedBox(
width: Responsive
.isDesktop(
context)
? 0
: 5), // Adjust space between icon and text
Column(
mainAxisAlignment:
MainAxisAlignment
.center,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
'Claims Track',
textAlign:
TextAlign.start,
style:
GoogleFonts.poppins(
fontSize: 16,
fontWeight:
FontWeight.w600,
color:
Color(0xFF000000),
),
),
],
),
],
),
),
),
],
),
// Add more rows as needed
],
),
),
SizedBox(height: 15),
Container(
child: SingleChildScrollView(
child: Column(children: [
...claimTrackMsgList.map<Widget>((message) {
bool isUserMessage =
message['staff_name'] == null;
String messageContent =
message['message'];
String messageDate = message['date'];
print('isUserMessage');
print(isUserMessage);
dynamic messagername;
if (isUserMessage) {
messagername = empName;
} else {
messagername = message['staff_name'];
}
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0),
child: Align(
alignment: isUserMessage
? Alignment.centerLeft
: Alignment.centerRight,
child: Container(
constraints:
BoxConstraints(maxWidth: 300),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: isUserMessage
? Colors.blue[100]
: Colors.green[100],
borderRadius:
BorderRadius.circular(10),
),
child: Column(
crossAxisAlignment: isUserMessage
? CrossAxisAlignment.start
: CrossAxisAlignment.end,
children: [
Row(
mainAxisAlignment: isUserMessage
? MainAxisAlignment.end
: MainAxisAlignment
.start, // Aligns children to the end (right) of the row
children: [
Text(
messagername,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight.w500,
color:
Color(0xFF000000),
),
),
SizedBox(width: 5),
Icon(
Icons
.person, // Replace with your desired icon
color: Color(
0xFFE26728), // Customize the icon color
size:
15, // Customize the icon size
),
],
),
Text(
messageContent,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 14
: 12,
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
),
),
SizedBox(height: 5),
Text(
formatDate(messageDate),
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 12
: 10,
fontWeight: FontWeight.w400,
color: Color(0xFF636363),
),
),
],
),
),
),
);
}).toList(),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0),
child: Row(
children: [
Expanded(
flex:
Responsive.isDesktop(context)
? 10
: 9,
child: TextFormField(
controller: messageController,
onChanged: (value) => null,
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Message',
labelText: 'Message',
contentPadding:
EdgeInsets.symmetric(
vertical: 10,
horizontal: 15),
),
validator: (value) {
if (value == null ||
value.isEmpty) {
return 'Message is required';
}
return null;
},
),
),
Expanded(
flex:
Responsive.isDesktop(context)
? 2
: 3,
child: Container(
alignment:
Alignment.centerRight,
child: ElevatedButton(
onPressed: () {
// Check if any of the fields are empty
if (messageController
.text.isEmpty) {
ToastHelper.showWarningToast(
context,
'All fields are required');
} else {
// Create a map to hold the form data
Map<String, dynamic>
formData = {
'ticket_id': ticketID,
'replier': 'user',
'message':
messageController
.text,
// Add more form fields as needed
};
// Call the function to send form data to API
sendClaimsMessage(
formData);
}
},
child: Text(
'Reply',
style: GoogleFonts.poppins(
color: Colors.white),
),
style:
ElevatedButton.styleFrom(
backgroundColor:
Color(0xFFE26728),
shape:
RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(
5),
),
),
),
),
),
],
)
// ElevatedButton(
// onPressed: () {
//
// },
// child: Text('Reply'),
// ),
),
]),
)),
],
))),
],
),
),
),
SizedBox(height: Responsive.isDesktop(context) ? 40 : 10),
]),
)),
if (Responsive.isDesktop(context))
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity, // Make the footer full width
child: CustomFooter(),
),
),
]),
// floatingActionButton: Responsive.isDesktop(context)
// ? null
// : FloatingActionButton(
// onPressed: () {
// // Add your onPressed logic here
// },
// child: Icon(Icons.add),
// ),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(
onTabChanged: (index) {
// Add your navigation logic here
// For example:
if (index == 0) {
Navigator.pushNamed(context, 'home');
} else if (index == 1) {
Navigator.pushNamed(context, 'claims');
} else if (index == 2) {
Navigator.pushNamed(context, 'profile');
} else if (index == 3) {
Navigator.pushNamed(context, 'help');
}
},
icons: [
Icons.home_outlined,
Icons.sticky_note_2_outlined,
Icons.person_outline_outlined,
Icons.headset_mic_outlined,
],
labels: [
"Home",
"Claim",
"Profile",
"Help",
], // Initial index of the bottom navigation bar
),
);
}
String formatDate(String timestamp) {
// Convert the timestamp string to milliseconds
int milliseconds = int.parse(timestamp) * 1000;
// Create a DateTime object from milliseconds
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
// Format the DateTime object
String formattedDate = DateFormat('d MMM, y').format(date);
return formattedDate;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,388 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
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:nhance_app_pwa/customAppBar/enrollmentAppBar.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import '../../customAppBar/responsive.dart';
import '../../customAppBar/toastHelper.dart';
import '../../models/environment.dart';
class oldPolicy extends StatefulWidget {
const oldPolicy({Key? key}) : super(key: key);
@override
State<oldPolicy> createState() => _oldPolicyState();
}
class _oldPolicyState extends State<oldPolicy> {
dynamic _token;
dynamic empCodeString;
dynamic empPrimaryId;
dynamic client_id;
dynamic gpaEmpName;
dynamic oldPolicyList;
dynamic oldPolicyName;
dynamic oldPolicyClientId;
dynamic oldPolicyClientPolicyId;
dynamic oldPolicySiGstValue;
dynamic oldPolicySiPremiumValue;
dynamic oldPolicySiValue;
dynamic oldPolicyType;
dynamic oldPolicyEmployeePolicy;
dynamic oldPolicyDataIsEmpty = 1;
dynamic oldPolicyTypeHeading;
dynamic oldPolicyFloaterTextHeading;
dynamic oldPolicyStartDate;
dynamic oldPolicyEndDate;
dynamic empClientBranchId;
@override
void initState() {
super.initState();
_loadToken();
}
@override
void dispose() {
super.dispose();
}
Future<void> _loadToken() async {
print('_loadToken');
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
setState(() {
_token = token;
});
// Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
print(decodedToken);
empClientBranchId = prefs.getString('empClientBranchId');
empCodeString = prefs.getString('empCode');
print(empCodeString); // Check if emp_code is correct
empPrimaryId = prefs.getString('empPrimaryId');
gpaEmpName = prefs.getString('gpaEmpName');
client_id = prefs.getString('client_id');
print(client_id);
getOldPolicyDetails();
} else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'phone');
}
}
Future<void> getOldPolicyDetails() async {
var url = Uri.parse(Environment.apiUrl +
'getEmployeeActiveOrInactivePolicy?client_id=$client_id&emp_code=$empCodeString&type=Inactive&client_branch_id=$empClientBranchId');
try {
var response = await http.get(
url,
headers: {
'Authorization':
'Bearer $_token', // Add token to the Authorization header
},
);
if (response.statusCode == 200) {
Map<String, dynamic> data = json.decode(response.body);
if (data['status'] == 'success') {
setState(() {
oldPolicyList = data['data'];
print('gmcPolicies');
});
// Assuming data is a List
print(oldPolicyList);
} else {
setState(() {
oldPolicyDataIsEmpty = 0;
});
// 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 {
setState(() {
oldPolicyDataIsEmpty = 0;
});
// 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) {
return Scaffold(
appBar: CustomAppBar(),
body: _buildBody(),
);
}
Widget _buildBody() {
if (oldPolicyList == null) {
return Center(child: _buildNoDataWidget());
} else if (oldPolicyList!.isEmpty) {
return Center(child: _buildNoDataWidget());
} else {
return _buildPolicyListWidget();
}
}
Widget _buildNoDataWidget() {
return SingleChildScrollView(
child: Container(
color: Color(0xFFEFF3F6),
child: Column(
children: [
Center(
child: Text('No Data Available'),
)
],
),
),
);
}
Widget _buildPolicyListWidget() {
return Stack(
children: [
SingleChildScrollView(
child: Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width *
0.2, // 30% of screen width as horizontal padding
vertical: MediaQuery.of(context).size.height *
0.03, // 5% of screen height as vertical padding
)
: EdgeInsets.all(10),
color: Color(0xFFEFF3F6),
child: Column(
children: [
if (oldPolicyDataIsEmpty == 1)
...generateGmcCards(oldPolicyList),
],
),
),
)
],
);
}
List<Widget> generateGmcCards(List<dynamic> data) {
List<Widget> cards = [];
print('data');
print(data);
for (var item in data) {
setState(() {
oldPolicyName = item['policy_name'];
oldPolicyTypeHeading = item['heading'];
oldPolicyFloaterTextHeading = item['floter_text_heading'];
oldPolicyClientId = item['client_id'];
oldPolicyClientPolicyId = item['client_policy_id'];
oldPolicySiGstValue = item['si_gst_value'];
oldPolicySiPremiumValue = item['si_premium_value'];
oldPolicySiValue = item['si_value'];
oldPolicyType = item['policy_type'];
oldPolicyStartDate = item['policy_start_date'];
oldPolicyEndDate = item['policy_end_date'];
oldPolicyEmployeePolicy = item['EmployeePolicy'];
});
Widget card = Card(
elevation: 0,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(20)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15, bottom: 15, left: 25, right: 25)
: EdgeInsets.only(
top: 10, bottom: 10, left: 10, right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 8,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
oldPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 18
: 14,
),
),
Text(
oldPolicyTypeHeading ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 20
: 16,
fontWeight: FontWeight.w600,
),
),
],
))),
Expanded(
flex: 4,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
oldPolicyFloaterTextHeading ?? '',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 18
: 14,
),
),
Text(
'${oldPolicySiValue != null ? oldPolicySiValue : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 20
: 16,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: oldPolicyEmployeePolicy.map<Widget>((data) {
String formattedDate = formatDate(data['dob']);
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
'${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 16,
color: Color(0xFF232526),
),
),
),
],
);
}).toList(),
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 0, bottom: 0, left: 25, right: 25)
: EdgeInsets.only(top: 0, bottom: 0, left: 10, right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
text: 'Policy Period : ',
style: GoogleFonts.poppins(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Color(0xFF232526),
),
children: <TextSpan>[
TextSpan(
text:
'$oldPolicyStartDate To $oldPolicyEndDate',
style: GoogleFonts.poppins(
fontSize: 14,
color: Color(0xFF232526),
),
),
],
),
),
],
),
),
),
],
),
),
],
),
));
cards.add(card);
cards.add(SizedBox(height: 10));
}
return cards;
}
String formatDate(String inputDate) {
// Parse the input date string
DateTime dateTime = DateTime.parse(inputDate);
// Format the date to 'dd MMMM yyyy'
String formattedDate = DateFormat('dd MMMM yyyy').format(dateTime);
return formattedDate;
}
}

View File

@ -0,0 +1,502 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:convert';
import '../../../customAppBar/toastHelper.dart';
import '../../../models/environment.dart';
class ApiService {
final BuildContext context;
String? _token;
String? _hrtoken;
bool _isSessionOutToastShown = false; // Flag to track toast message
ApiService(this.context) {
_initializeToken();
}
Future<void> _initializeToken() async {
final prefs = await SharedPreferences.getInstance();
_token = prefs.getString('token') ?? '';
final hrprefs = await SharedPreferences.getInstance();
_hrtoken = hrprefs.getString('hrtoken') ?? '';
}
Future<Map<String, dynamic>> getClientLogoAndDetailsToApi(
String clientId, String empCode, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getClientDetails?client_id=$clientId&emp_code=$empCode&client_branch_id=$branchID');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getSelfEmployeeProfileToApi(
String clientId, String empCode, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getEmployeeProfile?emp_code=$empCode&client_id=$clientId&client_branch_id=$branchID');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> fetchRelationshipListToApi() async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}relationshipList');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getGpaEmpPolicyDetailsToApi(String empPrimaryId,
String empCode, String clientId, String policy, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getGmcEmpPolicyDetailsToApi(String empPrimaryId,
String empCode, String clientId, String policy, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getGmcSiTopUpToApi(
String client_id, String emp_code, String policy, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getGmcSiParentTopUpToApi(
String client_id, String emp_code, String policy, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getGmcDependentAddOnsToApi(
String client_id, String emp_code, String policy, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> removeAddonsGmcDependentToAPI(
String empCodeString, String addOnsDependentClientPolicyId) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$addOnsDependentClientPolicyId');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> removeAddonsGmcSiToAPI(
String empCodeString, String topUpClientPolicyId) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpClientPolicyId');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> removeAddonsGmcParentSiToAPI(
String empCodeString, String topUpParentClientPolicyId) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpParentClientPolicyId');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> deleteItemToApi(id) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}deleteDependence?id=$id');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> saveFamilyMemberDetailsToApi(
List<Map<String, dynamic>> formDataList) async {
print('saveFamilyMemberDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}addEmployeeAndDependence');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> saveAddOnsDetailsToApi(
List<Map<String, dynamic>> formDataList) async {
print('saveAddOnsDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}addEmployeeAndDependence');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> sendAddonsGmcDependentToAPI(
List<Map<String, dynamic>> formDataList) async {
print('saveAddOnsDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url =
Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> sendAddonsGmcSiToAPI(
List<Map<String, dynamic>> formDataList) async {
print('saveAddOnsDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url =
Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> sendAddonsGmcParentSiToAPI(
List<Map<String, dynamic>> formDataList) async {
print('saveAddOnsDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url =
Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> sendAddOnToAPI(
Map<String, dynamic> formData) async {
print('sendAddOnToAPI API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}iAgreeForAddOn');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formData);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> topUpSiCalculationToAPI(formDataList) async {
print('saveAddOnsDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}calculatePremium');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> topUpParentSiCalculationToAPI(
formDataList) async {
print('saveAddOnsDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}calculatePremium');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
Future<Map<String, dynamic>> addOnsDependentCalculationToAPI(
formDataList) async {
print('saveAddOnsDetailsToApi API SERVICE');
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}calculatePremium');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'Content-Type': 'application/json', // Ensure content type is JSON
};
// Convert formDataList to JSON string
final formDataJson = jsonEncode(formDataList);
// Send formDataJson as the body
final response = await _makePostRequest(url, formDataJson, headers);
return response;
}
//HR API STARTS
Future<Map<String, dynamic>> getCashDepositDetailsToApi(
String clintID, String empRefId) async {
print(_hrtoken);
if (_hrtoken == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getCashDepositData?client_id=$clintID&client_branch_id=$empRefId');
final headers = {
'Authorization': 'Bearer $_hrtoken' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getEmployeeAndDependenceToApi(
String clintID, String getPolicyNo, String empRefId) async {
print(_hrtoken);
if (_hrtoken == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo&client_branch_id=$empRefId');
final headers = {
'Authorization': 'Bearer $_hrtoken' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
// Future<Map<String, dynamic>> getTrackClaimsList(
// String empMobileNo, String empCode) async {
// final url = Uri.parse(
// '${Environment.apiUrlTicket}/ticket/get_ticket_data?emp_code=$empCode&mobile_number=$empMobileNo');
// final response = await _makeGetRequest(url, {
// 'Token': Environment.ticketToken,
// });
// return response;
// }
//
// Future<Map<String, dynamic>> fetchDepartmentList() async {
// final url = Uri.parse('${Environment.apiUrlTicket}/departments');
// final response = await _makeGetRequest(url, {
// 'Token': Environment.ticketToken,
// });
// return response;
// }
//
// Future<Map<String, dynamic>> sendFormDataToApi(
// Map<String, dynamic> formData) async {
// final url = Uri.parse('${Environment.apiUrlTicket}/tickets/create');
// // Convert formData to Map<String, String>
// Map<String, String> stringFormData =
// formData.map((key, value) => MapEntry(key, value.toString()));
// final response = await _makePostRequest(url, stringFormData, {
// 'Content-Type': 'application/x-www-form-urlencoded',
// 'Token': Environment.ticketToken,
// });
// return response;
// }
//
// Future<Map<String, dynamic>> sendClaimsMessageToApi(
// Map<String, dynamic> formData) async {
// final url = Uri.parse('${Environment.apiUrlTicket}/messages/create');
// // Convert formData to Map<String, String>
// Map<String, String> stringFormData =
// formData.map((key, value) => MapEntry(key, value.toString()));
// final response = await _makePostRequest(url, stringFormData, {
// 'Content-Type': 'application/x-www-form-urlencoded',
// 'Token': Environment.ticketToken,
// });
// return response;
// }
Future<Map<String, dynamic>> _makeGetRequest(
Uri url, Map<String, String> headers) async {
final response = await http.get(url, headers: headers);
return _handleResponse(response);
}
Future<Map<String, dynamic>> _makePostRequest(
Uri url, String body, Map<String, String> headers) async {
final response = await http.post(url, headers: headers, body: body);
return _handleResponse(response);
}
Future<Map<String, dynamic>> _handleResponse(http.Response response) async {
if (response.statusCode == 200) {
return jsonDecode(response.body);
} else if (response.statusCode == 401) {
if (!_isSessionOutToastShown) {
_isSessionOutToastShown = true;
await _clearLocalStorageAndRedirect();
}
return {};
} else {
throw Exception('Failed to load data');
}
}
Future<void> _clearLocalStorageAndRedirect() async {
final prefs = await SharedPreferences.getInstance();
await prefs.clear();
// Assuming you have access to the context
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushNamed(context, 'phone');
}
}

View File

@ -1,460 +0,0 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
class help extends StatefulWidget {
const help({Key? key}) : super(key: key);
@override
State<help> createState() => _helpState();
}
class _helpState extends State<help> {
late ApiService apiService;
int _currentIndex = 0;
bool isActive = true;
dynamic _token;
dynamic empCodeString;
dynamic empPrimaryId;
dynamic client_id;
dynamic policyList;
dynamic policyDataIsEmpty = 1;
dynamic policyHeading;
dynamic policyName;
dynamic EmployeePolicy;
List<Map<String, String>> employeeDetails = [];
dynamic argumentsData;
dynamic accountManagerDetails;
dynamic accountManagerMobileNo;
dynamic accountManagerEmail;
void _onTabChanged(int index) {
setState(() {
_currentIndex = index;
});
}
@override
void initState() {
super.initState();
apiService = ApiService(context); // Initialize ApiService here
_loadToken();
}
@override
void dispose() {
super.dispose();
}
Future<void> _loadToken() async {
print('_loadToken');
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
setState(() {
_token = token;
});
// Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
print(decodedToken);
empCodeString = prefs.getString('empCode');
print(empCodeString); // Check if emp_code is correct
empPrimaryId = prefs.getString('empPrimaryId');
client_id = prefs.getString('client_id');
print(client_id);
getSelfEmployeeProfile();
} else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'login');
}
}
Future<void> getSelfEmployeeProfile() async {
print(getSelfEmployeeProfile);
if (client_id == null || empCodeString == null) {
return;
}
print('check 1');
final response = await apiService.getSelfEmployeeProfileDetails(
client_id!, empCodeString!);
print('check 1');
if (response['status'] == 'success') {
print(response);
setState(() {
accountManagerDetails = response['AccountManagerDetails'];
print('accountManagerDetails');
print(accountManagerDetails);
accountManagerEmail = accountManagerDetails['email'];
print(accountManagerEmail);
accountManagerMobileNo = accountManagerDetails['mobile'];
print(accountManagerMobileNo);
});
} else {
print('API request failed with status: ${response['status']}');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
child: Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width *
0.2, // 30% of screen width as horizontal padding
vertical: MediaQuery.of(context).size.height *
0.03, // 5% of screen height as vertical padding
)
: EdgeInsets.all(10),
color: Colors.white,
child: Column(children: [
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 15, bottom: 15, left: 25, right: 25)
: EdgeInsets.only(top: 0, bottom: 0, left: 0, right: 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (!Responsive.isDesktop(context))
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, 'home');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
],
),
),
),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
'assets/help.png',
width: 300,
height: 300,
),
],
))),
],
),
// Add more rows as needed
],
),
),
SizedBox(height: 15),
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
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 10, bottom: 10, left: 10, right: 10)
: EdgeInsets.only(
top: 10, bottom: 10, left: 10, right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 11,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Image.asset(
'assets/tickets.png',
width: 60,
height: 60,
),
SizedBox(
width:
10), // Adjust space between icon and text
Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'No service request yet!',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
),
Container(
constraints: BoxConstraints(
maxWidth: Responsive.isDesktop(
context)
? 800
: 250), // Adjust the maximum width as needed
child: Text(
'Please raise a service request, if you have any concerns with your policy.',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 14
: 12,
fontWeight: FontWeight.w400,
color: Color(0xFF777777),
),
softWrap:
true, // Ensure text automatically wraps
),
),
],
))
],
),
),
],
),
),
])),
SizedBox(height: 15),
Container(
width: double.infinity,
height: 75,
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 20, bottom: 20, left: 30, right: 30)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10), // Add padding to the container
child: Row(
children: [
Expanded(
flex: 8,
child: Container(
width: 300,
height: 150,
alignment: Alignment.center,
child: ElevatedButton(
onPressed: () {
var details = {
'claimsDetails': '',
'fromClaimPage': 1
};
Navigator.pushNamed(context, 'planclaimsform',
arguments: details);
},
child: Text(
'Raise a request',
style: GoogleFonts.poppins(color: Colors.white),
),
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFFE26728),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
),
),
)),
],
),
),
SizedBox(height: 15),
if (accountManagerDetails != null)
Container(
decoration: BoxDecoration(
color: Colors.white, // Set background color for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10)
: EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.only(bottom: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Nhance Account Manager Contact',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 16 : 12,
fontWeight: FontWeight.w400,
color: Color(0xFF777777),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 10),
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment
.center, // Center align the row
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.email,
size: 20,
color: Color(0xFFE26728),
),
SizedBox(
width: 10), // Space between icon and text
Text(
accountManagerEmail ?? '',
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 16
: 14,
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
),
),
],
),
SizedBox(
height:
10), // Space between email and mobile rows
Row(
mainAxisAlignment: MainAxisAlignment
.center, // Center align the row
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.smartphone,
size: 20,
color: Color(0xFFE26728),
),
SizedBox(
width: 10), // Space between icon and text
Text(
accountManagerMobileNo ?? '',
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 16
: 14,
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
),
),
],
),
],
),
),
)
]),
),
SizedBox(height: Responsive.isDesktop(context) ? 40 : 10),
]),
)),
if (Responsive.isDesktop(context))
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity, // Make the footer full width
child: CustomFooter(),
),
),
]),
// floatingActionButton: Responsive.isDesktop(context)
// ? null
// : FloatingActionButton(
// onPressed: () {
// // Add your onPressed logic here
// },
// child: Icon(Icons.add),
// ),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(
onTabChanged: (index) {
// Add your navigation logic here
// For example:
if (index == 0) {
Navigator.pushNamed(context, 'home');
} else if (index == 1) {
Navigator.pushNamed(context, 'claims');
} else if (index == 2) {
Navigator.pushNamed(context, 'profile');
} else if (index == 3) {
Navigator.pushNamed(context, 'help');
}
},
icons: [
Icons.home_outlined,
Icons.sticky_note_2_outlined,
Icons.person_outline_outlined,
Icons.headset_mic_outlined,
],
labels: [
"Home",
"Claim",
"Profile",
"Help",
],
initialIndex: 3, // Initial index of the bottom navigation bar
),
);
}
}

View File

@ -0,0 +1,235 @@
import 'package:dash_chat_2/dash_chat_2.dart';
import 'package:flutter/material.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:webview_flutter/webview_flutter.dart';
import '../../customAppBar/customAppBar.dart';
import 'data.dart';
class chatbot extends StatefulWidget {
@override
_chatbotState createState() => _chatbotState();
}
class _chatbotState extends State<chatbot> {
late ApiService apiService;
List<ChatMessage> messages = <ChatMessage>[];
Map<String, String> firstApiOptions = {};
dynamic isOptionStatus;
dynamic requestStatus;
dynamic returnMessage;
dynamic mobileNo;
dynamic policyID;
@override
void initState() {
super.initState();
apiService = ApiService(context); // Initialize ApiService here
quickReplyOptions();
}
@override
void dispose() {
super.dispose();
}
void quickReplyOptions() async {
final response =
await apiService.getBotDetails('Start', '1', '0', '', '', '');
print(response);
if (response['status'] == 'success') {
print('check 2');
dynamic data = response['data'];
print('data: $data');
dynamic optionsData = data['options'];
print('optionsData: $optionsData');
isOptionStatus = data['is_option'];
print('isOptionStatus: $isOptionStatus');
requestStatus = data['request_for'];
print('requestStatus: $requestStatus');
setState(() {
firstApiOptions = Map<String, String>.from(optionsData);
print('firstApiOptions: $firstApiOptions');
addInitialMessage();
});
} else {
// Handle the error accordingly
print('Failed to load quick reply options');
}
}
void addInitialMessage() {
List<QuickReply> quickReplies = firstApiOptions.entries
.map((entry) => QuickReply(title: entry.value, value: entry.key))
.toList();
final ChatMessage initialMessage = ChatMessage(
text: 'Welcome to our service. How can we assist you today?',
user: user4,
createdAt: DateTime.now(),
quickReplies: quickReplies,
);
setState(() {
messages.add(initialMessage);
});
}
void handleQuickReply(QuickReply quickReply) async {
print('QuickReply value: ${quickReply.value}');
print('QuickReply title: ${quickReply.title}');
final ChatMessage replyMessage = ChatMessage(
user: user,
text: quickReply.title,
createdAt: DateTime.now(),
);
setState(() {
messages.insert(0, replyMessage);
});
await processMessage(quickReply.value ?? quickReply.title);
}
Future<void> processMessage(String messageText) async {
print('Processing message: $messageText');
// Add a placeholder loading message with an animated loader
final ChatMessage loadingMessage = ChatMessage(
user: user4,
text: 'Loading...',
createdAt: DateTime.now(),
customProperties: {
'isLoading': true,
},
);
setState(() {
messages.insert(0, loadingMessage);
});
// Simulate API call with a delay of 2 seconds
await Future.delayed(Duration(seconds: 2));
final response = await apiService.getBotDetails(requestStatus,
isOptionStatus, messageText, returnMessage, mobileNo, policyID);
if (response['status'] == 'success') {
dynamic chatApiData = response['data'];
print('chatApiData : $chatApiData');
dynamic optionsData = chatApiData['options'];
returnMessage = chatApiData['text'];
isOptionStatus = chatApiData['is_option'];
requestStatus = chatApiData['request_for'];
if (chatApiData.containsKey('mobile_no')) {
mobileNo = chatApiData['mobile_no'];
}
if (chatApiData.containsKey('policy_id')) {
policyID = chatApiData['policy_id'];
}
setState(() {
// Split and format the returnMessage
String formattedMessage = '';
if (returnMessage != null) {
if (returnMessage.contains('%')) {
try {
List<String> messageParts = returnMessage
.split('%')
.map((part) => part.trim())
.cast<String>()
.toList();
formattedMessage = messageParts
.asMap()
.map((index, part) => MapEntry(index, '${index + 1}. $part'))
.values
.join('\n');
} catch (e) {
print('Error splitting returnMessage: $e');
formattedMessage = returnMessage; // Fallback to original message
}
} else {
formattedMessage = returnMessage;
}
} else {
print('returnMessage is null');
}
print('formattedMessage: $formattedMessage');
firstApiOptions =
optionsData != null ? Map<String, String>.from(optionsData) : {};
final ChatMessage apiResponseMessage = ChatMessage(
user: user4,
text: formattedMessage ?? '',
createdAt: DateTime.now(),
customProperties: {
'isLoading': false,
},
quickReplies: firstApiOptions.entries
.map((entry) => QuickReply(title: entry.value, value: entry.key))
.toList(),
);
// Remove the loading message and add the actual response
messages.removeAt(0);
messages.insert(0, apiResponseMessage);
});
} else {
setState(() {
// Remove the loading message and add an error message
messages.removeAt(0);
messages.insert(
0,
ChatMessage(
user: user4,
text: 'Failed to load data from API',
createdAt: DateTime.now(),
customProperties: {
'isLoading': false,
},
),
);
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(),
body: DashChat(
currentUser: user,
onSend: (ChatMessage m) {
setState(() {
messages.insert(0, m);
});
processMessage(m.text);
},
quickReplyOptions: QuickReplyOptions(onTapQuickReply: handleQuickReply),
messages: messages,
),
);
}
// late WebViewController _controller;
//
// @override
// void initState() {
// super.initState();
// _controller = WebViewController()
// ..setJavaScriptMode(JavaScriptMode.unrestricted)
// ..loadRequest(Uri.parse(
// 'https://mediafiles.botpress.cloud/0439df41-8f0c-4bfd-ad85-340462deebc0/webchat/bot.html'));
// }
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// backgroundColor: Colors.white,
// appBar: CustomAppBar(),
// body: WebViewWidget(controller: _controller),
// );
// }
}

View File

@ -2,16 +2,15 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
class claimprocess extends StatefulWidget {
const claimprocess({Key? key}) : super(key: key);
@ -125,6 +124,7 @@ class _claimprocessState extends State<claimprocess> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(
children: [
@ -783,9 +783,17 @@ class _claimprocessState extends State<claimprocess> {
),
],
),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(context, 'chatbot');
},
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(

View File

@ -6,16 +6,15 @@ import 'package:flutter_svg/svg.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
class claims extends StatefulWidget {
const claims({Key? key}) : super(key: key);
@ -43,7 +42,8 @@ class _claimsState extends State<claims> {
List<Map<String, String>> employeeDetails = [];
dynamic argumentsData;
dynamic empMobileNo;
dynamic trackClaimsList;
List<dynamic> reversedClaimsList = [];
List<dynamic> trackClaimsList = [];
int trackClaimsActive = 1;
int yourPlanActive = 0;
int? serviceId;
@ -135,7 +135,11 @@ class _claimsState extends State<claims> {
print('check 1');
if (response['success'] == true) {
setState(() {
trackClaimsList = response['data'];
trackClaimsList = response['data']
.where((item) => item['department_name'] == 'Claims')
.toList();
reversedClaimsList = List<Map<String, dynamic>>.from(trackClaimsList);
trackClaimsList = reversedClaimsList.reversed.toList();
});
print(trackClaimsList);
} else {
@ -173,6 +177,7 @@ class _claimsState extends State<claims> {
print("Arguments are null or not in the expected format");
}
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
@ -188,103 +193,61 @@ class _claimsState extends State<claims> {
color: Colors.white,
child: Column(children: [
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10)
: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (!Responsive.isDesktop(context))
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, 'home');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
SizedBox(
width:
5), // Adjust space between icon and text
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Claim assistance',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, 'home');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
SizedBox(
width:
5), // Adjust space between icon and text
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Claim assistance',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
Text(
'Manage your claims',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
12, // Adjust the font size as needed
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
),
),
Text(
'Manage your claims',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
12, // Adjust the font size as needed
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
),
],
),
],
),
),
],
),
],
),
),
],
),
if (Responsive.isDesktop(context))
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Claim assistance',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 18
: 16,
fontWeight: FontWeight.w500,
color: Color(0xFF000000),
),
),
Text(
'Manage your claims',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 12
: 10,
fontWeight: FontWeight.w400,
color: Color(0xFF7A7A7A),
),
),
],
))),
],
),
),
],
),
// Add more rows as needed
],
),
@ -649,17 +612,17 @@ class _claimsState extends State<claims> {
),
),
]),
// floatingActionButton: Responsive.isDesktop(context)
// ? null
// : FloatingActionButton(
// onPressed: () {
// // Add your onPressed logic here
// },
// child: Icon(Icons.add),
// ),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(context, 'chatbot');
},
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(
@ -830,6 +793,7 @@ class _claimsState extends State<claims> {
var item = data[index];
String claimsName = item['user_name'];
String claimsSubject = item['subject'];
String claimsDate = item['date'];
String claimsReplies = item['replies'];
String claimStatus = item['status_value'];
String claimsDepartmentName = item['department_name'];
@ -867,97 +831,103 @@ class _claimsState extends State<claims> {
color: Colors.white,
borderRadius: BorderRadius.circular(15.0),
),
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment
.spaceBetween, // Center content horizontally
crossAxisAlignment:
CrossAxisAlignment.center, // Center content vertically
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 4,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Service',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 16 : 12,
fontWeight: FontWeight.w400,
color: Color(0xFF979797),
),
),
Text(
claimsDepartmentName,
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
),
],
),
flex: 6,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Adjust space between icon and text
Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
claimsDepartmentName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 18
: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
),
SizedBox(height: 5),
Text(
claimsSubject,
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 14
: 12,
fontWeight: FontWeight.w400,
color: Color(0xFF777777),
), // Ensure text automatically wraps
),
],
))
],
),
),
Expanded(
flex: 4,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Subject',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 16 : 12,
fontWeight: FontWeight.w400,
color: Color(0xFF979797),
),
),
Text(
claimsSubject ?? '',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
),
],
),
),
),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
claimStatus ?? '',
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 16 : 12,
fontWeight: FontWeight.w400,
color: statusColor,
),
),
],
),
flex: 5,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// Adjust space between icon and text
Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
width: 100,
decoration: BoxDecoration(
color: statusColor,
borderRadius: BorderRadius.circular(
50), // Border radius set to 50
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Text(
claimStatus,
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 12
: 10,
fontWeight: FontWeight.w400,
color: Colors
.white, // Text color against the background
),
),
),
),
SizedBox(height: 5),
Text(
formatDateWithTime(claimsDate),
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
? 14
: 12,
fontWeight: FontWeight.w400,
color: Color(0xFF777777),
), // Ensure text automatically wraps
),
],
))
],
),
),
Expanded(
@ -981,4 +951,17 @@ class _claimsState extends State<claims> {
),
];
}
String formatDateWithTime(String timestamp) {
// Convert the timestamp string to milliseconds
int milliseconds = int.parse(timestamp) * 1000;
// Create a DateTime object from milliseconds
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
// Format the DateTime object with date and time
String formattedDate = DateFormat('d MMM, y HH:mm a').format(date);
return formattedDate;
}
}

View File

@ -0,0 +1,631 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
class claimtracklist extends StatefulWidget {
const claimtracklist({Key? key}) : super(key: key);
@override
State<claimtracklist> createState() => _claimtracklistformState();
}
class _claimtracklistformState extends State<claimtracklist> {
late ApiService apiService;
dynamic _token;
dynamic empCodeString;
dynamic empPrimaryId;
dynamic client_id;
dynamic policyList;
dynamic policyDataIsEmpty = 1;
dynamic policyHeading;
dynamic policyName;
dynamic policyDate;
dynamic policyStatus;
dynamic policySubject;
dynamic policyNo;
dynamic EmployeePolicy;
List<Map<String, String>> employeeDetails = [];
dynamic argumentsData;
dynamic decodedToken;
dynamic claimTrackMsgList;
dynamic empName;
dynamic ticketID;
late TextEditingController messageController;
final Map<String, Color> statusColors = {
'Open': Colors.green,
'Answered': Colors.blue,
'Awaiting Reply': Colors.orange,
'Inprogress': Colors.yellow,
'Closed': Colors.red,
};
// Create a unique form key for each accordion section
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
@override
void initState() {
super.initState();
apiService = ApiService(context); // Initialize ApiService here
_loadToken();
messageController = TextEditingController();
}
@override
void dispose() {
super.dispose();
messageController.dispose();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
dynamic arguments = ModalRoute.of(context)!.settings.arguments;
if (arguments != null && arguments is Map<String, dynamic>) {
argumentsData = arguments;
print('argumentsData');
print(argumentsData);
ticketID = argumentsData['id'];
claimTrackMsgList = argumentsData['message_list'];
policyName = argumentsData['policy_name'];
policyStatus = argumentsData['status_value'];
policyNo = argumentsData['policy_no'];
policySubject = argumentsData['subject'];
policyDate = formatDateWithTime(argumentsData['date']);
print(claimTrackMsgList);
}
}
Future<void> _loadToken() async {
print('_loadToken');
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
setState(() {
_token = token;
});
// Decode the JWT token received from the API response
decodedToken = Jwt.parseJwt(token);
print(decodedToken);
empName = decodedToken['name'];
empCodeString = prefs.getString('empCode');
print(empCodeString); // Check if emp_code is correct
empPrimaryId = prefs.getString('empPrimaryId');
client_id = prefs.getString('client_id');
print(client_id);
} else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'login');
}
}
void sendClaimsMessage(Map<String, dynamic> formData) async {
try {
formData = formData.map((key, value) => MapEntry(key, value.toString()));
final response = await apiService.sendClaimsMessageToApi(formData);
if (response['success'] == 1) {
messageController.clear();
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
messageController.clear();
Navigator.pushNamed(context, 'claims', arguments: 0);
print('Form data sent successfully.');
} else {
print('Failed to submit form data: ${response['status']}');
}
} catch (e) {
print('Error submitting form data: $e');
}
}
Color getStatusColor(String? policyStatus) {
if (policyStatus != null && statusColors.containsKey(policyStatus)) {
return statusColors[policyStatus]!;
} else {
return Color(0xFF000000); // Default color for policyStatus text
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
child: Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width *
0.2, // 30% of screen width as horizontal padding
vertical: MediaQuery.of(context).size.height *
0.03, // 5% of screen height as vertical padding
)
: EdgeInsets.all(10),
color: Colors.white,
child: Column(children: [
Card(
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(15.0), // Set border radius here
),
child: Container(
decoration: BoxDecoration(
color: Colors.white, // Set background color to white
borderRadius: BorderRadius.circular(
15.0), // Set border radius for Container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10), // Add padding to the container
child: Row(
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFFCE5), // Set background color for the container
borderRadius: BorderRadius.circular(
10), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 20,
bottom: 20,
left: 10,
right: 10)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pushNamed(
context, 'claims');
},
child: Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
),
),
Expanded(
flex: 11,
child: Row(
mainAxisAlignment:
Responsive.isDesktop(context)
? MainAxisAlignment.center
: MainAxisAlignment.start,
children: [
Text(
policyName ?? '',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
)
],
),
)
],
),
SizedBox(
height: Responsive.isDesktop(context)
? 20
: 20), // Space between rows
Column(
children: [
Responsive.isDesktop(context)
? buildDesktopLayout(context)
: buildMobileLayout(context)
],
), // Space between rows
// Add more rows as needed
],
),
),
SizedBox(height: 15),
Container(
child: SingleChildScrollView(
child: Column(children: [
...claimTrackMsgList
.map<Widget>((message) {
bool isUserMessage =
message['staff_name'] == null;
String messageContent =
message['message'];
String messageDate = message['date'];
dynamic messagername;
if (isUserMessage) {
messagername = empName;
} else {
messagername = message['staff_name'];
}
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0),
child: Align(
alignment: isUserMessage
? Alignment.centerLeft
: Alignment.centerLeft,
child: Container(
constraints:
BoxConstraints(maxWidth: 800),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: isUserMessage
? Colors.blue[100]
: Colors.green[100],
borderRadius:
BorderRadius.circular(10),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
messageContent,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 14
: 12,
fontWeight:
FontWeight.w400,
color: Color(0xFF000000),
),
),
SizedBox(height: 5),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Row(
children: [
Icon(
Icons.person,
color: Color(
0xFFE26728),
size: 15,
),
SizedBox(width: 5),
Text(
messagername,
style: GoogleFonts
.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight
.w500,
color: Color(
0xFF000000),
),
),
],
),
Text(
formatDateWithTime(
messageDate),
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 12
: 10,
fontWeight:
FontWeight.w400,
color:
Color(0xFF636363),
),
),
],
),
],
),
),
),
);
}).toList(),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0),
child: Row(
children: [
Expanded(
flex: Responsive.isDesktop(
context)
? 10
: 9,
child: TextFormField(
controller: messageController,
onChanged: (value) => null,
decoration: InputDecoration(
border:
OutlineInputBorder(),
hintText: 'Message',
labelText: 'Message',
contentPadding:
EdgeInsets.symmetric(
vertical: 10,
horizontal: 15),
),
validator: (value) {
if (value == null ||
value.isEmpty) {
return 'Message is required';
}
return null;
},
),
),
Expanded(
flex: Responsive.isDesktop(
context)
? 2
: 3,
child: Container(
alignment:
Alignment.centerRight,
child: ElevatedButton(
onPressed: () {
// Check if any of the fields are empty
if (messageController
.text.isEmpty) {
ToastHelper
.showWarningToast(
context,
'All fields are required');
} else {
// Create a map to hold the form data
Map<String, dynamic>
formData = {
'ticket_id': ticketID,
'replier': 'user',
'message':
messageController
.text,
// Add more form fields as needed
};
// Call the function to send form data to API
sendClaimsMessage(
formData);
}
},
child: Text(
'Reply',
style:
GoogleFonts.poppins(
color:
Colors.white),
),
style: ElevatedButton
.styleFrom(
backgroundColor:
Color(0xFFE26728),
shape:
RoundedRectangleBorder(
borderRadius:
BorderRadius
.circular(5),
),
),
),
),
),
],
)
// ElevatedButton(
// onPressed: () {
//
// },
// child: Text('Reply'),
// ),
),
]),
),
),
],
))),
],
),
),
),
SizedBox(height: Responsive.isDesktop(context) ? 40 : 10),
]),
)),
if (Responsive.isDesktop(context))
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity, // Make the footer full width
child: CustomFooter(),
),
),
]),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(context, 'chatbot');
},
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(
onTabChanged: (index) {
// Add your navigation logic here
// For example:
if (index == 0) {
Navigator.pushNamed(context, 'home');
} else if (index == 1) {
Navigator.pushNamed(context, 'claims');
} else if (index == 2) {
Navigator.pushNamed(context, 'profile');
} else if (index == 3) {
Navigator.pushNamed(context, 'help');
}
},
icons: [
Icons.home_outlined,
Icons.sticky_note_2_outlined,
Icons.person_outline_outlined,
Icons.headset_mic_outlined,
],
labels: [
"Home",
"Claim",
"Profile",
"Help",
], // Initial index of the bottom navigation bar
),
);
}
String formatDateWithTime(String timestamp) {
// Convert the timestamp string to milliseconds
int milliseconds = int.parse(timestamp) * 1000;
// Create a DateTime object from milliseconds
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
// Format the DateTime object with date and time
String formattedDate = DateFormat('d MMM, y HH:mm a').format(date);
return formattedDate;
}
Widget buildDesktopLayout(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
buildExpandedColumn(context, 'Policy No', policyNo),
buildExpandedColumn(context, 'Status', policyStatus),
buildExpandedColumn(context, 'Subject', policySubject),
],
);
}
Widget buildMobileLayout(BuildContext context) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
buildExpandedColumn(context, 'Policy No', policyNo),
buildExpandedColumn(context, 'Status', policyStatus),
],
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
buildExpandedColumn(context, 'Subject', policySubject),
buildExpandedColumn(context, '', ''),
],
),
],
);
}
Widget buildExpandedColumn(
BuildContext context, String title, String? value) {
return Expanded(
flex: 3,
child: Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
title,
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 14,
fontWeight: FontWeight.w400,
color: Color(0xFF000000),
),
),
SizedBox(height: Responsive.isDesktop(context) ? 10 : 4),
title == 'Status'
? Text(
value ?? '', // Null check for value
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 16,
fontWeight: FontWeight.w600,
color: getStatusColor(policyStatus),
),
)
: Text(
value ?? '', // Null check for value
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
),
],
),
),
);
}
}

View File

@ -0,0 +1,192 @@
import 'package:dash_chat_2/dash_chat_2.dart';
String profileImage =
'https://e7.pngegg.com/pngimages/811/700/png-clipart-chatbot-internet-bot-business-natural-language-processing-facebook-messenger-business-people-logo-thumbnail.png';
// We have all the possibilities for users
ChatUser user = ChatUser(id: '0');
ChatUser user1 = ChatUser(id: '1');
ChatUser user2 = ChatUser(id: '2', firstName: 'Niki Lauda');
ChatUser user3 = ChatUser(id: '3', lastName: 'Clark');
ChatUser user4 = ChatUser(id: '4', profileImage: profileImage);
ChatUser user5 = ChatUser(id: '5', firstName: 'Charles', lastName: 'Leclerc');
ChatUser user6 =
ChatUser(id: '6', firstName: 'Max', profileImage: profileImage);
ChatUser user7 =
ChatUser(id: '7', lastName: 'Toto', profileImage: profileImage);
ChatUser user8 = ChatUser(
id: '8', firstName: 'Toto', lastName: 'Clark', profileImage: profileImage);
List<ChatMessage> allUsersSample = <ChatMessage>[
ChatMessage(
text: 'Test',
user: user1,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'Test',
user: user2,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'Test',
user: user3,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'Test',
user: user4,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'Test',
user: user5,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'Test',
user: user6,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'Test',
user: user7,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'Test',
user: user8,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
];
List<ChatMessage> basicSample = <ChatMessage>[
ChatMessage(
text: 'google.com hello you @Marc is it &you okay?',
user: user2,
createdAt: DateTime(2021, 01, 31, 16, 45),
mentions: [
Mention(title: '@Marc'),
Mention(title: '&you'),
],
),
ChatMessage(
text: 'google.com',
user: user2,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: "Oh what's up guys?",
user: user2,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
ChatMessage(
text: 'How you doin?',
user: user8,
createdAt: DateTime(2021, 01, 30, 16, 34),
),
ChatMessage(
isMarkdown: true,
text:
"```dart\nvoid main() {\n print('Hello World');\n}\n```\nThe above code will print \"Hello World\" to the console when run.\n\nHere's a breakdown of the code:\n\n* The `main()` function is the entry point of the program. It's where execution begins.\n* `print('Hello World')` prints \"Hello World\" to the console. The `print()` function is a built-in function in Dart that outputs data to the console.\n\nYou can run this code by creating a new Dart file (e.g., `hello_world.dart`) and pasting the code into it. Then, open a terminal window, navigate to the directory where the file is saved, and run the following command:\n\n```\ndart hello_world.dart\n```\n\nThis will compile and run the Dart program, and you should see \"Hello World\" printed to the console. Know more: www.google.com ",
user: user2,
createdAt: DateTime(2021, 01, 30, 15, 50),
),
ChatMessage(
text: 'Hey!',
user: user,
createdAt: DateTime(2021, 01, 30, 15, 50),
),
ChatMessage(
text: 'Hey!',
user: user,
createdAt: DateTime(2021, 01, 28, 15, 50),
),
ChatMessage(
text: 'Hey!',
user: user,
createdAt: DateTime(2021, 01, 28, 15, 50),
),
];
List<ChatMessage> media = <ChatMessage>[
ChatMessage(
medias: <ChatMedia>[
ChatMedia(
url:
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
type: MediaType.image,
fileName: 'image.png',
isUploading: true,
),
ChatMedia(
url:
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
type: MediaType.image,
fileName: 'image.png',
),
ChatMedia(
url:
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/chat_medias%2F2GFlPkj94hKCqonpEdf1%2F20210526_162318.mp4?alt=media&token=01b814b9-d93a-4bf1-8be1-cf9a49058f97',
type: MediaType.video,
fileName: 'video.mp4',
isUploading: false,
),
ChatMedia(
url:
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/chat_medias%2F2GFlPkj94hKCqonpEdf1%2F20210526_162318.mp4?alt=media&token=01b814b9-d93a-4bf1-8be1-cf9a49058f97',
type: MediaType.video,
fileName: 'video.mp4',
isUploading: false,
),
ChatMedia(
url:
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
type: MediaType.file,
fileName: 'image.png',
),
ChatMedia(
url:
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
type: MediaType.image,
fileName: 'image.png',
)
],
user: user3,
createdAt: DateTime(2021, 01, 30, 16, 34),
),
];
List<ChatMessage> quickReplies = <ChatMessage>[
ChatMessage(
text: 'How you doin?',
user: user3,
createdAt: DateTime.now(),
quickReplies: <QuickReply>[
QuickReply(title: 'Great!'),
QuickReply(title: 'Awesome'),
QuickReply(title: 'Hello'),
QuickReply(title: 'Hava a nice day'),
QuickReply(title: 'Hello @Niki, you should check #channel'),
],
),
];
List<ChatMessage> mentionSample = <ChatMessage>[
ChatMessage(
text: 'Hello @Niki, you should check #channel',
user: user2,
createdAt: DateTime(2021, 01, 31, 16, 45),
mentions: [
Mention(title: '@Niki', customProperties: {'userId': user5.id}),
Mention(title: '#channel'),
],
),
ChatMessage(
text: "Oh what's up guys?",
user: user5,
createdAt: DateTime(2021, 01, 30, 16, 45),
),
];
List<ChatMessage> d = <ChatMessage>[];

View File

@ -2,16 +2,15 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
import 'package:http/http.dart' as http;
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
class generalExclusionsDeductibles extends StatefulWidget {
const generalExclusionsDeductibles({Key? key}) : super(key: key);
@ -173,6 +172,7 @@ class _generalExclusionsDeductiblesState
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(
children: [
@ -828,9 +828,17 @@ class _generalExclusionsDeductiblesState
),
],
),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(context, 'chatbot');
},
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(

File diff suppressed because it is too large Load Diff

View File

@ -5,16 +5,15 @@ import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import 'chatbot.dart';
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@ -154,6 +153,7 @@ class _MyAppState extends State<MyApp> {
statusBarIconBrightness: Brightness.dark, // Light icons for status bar
));
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
@ -251,7 +251,11 @@ class _MyAppState extends State<MyApp> {
width: double.infinity,
/// Height of the [ImageSlideshow].
height: 200,
height:
Responsive.isDesktop(
context)
? 200
: 150,
/// The page to show when first creating the [ImageSlideshow].
initialPage: 0,
@ -397,24 +401,28 @@ class _MyAppState extends State<MyApp> {
borderRadius:
BorderRadius.circular(10),
color: Colors.white,
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
padding: EdgeInsets.symmetric(
horizontal: Responsive
.isDesktop(
context)
? 160
: 60,
child: SizedBox(
width: Responsive.isDesktop(
context)
? 400
: 150, // Set the width here
child: TextButton(
onPressed: () {},
style:
TextButton.styleFrom(
padding: EdgeInsets
.symmetric(
vertical: Responsive
.isDesktop(
context)
? 12
: 7),
),
child: Text(
'Active',
style: GoogleFonts.poppins(
: 7,
),
),
child: Text(
'Active',
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
@ -422,8 +430,10 @@ class _MyAppState extends State<MyApp> {
: 14,
fontWeight:
FontWeight.w500,
color: Color(
0xFF593AFF)),
color:
Color(0xFF593AFF),
),
),
),
),
)
@ -460,35 +470,38 @@ class _MyAppState extends State<MyApp> {
borderRadius:
BorderRadius.circular(10),
color: Colors.white,
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
padding: EdgeInsets.symmetric(
horizontal: Responsive
.isDesktop(
context)
? 150
: 60,
child: SizedBox(
width: Responsive.isDesktop(
context)
? 400
: 150, // Set the width here
child: TextButton(
onPressed: () {},
style:
TextButton.styleFrom(
padding: EdgeInsets
.symmetric(
vertical: Responsive
.isDesktop(
context)
? 12
: 7),
// primary: Color(0xFF000000),
),
child: Text(
'Inactive',
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 18
: 14,
color:
Color(0xFF593AFF),
fontWeight:
FontWeight.w500,
: 7,
),
),
child: Text(
'Inactive',
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 18
: 14,
fontWeight:
FontWeight.w500,
color:
Color(0xFF593AFF),
),
),
),
),
@ -534,17 +547,15 @@ class _MyAppState extends State<MyApp> {
),
),
]),
// floatingActionButton: Responsive.isDesktop(context)
// ? null
// : FloatingActionButton(
// onPressed: () {
// // Add your onPressed logic here
// },
// child: Icon(Icons.add),
// ),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () => push(chatbot()),
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.miniCenterDocked,
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(
@ -599,7 +610,7 @@ class _MyAppState extends State<MyApp> {
crossAxisCount: Responsive.isDesktop(context) ? 2 : 1,
crossAxisSpacing: 20.0,
mainAxisSpacing: 20.0,
childAspectRatio: Responsive.isDesktop(context) ? 3.2 : 3.6,
childAspectRatio: Responsive.isDesktop(context) ? 3.2 : 3.5,
),
itemCount: data.length,
itemBuilder: (BuildContext context, int index) {
@ -823,4 +834,14 @@ class _MyAppState extends State<MyApp> {
),
];
}
void push(Widget page) {
Navigator.of(context).push(
MaterialPageRoute<String>(
builder: (BuildContext context) {
return page;
},
),
);
}
}

View File

@ -2,18 +2,15 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/pages/policies.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
class planclaimsform extends StatefulWidget {
const planclaimsform({Key? key}) : super(key: key);
@ -225,6 +222,7 @@ class _planclaimsformState extends State<planclaimsform> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
@ -269,14 +267,23 @@ class _planclaimsformState extends State<planclaimsform> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFFCE5), // Set background color for the container
borderRadius: BorderRadius.circular(
10), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
top: 20,
bottom: 20,
left: 0,
right: 0)
: EdgeInsets.only(
top: 0, bottom: 0, left: 0, right: 0),
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
@ -286,63 +293,52 @@ class _planclaimsformState extends State<planclaimsform> {
MainAxisAlignment.start,
children: [
Expanded(
flex: 12,
flex: 1,
child: InkWell(
onTap: () {
Navigator.pushNamed(
context, 'claims');
context,
fromClaimsPage == 0
? 'claims'
: 'help');
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
if (!Responsive.isDesktop(
context))
Icon(
Icons.chevron_left,
// Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
if (!Responsive.isDesktop(
context))
SizedBox(
width: Responsive
.isDesktop(
context)
? 0
: 5),
// Adjust space between icon and text
Column(
mainAxisAlignment:
MainAxisAlignment
.center,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
claimsDetails[
'policy_name'],
textAlign:
TextAlign.start,
style:
GoogleFonts.poppins(
fontSize: 16,
fontWeight:
FontWeight.w600,
color:
Color(0xFF000000),
),
),
],
),
],
child: Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
),
),
Expanded(
flex: 11,
child: Row(
mainAxisAlignment:
Responsive.isDesktop(context)
? MainAxisAlignment.center
: MainAxisAlignment.start,
children: [
Text(
fromClaimsPage == 0
? claimsDetails[
'policy_name']
: 'Raise a Request',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF000000),
),
)
],
),
)
],
),
), // Space between rows
// Add more rows as needed
],
),
@ -368,107 +364,41 @@ class _planclaimsformState extends State<planclaimsform> {
key: formKey,
child: Column(
children: [
!Responsive.isDesktop(
context)
? Column(
children: [
if (fromClaimsPage !=
0)
buildDropdownField(
'Select Policy',
(value) {
setState(
() {
policyNumberId =
value;
});
},
fromClaimsPage ==
0,
policyNumberList,
'policyName'),
buildDropdownField(
'Service',
(value) {
setState(() {
serviceId =
value;
});
},
fromClaimsPage ==
0,
departmentList,
'name'),
buildTextField(
'Subject',
subjectController),
],
)
: Row(
children: [
if (fromClaimsPage !=
0) ...[
Expanded(
child: buildDropdownField(
'Select Policy',
(value) {
setState(
() {
policyNumberId =
value;
});
},
fromClaimsPage ==
0,
policyNumberList,
'policyName'),
),
],
if (fromClaimsPage !=
0)
SizedBox(
width:
12),
Expanded(
child: buildDropdownField(
'Service',
(value) {
setState(
() {
serviceId =
value;
});
},
fromClaimsPage ==
0,
departmentList,
'name'),
),
SizedBox(
width: 12),
Expanded(
child: buildTextField(
'Subject',
subjectController)),
],
),
!Responsive.isDesktop(
context)
? Column(
children: [
buildTextAreaField(
'Message',
messageController),
],
)
: Row(
children: [
Expanded(
child: buildTextAreaField(
'Message',
messageController)),
],
),
// Only show Select Policy field when Service value is 'Claims'
buildDropdownField(
'Service',
(value) {
setState(() {
serviceId = value;
// Reset policyNumberId if Service is changed
policyNumberId =
null;
});
},
fromClaimsPage == 0,
departmentList,
'name',
),
if (serviceId == 2 &&
fromClaimsPage == 1)
buildDropdownField(
'Select Policy',
(value) {
setState(() {
policyNumberId =
value;
});
},
fromClaimsPage == 0,
policyNumberList,
'policyName',
),
buildTextField('Subject',
subjectController),
buildTextAreaField(
'Message',
messageController),
],
),
),
@ -528,17 +458,17 @@ class _planclaimsformState extends State<planclaimsform> {
),
),
]),
// floatingActionButton: Responsive.isDesktop(context)
// ? null
// : FloatingActionButton(
// onPressed: () {
// // Add your onPressed logic here
// },
// child: Icon(Icons.add),
// ),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(context, 'chatbot');
},
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(

View File

@ -7,20 +7,18 @@ import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import 'package:http/http.dart' as http;
import 'package:accordion/accordion.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../service/api_service.dart';
class policies extends StatefulWidget {
const policies({Key? key}) : super(key: key);
@ -138,6 +136,7 @@ class _policiesState extends State<policies> {
print(employeeDetails);
}
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
@ -169,23 +168,22 @@ class _policiesState extends State<policies> {
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (!Responsive.isDesktop(context))
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, 'home');
},
child: Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, 'home');
},
child: Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
),
),
Expanded(
flex: !Responsive.isDesktop(context) ? 11 : 12,
flex: 11,
child: Row(
mainAxisAlignment: Responsive.isDesktop(context)
? MainAxisAlignment.center
@ -944,17 +942,17 @@ class _policiesState extends State<policies> {
),
),
]),
// floatingActionButton: Responsive.isDesktop(context)
// ? null
// : FloatingActionButton(
// onPressed: () {
// // Add your onPressed logic here
// },
// child: Icon(Icons.add),
// ),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(context, 'chatbot');
},
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(

View File

@ -3,12 +3,10 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import 'package:http/http.dart' as http;
class privacypolicy extends StatefulWidget {
@ -32,6 +30,7 @@ class _privacypolicyState extends State<privacypolicy> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
children: [
SingleChildScrollView(

View File

@ -3,17 +3,15 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import 'package:http/http.dart' as http;
import '../service/api_service.dart';
class profile extends StatefulWidget {
const profile({Key? key}) : super(key: key);
@ -48,6 +46,7 @@ class _profileState extends State<profile> {
dynamic selfEmpCode;
dynamic selfFamilyFloaterKey;
dynamic selfEmpStatus;
dynamic client_branch_id;
void _onTabChanged(int index) {
setState(() {
@ -78,6 +77,7 @@ class _profileState extends State<profile> {
// Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
print(decodedToken);
client_branch_id = decodedToken['client_branch_id'];
empCodeString = prefs.getString('empCode');
print(empCodeString); // Check if emp_code is correct
empPrimaryId = prefs.getString('empPrimaryId');
@ -105,7 +105,7 @@ class _profileState extends State<profile> {
}
print('check 1');
final response = await apiService.getSelfEmployeeProfileDetails(
client_id!, empCodeString!);
client_id!, empCodeString!, client_branch_id!);
print('check 1');
if (response['status'] == 'success') {
if (response.containsKey('data')) {
@ -149,6 +149,7 @@ class _profileState extends State<profile> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: CustomAppBar(),
body: Stack(children: [
SingleChildScrollView(
@ -171,21 +172,27 @@ class _profileState extends State<profile> {
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (!Responsive.isDesktop(context))
Expanded(
flex: 1,
child: Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(top: 10, left: 10),
child: Icon(
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, 'home');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons
.chevron_left, // Replace with your desired icon
color: Color(0xFF000000),
size: 30,
),
)),
],
),
),
),
Expanded(
flex: Responsive.isDesktop(context) ? 12 : 11,
flex: 11,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@ -213,13 +220,12 @@ class _profileState extends State<profile> {
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (!Responsive.isDesktop(context))
Expanded(
flex: 1,
child: Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(top: 10, left: 10),
child: Text(''))),
Expanded(
flex: 1,
child: Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(top: 10, left: 10),
child: Text(''))),
Expanded(
flex: Responsive.isDesktop(context) ? 12 : 11,
child: Row(
@ -585,17 +591,17 @@ class _profileState extends State<profile> {
),
),
]),
// floatingActionButton: Responsive.isDesktop(context)
// ? null
// : FloatingActionButton(
// onPressed: () {
// // Add your onPressed logic here
// },
// child: Icon(Icons.add),
// ),
floatingActionButton: Responsive.isDesktop(context)
? null
: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(context, 'chatbot');
},
child: Icon(Icons.chat),
),
floatingActionButtonLocation: Responsive.isDesktop(context)
? null
: FloatingActionButtonLocation.centerDocked,
: FloatingActionButtonLocation.miniEndFloat,
bottomNavigationBar: Responsive.isDesktop(context)
? null
: CustomBottomNavigationBar(

View File

@ -27,7 +27,7 @@ class ApiService {
final url = Uri.parse(
'${Environment.apiUrl}getEmployeeActiveOrInactivePolicy?client_id=$clientId&emp_code=$empCode&type=$status&client_branch_id=$branchID');
final headers = {
'Authorization': _token ?? '',
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
@ -40,7 +40,7 @@ class ApiService {
}
final url = Uri.parse('${Environment.apiUrl}getAdvertisementImage');
final headers = {
'Authorization': _token ?? '',
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
@ -53,22 +53,22 @@ class ApiService {
}
final url = Uri.parse('${Environment.apiUrl}getFEContent');
final headers = {
'Authorization': _token ?? '',
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> getSelfEmployeeProfileDetails(
String clientId, String empCode) async {
String clientId, String empCode, String branchID) async {
print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse(
'${Environment.apiUrl}getEmployeeProfile?emp_code=$empCode&client_id=$clientId');
'${Environment.apiUrl}getEmployeeProfile?emp_code=$empCode&client_id=$clientId&client_branch_id=$branchID');
final headers = {
'Authorization': Environment.ticketToken ?? '',
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
@ -148,4 +148,32 @@ class ApiService {
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushNamed(context, 'login');
}
Future<Map<String, dynamic>> getBotDetails(String requestFor, is_option,
option, returnMessage, mobileNo, policyID) async {
print('requestFor: $requestFor');
print('is_option: $is_option');
print('option: $option');
print('returnMessage: $returnMessage');
print('mobileNo: $mobileNo');
print('policyID: $policyID');
if (_token == null) {
await _initializeToken();
}
final url;
if (is_option != '0') {
url = Uri.parse(
'${Environment.apiUrl}getChatResponse?request_for=$requestFor&is_option=$is_option&option=$option&mobile_no=$mobileNo&policy_id=$policyID');
} else {
url = Uri.parse(
'${Environment.apiUrl}getChatResponse?request_for=$requestFor&is_option=$is_option&text=$returnMessage&value=$option&mobile_no=$mobileNo&policy_id=$policyID');
}
print(url);
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response;
}
}

View File

@ -3,12 +3,10 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:jwt_decode/jwt_decode.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../customAppBar/customAppBar.dart';
import '../customAppBar/customFooter.dart';
import '../customAppBar/tabs.dart';
import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import 'package:http/http.dart' as http;
class termsofuse extends StatefulWidget {
@ -32,6 +30,7 @@ class _termsofuseState extends State<termsofuse> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
children: [
SingleChildScrollView(

View File

@ -27,12 +27,14 @@ class _MyVerifyState extends State<MyVerify> {
int _secondsRemaining = 30;
bool _isTimerRunning = false;
dynamic empCodeString;
dynamic empClientBranchId;
dynamic empPrimaryId;
dynamic gpaEmpName;
dynamic client_id;
dynamic _token;
dynamic clientName;
dynamic clientLogo;
dynamic emp_status;
@override
void initState() {
@ -65,10 +67,15 @@ class _MyVerifyState extends State<MyVerify> {
Future<void> checkTokenAvailability() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
final String? emp_status = prefs.getString('emp_status');
if (token != null && token.isNotEmpty) {
// Token available, navigate to home page
Navigator.pushReplacementNamed(context, 'home');
if (emp_status == 'enrolled') {
Navigator.pushReplacementNamed(context, 'home');
} else {
Navigator.pushReplacementNamed(context, 'empDetails');
}
}
}
@ -120,7 +127,7 @@ class _MyVerifyState extends State<MyVerify> {
if (response.statusCode == 200) {
Map<String, dynamic> data = json.decode(response.body);
print(data);
print('data: $data');
_token = data['data'];
String status = data['status'];
print(status);
@ -130,7 +137,9 @@ class _MyVerifyState extends State<MyVerify> {
// Decode the JWT token received from the API response
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
print(decodedToken);
print('decodedToken : $decodedToken');
empClientBranchId = decodedToken['client_branch_id'];
prefs.setString('empClientBranchId', empClientBranchId);
empCodeString = decodedToken['emp_code'].toString();
prefs.setString('empCode', empCodeString);
empPrimaryId = decodedToken['id'];
@ -139,6 +148,8 @@ class _MyVerifyState extends State<MyVerify> {
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');
@ -147,13 +158,16 @@ class _MyVerifyState extends State<MyVerify> {
final token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
ToastHelper.showSuccessToast(context, 'Successfully Login');
Navigator.pushReplacementNamed(context, 'home',
arguments: {'mobile': ''});
if (emp_status == 'enrolled') {
Navigator.pushReplacementNamed(context, 'home');
} else {
Navigator.pushReplacementNamed(context, 'empDetails');
}
} else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'phone');
Navigator.pushReplacementNamed(context, 'login');
}
} else {
ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
@ -462,7 +476,7 @@ class _MyVerifyState extends State<MyVerify> {
..onTap = () {
// Navigate to the page where the user can change the phone number
Navigator.pushNamed(
context, 'phone');
context, 'login');
},
),
],

View File

@ -8,11 +8,15 @@ import Foundation
import path_provider_foundation
import shared_preferences_foundation
import smart_auth
import sqflite
import url_launcher_macos
import video_player_avfoundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SmartAuthPlugin.register(with: registry.registrar(forPlugin: "SmartAuthPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
}

View File

@ -52,6 +52,10 @@ dependencies:
accordion: ^2.6.0
url_launcher: ^6.2.6
flutter_svg: ^2.0.10+1
webview_flutter: ^4.8.0
webview_flutter_android: ^3.16.4
path_provider: ^2.1.3
dash_chat_2: ^0.0.21
dev_dependencies:
flutter_test:

View File

@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:nhance_app_pwa/main.dart';
import 'package:nhance_app_pwa/pages/home.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/home.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {

View File

@ -63,7 +63,7 @@
<script>
// The value below is injected by flutter build, do not touch.
const serviceWorkerVersion = null;
const serviceWorkerVersion = {{flutter_service_worker_version}};
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
@ -96,5 +96,6 @@
}
},5000);
};
</script>
</body>
</html>