botman and enrollment

This commit is contained in:
venbaittech 2025-03-21 17:29:22 +05:30
parent 7d4d82042a
commit 92592bd057
24 changed files with 1196 additions and 388 deletions

10
.env
View File

@ -1,5 +1,7 @@
API_URL=https://venbait.in/nhance/dev/employeeRest/ API_URL=https://app.nhanceindia.in/zenith/employeeRest/
TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api #CHAT_BOT_URL=https://venbait.in/nhance/dev
API_URL_Enrollment=https://app.nhanceindia.in/enrolment/employeeRest/
TICKET_API_URL=https://venbait.in/nhance/dev/api
ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
BASE_HREF=/nhance/employee/dev/ BASE_HREF=/app/
ENV=development ENV=production

View File

@ -1,5 +1,7 @@
API_URL=https://app.nhanceindia.in/zenith/employeeRest/ API_URL=https://app.nhanceindia.in/zenith/employeeRest/
TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api #CHAT_BOT_URL=https://venbait.in/nhance/dev
API_URL_Enrollment=https://app.nhanceindia.in/enrolment/employeeRest/
TICKET_API_URL=https://venbait.in/nhance/dev/api
ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
BASE_HREF=/app/ BASE_HREF=/app/
ENV=production ENV=production

View File

@ -1,5 +1,7 @@
API_URL=https://app.nhanceindia.in/zenith/employeeRest/ API_URL=https://appstage.nhanceindia.in/arena/crm/employeeRest/
TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api #CHAT_BOT_URL=https://venbait.in/nhance/dev
ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH API_URL_Enrollment=https://appstage.nhanceindia.in/arena/enrolment/employeeRest/
BASE_HREF=/app/ TICKET_API_URL=https://venbait.in/nhance/dev/api
ENV=production #ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
BASE_HREF=/arena/app/
ENV=uat

View File

@ -1,5 +1,7 @@
API_URL=https://app.nhanceindia.in/zenith/employeeRest/ API_URL=https://appstage.nhanceindia.in/arena/crm/employeeRest/
TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api #CHAT_BOT_URL=https://venbait.in/nhance/dev
ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH API_URL_Enrollment=https://appstage.nhanceindia.in/arena/enrolment/employeeRest/
BASE_HREF=/app/ TICKET_API_URL=https://venbait.in/nhance/dev/api
ENV=production #ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
BASE_HREF=/arena/app/
ENV=uat

66
assets/botman_chat.html Normal file
View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Botman Chat</title>
<script src="https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js"></script>
</head>
<body>
<script>
function generateSessionId(length = 15) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let sessionId = '';
for (let i = 0; i < length; i++) {
sessionId += characters.charAt(Math.floor(Math.random() * characters.length));
}
return sessionId;
}
var emp_name = localStorage.getItem('gpaEmpName') || 'Guest';
var employee_id = localStorage.getItem('empPrimaryId') || '12288';
var emp_code = localStorage.getItem('empCode') || 'HTL-007';
var client_id = localStorage.getItem('client_id') || 159;
var client_branch_id = localStorage.getItem('empClientBranchId') || 125;
var session_id = generateSessionId(15);
var botmanWidget = {
chatServer: 'https://venbait.in/nhance/dev/chat',
frameEndpoint: 'https://venbait.in/nhance/dev/widget',
title: "Ask ILA",
introMessage: "",
bubbleBackground: "#007bff",
mainColor: "#007bff",
placeholderText: "Type your message here...",
aboutText: "Insurance Assistant ILA",
enableAttachments: false,
parameters: {
employee_id: employee_id,
session_id: session_id,
origin: "mobile",
emp_code: emp_code,
client_id: client_id,
client_branch_id: client_branch_id
}
};
function openBotmanChat() {
var checkBotman = setInterval(function () {
if (typeof botmanChatWidget !== "undefined" && botmanChatWidget.open) {
clearInterval(checkBotman);
botmanChatWidget.open();
setTimeout(function () {
botmanChatWidget.sayAsBot('Hi ' + emp_name + ', This is ILA, your Insurance Assistant. How can I help you?');
}, 2000);
} else {
console.log("Waiting for Botman to initialize...");
}
}, 500);
}
setTimeout(openBotmanChat, 1000);
</script>
</body>
</html>

View File

@ -10,7 +10,7 @@ class CustomFooter extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
'Copyright@ 2024 Nhance', 'Copyright @ ${DateTime.now().year} Nhance',
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.grey[600], // Text color color: Colors.grey[600], // Text color

View File

@ -19,6 +19,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
bool showBackToHR = true; bool showBackToHR = true;
bool hideInactiveStatus = true; bool hideInactiveStatus = true;
dynamic empStatus; dynamic empStatus;
dynamic _postToken;
bool isTokenAvailable = false;
@override @override
void initState() { void initState() {
@ -26,16 +28,27 @@ class _CustomAppBarState extends State<CustomAppBar> {
getEmpStatus(); getEmpStatus();
} }
Future<void> checkEnrollToken() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
isTokenAvailable = prefs.getString('enrollToken') != null;
});
}
Future<void> getEmpStatus() async { Future<void> getEmpStatus() async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
empStatus = prefs.getString('enrollmentEmp_status'); setState(() {
empStatus = prefs.getString('enrollmentEmp_status');
// _postToken = prefs.getString('_postToken');
isTokenAvailable = prefs.getString('_postToken') != null;
});
} }
Future<void> logout(BuildContext context) async { Future<void> logout(BuildContext context) async {
// final prefs = await SharedPreferences.getInstance(); // final prefs = await SharedPreferences.getInstance();
// final String? token = prefs.getString('token'); // final String? token = prefs.getString('token');
// //
// if (token != null && token.isNotEmpty) { // if (_postToken != null && _postToken.isNotEmpty) {
// await prefs.clear(); // await prefs.clear();
// Navigator.pushNamed(context, 'login'); // Navigator.pushNamed(context, 'login');
// } // }
@ -99,7 +112,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
), ),
), ),
// AdaptiveNavBar Column // AdaptiveNavBar Column
if (empStatus != 'enrolled') if (!isTokenAvailable)
Expanded( Expanded(
flex: Responsive.isDesktop(context) ? 9 : 3, flex: Responsive.isDesktop(context) ? 9 : 3,
child: AdaptiveNavBar( child: AdaptiveNavBar(
@ -116,7 +129,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
// Navigator.pushNamed(context, 'oldPolicy'); // Navigator.pushNamed(context, 'oldPolicy');
}, },
), ),
if (empStatus != 'enrolled') if (!isTokenAvailable)
NavBarItem( NavBarItem(
text: "Logout", text: "Logout",
onTap: () async { onTap: () async {
@ -126,7 +139,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
], ],
), ),
), ),
if (empStatus == 'enrolled') // if (empStatus == 'enrolled')
if (isTokenAvailable)
Expanded( Expanded(
flex: Responsive.isDesktop(context) ? 9 : 3, flex: Responsive.isDesktop(context) ? 9 : 3,
child: AdaptiveNavBar( child: AdaptiveNavBar(

View File

@ -48,9 +48,7 @@ Future<void> main() async {
appId: '1:1084115316849:android:963ff492c3d23ab06c6bd0', appId: '1:1084115316849:android:963ff492c3d23ab06c6bd0',
messagingSenderId: '1084115316849', messagingSenderId: '1084115316849',
projectId: 'nhance-ee8d1')); projectId: 'nhance-ee8d1'));
await dotenv.load(fileName: Environment.fileName);
// Load environment variables
await dotenv.load(fileName: Environment.fileName); await dotenv.load(fileName: Environment.fileName);
runApp(MyApp()); runApp(MyApp());

View File

@ -25,6 +25,10 @@ class Environment {
return dotenv.env['API_URL_Enrollment'] ?? 'API_URL not found!'; return dotenv.env['API_URL_Enrollment'] ?? 'API_URL not found!';
} }
static String get chatBotUrl {
return dotenv.env['CHAT_BOT_URL'] ?? 'CHAT_BOT_URL not found!';
}
static String get baseHref { static String get baseHref {
return dotenv.env['BASE_HREF'] ?? 'BASE_HREF not found!'; return dotenv.env['BASE_HREF'] ?? 'BASE_HREF not found!';
} }

View File

@ -139,7 +139,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
void verifyOTP(String otp) async { void verifyOTP(String otp) async {
try { try {
final response = await http.post( final response = await http.post(
Uri.parse(Environment.apiUrl + 'getVerifiedUserData'), Uri.parse(Environment.apiUrlEnrollment + 'getVerifiedUserData'),
body: body:
json.encode({'email_id': widget.email, 'otp': _otpController.text}), json.encode({'email_id': widget.email, 'otp': _otpController.text}),
headers: { headers: {
@ -222,7 +222,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
prefs.setString('client_id', client_id); prefs.setString('client_id', client_id);
emp_status = decodedToken['emp_status']; emp_status = decodedToken['emp_status'];
prefs.setString('emp_status', emp_status); prefs.setString('emp_status', emp_status);
getClientLogoAndDetails(); // getClientLogoAndDetails();
print('Successfully Login'); print('Successfully Login');
@ -249,7 +249,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
prefs.setString('enrollmentClient_id', enrollmentClient_id); prefs.setString('enrollmentClient_id', enrollmentClient_id);
enrollmentEmp_status = decodedToken['emp_status']; enrollmentEmp_status = decodedToken['emp_status'];
prefs.setString('enrollmentEmp_status', enrollmentEmp_status); prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
// getClientLogoAndDetails(); getClientLogoAndDetails();
} }
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
@ -365,8 +365,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
} }
Future<void> getClientLogoAndDetails() async { Future<void> getClientLogoAndDetails() async {
var url = Uri.parse(Environment.apiUrl + var url = Uri.parse(Environment.apiUrlEnrollment +
'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); 'getClientDetails?client_id=$enrollmentClient_id&emp_code=$enrollmentEmpCodeString&client_branch_id=$enrollmentEmpClientBranchId');
try { try {
var response = await http.get( var response = await http.get(
url, url,

View File

@ -146,9 +146,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
dynamic empRefId; dynamic empRefId;
dynamic enrollmentEmpClientBranchId; dynamic enrollmentEmpClientBranchId;
dynamic selfEmpStatus; dynamic selfEmpStatus;
dynamic gpaTotalAmt;
dynamic gmcTotalAmt;
List<Map<String, dynamic>> allDisclaimer = List<Map<String, dynamic>> allDisclaimer =
[]; // Declare this to store all disclaimers []; // Declare this to store all disclaimers
late List<bool> checkboxValues; late List<bool> checkboxValues;
bool isTokenAvailable = false;
@override @override
void initState() { void initState() {
@ -164,6 +167,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
}); });
}); });
checkboxValues = List<bool>.filled(allDisclaimer.length, false); checkboxValues = List<bool>.filled(allDisclaimer.length, false);
getTokenStatus();
} }
@override @override
@ -174,6 +178,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
super.dispose(); super.dispose();
} }
Future<void> getTokenStatus() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
isTokenAvailable = prefs.getString('_postToken') != null;
});
}
void _sortDisclaimerByTypeOrder() { void _sortDisclaimerByTypeOrder() {
allDisclaimer.sort((a, b) { allDisclaimer.sort((a, b) {
int indexA = typeOrder.indexOf(a['type']); int indexA = typeOrder.indexOf(a['type']);
@ -1371,7 +1382,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
), ),
), ),
onPressed: () { onPressed: () {
Navigator.popAndPushNamed(context, 'home'); Navigator.of(context).pop();
// Navigator.popAndPushNamed(context, 'home');
}, },
), ),
], ],
@ -1432,6 +1444,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
return isChecked && disclaimeStatus; return isChecked && disclaimeStatus;
} }
double allTotalSum() {
double total = 0.0; // Initialize to avoid unwanted accumulation
if (gpaTotalAmt != null) total += gpaTotalAmt!;
if (gmcTotalAmt != null) total += gmcTotalAmt!;
return total;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) { if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) {
@ -3736,6 +3755,215 @@ class _addOnsDetailsState extends State<addOnsDetails> {
: EdgeInsets.all(10), : EdgeInsets.all(10),
child: Column( child: Column(
children: [ children: [
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Premium Summary',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 12,
child: Container(
alignment: Alignment
.centerLeft, // Adjust padding as needed
child: Table(
columnWidths: {
0: FlexColumnWidth(
2), // Adjust column width as needed
1: FlexColumnWidth(2),
2: FlexColumnWidth(
2), // Adjust column width as needed
3: FlexColumnWidth(2),
},
children: [
TableRow(
children: [
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'Policy ',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight
.bold),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'Additional Premium',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight
.bold),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'GST',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight
.bold),
),
),
),
TableCell(
child: Padding(
padding:
EdgeInsets.all(8.0),
child: Text(
'Total',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 14,
fontWeight:
FontWeight
.bold),
),
),
),
],
),
if (gpaPolicies != null &&
gpaPolicies.length > 0)
...gpaBuildPolicyRows(
gpaPolicies, context),
if (gmcPolicies != null &&
gmcPolicies.length > 0)
...gmcBuildPolicyRows(
gmcPolicies, context),
],
),
))
],
),
),
SizedBox(height: 10),
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 6,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Total Payable',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 16,
color: Color(0xFF181818),
fontWeight: FontWeight.w600,
),
),
],
))),
Expanded(
flex: 6,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'${allTotalSum()}/Year',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
color: Color(0xFFE26728),
fontWeight: FontWeight.w500,
),
),
],
)))
],
),
),
SizedBox(height: 10),
Container( Container(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -4047,7 +4275,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
), ),
), ),
if (Responsive.isDesktop(context) || if (Responsive.isDesktop(context) ||
(!Responsive.isDesktop(context) && selfEmpStatus != 'enrolled')) (!Responsive.isDesktop(context) && !isTokenAvailable))
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Container( child: Container(
@ -4058,7 +4286,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
]), ]),
floatingActionButton: Responsive.isDesktop(context) floatingActionButton: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? FloatingActionButton( ? FloatingActionButton(
onPressed: () => Navigator.push( onPressed: () => Navigator.push(
context, context,
@ -4069,12 +4297,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
: null, : null,
floatingActionButtonLocation: Responsive.isDesktop(context) floatingActionButtonLocation: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? FloatingActionButtonLocation.miniEndFloat ? FloatingActionButtonLocation.miniEndFloat
: null, : null,
bottomNavigationBar: Responsive.isDesktop(context) bottomNavigationBar: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? CustomBottomNavigationBar( ? CustomBottomNavigationBar(
onTabChanged: (index) { onTabChanged: (index) {
// Add your navigation logic here // Add your navigation logic here
@ -5232,4 +5460,175 @@ class _addOnsDetailsState extends State<addOnsDetails> {
return cards; return cards;
} }
double calculateGpaTotalAmt(List<Map<String, dynamic>> policies) {
double total = policies
.where((policy) => policy is Map<String, dynamic>)
.map((policy) =>
(policy["si_gst_value"] ?? 0) + (policy["si_premium_value"] ?? 0))
.fold(0.0, (sum, value) => sum + value);
print('Calculated gpaTotalAmt: $total'); // Debug print
return total;
}
List<TableRow> gpaBuildPolicyRows(dynamic policies, BuildContext context) {
if (policies is! List) {
return []; // Return empty list if policies is not a list
}
gpaTotalAmt = calculateGpaTotalAmt(policies.cast<Map<String, dynamic>>());
print('gpaTotalAmt $gpaTotalAmt');
return (policies as List)
.where((policy) => policy is Map<String,
dynamic>) // Ensure each item is a Map<String, dynamic>
.map((policy) {
var siGstValue = policy["si_gst_value"] ?? 0;
var siPremiumValue = policy["si_premium_value"] ?? 0;
if (siGstValue == 0 || siPremiumValue == 0)
return null; // Skip invalid policies
return TableRow(
children: [
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
Responsive.isDesktop(context)
? (policy["Policy_Name"] ?? 'Default Policy Name')
: policy['type'],
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'${policy["si_premium_value"]}/Year',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'${policy["si_gst_value"]}/-',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'${(policy["si_premium_value"] ?? 0) + (policy["si_gst_value"] ?? 0)}/-',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
],
);
})
.whereType<TableRow>() // Filter out null values
.toList();
}
double calculateGmcTotalAmt(List<Map<String, dynamic>> policies) {
double total = policies
.where((policy) => policy is Map<String, dynamic>)
.map((policy) =>
(policy["family_floaters_of_dependent_and_gst_value"] ?? 0) +
(policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0))
.fold(0.0, (sum, value) => sum + value);
print('Calculated gmcTotalAmt: $total'); // Debug print
return total;
}
List<TableRow> gmcBuildPolicyRows(dynamic policies, BuildContext context) {
print('gmcBuildPolicyRows $policies');
if (policies is! List) {
return []; // Return empty list if policies is not a list
}
gmcTotalAmt = calculateGmcTotalAmt(policies.cast<Map<String, dynamic>>());
print('gmcTotalAmt $gmcTotalAmt');
return (policies as List)
.where((policy) => policy is Map<String,
dynamic>) // Ensure each item is a Map<String, dynamic>
.map((policy) {
var siGstValue =
policy["family_floaters_of_dependent_and_gst_value"] ?? 0;
var siPremiumValue =
policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0;
if (siGstValue == 0 || siPremiumValue == 0)
return null; // Skip invalid policies
return TableRow(
children: [
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
Responsive.isDesktop(context)
? (policy["Policy_Name"] ?? 'Default Policy Name')
: policy['type'],
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'${policy["family_floaters_of_dependent_and_si_premium_value"]}/Year',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'${policy["family_floaters_of_dependent_and_gst_value"]}/-',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
TableCell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'${(policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0) + (policy["family_floaters_of_dependent_and_gst_value"] ?? 0)}/-',
textAlign: TextAlign.start,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 14 : 12),
),
),
),
],
);
})
.whereType<TableRow>() // Filter out null values
.toList();
}
} }

View File

@ -99,6 +99,7 @@ class _empDetailsState extends State<empDetails> {
dynamic hrPrimaryId; dynamic hrPrimaryId;
dynamic empRefId; dynamic empRefId;
dynamic enrollmentEmpClientBranchId; dynamic enrollmentEmpClientBranchId;
bool isTokenAvailable = false;
@override @override
void initState() { void initState() {
@ -114,6 +115,8 @@ class _empDetailsState extends State<empDetails> {
isLoading = false; isLoading = false;
}); });
}); });
getTokenStatus();
} }
@override @override
@ -124,6 +127,13 @@ class _empDetailsState extends State<empDetails> {
super.dispose(); super.dispose();
} }
Future<void> getTokenStatus() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
isTokenAvailable = prefs.getString('_postToken') != null;
});
}
Future<void> _loadToken() async { Future<void> _loadToken() async {
print('_loadToken'); print('_loadToken');
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
@ -815,7 +825,7 @@ class _empDetailsState extends State<empDetails> {
), ),
), ),
if (Responsive.isDesktop(context) || if (Responsive.isDesktop(context) ||
(!Responsive.isDesktop(context) && selfEmpStatus != 'enrolled')) (!Responsive.isDesktop(context) && !isTokenAvailable))
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Container( child: Container(
@ -826,7 +836,7 @@ class _empDetailsState extends State<empDetails> {
]), ]),
floatingActionButton: Responsive.isDesktop(context) floatingActionButton: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? FloatingActionButton( ? FloatingActionButton(
onPressed: () => Navigator.push( onPressed: () => Navigator.push(
context, context,
@ -837,12 +847,12 @@ class _empDetailsState extends State<empDetails> {
: null, : null,
floatingActionButtonLocation: Responsive.isDesktop(context) floatingActionButtonLocation: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? FloatingActionButtonLocation.miniEndFloat ? FloatingActionButtonLocation.miniEndFloat
: null, : null,
bottomNavigationBar: Responsive.isDesktop(context) bottomNavigationBar: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? CustomBottomNavigationBar( ? CustomBottomNavigationBar(
onTabChanged: (index) { onTabChanged: (index) {
// For example: // For example:
@ -2059,18 +2069,27 @@ class _empDetailsState extends State<empDetails> {
print(item); print(item);
setState(() { setState(() {
gmcPolicyName = item['Policy_Name']; gmcPolicyName = item['Policy_Name'];
print('gmcPolicyName $gmcPolicyName');
gmcPolicyType = item['type']; gmcPolicyType = item['type'];
print('gmcPolicyType $gmcPolicyType');
gmcFloaterTextHeading = item['floter_text_heading']; gmcFloaterTextHeading = item['floter_text_heading'];
print('gmcFloaterTextHeading $gmcFloaterTextHeading');
gmcFloaterTextDescription = item['floter_text_description']; gmcFloaterTextDescription = item['floter_text_description'];
print('gmcFloaterTextDescription $gmcFloaterTextDescription');
gmcNotes = item['notes']; gmcNotes = item['notes'];
print('gmcNotes $gmcNotes');
gmcECardDownload = item['eCardDownload']; gmcECardDownload = item['eCardDownload'];
print('gmcECardDownload $gmcECardDownload');
gmcGstValue = item['family_floaters_of_dependent_and_gst_value']; gmcGstValue = item['family_floaters_of_dependent_and_gst_value'];
print('gmcGstValue $gmcGstValue');
gmcSiPremiumValue = gmcSiPremiumValue =
item['family_floaters_of_dependent_and_si_premium_value']; item['family_floaters_of_dependent_and_si_premium_value'];
print('gmcSiPremiumValue $gmcSiPremiumValue');
gmcTotalableValue = gmcGstValue + gmcSiPremiumValue; gmcTotalableValue = gmcGstValue + gmcSiPremiumValue;
gmcIsValueValid = (gmcSiPremiumValue != 0 && gmcGstValue != 0); gmcIsValueValid = (gmcSiPremiumValue != 0 && gmcGstValue != 0);
gmcMappedFamilyFloaters = item['mapped_family_floaters']; gmcMappedFamilyFloaters = item['mapped_family_floaters'];
print('gmcMappedFamilyFloaters $gmcMappedFamilyFloaters');
dynamic getTrueObjects = gmcMappedFamilyFloaters dynamic getTrueObjects = gmcMappedFamilyFloaters
.where((element) => element['is_value_exist'] == true) .where((element) => element['is_value_exist'] == true)
.toList(); .toList();
@ -2085,6 +2104,7 @@ class _empDetailsState extends State<empDetails> {
} }
String intOpenForEnrollment = item['OpenForEnrollment']; String intOpenForEnrollment = item['OpenForEnrollment'];
gmcOpenForEnrollment = int.parse(intOpenForEnrollment); gmcOpenForEnrollment = int.parse(intOpenForEnrollment);
print('gmcOpenForEnrollment $gmcOpenForEnrollment');
gmcTypeName = item['type']; gmcTypeName = item['type'];
}); });

View File

@ -160,6 +160,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
List<Map<String, dynamic>> allDisclaimer = List<Map<String, dynamic>> allDisclaimer =
[]; // Declare this to store all disclaimers []; // Declare this to store all disclaimers
late List<bool> checkboxValues; late List<bool> checkboxValues;
bool isTokenAvailable = false;
@override @override
void initState() { void initState() {
@ -172,6 +173,15 @@ class _empReviewDetailsState extends State<empReviewDetails> {
}); });
}); });
checkboxValues = List<bool>.filled(allDisclaimer.length, false); checkboxValues = List<bool>.filled(allDisclaimer.length, false);
getTokenStatus();
}
Future<void> getTokenStatus() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
isTokenAvailable = prefs.getString('_postToken') != null;
});
} }
@override @override
@ -1039,7 +1049,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
), ),
), ),
onPressed: () { onPressed: () {
Navigator.popAndPushNamed(context, 'home'); Navigator.of(context).pop();
// Navigator.popAndPushNamed(context, 'home');
}, },
), ),
], ],
@ -2709,7 +2720,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
), ),
), ),
if (Responsive.isDesktop(context) || if (Responsive.isDesktop(context) ||
(!Responsive.isDesktop(context) && selfEmpStatus != 'enrolled')) (!Responsive.isDesktop(context) && !isTokenAvailable))
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Container( child: Container(
@ -2720,7 +2731,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
]), ]),
floatingActionButton: Responsive.isDesktop(context) floatingActionButton: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? FloatingActionButton( ? FloatingActionButton(
onPressed: () => Navigator.push( onPressed: () => Navigator.push(
context, context,
@ -2731,12 +2742,12 @@ class _empReviewDetailsState extends State<empReviewDetails> {
: null, : null,
floatingActionButtonLocation: Responsive.isDesktop(context) floatingActionButtonLocation: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? FloatingActionButtonLocation.miniEndFloat ? FloatingActionButtonLocation.miniEndFloat
: null, : null,
bottomNavigationBar: Responsive.isDesktop(context) bottomNavigationBar: Responsive.isDesktop(context)
? null ? null
: selfEmpStatus == 'enrolled' : isTokenAvailable
? CustomBottomNavigationBar( ? CustomBottomNavigationBar(
onTabChanged: (index) { onTabChanged: (index) {
// Add your navigation logic here // Add your navigation logic here

View File

@ -496,21 +496,6 @@ class _loginState extends State<login> {
), ),
Column( Column(
children: [ children: [
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: toggleField,
child: Text(
isEmailFieldVisible
? "Login with Mobile No"
: "Login with Email",
style: TextStyle(
color: Color(0xFF00989E),
),
),
),
),
SizedBox(height: 15),
isEmailFieldVisible isEmailFieldVisible
? Container( ? Container(
height: 55, height: 55,
@ -690,6 +675,21 @@ class _loginState extends State<login> {
), ),
), ),
), ),
SizedBox(height: 15),
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: toggleField,
child: Text(
isEmailFieldVisible
? "Login with Mobile No"
: "Login with Email",
style: TextStyle(
color: Color(0xFF00989E),
),
),
),
),
], ],
), ),
SizedBox( SizedBox(

View File

@ -133,48 +133,46 @@ class _claimsState extends State<claims> {
return; return;
} }
print('check 1'); print('check 1');
final response = final response = await apiService.getTrackClaimsList(empPrimaryId!);
await apiService.getTrackClaimsList(empMobileNo!, empCodeString!);
print('check 1'); print('check 1');
if (response['success'] == true) { // if (response['success'] == true) {
setState(() { setState(() {
List<dynamic> data = response['data']; List<dynamic> data = response['ticket_data'];
print('Data from response: $data'); print('Data from response: $data');
trackClaimsList = data.where((item) { // trackClaimsList = data.where((item) {
// Check if item is a Map and has the departmentId key // // Check if item is a Map and has the departmentId key
if (item is Map<String, dynamic> && // if (item is Map<String, dynamic> && item.containsKey('department_id')) {
item.containsKey('department_id')) { // final departmentId = item['department_id'];
final departmentId = item['department_id']; //
// // Print each departmentId for debugging
// print('Item department_id: $departmentId');
//
// // Ensure departmentId is an int or string, and compare
// if (departmentId is int) {
// return departmentId == 3 || departmentId == 4;
// } else if (departmentId is String) {
// return int.tryParse(departmentId) == 3 ||
// int.tryParse(departmentId) == 4;
// }
// }
// return false;
// }).toList();
// Print each departmentId for debugging print('Filtered trackClaimsList: $data');
print('Item department_id: $departmentId'); reversedClaimsList = List<Map<String, dynamic>>.from(data);
print('reversedClaimsList $reversedClaimsList');
// Ensure departmentId is an int or string, and compare trackClaimsList = reversedClaimsList.reversed.toList();
if (departmentId is int) { print('trackClaimsList $trackClaimsList');
return departmentId == 3 || departmentId == 4; });
} else if (departmentId is String) { print(trackClaimsList);
return int.tryParse(departmentId) == 3 || // } else {
int.tryParse(departmentId) == 4; // setState(() {
} // trackClaimsIsEmpty = 0;
} // });
return false; // print('API request failed with status: ${response['status']}');
}).toList(); // }
print('Filtered trackClaimsList: $trackClaimsList');
reversedClaimsList = List<Map<String, dynamic>>.from(trackClaimsList);
print('reversedClaimsList $reversedClaimsList');
trackClaimsList = reversedClaimsList.reversed.toList();
print('trackClaimsList $trackClaimsList');
});
print(trackClaimsList);
} else {
setState(() {
trackClaimsIsEmpty = 0;
});
print('API request failed with status: ${response['status']}');
}
} }
String formatDate(String timestamp) { String formatDate(String timestamp) {
@ -617,8 +615,7 @@ class _claimsState extends State<claims> {
SingleChildScrollView( SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: generateTrackList( children: generateTrackList(trackClaimsList),
trackClaimsList), // Replace 'yourDataList' with your actual data list
), ),
), ),
SizedBox(height: Responsive.isDesktop(context) ? 40 : 70), SizedBox(height: Responsive.isDesktop(context) ? 40 : 70),
@ -827,20 +824,29 @@ class _claimsState extends State<claims> {
itemCount: data.length, itemCount: data.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
var item = data[index]; var item = data[index];
String claimsName = item['user_name']; // String claimsName = item['user_name'];
String claimsSubject = item['subject']; String claimsSubject = item['subject'] ?? '';
String claimsDate = item['date']; String claimsDate = item['created_at'] ?? '';
String claimsReplies = item['replies']; String claimStatus = item['claim_status'] ?? '';
String claimStatus = item['status_value']; String claimsDepartmentName = item['ticket_policy_type'] ?? '';
String claimsDepartmentName = item['department_name']; // String claimsReplies = item['replies'];
List<dynamic> messageList = item['message_list']; // List<dynamic> messageList = item['message_list'];
print('generateTrackList');
print(claimsSubject);
print(claimsDate);
print(claimStatus);
print(claimsDepartmentName);
final Map<String, Color> statusColors = { final Map<String, Color> statusColors = {
'Open': Colors.green, 'Received': Colors.amber,
'Answered': Colors.blue, 'Rejected': Colors.red,
'Awaiting Reply': Colors.orange, 'Cancelled': Colors.red,
'Inprogress': Colors.yellow, 'Returned': Colors.deepOrange,
'Closed': Colors.red, 'Closed': Colors.grey,
'Approved': Colors.green,
'Settled': Colors.lightBlueAccent,
'Under Process': Colors.brown,
}; };
// Determine the color based on the claimStatus // Determine the color based on the claimStatus
@ -853,7 +859,7 @@ class _claimsState extends State<claims> {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
Navigator.pushNamed(context, 'claimtracklist', arguments: item); // Navigator.pushNamed(context, 'claimtracklist', arguments: item);
}, },
child: MouseRegion( child: MouseRegion(
cursor: SystemMouseCursors.click, cursor: SystemMouseCursors.click,
@ -896,17 +902,24 @@ class _claimsState extends State<claims> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
Text( Tooltip(
claimsSubject, message:
textAlign: TextAlign.left, claimsSubject, // Full text shown on hover
style: GoogleFonts.poppins( child: Text(
fontSize: Responsive.isDesktop(context) claimsSubject.length > 30
? 14 ? '${claimsSubject.substring(0, 30)}...'
: 12, : claimsSubject,
fontWeight: FontWeight.w400, textAlign: TextAlign.left,
color: Color(0xFF777777), style: GoogleFonts.poppins(
), // Ensure text automatically wraps fontSize:
), Responsive.isDesktop(context)
? 14
: 12,
fontWeight: FontWeight.w400,
color: Color(0xFF777777),
),
),
)
], ],
)) ))
], ],
@ -989,11 +1002,8 @@ class _claimsState extends State<claims> {
} }
String formatDateWithTime(String timestamp) { String formatDateWithTime(String timestamp) {
// Convert the timestamp string to milliseconds // Parse the timestamp string to DateTime
int milliseconds = int.parse(timestamp) * 1000; DateTime date = DateTime.parse(timestamp);
// Create a DateTime object from milliseconds
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
// Format the DateTime object with date and time // Format the DateTime object with date and time
String formattedDate = DateFormat('d MMM, y HH:mm a').format(date); String formattedDate = DateFormat('d MMM, y HH:mm a').format(date);

View File

@ -135,38 +135,37 @@ class _helpState extends State<help> {
isLoading = true; isLoading = true;
}); });
print('check 1'); print('check 1');
final response = final response = await apiService.getTrackClaimsList(empPrimaryId!);
await apiService.getTrackClaimsList(empMobileNo!, empCodeString!);
print('check 2'); print('check 2');
setState(() { setState(() {
isLoading = false; isLoading = false;
}); });
if (response['success'] == true && response['data'] is List) { // if (response['success'] == true && response['data'] is List) {
setState(() { setState(() {
trackClaimsList = response['data'] trackClaimsList = response['ticket_data']
.where((item) => item['status_value'] != 'Closed') .where((item) => item['status_value'] != 'Closed')
.toList(); .toList();
reversedClaimsList = List<Map<String, dynamic>>.from(trackClaimsList); reversedClaimsList = List<Map<String, dynamic>>.from(trackClaimsList);
trackClaimsList = reversedClaimsList.reversed.toList(); trackClaimsList = reversedClaimsList.reversed.toList();
trackClaimsClosedList = response['data'] trackClaimsClosedList = response['ticket_data']
.where((item) => item['status_value'] == 'Closed') .where((item) => item['status_value'] == 'Closed')
.toList(); .toList();
reversedClaimsClosedList = reversedClaimsClosedList =
List<Map<String, dynamic>>.from(trackClaimsClosedList); List<Map<String, dynamic>>.from(trackClaimsClosedList);
trackClaimsClosedList = reversedClaimsClosedList.reversed.toList(); trackClaimsClosedList = reversedClaimsClosedList.reversed.toList();
}); });
} else if (response['success'] == true && // } else if (response['success'] == true &&
response['data'] == "User Not Found") { // response['data'] == "User Not Found") {
setState(() { // setState(() {
trackClaimsList = []; // trackClaimsList = [];
trackClaimsClosedList = []; // trackClaimsClosedList = [];
}); // });
} else { // } else {
ToastHelper.showErrorToast(context, 'Something went wrong'); // ToastHelper.showErrorToast(context, 'Something went wrong');
print('API request failed with status: ${response['status']}'); // print('API request failed with status: ${response['status']}');
} // }
} }
Color getStatusColor(String? policyStatus) { Color getStatusColor(String? policyStatus) {
@ -869,20 +868,30 @@ class _helpState extends State<help> {
itemCount: data.length, itemCount: data.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
var item = data[index]; var item = data[index];
String claimsName = item['user_name'];
String claimsDate = item['date']; // String claimsName = item['user_name'];
String claimsSubject = item['subject']; String claimsSubject = item['subject'] ?? '';
String claimsReplies = item['replies']; String claimsDate = item['created_at'] ?? '';
String claimStatus = item['status_value']; String claimStatus = item['claim_status'] ?? '';
String claimsDepartmentName = item['department_name']; String claimsDepartmentName = item['ticket_policy_type'] ?? '';
List<dynamic> messageList = item['message_list']; // String claimsReplies = item['replies'];
// List<dynamic> messageList = item['message_list'];
print('generateTrackList');
print(claimsSubject);
print(claimsDate);
print(claimStatus);
print(claimsDepartmentName);
final Map<String, Color> statusColors = { final Map<String, Color> statusColors = {
'Open': Colors.green, 'Received': Colors.amber,
'Answered': Colors.blue, 'Rejected': Colors.red,
'Awaiting Reply': Colors.orange, 'Cancelled': Colors.red,
'Inprogress': Colors.yellow, 'Returned': Colors.deepOrange,
'Closed': Colors.red, 'Closed': Colors.grey,
'Approved': Colors.green,
'Settled': Colors.lightBlueAccent,
'Under Process': Colors.brown,
}; };
// Determine the color based on the claimStatus // Determine the color based on the claimStatus
@ -956,24 +965,26 @@ class _helpState extends State<help> {
), ),
SizedBox(height: 5), SizedBox(height: 5),
Container( Container(
width: alignment: Alignment
150, // Set a fixed width or adjust based on your layout .centerLeft, // Set a fixed width or adjust based on your layout
child: Text( child: Tooltip(
claimsSubject, message: claimsSubject,
textAlign: TextAlign.left, child: Text(
style: GoogleFonts.poppins( claimsSubject.length > 30
fontSize: ? '${claimsSubject.substring(0, 30)}...'
Responsive.isDesktop(context) : claimsSubject,
? 14 textAlign: TextAlign.left,
: 12, style: GoogleFonts.poppins(
fontWeight: FontWeight.w400, fontSize:
color: Color(0xFF777777), Responsive.isDesktop(
), context)
overflow: TextOverflow ? 14
.ellipsis, // Show ellipsis when text overflows : 12,
maxLines: 1, // Limit to one line fontWeight: FontWeight.w400,
), color: Color(0xFF777777),
) ),
),
))
], ],
)) ))
], ],
@ -1054,20 +1065,23 @@ class _helpState extends State<help> {
itemCount: data.length, itemCount: data.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
var item = data[index]; var item = data[index];
String claimsName = item['user_name']; // String claimsName = item['user_name'];
String claimsDate = item['date']; String claimsSubject = item['subject'] ?? '';
String claimsSubject = item['subject']; String claimsDate = item['created_at'] ?? '';
String claimsReplies = item['replies']; String claimStatus = item['claim_status'] ?? '';
String claimStatus = item['status_value']; String claimsDepartmentName = item['ticket_policy_type'] ?? '';
String claimsDepartmentName = item['department_name']; // String claimsReplies = item['replies'];
List<dynamic> messageList = item['message_list']; // List<dynamic> messageList = item['message_list'];
final Map<String, Color> statusColors = { final Map<String, Color> statusColors = {
'Open': Colors.green, 'Received': Colors.amber,
'Answered': Colors.blue, 'Rejected': Colors.red,
'Awaiting Reply': Colors.orange, 'Cancelled': Colors.red,
'Inprogress': Colors.yellow, 'Returned': Colors.deepOrange,
'Closed': Colors.red, 'Closed': Colors.grey,
'Approved': Colors.green,
'Settled': Colors.lightBlueAccent,
'Under Process': Colors.brown,
}; };
// Determine the color based on the claimStatus // Determine the color based on the claimStatus
@ -1140,18 +1154,23 @@ class _helpState extends State<help> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
Text( Tooltip(
claimsSubject, message: claimsSubject,
textAlign: TextAlign.left, child: Text(
style: GoogleFonts.poppins( claimsSubject.length > 30
fontSize: ? '${claimsSubject.substring(0, 30)}...'
Responsive.isDesktop(context) : claimsSubject,
? 14 textAlign: TextAlign.left,
: 12, style: GoogleFonts.poppins(
fontWeight: FontWeight.w400, fontSize:
color: Color(0xFF777777), Responsive.isDesktop(context)
), // Ensure text automatically wraps ? 14
), : 12,
fontWeight: FontWeight.w400,
color: Color(0xFF777777),
),
),
)
], ],
)) ))
], ],
@ -1224,11 +1243,8 @@ class _helpState extends State<help> {
} }
String formatDateWithTime(String timestamp) { String formatDateWithTime(String timestamp) {
// Convert the timestamp string to milliseconds // Parse the timestamp string to DateTime
int milliseconds = int.parse(timestamp) * 1000; DateTime date = DateTime.parse(timestamp);
// Create a DateTime object from milliseconds
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
// Format the DateTime object with date and time // Format the DateTime object with date and time
String formattedDate = DateFormat('d MMM, y HH:mm a').format(date); String formattedDate = DateFormat('d MMM, y HH:mm a').format(date);

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_image_slideshow/flutter_image_slideshow.dart'; import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
@ -8,11 +10,14 @@ import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart'; import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:webview_flutter/webview_flutter.dart';
import '../../customAppBar/customFooter.dart'; import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart'; import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart'; import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart'; import '../../customAppBar/toastHelper.dart';
import 'chatbot.dart'; import 'chatbot.dart';
import 'dart:html' as html;
import 'dart:js' as js;
class Home extends StatefulWidget { class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key); const Home({Key? key}) : super(key: key);
@ -40,6 +45,8 @@ class _HomeState extends State<Home> {
List<String> advertisementImages = []; List<String> advertisementImages = [];
bool isLoading = true; bool isLoading = true;
dynamic policyCount; dynamic policyCount;
bool isTokenAvailable = false; // Default: button disabled
late WebViewController _controller;
void _onTabChanged(int index) { void _onTabChanged(int index) {
setState(() { setState(() {
@ -52,6 +59,10 @@ class _HomeState extends State<Home> {
super.initState(); super.initState();
apiService = ApiService(context); // Initialize ApiService here apiService = ApiService(context); // Initialize ApiService here
_loadToken(); _loadToken();
checkEnrollToken();
// openChat();
// _injectBotmanScript();
// openBotmanChat();
} }
@override @override
@ -59,6 +70,36 @@ class _HomeState extends State<Home> {
super.dispose(); super.dispose();
} }
// void _injectBotmanScript() {
// final script = html.ScriptElement()..innerHtml = "initializeBotman();";
// html.document.body?.append(script);
// }
// void openBotmanChat() {
// html.window.console.log("Opening Botman Chat...");
// // html.window.callMethod('showBotmanChat');
// final script = html.ScriptElement()..innerHtml = "showBotmanChat();";
// html.document.body?.append(script);
// }
void openChat() {
js.context.callMethod('openBotmanChat'); // Correct way to call JS function
}
Future<void> checkEnrollToken() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
isTokenAvailable = prefs.getString('enrollToken') != null;
});
}
// void _loadChatbot() async {
// String chatbotHtml = await DefaultAssetBundle.of(context)
// .loadString("assets/botman_chat.html");
// _controller.loadUrl(Uri.dataFromString(chatbotHtml,
// mimeType: 'text/html', encoding: Encoding.getByName('utf-8'))
// .toString());
// }
Future<void> _loadToken() async { Future<void> _loadToken() async {
print('_loadToken'); print('_loadToken');
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
@ -273,9 +314,12 @@ class _HomeState extends State<Home> {
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: isTokenAvailable
Navigator.pushNamed(context, 'empDetails'); ? () {
}, Navigator.pushNamed(
context, 'empDetails');
}
: null,
child: Text('View Details'), child: Text('View Details'),
), ),
], ],
@ -630,12 +674,13 @@ class _HomeState extends State<Home> {
), ),
), ),
]), ]),
floatingActionButton: Responsive.isDesktop(context) // floatingActionButton: Responsive.isDesktop(context)
? null // ? null
: FloatingActionButton( // : FloatingActionButton(
onPressed: () => push(chatbot()), // onPressed: () => push(chatbot()),
child: Icon(Icons.chat), // // onPressed: openChat,
), // child: Icon(Icons.chat),
// ),
floatingActionButtonLocation: Responsive.isDesktop(context) floatingActionButtonLocation: Responsive.isDesktop(context)
? null ? null
: FloatingActionButtonLocation.miniEndFloat, : FloatingActionButtonLocation.miniEndFloat,
@ -644,7 +689,6 @@ class _HomeState extends State<Home> {
: CustomBottomNavigationBar( : CustomBottomNavigationBar(
onTabChanged: (index) { onTabChanged: (index) {
// Add your navigation logic here // Add your navigation logic here
// For example:
if (index == 0) { if (index == 0) {
Navigator.pushNamed(context, 'home'); Navigator.pushNamed(context, 'home');
} else if (index == 1) { } else if (index == 1) {

View File

@ -3,6 +3,7 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:jwt_decode/jwt_decode.dart'; import 'package:jwt_decode/jwt_decode.dart';
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart'; import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/claimtracklist.dart';
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart'; import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../../customAppBar/customFooter.dart'; import '../../customAppBar/customFooter.dart';
@ -44,8 +45,10 @@ class _planclaimsformState extends State<planclaimsform> {
String? selectedServiceName; String? selectedServiceName;
String? selectedPolicyNo; String? selectedPolicyNo;
dynamic claimsDepartmentId; dynamic claimsDepartmentId;
dynamic claimsPolicyNo;
dynamic client_branch_id; dynamic client_branch_id;
dynamic policyTypeCondition; dynamic policyTypeCondition;
dynamic client_policy_id;
dynamic selfDetails; dynamic selfDetails;
List<Map<String, dynamic>> employeePolicyList = []; List<Map<String, dynamic>> employeePolicyList = [];
@ -55,13 +58,22 @@ class _planclaimsformState extends State<planclaimsform> {
late TextEditingController accidentDetailsController; late TextEditingController accidentDetailsController;
late TextEditingController hospitalNameController; late TextEditingController hospitalNameController;
late TextEditingController claimAmountController; late TextEditingController claimAmountController;
late TextEditingController sumInsuredController;
late TextEditingController admitDateController; late TextEditingController admitDateController;
late TextEditingController dischargeDateController; late TextEditingController dischargeDateController;
DateTime? accidentDate; DateTime? accidentDate;
DateTime? deathDate;
DateTime? intimationDate;
DateTime? birthDate;
DateTime? admitDate; DateTime? admitDate;
DateTime? dischargeDate; DateTime? dischargeDate;
Map<String, DateTime?> selectedDates = {
"Accident Date": null,
"Date of Death": null,
};
List<Map<String, dynamic>> filteredPoliciesList = []; List<Map<String, dynamic>> filteredPoliciesList = [];
// Create a unique form key for each accordion section // Create a unique form key for each accordion section
@ -75,6 +87,7 @@ class _planclaimsformState extends State<planclaimsform> {
accidentDetailsController = TextEditingController(); accidentDetailsController = TextEditingController();
hospitalNameController = TextEditingController(); hospitalNameController = TextEditingController();
claimAmountController = TextEditingController(); claimAmountController = TextEditingController();
sumInsuredController = TextEditingController();
admitDateController = TextEditingController(); admitDateController = TextEditingController();
dischargeDateController = TextEditingController(); dischargeDateController = TextEditingController();
apiService = ApiService(context); // Initialize ApiService here apiService = ApiService(context); // Initialize ApiService here
@ -93,6 +106,7 @@ class _planclaimsformState extends State<planclaimsform> {
accidentDetailsController.dispose(); accidentDetailsController.dispose();
hospitalNameController.dispose(); hospitalNameController.dispose();
claimAmountController.dispose(); claimAmountController.dispose();
sumInsuredController.dispose();
admitDateController.dispose(); admitDateController.dispose();
dischargeDateController.dispose(); dischargeDateController.dispose();
super.dispose(); super.dispose();
@ -113,9 +127,10 @@ class _planclaimsformState extends State<planclaimsform> {
print('fromClaimsPage $fromClaimsPage'); print('fromClaimsPage $fromClaimsPage');
} }
if (fromClaimsPage == 0) { if (fromClaimsPage == 0) {
claimsDepartmentId = claimsDetails['department_id']; claimsDepartmentId = claimsDetails['ticket_type_id'];
print('claimsDepartmentId $claimsDepartmentId'); print('claimsDepartmentId $claimsDepartmentId');
claimsPolicyNo = claimsDetails['policy_no'];
client_policy_id = claimsDetails['client_policy_id'];
// employeePolicyList = claimsDetails['EmployeePolicy']; // employeePolicyList = claimsDetails['EmployeePolicy'];
// print('employeePolicyList : $employeePolicyList'); // print('employeePolicyList : $employeePolicyList');
List<dynamic> empList = claimsDetails['EmployeePolicy']; List<dynamic> empList = claimsDetails['EmployeePolicy'];
@ -129,9 +144,9 @@ class _planclaimsformState extends State<planclaimsform> {
print('employeePolicyList : $employeePolicyList'); print('employeePolicyList : $employeePolicyList');
}); });
// if (claimsDetails['department_id'] == 3 || // if (claimsDetails['ticket_type_id'] == 3 ||
// claimsDetails['department_id'] == 4) { // claimsDetails['ticket_type_id'] == 4) {
policyTypeCondition = claimsDetails['department_id']; policyTypeCondition = claimsDetails['ticket_type_id'];
// } else { // } else {
// String policyType = claimsDetails['policy_type']; // String policyType = claimsDetails['policy_type'];
// policyTypeCondition = policyType.split('-')[0].trim(); // policyTypeCondition = policyType.split('-')[0].trim();
@ -194,6 +209,10 @@ class _planclaimsformState extends State<planclaimsform> {
policyList = List<Map<String, dynamic>>.from(response['data']); policyList = List<Map<String, dynamic>>.from(response['data']);
}); });
print(policyList); print(policyList);
if (fromClaimsPage == 0) {
print('fromClaimsPage == 0');
fetchPoliciesBasedOnService(claimsDepartmentId);
}
} else { } else {
setState(() { setState(() {
policyDataIsEmpty = 0; policyDataIsEmpty = 0;
@ -234,14 +253,16 @@ class _planclaimsformState extends State<planclaimsform> {
}); });
try { try {
final response = await apiService.fetchDepartmentList(); final response = await apiService.fetchDepartmentList();
if (response['departments'] != null) { print(response);
List<dynamic> departments = response['departments']; if (response['ticket_type'] != null) {
print(response['ticket_type']);
List<dynamic> departments = response['ticket_type'];
setState(() { setState(() {
departmentList = departments.map((department) { departmentList = departments.map((department) {
return { return {
'id': int.parse(department['id']), 'id': department['id'],
'name': department['name'], 'name': department['name'],
'private': department['private'], // 'private': department['private'],
}; };
}).toList(); }).toList();
isLoading = false; isLoading = false;
@ -265,18 +286,19 @@ class _planclaimsformState extends State<planclaimsform> {
setState(() { setState(() {
policyNumberId = null; policyNumberId = null;
policyTypeCondition = null; policyTypeCondition = null;
client_policy_id = null;
}); });
print('1111 serviceId : $serviceId'); print('1111 serviceId : $serviceId');
if (serviceId == 3 || serviceId == 4) { if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4) {
print('2222'); print('2222');
// Filter policies based on the department_id // Filter policies based on the ticket_type_id
List<Map<String, dynamic>> filteredPolicies = policyList.where((policy) { List<Map<String, dynamic>> filteredPolicies = policyList.where((policy) {
return policy['department_id'] == serviceId; return policy['ticket_type_id'] == serviceId;
}).toList(); }).toList();
print('Filtered matching policies: $filteredPolicies'); print('Filtered matching policies: $filteredPolicies');
// if (filteredPolicies[0]['department_id'] == 3 || // if (filteredPolicies[0]['ticket_type_id'] == 3 ||
// filteredPolicies[0]['department_id'] == 4) { // filteredPolicies[0]['ticket_type_id'] == 4) {
setState(() { setState(() {
// Ensure unique IDs for dropdown values // Ensure unique IDs for dropdown values
policyNumberList = filteredPolicies.asMap().entries.map((entry) { policyNumberList = filteredPolicies.asMap().entries.map((entry) {
@ -293,34 +315,52 @@ class _planclaimsformState extends State<planclaimsform> {
print('policyNumberList : $policyNumberList'); print('policyNumberList : $policyNumberList');
policyTypeCondition = filteredPolicies[0]['department_id']; if (fromClaimsPage == 0) {
// Find the object where 'policy_no' matches 'claimsPolicyNo'
final matchingPolicy = policyNumberList.firstWhere(
(item) => item['policy_no'] == claimsPolicyNo,
orElse: () => {});
// Set policyNumberId to the matching policy's ID
if (matchingPolicy.isNotEmpty) {
policyNumberId = matchingPolicy['id'];
}
}
policyTypeCondition = filteredPolicies[0]['ticket_type_id'];
// client_policy_id = filteredPolicies[0]['client_policy_id'];
print('Output : $policyTypeCondition'); // Output: GMC print('Output : $policyTypeCondition'); // Output: GMC
}); });
} else if (serviceId == 2) {
setState(() {
// Ensure unique IDs for dropdown values
policyNumberList = policyList.asMap().entries.map((entry) {
final index = entry.key;
final policy = entry.value;
// Assign unique ID
return {
'policy_no': policy['policy_no'],
'policy_name': policy['policy_name'],
'id': index + 1 // Use index + 1 as a unique ID
};
}).toList();
print('policyNumberList : $policyNumberList');
policyTypeCondition = serviceId;
print('Output : $policyTypeCondition');
});
} else { } else {
setState(() { setState(() {
policyTypeCondition = null; policyTypeCondition = null;
}); });
} }
// else if (serviceId == 2) {
// setState(() {
// // Ensure unique IDs for dropdown values
// policyNumberList = policyList.asMap().entries.map((entry) {
// final index = entry.key;
// final policy = entry.value;
//
// // Assign unique ID
// return {
// 'policy_no': policy['policy_no'],
// 'policy_name': policy['policy_name'],
// 'id': index + 1 // Use index + 1 as a unique ID
// };
// }).toList();
//
// print('policyNumberList : $policyNumberList');
//
// policyTypeCondition = serviceId;
// print('Output : $policyTypeCondition');
// });
// } else {
// setState(() {
// policyTypeCondition = null;
// });
// }
} }
void fetchMemberBasedOnPolicy(selectedPolicyNo) { void fetchMemberBasedOnPolicy(selectedPolicyNo) {
@ -329,8 +369,8 @@ class _planclaimsformState extends State<planclaimsform> {
return; return;
} }
if (serviceId == 3 || serviceId == 4) { if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4) {
// Filter policies based on the department_id // Filter policies based on the ticket_type_id
print('policyNumberId : $policyNumberId'); print('policyNumberId : $policyNumberId');
filteredPoliciesList = policyList.where((policy) { filteredPoliciesList = policyList.where((policy) {
@ -339,6 +379,8 @@ class _planclaimsformState extends State<planclaimsform> {
print('Filtered matching policy_no: $filteredPoliciesList'); print('Filtered matching policy_no: $filteredPoliciesList');
client_policy_id = filteredPoliciesList[0]['client_policy_id'];
if (filteredPoliciesList.isNotEmpty) { if (filteredPoliciesList.isNotEmpty) {
// Assuming you need to access the first matched policy // Assuming you need to access the first matched policy
Map<String, dynamic> firstPolicy = filteredPoliciesList.first; Map<String, dynamic> firstPolicy = filteredPoliciesList.first;
@ -369,29 +411,35 @@ class _planclaimsformState extends State<planclaimsform> {
employeePolicyList = []; // Clear the list or handle it as needed employeePolicyList = []; // Clear the list or handle it as needed
}); });
} }
} else if (serviceId == 2) {
filteredPoliciesList = policyList.where((policy) {
return policy['policy_no'] == selectedPolicyNo;
}).toList();
print('Filtered matching policy_no: $filteredPoliciesList');
} }
// else if (serviceId == 2) {
// filteredPoliciesList = policyList.where((policy) {
// return policy['policy_no'] == selectedPolicyNo;
// }).toList();
//
// print('Filtered matching policy_no: $filteredPoliciesList');
// }
} }
Future<void> sendFormDataToApi() async { Future<void> sendFormDataToApi() async {
setState(() { setState(() {
isLoading = true; isLoading = true;
}); });
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? emp_id = prefs.getString('empPrimaryId');
// print('Check One'); // print('Check One');
// print(employeePolicyList[0]['name']); // print(employeePolicyList[0]['name']);
// print('Help $filteredPoliciesList'); // print('Help $filteredPoliciesList');
try { try {
print('Check One'); print('Check One');
Map<String, dynamic> formData = { Map<String, dynamic> formData = {
'opener': 'user', // 'opener': 'user',
'department_id': serviceId, 'emp_id': emp_id,
'client_policy_id': client_policy_id,
'ticket_type_id': serviceId,
'subject': subjectController.text, 'subject': subjectController.text,
'body': messageController.text, 'message': messageController.text,
// 'policy_id': fromClaimsPage == 0 // 'policy_id': fromClaimsPage == 0
// ? claimsDetails['client_policy_id'] // ? claimsDetails['client_policy_id']
// : policyNumberId, // : policyNumberId,
@ -412,38 +460,56 @@ class _planclaimsformState extends State<planclaimsform> {
: (fromClaimsPage == 0 : (fromClaimsPage == 0
? claimsDetails['policy_name'] ? claimsDetails['policy_name']
: filteredPoliciesList[0]['policy_name']), : filteredPoliciesList[0]['policy_name']),
'tpa': serviceId == 1 // 'tpa': serviceId == 1
? null // ? null
: (fromClaimsPage == 0 // : (fromClaimsPage == 0
? claimsDetails['tpa_name'] // ? claimsDetails['tpa_name']
: filteredPoliciesList[0]['tpa_name']), // : filteredPoliciesList[0]['tpa_name']),
'insurer': serviceId == 1 // 'insurer': serviceId == 1
? null // ? null
: (fromClaimsPage == 0 // : (fromClaimsPage == 0
? claimsDetails['insurer_name'] // ? claimsDetails['insurer_name']
: filteredPoliciesList[0]['insurer_name']), // : filteredPoliciesList[0]['insurer_name']),
}; };
// Conditionally add fields based on the first word in policy_type // Conditionally add fields based on the first word in policy_type
if (policyTypeCondition == 3) { // if (policyTypeCondition == 3) {
// String formattedAccidentDate =
// DateFormat('yyyy-MM-dd').format(accidentDate!);
// // formData['accident_details'] = accidentDetailsController.text;
// formData['accident_details'] = messageController.text;
// formData['accident_date'] = formattedAccidentDate;
// formData['claim_amount'] = claimAmountController.text;
// formData['policyholder_name'] = employeePolicyList[0]['name'];
// formData['member_name'] = selectedMemberName;
// formData['emp_policy_id'] = selectedMemberId;
// } else
if (policyTypeCondition == 1) {
formData['hospital_name'] = hospitalNameController.text;
formData['doa'] = admitDateController.text;
formData['dod'] = dischargeDateController.text;
formData['claim_amount'] = claimAmountController.text;
formData['policyholder_name'] = employeePolicyList[0]['name'];
formData['member_name'] = selectedMemberName;
formData['insured_emp_id'] = selectedMemberId;
} else {
String formattedAccidentDate = String formattedAccidentDate =
DateFormat('yyyy-MM-dd').format(accidentDate!); DateFormat('yyyy-MM-dd').format(accidentDate!);
String formattedDeathDate = DateFormat('yyyy-MM-dd').format(deathDate!);
String formattedBirthDate = DateFormat('yyyy-MM-dd').format(birthDate!);
String formattedIntimationDate =
DateFormat('yyyy-MM-dd').format(intimationDate!);
// formData['accident_details'] = accidentDetailsController.text; // formData['accident_details'] = accidentDetailsController.text;
formData['accident_details'] = messageController.text; // formData['accident_details'] = messageController.text;
formData['accident_date'] = formattedAccidentDate; formData['date_of_accident'] = formattedAccidentDate;
formData['claim_amount'] = claimAmountController.text; formData['dob'] = formattedBirthDate;
formData['date_of_intimat'] = formattedIntimationDate;
formData['date_of_death'] = formattedDeathDate;
formData['si_amt'] = sumInsuredController.text;
formData['policyholder_name'] = employeePolicyList[0]['name']; formData['policyholder_name'] = employeePolicyList[0]['name'];
formData['member_name'] = selectedMemberName; formData['member_name'] = selectedMemberName;
formData['emp_policy_id'] = selectedMemberId; formData['insured_emp_id'] = selectedMemberId;
} else if (policyTypeCondition == 4) {
formData['hospital_name'] = hospitalNameController.text;
formData['admit_date'] = admitDateController.text;
formData['discharge_date'] = dischargeDateController.text;
formData['claim_amount'] = claimAmountController.text;
formData['policyholder_name'] = employeePolicyList[0]['name'];
formData['member_name'] = selectedMemberName;
formData['emp_policy_id'] = selectedMemberId;
} }
// Convert integer values to strings // Convert integer values to strings
@ -451,7 +517,7 @@ class _planclaimsformState extends State<planclaimsform> {
final response = await apiService.sendFormDataToApi(formData); final response = await apiService.sendFormDataToApi(formData);
if (response['success'] == 1) { if (response['status'] == true) {
ToastHelper.showSuccessToast(context, response['message']); ToastHelper.showSuccessToast(context, response['message']);
serviceId = null; serviceId = null;
departmentList.clear(); departmentList.clear();
@ -468,16 +534,17 @@ class _planclaimsformState extends State<planclaimsform> {
} }
} }
Future<void> _pickAccidentDate(BuildContext context) async { Future<void> _pickDate(BuildContext context, String label) async {
final DateTime? pickedDate = await showDatePicker( final DateTime? pickedDate = await showDatePicker(
context: context, context: context,
initialDate: accidentDate ?? DateTime.now(), initialDate: selectedDates[label] ?? DateTime.now(),
firstDate: DateTime(2000), firstDate: DateTime(2000),
lastDate: DateTime.now(), lastDate: DateTime.now(),
); );
if (pickedDate != null && pickedDate != accidentDate) {
if (pickedDate != null && pickedDate != selectedDates[label]) {
setState(() { setState(() {
accidentDate = pickedDate; selectedDates[label] = pickedDate;
}); });
} }
} }
@ -683,7 +750,6 @@ class _planclaimsformState extends State<planclaimsform> {
null; null;
if (fromClaimsPage == if (fromClaimsPage ==
1) { 1) {
// Reset policy number selection
fetchPoliciesBasedOnService( fetchPoliciesBasedOnService(
serviceId); serviceId);
} }
@ -695,79 +761,70 @@ class _planclaimsformState extends State<planclaimsform> {
serviceId, // Pass current serviceId as selectedValue serviceId, // Pass current serviceId as selectedValue
), ),
SizedBox(height: 15), SizedBox(height: 15),
if (fromClaimsPage == 1 && // if (fromClaimsPage == 1)
(serviceId == 3 || buildDropdownField(
serviceId == 4 || 'Select Policy',
serviceId == 2)) (value) {
buildDropdownField( setState(() {
'Select Policy', policyNumberId =
(value) { value;
setState(() { selectedMemberId =
policyNumberId = null;
value; String?
selectedMemberId = selectedPolicyNo =
null; policyNumberList
String? .firstWhere(
selectedPolicyNo = (item) =>
policyNumberList.firstWhere( item['id'] ==
(item) => value,
item[ orElse: () =>
'id'] == {
value, 'policy_no': ''
orElse: () => })['policy_no'];
{
'policy_no':
''
})['policy_no'];
if (selectedPolicyNo != if (selectedPolicyNo !=
null && null &&
fromClaimsPage == fromClaimsPage ==
1) { 1) {
fetchMemberBasedOnPolicy( fetchMemberBasedOnPolicy(
selectedPolicyNo); selectedPolicyNo);
} }
}); });
}, },
fromClaimsPage == 0, fromClaimsPage == 0,
policyNumberList, policyNumberList,
'policy_no', 'policy_no',
policyNumberId, // Pass current policyNumberId as selectedValue policyNumberId, // Pass current policyNumberId as selectedValue
), ),
SizedBox(height: 15), SizedBox(height: 15),
if (serviceId == 3 || buildDropdownField(
serviceId == 4) 'Member Name',
buildDropdownField( (value) {
'Member Name', setState(() {
(value) { selectedMemberId =
setState(() { value;
selectedMemberId = selectedMemberName =
value; employeePolicyList
selectedMemberName = .firstWhere(
employeePolicyList (member) =>
.firstWhere( member[
(member) => 'id'] ==
member[ value,
'id'] == orElse: () =>
value, {'name': ''},
orElse: () => { )['name'];
'name': '' });
}, },
)['name']; false,
}); employeePolicyList,
}, 'name',
false, selectedMemberId, // Pass current selectedMemberId as selectedValue
employeePolicyList, ),
'name',
selectedMemberId, // Pass current selectedMemberId as selectedValue
),
buildTextField('Subject', buildTextField('Subject',
subjectController), subjectController),
SizedBox(height: 15), SizedBox(height: 15),
buildTextAreaField( buildTextAreaField(
serviceId == 3 'Message',
? 'Accident Details'
: 'Message',
messageController), messageController),
SizedBox(height: 15), SizedBox(height: 15),
// if (policyTypeCondition == // if (policyTypeCondition ==
@ -777,13 +834,29 @@ class _planclaimsformState extends State<planclaimsform> {
// accidentDetailsController), // accidentDetailsController),
SizedBox(height: 15), SizedBox(height: 15),
if (policyTypeCondition == if (policyTypeCondition ==
4) 1)
buildTextField( buildTextField(
'Hospital Name', 'Hospital Name',
hospitalNameController), hospitalNameController),
SizedBox(height: 15), SizedBox(height: 15),
if (policyTypeCondition == if (serviceId == 2 ||
3) serviceId == 3 ||
serviceId == 4) ...[
buildDatePickerField(
label:
'Date of Birth',
selectedDate:
birthDate,
allowFuture: false,
onDateSelected:
(selectedDate) {
setState(() {
birthDate =
selectedDate;
});
},
),
SizedBox(height: 15),
buildDatePickerField( buildDatePickerField(
label: label:
'Accident Date', 'Accident Date',
@ -798,13 +871,44 @@ class _planclaimsformState extends State<planclaimsform> {
}); });
}, },
), ),
SizedBox(height: 15),
buildDatePickerField(
label:
'Date of Death',
selectedDate:
deathDate,
allowFuture: false,
onDateSelected:
(selectedDate) {
setState(() {
deathDate =
selectedDate;
});
},
),
SizedBox(height: 15),
buildDatePickerField(
label:
'Date of Intimation',
selectedDate:
intimationDate,
allowFuture: false,
onDateSelected:
(selectedDate) {
setState(() {
intimationDate =
selectedDate;
});
},
),
],
SizedBox(height: 15), SizedBox(height: 15),
// buildTextAreaField( // buildTextAreaField(
// 'Accident Details', // 'Accident Details',
// accidentDetailsController), // accidentDetailsController),
// SizedBox(height: 15), // SizedBox(height: 15),
if (policyTypeCondition == if (policyTypeCondition ==
4) 1)
InkWell( InkWell(
onTap: () => onTap: () =>
_pickFromToDate( _pickFromToDate(
@ -831,14 +935,21 @@ class _planclaimsformState extends State<planclaimsform> {
), ),
), ),
SizedBox(height: 15), SizedBox(height: 15),
if (serviceId == 3 || if (serviceId == 1)
serviceId == 4)
buildTextField( buildTextField(
'Claim Amount', 'Claim Amount',
claimAmountController, claimAmountController,
TextInputType.number, TextInputType.number,
), ),
SizedBox(height: 15), SizedBox(height: 15),
if (serviceId == 2 ||
serviceId == 3 ||
serviceId == 4)
buildTextField(
'Sum Insured',
sumInsuredController,
TextInputType.number,
),
], ],
), ),
), ),
@ -993,8 +1104,19 @@ class _planclaimsformState extends State<planclaimsform> {
required ValueChanged<DateTime?> onDateSelected, required ValueChanged<DateTime?> onDateSelected,
}) { }) {
return InkWell( return InkWell(
onTap: () { onTap: () async {
_pickAccidentDate(context); final DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: label == "Date of Intimation"
? DateTime.now() // Set current date only for "Date of Intimation"
: (selectedDate ?? DateTime.now()),
firstDate: DateTime(2000),
lastDate: allowFuture ? DateTime(2100) : DateTime.now(),
);
if (pickedDate != null) {
onDateSelected(pickedDate);
}
}, },
child: InputDecorator( child: InputDecorator(
decoration: InputDecoration( decoration: InputDecoration(

View File

@ -15,6 +15,7 @@ import '../../models/platform_helper_mobile.dart'
if (dart.library.html) '../../models/platform_helper_other.dart'; if (dart.library.html) '../../models/platform_helper_other.dart';
import '../session/authenticationService.dart'; import '../session/authenticationService.dart';
import 'dart:html' as html;
class profile extends StatefulWidget { class profile extends StatefulWidget {
const profile({Key? key}) : super(key: key); const profile({Key? key}) : super(key: key);
@ -158,7 +159,7 @@ class _profileState extends State<profile> {
// Clear all keys // Clear all keys
await prefs.clear(); await prefs.clear();
html.window.localStorage.clear();
// Re-set the mobile_number key // Re-set the mobile_number key
if (mobileNumber != null) { if (mobileNumber != null) {
await prefs.setString('empMobileNo', mobileNumber); await prefs.setString('empMobileNo', mobileNumber);

View File

@ -74,33 +74,46 @@ class ApiService {
return response; return response;
} }
Future<Map<String, dynamic>> getTrackClaimsList( Future<Map<String, dynamic>> getTrackClaimsList(String empPrimaryId) async {
String empMobileNo, String empCode) async { print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse( final url = Uri.parse(
'${Environment.apiUrlTicket}/ticket/get_ticket_data?emp_code=$empCode&mobile_number=$empMobileNo'); '${Environment.apiUrlTicket}/get_ticket_data?emp_id=$empPrimaryId');
final response = await _makeGetRequest(url, { final headers = {
'Token': Environment.ticketToken, 'Authorization': 'Bearer $_token' ?? '',
}); };
final response = await _makeGetRequest(url, headers);
return response; return response;
} }
Future<Map<String, dynamic>> fetchDepartmentList() async { Future<Map<String, dynamic>> fetchDepartmentList() async {
final url = Uri.parse('${Environment.apiUrlTicket}/departments'); print(_token);
final response = await _makeGetRequest(url, { if (_token == null) {
'Token': Environment.ticketToken, await _initializeToken();
}); }
final url = Uri.parse('${Environment.apiUrlTicket}/get_ticket_type');
final headers = {
'Authorization': 'Bearer $_token' ?? '',
};
final response = await _makeGetRequest(url, headers);
return response; return response;
} }
Future<Map<String, dynamic>> sendFormDataToApi( Future<Map<String, dynamic>> sendFormDataToApi(
Map<String, dynamic> formData) async { Map<String, dynamic> formData) async {
final url = Uri.parse('${Environment.apiUrlTicket}/tickets/create'); print(_token);
if (_token == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrlTicket}/initiateClaim');
// Convert formData to Map<String, String> // Convert formData to Map<String, String>
Map<String, String> stringFormData = Map<String, String> stringFormData =
formData.map((key, value) => MapEntry(key, value.toString())); formData.map((key, value) => MapEntry(key, value.toString()));
final response = await _makePostRequest(url, stringFormData, { final response = await _makePostRequest(url, stringFormData, {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
'Token': Environment.ticketToken, 'Authorization': 'Bearer $_token' ?? '',
}); });
return response; return response;
} }

View File

@ -7,6 +7,7 @@ import 'package:pinput/pinput.dart';
import 'dart:async'; import 'dart:async';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'dart:html' as html;
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -244,7 +245,21 @@ class _MyVerifyState extends State<MyVerify> {
prefs.setString('client_id', client_id); prefs.setString('client_id', client_id);
emp_status = decodedToken['emp_status']; emp_status = decodedToken['emp_status'];
prefs.setString('emp_status', emp_status); prefs.setString('emp_status', emp_status);
getClientLogoAndDetails(); // getClientLogoAndDetails();
html.window.localStorage['gpaEmpName'] = gpaEmpName;
html.window.localStorage['empPrimaryId'] = empPrimaryId;
html.window.localStorage['empCode'] = empCodeString;
html.window.localStorage['client_id'] = client_id;
html.window.localStorage['empClientBranchId'] = empClientBranchId;
// Dispatch a custom event with a message
// 🌟 Dispatch event to notify JavaScript
html.window.dispatchEvent(
html.CustomEvent('userLoggedIn', detail: {'status': 'success'}));
print("✅ User logged in! LocalStorage values set.");
print('Successfully Login'); print('Successfully Login');
@ -271,7 +286,7 @@ class _MyVerifyState extends State<MyVerify> {
prefs.setString('enrollmentClient_id', enrollmentClient_id); prefs.setString('enrollmentClient_id', enrollmentClient_id);
enrollmentEmp_status = decodedToken['emp_status']; enrollmentEmp_status = decodedToken['emp_status'];
prefs.setString('enrollmentEmp_status', enrollmentEmp_status); prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
// getClientLogoAndDetails(); getClientLogoAndDetails();
} }
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
@ -390,8 +405,9 @@ class _MyVerifyState extends State<MyVerify> {
} }
Future<void> getClientLogoAndDetails() async { Future<void> getClientLogoAndDetails() async {
print('getClientLogoAndDetails');
var url = Uri.parse(Environment.apiUrl + var url = Uri.parse(Environment.apiUrl +
'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); 'getClientDetails?client_id=$enrollmentClient_id&emp_code=$enrollmentEmpCodeString&client_branch_id=$enrollmentEmpClientBranchId');
try { try {
var response = await http.get( var response = await http.get(
url, url,

View File

@ -15,6 +15,7 @@ import shared_preferences_foundation
import sqflite_darwin import sqflite_darwin
import url_launcher_macos import url_launcher_macos
import video_player_avfoundation import video_player_avfoundation
import webview_flutter_wkwebview
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
@ -27,4 +28,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin")) FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
} }

View File

@ -55,6 +55,9 @@ dependencies:
local_auth: ^2.2.0 local_auth: ^2.2.0
google_sign_in: ^6.2.1 google_sign_in: ^6.2.1
dio: ^5.7.0 dio: ^5.7.0
webview_flutter: ^4.10.0
webview_flutter_wkwebview: ^3.18.1
webview_flutter_android: ^4.3.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@ -86,6 +89,7 @@ flutter:
- .env.production - .env.production
- .env.test - .env.test
- .env.uat - .env.uat
- assets/botman_chat.html
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg

View File

@ -50,6 +50,7 @@
</style> </style>
<!-- This script adds the flutter initialization JS code --> <!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script> <script src="flutter.js" defer></script>
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
</head> </head>
<body style="overflow:hidden"> <body style="overflow:hidden">
<div id="loading_indicator" class="container overlay"> <div id="loading_indicator" class="container overlay">
@ -94,5 +95,64 @@
}); });
}; };
</script> </script>
</body>
<script>
function generateSessionId(length = 15) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let sessionId = '';
for (let i = 0; i < length; i++) {
sessionId += characters.charAt(Math.floor(Math.random() * characters.length));
}
return sessionId;
}
var emp_name = localStorage.getItem('gpaEmpName') || 'Guest';
var employee_id = localStorage.getItem('empPrimaryId') || '12288';
var emp_code = localStorage.getItem('empCode') || 'HTL-007';
var client_id = localStorage.getItem('client_id') || 159;
var client_branch_id = localStorage.getItem('empClientBranchId') || 125;
var session_id = generateSessionId(15);
console.log("Loading Botman Chat for:", emp_name, employee_id, emp_code, client_id, client_branch_id);
var botmanWidget = {
chatServer: 'https://appstage.nhanceindia.in/arena/crm/chat',
frameEndpoint: 'https://appstage.nhanceindia.in/arena/crm/widget',
title: "Ask ILA",
introMessage: "",
bubbleBackground: "#007bff",
mainColor: "#007bff",
placeholderText: "Type your message here...",
aboutText: "Insurance Assistant ILA",
enableAttachments: false,
parameters: {
employee_id: employee_id,
session_id: session_id,
origin: "mobile",
emp_code: emp_code,
client_id: client_id,
client_branch_id: client_branch_id
}
};
function openBotmanChat() {
console.log("Start 1");
var checkBotman = setInterval(function () {
console.log("Start 2");
if (typeof botmanChatWidget !== "undefined" && botmanChatWidget.open) {
console.log("Start 3");
clearInterval(checkBotman);
botmanChatWidget.open();
setTimeout(function () {
console.log("Start 4");
botmanChatWidget.sayAsBot('Hi ' + emp_name + ', This is ILA, your Insurance Assistant. Please choose the following options.');
}, 2000);
} else {
console.log("Waiting for Botman to initialize...");
}
}, 500);
}
</script>
</body>
</html> </html>