botman and enrollment
This commit is contained in:
parent
7d4d82042a
commit
92592bd057
10
.env
10
.env
@ -1,5 +1,7 @@
|
||||
API_URL=https://venbait.in/nhance/dev/employeeRest/
|
||||
TICKET_API_URL=https://venbait.in/nhance/helpdesk/dev/api
|
||||
API_URL=https://app.nhanceindia.in/zenith/employeeRest/
|
||||
#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
|
||||
BASE_HREF=/nhance/employee/dev/
|
||||
ENV=development
|
||||
BASE_HREF=/app/
|
||||
ENV=production
|
||||
@ -1,5 +1,7 @@
|
||||
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
|
||||
BASE_HREF=/app/
|
||||
ENV=production
|
||||
12
.env.test
12
.env.test
@ -1,5 +1,7 @@
|
||||
API_URL=https://app.nhanceindia.in/zenith/employeeRest/
|
||||
TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api
|
||||
ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
|
||||
BASE_HREF=/app/
|
||||
ENV=production
|
||||
API_URL=https://appstage.nhanceindia.in/arena/crm/employeeRest/
|
||||
#CHAT_BOT_URL=https://venbait.in/nhance/dev
|
||||
API_URL_Enrollment=https://appstage.nhanceindia.in/arena/enrolment/employeeRest/
|
||||
TICKET_API_URL=https://venbait.in/nhance/dev/api
|
||||
#ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
|
||||
BASE_HREF=/arena/app/
|
||||
ENV=uat
|
||||
12
.env.uat
12
.env.uat
@ -1,5 +1,7 @@
|
||||
API_URL=https://app.nhanceindia.in/zenith/employeeRest/
|
||||
TICKET_API_URL=https://app.nhanceindia.in/helpdesk/api
|
||||
ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
|
||||
BASE_HREF=/app/
|
||||
ENV=production
|
||||
API_URL=https://appstage.nhanceindia.in/arena/crm/employeeRest/
|
||||
#CHAT_BOT_URL=https://venbait.in/nhance/dev
|
||||
API_URL_Enrollment=https://appstage.nhanceindia.in/arena/enrolment/employeeRest/
|
||||
TICKET_API_URL=https://venbait.in/nhance/dev/api
|
||||
#ticketToken=3YTSia2mRoZ7A4zvBgkqbGPrCd6Ewp8IDOuyjXhVFsl1nxWNcQJ95MeUftKH
|
||||
BASE_HREF=/arena/app/
|
||||
ENV=uat
|
||||
66
assets/botman_chat.html
Normal file
66
assets/botman_chat.html
Normal 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>
|
||||
@ -10,7 +10,7 @@ class CustomFooter extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Copyright@ 2024 Nhance',
|
||||
'Copyright @ ${DateTime.now().year} Nhance',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600], // Text color
|
||||
|
||||
@ -19,6 +19,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
bool showBackToHR = true;
|
||||
bool hideInactiveStatus = true;
|
||||
dynamic empStatus;
|
||||
dynamic _postToken;
|
||||
bool isTokenAvailable = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -26,16 +28,27 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
getEmpStatus();
|
||||
}
|
||||
|
||||
Future<void> checkEnrollToken() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
isTokenAvailable = prefs.getString('enrollToken') != null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getEmpStatus() async {
|
||||
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 {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// final String? token = prefs.getString('token');
|
||||
//
|
||||
// if (token != null && token.isNotEmpty) {
|
||||
// if (_postToken != null && _postToken.isNotEmpty) {
|
||||
// await prefs.clear();
|
||||
// Navigator.pushNamed(context, 'login');
|
||||
// }
|
||||
@ -99,7 +112,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
),
|
||||
),
|
||||
// AdaptiveNavBar Column
|
||||
if (empStatus != 'enrolled')
|
||||
if (!isTokenAvailable)
|
||||
Expanded(
|
||||
flex: Responsive.isDesktop(context) ? 9 : 3,
|
||||
child: AdaptiveNavBar(
|
||||
@ -116,7 +129,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
// Navigator.pushNamed(context, 'oldPolicy');
|
||||
},
|
||||
),
|
||||
if (empStatus != 'enrolled')
|
||||
if (!isTokenAvailable)
|
||||
NavBarItem(
|
||||
text: "Logout",
|
||||
onTap: () async {
|
||||
@ -126,7 +139,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (empStatus == 'enrolled')
|
||||
// if (empStatus == 'enrolled')
|
||||
if (isTokenAvailable)
|
||||
Expanded(
|
||||
flex: Responsive.isDesktop(context) ? 9 : 3,
|
||||
child: AdaptiveNavBar(
|
||||
|
||||
@ -48,9 +48,7 @@ Future<void> main() async {
|
||||
appId: '1:1084115316849:android:963ff492c3d23ab06c6bd0',
|
||||
messagingSenderId: '1084115316849',
|
||||
projectId: 'nhance-ee8d1'));
|
||||
await dotenv.load(fileName: Environment.fileName);
|
||||
|
||||
// Load environment variables
|
||||
await dotenv.load(fileName: Environment.fileName);
|
||||
|
||||
runApp(MyApp());
|
||||
|
||||
@ -25,6 +25,10 @@ class Environment {
|
||||
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 {
|
||||
return dotenv.env['BASE_HREF'] ?? 'BASE_HREF not found!';
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
void verifyOTP(String otp) async {
|
||||
try {
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrl + 'getVerifiedUserData'),
|
||||
Uri.parse(Environment.apiUrlEnrollment + 'getVerifiedUserData'),
|
||||
body:
|
||||
json.encode({'email_id': widget.email, 'otp': _otpController.text}),
|
||||
headers: {
|
||||
@ -222,7 +222,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
prefs.setString('client_id', client_id);
|
||||
emp_status = decodedToken['emp_status'];
|
||||
prefs.setString('emp_status', emp_status);
|
||||
getClientLogoAndDetails();
|
||||
// getClientLogoAndDetails();
|
||||
|
||||
print('Successfully Login');
|
||||
|
||||
@ -249,7 +249,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
prefs.setString('enrollmentClient_id', enrollmentClient_id);
|
||||
enrollmentEmp_status = decodedToken['emp_status'];
|
||||
prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||
// getClientLogoAndDetails();
|
||||
getClientLogoAndDetails();
|
||||
}
|
||||
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@ -365,8 +365,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
}
|
||||
|
||||
Future<void> getClientLogoAndDetails() async {
|
||||
var url = Uri.parse(Environment.apiUrl +
|
||||
'getClientDetails?client_id=$client_id&emp_code=$empCodeString');
|
||||
var url = Uri.parse(Environment.apiUrlEnrollment +
|
||||
'getClientDetails?client_id=$enrollmentClient_id&emp_code=$enrollmentEmpCodeString&client_branch_id=$enrollmentEmpClientBranchId');
|
||||
try {
|
||||
var response = await http.get(
|
||||
url,
|
||||
|
||||
@ -146,9 +146,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
dynamic empRefId;
|
||||
dynamic enrollmentEmpClientBranchId;
|
||||
dynamic selfEmpStatus;
|
||||
dynamic gpaTotalAmt;
|
||||
dynamic gmcTotalAmt;
|
||||
List<Map<String, dynamic>> allDisclaimer =
|
||||
[]; // Declare this to store all disclaimers
|
||||
late List<bool> checkboxValues;
|
||||
bool isTokenAvailable = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -164,6 +167,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
});
|
||||
});
|
||||
checkboxValues = List<bool>.filled(allDisclaimer.length, false);
|
||||
getTokenStatus();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -174,6 +178,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> getTokenStatus() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
isTokenAvailable = prefs.getString('_postToken') != null;
|
||||
});
|
||||
}
|
||||
|
||||
void _sortDisclaimerByTypeOrder() {
|
||||
allDisclaimer.sort((a, b) {
|
||||
int indexA = typeOrder.indexOf(a['type']);
|
||||
@ -1371,7 +1382,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
),
|
||||
),
|
||||
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;
|
||||
}
|
||||
|
||||
double allTotalSum() {
|
||||
double total = 0.0; // Initialize to avoid unwanted accumulation
|
||||
if (gpaTotalAmt != null) total += gpaTotalAmt!;
|
||||
if (gmcTotalAmt != null) total += gmcTotalAmt!;
|
||||
return total;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) {
|
||||
@ -3736,6 +3755,215 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
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(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -4047,7 +4275,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
),
|
||||
),
|
||||
if (Responsive.isDesktop(context) ||
|
||||
(!Responsive.isDesktop(context) && selfEmpStatus != 'enrolled'))
|
||||
(!Responsive.isDesktop(context) && !isTokenAvailable))
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
@ -4058,7 +4286,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
]),
|
||||
floatingActionButton: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? FloatingActionButton(
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
@ -4069,12 +4297,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
: null,
|
||||
floatingActionButtonLocation: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? FloatingActionButtonLocation.miniEndFloat
|
||||
: null,
|
||||
bottomNavigationBar: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? CustomBottomNavigationBar(
|
||||
onTabChanged: (index) {
|
||||
// Add your navigation logic here
|
||||
@ -5232,4 +5460,175 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,6 +99,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
dynamic hrPrimaryId;
|
||||
dynamic empRefId;
|
||||
dynamic enrollmentEmpClientBranchId;
|
||||
bool isTokenAvailable = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -114,6 +115,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
isLoading = false;
|
||||
});
|
||||
});
|
||||
|
||||
getTokenStatus();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -124,6 +127,13 @@ class _empDetailsState extends State<empDetails> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> getTokenStatus() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
isTokenAvailable = prefs.getString('_postToken') != null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@ -815,7 +825,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
),
|
||||
),
|
||||
if (Responsive.isDesktop(context) ||
|
||||
(!Responsive.isDesktop(context) && selfEmpStatus != 'enrolled'))
|
||||
(!Responsive.isDesktop(context) && !isTokenAvailable))
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
@ -826,7 +836,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
]),
|
||||
floatingActionButton: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? FloatingActionButton(
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
@ -837,12 +847,12 @@ class _empDetailsState extends State<empDetails> {
|
||||
: null,
|
||||
floatingActionButtonLocation: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? FloatingActionButtonLocation.miniEndFloat
|
||||
: null,
|
||||
bottomNavigationBar: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? CustomBottomNavigationBar(
|
||||
onTabChanged: (index) {
|
||||
// For example:
|
||||
@ -2059,18 +2069,27 @@ class _empDetailsState extends State<empDetails> {
|
||||
print(item);
|
||||
setState(() {
|
||||
gmcPolicyName = item['Policy_Name'];
|
||||
print('gmcPolicyName $gmcPolicyName');
|
||||
gmcPolicyType = item['type'];
|
||||
print('gmcPolicyType $gmcPolicyType');
|
||||
gmcFloaterTextHeading = item['floter_text_heading'];
|
||||
print('gmcFloaterTextHeading $gmcFloaterTextHeading');
|
||||
gmcFloaterTextDescription = item['floter_text_description'];
|
||||
print('gmcFloaterTextDescription $gmcFloaterTextDescription');
|
||||
gmcNotes = item['notes'];
|
||||
print('gmcNotes $gmcNotes');
|
||||
gmcECardDownload = item['eCardDownload'];
|
||||
print('gmcECardDownload $gmcECardDownload');
|
||||
gmcGstValue = item['family_floaters_of_dependent_and_gst_value'];
|
||||
print('gmcGstValue $gmcGstValue');
|
||||
gmcSiPremiumValue =
|
||||
item['family_floaters_of_dependent_and_si_premium_value'];
|
||||
print('gmcSiPremiumValue $gmcSiPremiumValue');
|
||||
gmcTotalableValue = gmcGstValue + gmcSiPremiumValue;
|
||||
gmcIsValueValid = (gmcSiPremiumValue != 0 && gmcGstValue != 0);
|
||||
|
||||
gmcMappedFamilyFloaters = item['mapped_family_floaters'];
|
||||
print('gmcMappedFamilyFloaters $gmcMappedFamilyFloaters');
|
||||
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
||||
.where((element) => element['is_value_exist'] == true)
|
||||
.toList();
|
||||
@ -2085,6 +2104,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
}
|
||||
String intOpenForEnrollment = item['OpenForEnrollment'];
|
||||
gmcOpenForEnrollment = int.parse(intOpenForEnrollment);
|
||||
print('gmcOpenForEnrollment $gmcOpenForEnrollment');
|
||||
gmcTypeName = item['type'];
|
||||
});
|
||||
|
||||
|
||||
@ -160,6 +160,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
List<Map<String, dynamic>> allDisclaimer =
|
||||
[]; // Declare this to store all disclaimers
|
||||
late List<bool> checkboxValues;
|
||||
bool isTokenAvailable = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -172,6 +173,15 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
});
|
||||
});
|
||||
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
|
||||
@ -1039,7 +1049,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
),
|
||||
),
|
||||
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) ||
|
||||
(!Responsive.isDesktop(context) && selfEmpStatus != 'enrolled'))
|
||||
(!Responsive.isDesktop(context) && !isTokenAvailable))
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
@ -2720,7 +2731,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
]),
|
||||
floatingActionButton: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? FloatingActionButton(
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
@ -2731,12 +2742,12 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
: null,
|
||||
floatingActionButtonLocation: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? FloatingActionButtonLocation.miniEndFloat
|
||||
: null,
|
||||
bottomNavigationBar: Responsive.isDesktop(context)
|
||||
? null
|
||||
: selfEmpStatus == 'enrolled'
|
||||
: isTokenAvailable
|
||||
? CustomBottomNavigationBar(
|
||||
onTabChanged: (index) {
|
||||
// Add your navigation logic here
|
||||
|
||||
@ -496,21 +496,6 @@ class _loginState extends State<login> {
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
onTap: toggleField,
|
||||
child: Text(
|
||||
isEmailFieldVisible
|
||||
? "Login with Mobile No"
|
||||
: "Login with Email",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF00989E),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
isEmailFieldVisible
|
||||
? Container(
|
||||
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(
|
||||
|
||||
@ -133,48 +133,46 @@ class _claimsState extends State<claims> {
|
||||
return;
|
||||
}
|
||||
print('check 1');
|
||||
final response =
|
||||
await apiService.getTrackClaimsList(empMobileNo!, empCodeString!);
|
||||
final response = await apiService.getTrackClaimsList(empPrimaryId!);
|
||||
print('check 1');
|
||||
if (response['success'] == true) {
|
||||
setState(() {
|
||||
List<dynamic> data = response['data'];
|
||||
// if (response['success'] == true) {
|
||||
setState(() {
|
||||
List<dynamic> data = response['ticket_data'];
|
||||
|
||||
print('Data from response: $data');
|
||||
print('Data from response: $data');
|
||||
|
||||
trackClaimsList = data.where((item) {
|
||||
// Check if item is a Map and has the departmentId key
|
||||
if (item is Map<String, dynamic> &&
|
||||
item.containsKey('department_id')) {
|
||||
final departmentId = item['department_id'];
|
||||
// trackClaimsList = data.where((item) {
|
||||
// // Check if item is a Map and has the departmentId key
|
||||
// if (item is Map<String, dynamic> && item.containsKey('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('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('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']}');
|
||||
}
|
||||
print('Filtered trackClaimsList: $data');
|
||||
reversedClaimsList = List<Map<String, dynamic>>.from(data);
|
||||
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) {
|
||||
@ -617,8 +615,7 @@ class _claimsState extends State<claims> {
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: generateTrackList(
|
||||
trackClaimsList), // Replace 'yourDataList' with your actual data list
|
||||
children: generateTrackList(trackClaimsList),
|
||||
),
|
||||
),
|
||||
SizedBox(height: Responsive.isDesktop(context) ? 40 : 70),
|
||||
@ -827,20 +824,29 @@ class _claimsState extends State<claims> {
|
||||
itemCount: data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
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'];
|
||||
List<dynamic> messageList = item['message_list'];
|
||||
// String claimsName = item['user_name'];
|
||||
String claimsSubject = item['subject'] ?? '';
|
||||
String claimsDate = item['created_at'] ?? '';
|
||||
String claimStatus = item['claim_status'] ?? '';
|
||||
String claimsDepartmentName = item['ticket_policy_type'] ?? '';
|
||||
// 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 = {
|
||||
'Open': Colors.green,
|
||||
'Answered': Colors.blue,
|
||||
'Awaiting Reply': Colors.orange,
|
||||
'Inprogress': Colors.yellow,
|
||||
'Closed': Colors.red,
|
||||
'Received': Colors.amber,
|
||||
'Rejected': Colors.red,
|
||||
'Cancelled': Colors.red,
|
||||
'Returned': Colors.deepOrange,
|
||||
'Closed': Colors.grey,
|
||||
'Approved': Colors.green,
|
||||
'Settled': Colors.lightBlueAccent,
|
||||
'Under Process': Colors.brown,
|
||||
};
|
||||
|
||||
// Determine the color based on the claimStatus
|
||||
@ -853,7 +859,7 @@ class _claimsState extends State<claims> {
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, 'claimtracklist', arguments: item);
|
||||
// Navigator.pushNamed(context, 'claimtracklist', arguments: item);
|
||||
},
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
@ -896,17 +902,24 @@ class _claimsState extends State<claims> {
|
||||
),
|
||||
),
|
||||
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
|
||||
),
|
||||
Tooltip(
|
||||
message:
|
||||
claimsSubject, // Full text shown on hover
|
||||
child: Text(
|
||||
claimsSubject.length > 30
|
||||
? '${claimsSubject.substring(0, 30)}...'
|
||||
: claimsSubject,
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
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) {
|
||||
// Convert the timestamp string to milliseconds
|
||||
int milliseconds = int.parse(timestamp) * 1000;
|
||||
|
||||
// Create a DateTime object from milliseconds
|
||||
DateTime date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
|
||||
// Parse the timestamp string to DateTime
|
||||
DateTime date = DateTime.parse(timestamp);
|
||||
|
||||
// Format the DateTime object with date and time
|
||||
String formattedDate = DateFormat('d MMM, y HH:mm a').format(date);
|
||||
|
||||
@ -135,38 +135,37 @@ class _helpState extends State<help> {
|
||||
isLoading = true;
|
||||
});
|
||||
print('check 1');
|
||||
final response =
|
||||
await apiService.getTrackClaimsList(empMobileNo!, empCodeString!);
|
||||
final response = await apiService.getTrackClaimsList(empPrimaryId!);
|
||||
print('check 2');
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
|
||||
if (response['success'] == true && response['data'] is List) {
|
||||
setState(() {
|
||||
trackClaimsList = response['data']
|
||||
.where((item) => item['status_value'] != 'Closed')
|
||||
.toList();
|
||||
reversedClaimsList = List<Map<String, dynamic>>.from(trackClaimsList);
|
||||
trackClaimsList = reversedClaimsList.reversed.toList();
|
||||
// if (response['success'] == true && response['data'] is List) {
|
||||
setState(() {
|
||||
trackClaimsList = response['ticket_data']
|
||||
.where((item) => item['status_value'] != 'Closed')
|
||||
.toList();
|
||||
reversedClaimsList = List<Map<String, dynamic>>.from(trackClaimsList);
|
||||
trackClaimsList = reversedClaimsList.reversed.toList();
|
||||
|
||||
trackClaimsClosedList = response['data']
|
||||
.where((item) => item['status_value'] == 'Closed')
|
||||
.toList();
|
||||
reversedClaimsClosedList =
|
||||
List<Map<String, dynamic>>.from(trackClaimsClosedList);
|
||||
trackClaimsClosedList = reversedClaimsClosedList.reversed.toList();
|
||||
});
|
||||
} else if (response['success'] == true &&
|
||||
response['data'] == "User Not Found") {
|
||||
setState(() {
|
||||
trackClaimsList = [];
|
||||
trackClaimsClosedList = [];
|
||||
});
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('API request failed with status: ${response['status']}');
|
||||
}
|
||||
trackClaimsClosedList = response['ticket_data']
|
||||
.where((item) => item['status_value'] == 'Closed')
|
||||
.toList();
|
||||
reversedClaimsClosedList =
|
||||
List<Map<String, dynamic>>.from(trackClaimsClosedList);
|
||||
trackClaimsClosedList = reversedClaimsClosedList.reversed.toList();
|
||||
});
|
||||
// } else if (response['success'] == true &&
|
||||
// response['data'] == "User Not Found") {
|
||||
// setState(() {
|
||||
// trackClaimsList = [];
|
||||
// trackClaimsClosedList = [];
|
||||
// });
|
||||
// } else {
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
}
|
||||
|
||||
Color getStatusColor(String? policyStatus) {
|
||||
@ -869,20 +868,30 @@ class _helpState extends State<help> {
|
||||
itemCount: data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var item = data[index];
|
||||
String claimsName = item['user_name'];
|
||||
String claimsDate = item['date'];
|
||||
String claimsSubject = item['subject'];
|
||||
String claimsReplies = item['replies'];
|
||||
String claimStatus = item['status_value'];
|
||||
String claimsDepartmentName = item['department_name'];
|
||||
List<dynamic> messageList = item['message_list'];
|
||||
|
||||
// String claimsName = item['user_name'];
|
||||
String claimsSubject = item['subject'] ?? '';
|
||||
String claimsDate = item['created_at'] ?? '';
|
||||
String claimStatus = item['claim_status'] ?? '';
|
||||
String claimsDepartmentName = item['ticket_policy_type'] ?? '';
|
||||
// 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 = {
|
||||
'Open': Colors.green,
|
||||
'Answered': Colors.blue,
|
||||
'Awaiting Reply': Colors.orange,
|
||||
'Inprogress': Colors.yellow,
|
||||
'Closed': Colors.red,
|
||||
'Received': Colors.amber,
|
||||
'Rejected': Colors.red,
|
||||
'Cancelled': Colors.red,
|
||||
'Returned': Colors.deepOrange,
|
||||
'Closed': Colors.grey,
|
||||
'Approved': Colors.green,
|
||||
'Settled': Colors.lightBlueAccent,
|
||||
'Under Process': Colors.brown,
|
||||
};
|
||||
|
||||
// Determine the color based on the claimStatus
|
||||
@ -956,24 +965,26 @@ class _helpState extends State<help> {
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
Container(
|
||||
width:
|
||||
150, // Set a fixed width or adjust based on your layout
|
||||
child: Text(
|
||||
claimsSubject,
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(context)
|
||||
? 14
|
||||
: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF777777),
|
||||
),
|
||||
overflow: TextOverflow
|
||||
.ellipsis, // Show ellipsis when text overflows
|
||||
maxLines: 1, // Limit to one line
|
||||
),
|
||||
)
|
||||
alignment: Alignment
|
||||
.centerLeft, // Set a fixed width or adjust based on your layout
|
||||
child: Tooltip(
|
||||
message: claimsSubject,
|
||||
child: Text(
|
||||
claimsSubject.length > 30
|
||||
? '${claimsSubject.substring(0, 30)}...'
|
||||
: claimsSubject,
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(
|
||||
context)
|
||||
? 14
|
||||
: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF777777),
|
||||
),
|
||||
),
|
||||
))
|
||||
],
|
||||
))
|
||||
],
|
||||
@ -1054,20 +1065,23 @@ class _helpState extends State<help> {
|
||||
itemCount: data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var item = data[index];
|
||||
String claimsName = item['user_name'];
|
||||
String claimsDate = item['date'];
|
||||
String claimsSubject = item['subject'];
|
||||
String claimsReplies = item['replies'];
|
||||
String claimStatus = item['status_value'];
|
||||
String claimsDepartmentName = item['department_name'];
|
||||
List<dynamic> messageList = item['message_list'];
|
||||
// String claimsName = item['user_name'];
|
||||
String claimsSubject = item['subject'] ?? '';
|
||||
String claimsDate = item['created_at'] ?? '';
|
||||
String claimStatus = item['claim_status'] ?? '';
|
||||
String claimsDepartmentName = item['ticket_policy_type'] ?? '';
|
||||
// String claimsReplies = item['replies'];
|
||||
// List<dynamic> messageList = item['message_list'];
|
||||
|
||||
final Map<String, Color> statusColors = {
|
||||
'Open': Colors.green,
|
||||
'Answered': Colors.blue,
|
||||
'Awaiting Reply': Colors.orange,
|
||||
'Inprogress': Colors.yellow,
|
||||
'Closed': Colors.red,
|
||||
'Received': Colors.amber,
|
||||
'Rejected': Colors.red,
|
||||
'Cancelled': Colors.red,
|
||||
'Returned': Colors.deepOrange,
|
||||
'Closed': Colors.grey,
|
||||
'Approved': Colors.green,
|
||||
'Settled': Colors.lightBlueAccent,
|
||||
'Under Process': Colors.brown,
|
||||
};
|
||||
|
||||
// Determine the color based on the claimStatus
|
||||
@ -1140,18 +1154,23 @@ class _helpState extends State<help> {
|
||||
),
|
||||
),
|
||||
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
|
||||
),
|
||||
Tooltip(
|
||||
message: claimsSubject,
|
||||
child: Text(
|
||||
claimsSubject.length > 30
|
||||
? '${claimsSubject.substring(0, 30)}...'
|
||||
: claimsSubject,
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(context)
|
||||
? 14
|
||||
: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF777777),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
))
|
||||
],
|
||||
@ -1224,11 +1243,8 @@ class _helpState extends State<help> {
|
||||
}
|
||||
|
||||
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);
|
||||
// Parse the timestamp string to DateTime
|
||||
DateTime date = DateTime.parse(timestamp);
|
||||
|
||||
// Format the DateTime object with date and time
|
||||
String formattedDate = DateFormat('d MMM, y HH:mm a').format(date);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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:shared_preferences/shared_preferences.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import '../../customAppBar/customFooter.dart';
|
||||
import '../../customAppBar/responsive.dart';
|
||||
import '../../customAppBar/tabs.dart';
|
||||
import '../../customAppBar/toastHelper.dart';
|
||||
import 'chatbot.dart';
|
||||
import 'dart:html' as html;
|
||||
import 'dart:js' as js;
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
const Home({Key? key}) : super(key: key);
|
||||
@ -40,6 +45,8 @@ class _HomeState extends State<Home> {
|
||||
List<String> advertisementImages = [];
|
||||
bool isLoading = true;
|
||||
dynamic policyCount;
|
||||
bool isTokenAvailable = false; // Default: button disabled
|
||||
late WebViewController _controller;
|
||||
|
||||
void _onTabChanged(int index) {
|
||||
setState(() {
|
||||
@ -52,6 +59,10 @@ class _HomeState extends State<Home> {
|
||||
super.initState();
|
||||
apiService = ApiService(context); // Initialize ApiService here
|
||||
_loadToken();
|
||||
checkEnrollToken();
|
||||
// openChat();
|
||||
// _injectBotmanScript();
|
||||
// openBotmanChat();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -59,6 +70,36 @@ class _HomeState extends State<Home> {
|
||||
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 {
|
||||
print('_loadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@ -273,9 +314,12 @@ class _HomeState extends State<Home> {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, 'empDetails');
|
||||
},
|
||||
onPressed: isTokenAvailable
|
||||
? () {
|
||||
Navigator.pushNamed(
|
||||
context, 'empDetails');
|
||||
}
|
||||
: null,
|
||||
child: Text('View Details'),
|
||||
),
|
||||
],
|
||||
@ -630,12 +674,13 @@ class _HomeState extends State<Home> {
|
||||
),
|
||||
),
|
||||
]),
|
||||
floatingActionButton: Responsive.isDesktop(context)
|
||||
? null
|
||||
: FloatingActionButton(
|
||||
onPressed: () => push(chatbot()),
|
||||
child: Icon(Icons.chat),
|
||||
),
|
||||
// floatingActionButton: Responsive.isDesktop(context)
|
||||
// ? null
|
||||
// : FloatingActionButton(
|
||||
// onPressed: () => push(chatbot()),
|
||||
// // onPressed: openChat,
|
||||
// child: Icon(Icons.chat),
|
||||
// ),
|
||||
floatingActionButtonLocation: Responsive.isDesktop(context)
|
||||
? null
|
||||
: FloatingActionButtonLocation.miniEndFloat,
|
||||
@ -644,7 +689,6 @@ class _HomeState extends State<Home> {
|
||||
: CustomBottomNavigationBar(
|
||||
onTabChanged: (index) {
|
||||
// Add your navigation logic here
|
||||
// For example:
|
||||
if (index == 0) {
|
||||
Navigator.pushNamed(context, 'home');
|
||||
} else if (index == 1) {
|
||||
|
||||
@ -3,6 +3,7 @@ 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/claimtracklist.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../customAppBar/customFooter.dart';
|
||||
@ -44,8 +45,10 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
String? selectedServiceName;
|
||||
String? selectedPolicyNo;
|
||||
dynamic claimsDepartmentId;
|
||||
dynamic claimsPolicyNo;
|
||||
dynamic client_branch_id;
|
||||
dynamic policyTypeCondition;
|
||||
dynamic client_policy_id;
|
||||
dynamic selfDetails;
|
||||
List<Map<String, dynamic>> employeePolicyList = [];
|
||||
|
||||
@ -55,13 +58,22 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
late TextEditingController accidentDetailsController;
|
||||
late TextEditingController hospitalNameController;
|
||||
late TextEditingController claimAmountController;
|
||||
late TextEditingController sumInsuredController;
|
||||
late TextEditingController admitDateController;
|
||||
late TextEditingController dischargeDateController;
|
||||
|
||||
DateTime? accidentDate;
|
||||
DateTime? deathDate;
|
||||
DateTime? intimationDate;
|
||||
DateTime? birthDate;
|
||||
DateTime? admitDate;
|
||||
DateTime? dischargeDate;
|
||||
|
||||
Map<String, DateTime?> selectedDates = {
|
||||
"Accident Date": null,
|
||||
"Date of Death": null,
|
||||
};
|
||||
|
||||
List<Map<String, dynamic>> filteredPoliciesList = [];
|
||||
|
||||
// Create a unique form key for each accordion section
|
||||
@ -75,6 +87,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
accidentDetailsController = TextEditingController();
|
||||
hospitalNameController = TextEditingController();
|
||||
claimAmountController = TextEditingController();
|
||||
sumInsuredController = TextEditingController();
|
||||
admitDateController = TextEditingController();
|
||||
dischargeDateController = TextEditingController();
|
||||
apiService = ApiService(context); // Initialize ApiService here
|
||||
@ -93,6 +106,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
accidentDetailsController.dispose();
|
||||
hospitalNameController.dispose();
|
||||
claimAmountController.dispose();
|
||||
sumInsuredController.dispose();
|
||||
admitDateController.dispose();
|
||||
dischargeDateController.dispose();
|
||||
super.dispose();
|
||||
@ -113,9 +127,10 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
print('fromClaimsPage $fromClaimsPage');
|
||||
}
|
||||
if (fromClaimsPage == 0) {
|
||||
claimsDepartmentId = claimsDetails['department_id'];
|
||||
claimsDepartmentId = claimsDetails['ticket_type_id'];
|
||||
print('claimsDepartmentId $claimsDepartmentId');
|
||||
|
||||
claimsPolicyNo = claimsDetails['policy_no'];
|
||||
client_policy_id = claimsDetails['client_policy_id'];
|
||||
// employeePolicyList = claimsDetails['EmployeePolicy'];
|
||||
// print('employeePolicyList : $employeePolicyList');
|
||||
List<dynamic> empList = claimsDetails['EmployeePolicy'];
|
||||
@ -129,9 +144,9 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
print('employeePolicyList : $employeePolicyList');
|
||||
});
|
||||
|
||||
// if (claimsDetails['department_id'] == 3 ||
|
||||
// claimsDetails['department_id'] == 4) {
|
||||
policyTypeCondition = claimsDetails['department_id'];
|
||||
// if (claimsDetails['ticket_type_id'] == 3 ||
|
||||
// claimsDetails['ticket_type_id'] == 4) {
|
||||
policyTypeCondition = claimsDetails['ticket_type_id'];
|
||||
// } else {
|
||||
// String policyType = claimsDetails['policy_type'];
|
||||
// policyTypeCondition = policyType.split('-')[0].trim();
|
||||
@ -194,6 +209,10 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
policyList = List<Map<String, dynamic>>.from(response['data']);
|
||||
});
|
||||
print(policyList);
|
||||
if (fromClaimsPage == 0) {
|
||||
print('fromClaimsPage == 0');
|
||||
fetchPoliciesBasedOnService(claimsDepartmentId);
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
policyDataIsEmpty = 0;
|
||||
@ -234,14 +253,16 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
});
|
||||
try {
|
||||
final response = await apiService.fetchDepartmentList();
|
||||
if (response['departments'] != null) {
|
||||
List<dynamic> departments = response['departments'];
|
||||
print(response);
|
||||
if (response['ticket_type'] != null) {
|
||||
print(response['ticket_type']);
|
||||
List<dynamic> departments = response['ticket_type'];
|
||||
setState(() {
|
||||
departmentList = departments.map((department) {
|
||||
return {
|
||||
'id': int.parse(department['id']),
|
||||
'id': department['id'],
|
||||
'name': department['name'],
|
||||
'private': department['private'],
|
||||
// 'private': department['private'],
|
||||
};
|
||||
}).toList();
|
||||
isLoading = false;
|
||||
@ -265,18 +286,19 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
setState(() {
|
||||
policyNumberId = null;
|
||||
policyTypeCondition = null;
|
||||
client_policy_id = null;
|
||||
});
|
||||
print('1111 serviceId : $serviceId');
|
||||
if (serviceId == 3 || serviceId == 4) {
|
||||
if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4) {
|
||||
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) {
|
||||
return policy['department_id'] == serviceId;
|
||||
return policy['ticket_type_id'] == serviceId;
|
||||
}).toList();
|
||||
|
||||
print('Filtered matching policies: $filteredPolicies');
|
||||
// if (filteredPolicies[0]['department_id'] == 3 ||
|
||||
// filteredPolicies[0]['department_id'] == 4) {
|
||||
// if (filteredPolicies[0]['ticket_type_id'] == 3 ||
|
||||
// filteredPolicies[0]['ticket_type_id'] == 4) {
|
||||
setState(() {
|
||||
// Ensure unique IDs for dropdown values
|
||||
policyNumberList = filteredPolicies.asMap().entries.map((entry) {
|
||||
@ -293,34 +315,52 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
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
|
||||
});
|
||||
} 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;
|
||||
});
|
||||
}
|
||||
// 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) {
|
||||
@ -329,8 +369,8 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (serviceId == 3 || serviceId == 4) {
|
||||
// Filter policies based on the department_id
|
||||
if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4) {
|
||||
// Filter policies based on the ticket_type_id
|
||||
print('policyNumberId : $policyNumberId');
|
||||
|
||||
filteredPoliciesList = policyList.where((policy) {
|
||||
@ -339,6 +379,8 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
print('Filtered matching policy_no: $filteredPoliciesList');
|
||||
|
||||
client_policy_id = filteredPoliciesList[0]['client_policy_id'];
|
||||
|
||||
if (filteredPoliciesList.isNotEmpty) {
|
||||
// Assuming you need to access the first matched policy
|
||||
Map<String, dynamic> firstPolicy = filteredPoliciesList.first;
|
||||
@ -369,29 +411,35 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
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 {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final String? emp_id = prefs.getString('empPrimaryId');
|
||||
// print('Check One');
|
||||
// print(employeePolicyList[0]['name']);
|
||||
// print('Help $filteredPoliciesList');
|
||||
try {
|
||||
print('Check One');
|
||||
Map<String, dynamic> formData = {
|
||||
'opener': 'user',
|
||||
'department_id': serviceId,
|
||||
// 'opener': 'user',
|
||||
'emp_id': emp_id,
|
||||
'client_policy_id': client_policy_id,
|
||||
'ticket_type_id': serviceId,
|
||||
'subject': subjectController.text,
|
||||
'body': messageController.text,
|
||||
'message': messageController.text,
|
||||
// 'policy_id': fromClaimsPage == 0
|
||||
// ? claimsDetails['client_policy_id']
|
||||
// : policyNumberId,
|
||||
@ -412,38 +460,56 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
: (fromClaimsPage == 0
|
||||
? claimsDetails['policy_name']
|
||||
: filteredPoliciesList[0]['policy_name']),
|
||||
'tpa': serviceId == 1
|
||||
? null
|
||||
: (fromClaimsPage == 0
|
||||
? claimsDetails['tpa_name']
|
||||
: filteredPoliciesList[0]['tpa_name']),
|
||||
'insurer': serviceId == 1
|
||||
? null
|
||||
: (fromClaimsPage == 0
|
||||
? claimsDetails['insurer_name']
|
||||
: filteredPoliciesList[0]['insurer_name']),
|
||||
// 'tpa': serviceId == 1
|
||||
// ? null
|
||||
// : (fromClaimsPage == 0
|
||||
// ? claimsDetails['tpa_name']
|
||||
// : filteredPoliciesList[0]['tpa_name']),
|
||||
// 'insurer': serviceId == 1
|
||||
// ? null
|
||||
// : (fromClaimsPage == 0
|
||||
// ? claimsDetails['insurer_name']
|
||||
// : filteredPoliciesList[0]['insurer_name']),
|
||||
};
|
||||
|
||||
// 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 =
|
||||
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'] = messageController.text;
|
||||
formData['accident_date'] = formattedAccidentDate;
|
||||
formData['claim_amount'] = claimAmountController.text;
|
||||
// formData['accident_details'] = messageController.text;
|
||||
formData['date_of_accident'] = formattedAccidentDate;
|
||||
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['member_name'] = selectedMemberName;
|
||||
formData['emp_policy_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;
|
||||
formData['insured_emp_id'] = selectedMemberId;
|
||||
}
|
||||
|
||||
// Convert integer values to strings
|
||||
@ -451,7 +517,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
final response = await apiService.sendFormDataToApi(formData);
|
||||
|
||||
if (response['success'] == 1) {
|
||||
if (response['status'] == true) {
|
||||
ToastHelper.showSuccessToast(context, response['message']);
|
||||
serviceId = null;
|
||||
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(
|
||||
context: context,
|
||||
initialDate: accidentDate ?? DateTime.now(),
|
||||
initialDate: selectedDates[label] ?? DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (pickedDate != null && pickedDate != accidentDate) {
|
||||
|
||||
if (pickedDate != null && pickedDate != selectedDates[label]) {
|
||||
setState(() {
|
||||
accidentDate = pickedDate;
|
||||
selectedDates[label] = pickedDate;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -683,7 +750,6 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
null;
|
||||
if (fromClaimsPage ==
|
||||
1) {
|
||||
// Reset policy number selection
|
||||
fetchPoliciesBasedOnService(
|
||||
serviceId);
|
||||
}
|
||||
@ -695,79 +761,70 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
serviceId, // Pass current serviceId as selectedValue
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
if (fromClaimsPage == 1 &&
|
||||
(serviceId == 3 ||
|
||||
serviceId == 4 ||
|
||||
serviceId == 2))
|
||||
buildDropdownField(
|
||||
'Select Policy',
|
||||
(value) {
|
||||
setState(() {
|
||||
policyNumberId =
|
||||
value;
|
||||
selectedMemberId =
|
||||
null;
|
||||
String?
|
||||
selectedPolicyNo =
|
||||
policyNumberList.firstWhere(
|
||||
(item) =>
|
||||
item[
|
||||
'id'] ==
|
||||
value,
|
||||
orElse: () =>
|
||||
{
|
||||
'policy_no':
|
||||
''
|
||||
})['policy_no'];
|
||||
// if (fromClaimsPage == 1)
|
||||
buildDropdownField(
|
||||
'Select Policy',
|
||||
(value) {
|
||||
setState(() {
|
||||
policyNumberId =
|
||||
value;
|
||||
selectedMemberId =
|
||||
null;
|
||||
String?
|
||||
selectedPolicyNo =
|
||||
policyNumberList
|
||||
.firstWhere(
|
||||
(item) =>
|
||||
item['id'] ==
|
||||
value,
|
||||
orElse: () =>
|
||||
{
|
||||
'policy_no': ''
|
||||
})['policy_no'];
|
||||
|
||||
if (selectedPolicyNo !=
|
||||
null &&
|
||||
fromClaimsPage ==
|
||||
1) {
|
||||
fetchMemberBasedOnPolicy(
|
||||
selectedPolicyNo);
|
||||
}
|
||||
});
|
||||
},
|
||||
fromClaimsPage == 0,
|
||||
policyNumberList,
|
||||
'policy_no',
|
||||
policyNumberId, // Pass current policyNumberId as selectedValue
|
||||
),
|
||||
if (selectedPolicyNo !=
|
||||
null &&
|
||||
fromClaimsPage ==
|
||||
1) {
|
||||
fetchMemberBasedOnPolicy(
|
||||
selectedPolicyNo);
|
||||
}
|
||||
});
|
||||
},
|
||||
fromClaimsPage == 0,
|
||||
policyNumberList,
|
||||
'policy_no',
|
||||
policyNumberId, // Pass current policyNumberId as selectedValue
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
if (serviceId == 3 ||
|
||||
serviceId == 4)
|
||||
buildDropdownField(
|
||||
'Member Name',
|
||||
(value) {
|
||||
setState(() {
|
||||
selectedMemberId =
|
||||
value;
|
||||
selectedMemberName =
|
||||
employeePolicyList
|
||||
.firstWhere(
|
||||
(member) =>
|
||||
member[
|
||||
'id'] ==
|
||||
value,
|
||||
orElse: () => {
|
||||
'name': ''
|
||||
},
|
||||
)['name'];
|
||||
});
|
||||
},
|
||||
false,
|
||||
employeePolicyList,
|
||||
'name',
|
||||
selectedMemberId, // Pass current selectedMemberId as selectedValue
|
||||
),
|
||||
buildDropdownField(
|
||||
'Member Name',
|
||||
(value) {
|
||||
setState(() {
|
||||
selectedMemberId =
|
||||
value;
|
||||
selectedMemberName =
|
||||
employeePolicyList
|
||||
.firstWhere(
|
||||
(member) =>
|
||||
member[
|
||||
'id'] ==
|
||||
value,
|
||||
orElse: () =>
|
||||
{'name': ''},
|
||||
)['name'];
|
||||
});
|
||||
},
|
||||
false,
|
||||
employeePolicyList,
|
||||
'name',
|
||||
selectedMemberId, // Pass current selectedMemberId as selectedValue
|
||||
),
|
||||
buildTextField('Subject',
|
||||
subjectController),
|
||||
SizedBox(height: 15),
|
||||
buildTextAreaField(
|
||||
serviceId == 3
|
||||
? 'Accident Details'
|
||||
: 'Message',
|
||||
'Message',
|
||||
messageController),
|
||||
SizedBox(height: 15),
|
||||
// if (policyTypeCondition ==
|
||||
@ -777,13 +834,29 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
// accidentDetailsController),
|
||||
SizedBox(height: 15),
|
||||
if (policyTypeCondition ==
|
||||
4)
|
||||
1)
|
||||
buildTextField(
|
||||
'Hospital Name',
|
||||
hospitalNameController),
|
||||
SizedBox(height: 15),
|
||||
if (policyTypeCondition ==
|
||||
3)
|
||||
if (serviceId == 2 ||
|
||||
serviceId == 3 ||
|
||||
serviceId == 4) ...[
|
||||
buildDatePickerField(
|
||||
label:
|
||||
'Date of Birth',
|
||||
selectedDate:
|
||||
birthDate,
|
||||
allowFuture: false,
|
||||
onDateSelected:
|
||||
(selectedDate) {
|
||||
setState(() {
|
||||
birthDate =
|
||||
selectedDate;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
buildDatePickerField(
|
||||
label:
|
||||
'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),
|
||||
// buildTextAreaField(
|
||||
// 'Accident Details',
|
||||
// accidentDetailsController),
|
||||
// SizedBox(height: 15),
|
||||
if (policyTypeCondition ==
|
||||
4)
|
||||
1)
|
||||
InkWell(
|
||||
onTap: () =>
|
||||
_pickFromToDate(
|
||||
@ -831,14 +935,21 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
if (serviceId == 3 ||
|
||||
serviceId == 4)
|
||||
if (serviceId == 1)
|
||||
buildTextField(
|
||||
'Claim Amount',
|
||||
claimAmountController,
|
||||
TextInputType.number,
|
||||
),
|
||||
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,
|
||||
}) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
_pickAccidentDate(context);
|
||||
onTap: () async {
|
||||
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(
|
||||
decoration: InputDecoration(
|
||||
|
||||
@ -15,6 +15,7 @@ import '../../models/platform_helper_mobile.dart'
|
||||
if (dart.library.html) '../../models/platform_helper_other.dart';
|
||||
|
||||
import '../session/authenticationService.dart';
|
||||
import 'dart:html' as html;
|
||||
|
||||
class profile extends StatefulWidget {
|
||||
const profile({Key? key}) : super(key: key);
|
||||
@ -158,7 +159,7 @@ class _profileState extends State<profile> {
|
||||
|
||||
// Clear all keys
|
||||
await prefs.clear();
|
||||
|
||||
html.window.localStorage.clear();
|
||||
// Re-set the mobile_number key
|
||||
if (mobileNumber != null) {
|
||||
await prefs.setString('empMobileNo', mobileNumber);
|
||||
|
||||
@ -74,33 +74,46 @@ class ApiService {
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getTrackClaimsList(
|
||||
String empMobileNo, String empCode) async {
|
||||
Future<Map<String, dynamic>> getTrackClaimsList(String empPrimaryId) async {
|
||||
print(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
final url = Uri.parse(
|
||||
'${Environment.apiUrlTicket}/ticket/get_ticket_data?emp_code=$empCode&mobile_number=$empMobileNo');
|
||||
final response = await _makeGetRequest(url, {
|
||||
'Token': Environment.ticketToken,
|
||||
});
|
||||
'${Environment.apiUrlTicket}/get_ticket_data?emp_id=$empPrimaryId');
|
||||
final headers = {
|
||||
'Authorization': 'Bearer $_token' ?? '',
|
||||
};
|
||||
final response = await _makeGetRequest(url, headers);
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchDepartmentList() async {
|
||||
final url = Uri.parse('${Environment.apiUrlTicket}/departments');
|
||||
final response = await _makeGetRequest(url, {
|
||||
'Token': Environment.ticketToken,
|
||||
});
|
||||
print(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
final url = Uri.parse('${Environment.apiUrlTicket}/get_ticket_type');
|
||||
final headers = {
|
||||
'Authorization': 'Bearer $_token' ?? '',
|
||||
};
|
||||
final response = await _makeGetRequest(url, headers);
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> sendFormDataToApi(
|
||||
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>
|
||||
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,
|
||||
'Authorization': 'Bearer $_token' ?? '',
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:pinput/pinput.dart';
|
||||
import 'dart:async';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:html' as html;
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@ -244,7 +245,21 @@ class _MyVerifyState extends State<MyVerify> {
|
||||
prefs.setString('client_id', client_id);
|
||||
emp_status = decodedToken['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');
|
||||
|
||||
@ -271,7 +286,7 @@ class _MyVerifyState extends State<MyVerify> {
|
||||
prefs.setString('enrollmentClient_id', enrollmentClient_id);
|
||||
enrollmentEmp_status = decodedToken['emp_status'];
|
||||
prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||
// getClientLogoAndDetails();
|
||||
getClientLogoAndDetails();
|
||||
}
|
||||
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@ -390,8 +405,9 @@ class _MyVerifyState extends State<MyVerify> {
|
||||
}
|
||||
|
||||
Future<void> getClientLogoAndDetails() async {
|
||||
print('getClientLogoAndDetails');
|
||||
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 {
|
||||
var response = await http.get(
|
||||
url,
|
||||
|
||||
@ -15,6 +15,7 @@ import shared_preferences_foundation
|
||||
import sqflite_darwin
|
||||
import url_launcher_macos
|
||||
import video_player_avfoundation
|
||||
import webview_flutter_wkwebview
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
|
||||
@ -27,4 +28,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
|
||||
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
|
||||
}
|
||||
|
||||
@ -55,6 +55,9 @@ dependencies:
|
||||
local_auth: ^2.2.0
|
||||
google_sign_in: ^6.2.1
|
||||
dio: ^5.7.0
|
||||
webview_flutter: ^4.10.0
|
||||
webview_flutter_wkwebview: ^3.18.1
|
||||
webview_flutter_android: ^4.3.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@ -86,6 +89,7 @@ flutter:
|
||||
- .env.production
|
||||
- .env.test
|
||||
- .env.uat
|
||||
- assets/botman_chat.html
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
</style>
|
||||
<!-- This script adds the flutter initialization JS code -->
|
||||
<script src="flutter.js" defer></script>
|
||||
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
|
||||
</head>
|
||||
<body style="overflow:hidden">
|
||||
<div id="loading_indicator" class="container overlay">
|
||||
@ -94,5 +95,64 @@
|
||||
});
|
||||
};
|
||||
</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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user