ticket flow add
This commit is contained in:
parent
f063c3ac08
commit
9f4241fc9d
@ -19,12 +19,12 @@ if (project.hasProperty('google-services.json')) {
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '22'
|
||||
flutterVersionCode = '23'
|
||||
}
|
||||
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0.22'
|
||||
flutterVersionName = '1.0.23'
|
||||
}
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
|
||||
@ -22,6 +22,7 @@ import 'package:nhance_app_pwa/pages/postEnrollment/policies.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/privacypolicy.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/profile.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/termsofuse.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/tickets.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/wellness.dart';
|
||||
import 'package:nhance_app_pwa/pages/session/SetPinBiometric.dart';
|
||||
import 'package:nhance_app_pwa/pages/session/changePin.dart';
|
||||
@ -150,6 +151,7 @@ class MyApp extends StatelessWidget {
|
||||
'empDetails': (context) => empDetails(),
|
||||
'addOnsDetails': (context) => addOnsDetails(),
|
||||
'empReviewDetails': (context) => empReviewDetails(),
|
||||
'tickets': (context) => tickets(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1
lib/pages/helpers/botman.dart
Normal file
1
lib/pages/helpers/botman.dart
Normal file
@ -0,0 +1 @@
|
||||
export 'botman_stub.dart' if (dart.library.js) 'botman_web.dart';
|
||||
7
lib/pages/helpers/botman_stub.dart
Normal file
7
lib/pages/helpers/botman_stub.dart
Normal file
@ -0,0 +1,7 @@
|
||||
void openBotmanChat() {
|
||||
// No-op on mobile
|
||||
}
|
||||
|
||||
void repositionBotman() {
|
||||
// No-op on mobile
|
||||
}
|
||||
14
lib/pages/helpers/botman_web.dart
Normal file
14
lib/pages/helpers/botman_web.dart
Normal file
@ -0,0 +1,14 @@
|
||||
import 'dart:js' as js;
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
void openBotmanChat() {
|
||||
if (kIsWeb) {
|
||||
js.context.callMethod('openBotmanChat');
|
||||
}
|
||||
}
|
||||
|
||||
void repositionBotman() {
|
||||
if (kIsWeb) {
|
||||
js.context.callMethod('repositionBotmanWidget');
|
||||
}
|
||||
}
|
||||
6
lib/pages/helpers/html_stub.dart
Normal file
6
lib/pages/helpers/html_stub.dart
Normal file
@ -0,0 +1,6 @@
|
||||
// html_stub.dart
|
||||
class HtmlHelper {
|
||||
static void saveLoginData(Map<String, String> data) {
|
||||
// No-op for non-web platforms
|
||||
}
|
||||
}
|
||||
16
lib/pages/helpers/html_web.dart
Normal file
16
lib/pages/helpers/html_web.dart
Normal file
@ -0,0 +1,16 @@
|
||||
// html_web.dart
|
||||
import 'dart:html' as html;
|
||||
|
||||
class HtmlHelper {
|
||||
static void saveLoginData(Map<String, String> data) {
|
||||
data.forEach((key, value) {
|
||||
html.window.localStorage[key] = value;
|
||||
});
|
||||
|
||||
html.window.dispatchEvent(
|
||||
html.CustomEvent('userLoggedIn', detail: {'status': 'success'}),
|
||||
);
|
||||
|
||||
print("✅ User logged in! LocalStorage values set (web).");
|
||||
}
|
||||
}
|
||||
3
lib/pages/helpers/mobile_helpers.dart
Normal file
3
lib/pages/helpers/mobile_helpers.dart
Normal file
@ -0,0 +1,3 @@
|
||||
void setupBackButtonHandler(Function showDialogCallback) {
|
||||
// No-op on mobile
|
||||
}
|
||||
12
lib/pages/helpers/web_helpers.dart
Normal file
12
lib/pages/helpers/web_helpers.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'dart:html' as html;
|
||||
|
||||
void setupBackButtonHandler(Function showDialogCallback) {
|
||||
// Push a dummy state so back button triggers popstate instead of navigating
|
||||
html.window.history.pushState(null, 'home', html.window.location.href);
|
||||
|
||||
html.window.onPopState.listen((event) {
|
||||
showDialogCallback();
|
||||
// Re-push to prevent leaving
|
||||
html.window.history.pushState(null, 'home', html.window.location.href);
|
||||
});
|
||||
}
|
||||
@ -28,6 +28,7 @@ class _helpState extends State<help> {
|
||||
late ApiService apiService;
|
||||
int _currentIndex = 0;
|
||||
bool isActive = true;
|
||||
int tickets = 1;
|
||||
int closedTrackActive = 1;
|
||||
int allClaimsActive = 0;
|
||||
dynamic _token;
|
||||
@ -76,8 +77,6 @@ class _helpState extends State<help> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@ -399,11 +398,11 @@ class _helpState extends State<help> {
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 8,
|
||||
flex: 6,
|
||||
child: Container(
|
||||
width: 300,
|
||||
height: 150,
|
||||
alignment: Alignment.center,
|
||||
alignment: Alignment.centerRight,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
var details = {
|
||||
@ -425,172 +424,143 @@ class _helpState extends State<help> {
|
||||
),
|
||||
),
|
||||
)),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: Container(
|
||||
width: 300,
|
||||
height: 150,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, 'tickets');
|
||||
},
|
||||
child: Text(
|
||||
'Raise a Ticket',
|
||||
style: GoogleFonts.poppins(color: Colors.white),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Color(0xFFE26728),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
SizedBox(height: 15),
|
||||
SizedBox(height: 20),
|
||||
// SizedBox(height: 15),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Color(0xFFF6FAFF), // Set background color for the container
|
||||
borderRadius: BorderRadius.circular(
|
||||
5), // Set border radius for the container
|
||||
),
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.only(top: 10, bottom: 10, left: 25, right: 25)
|
||||
: EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 12,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = true;
|
||||
// policyList.clear();
|
||||
allClaimsActive = 0;
|
||||
closedTrackActive = 1;
|
||||
});
|
||||
},
|
||||
child: isActive
|
||||
? Material(
|
||||
elevation: 5,
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Responsive
|
||||
.isDesktop(
|
||||
context)
|
||||
? 120
|
||||
: 50,
|
||||
vertical: Responsive
|
||||
.isDesktop(
|
||||
context)
|
||||
? 15
|
||||
: 5),
|
||||
// primary: Color(0xFF000000),
|
||||
),
|
||||
child: Text(
|
||||
'All Claims',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: Responsive
|
||||
.isDesktop(
|
||||
context)
|
||||
? 18
|
||||
: 13,
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
color: Color(
|
||||
0xFF000000)),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'All Claims',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(
|
||||
context)
|
||||
? 18
|
||||
: 13,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF636363),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = false;
|
||||
// trackClaimsList.clear();
|
||||
allClaimsActive = 1;
|
||||
closedTrackActive = 0;
|
||||
});
|
||||
getTrackClaimsList();
|
||||
},
|
||||
child: !isActive
|
||||
? Material(
|
||||
elevation: 5,
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Responsive
|
||||
.isDesktop(
|
||||
context)
|
||||
? 120
|
||||
: 40,
|
||||
vertical: Responsive
|
||||
.isDesktop(
|
||||
context)
|
||||
? 15
|
||||
: 5),
|
||||
// primary: Color(0xFF000000),
|
||||
),
|
||||
child: Text(
|
||||
'Closed claims',
|
||||
style:
|
||||
GoogleFonts.poppins(
|
||||
fontSize: Responsive
|
||||
.isDesktop(
|
||||
context)
|
||||
? 18
|
||||
: 13,
|
||||
color:
|
||||
Color(0xFF000000),
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'Closed claims',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(
|
||||
context)
|
||||
? 18
|
||||
: 13,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF636363),
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
))),
|
||||
],
|
||||
color: Color(0xFFF6FAFF),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
child: Responsive.isDesktop(context)
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildTabButton(
|
||||
context: context,
|
||||
title: "All Claims",
|
||||
isActive: allClaimsActive == 0,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = true;
|
||||
allClaimsActive = 0;
|
||||
closedTrackActive = 1;
|
||||
tickets = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _buildTabButton(
|
||||
context: context,
|
||||
title: "Closed claims",
|
||||
isActive: closedTrackActive == 0,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = false;
|
||||
allClaimsActive = 1;
|
||||
closedTrackActive = 0;
|
||||
tickets = 1;
|
||||
});
|
||||
getTrackClaimsList();
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _buildTabButton(
|
||||
context: context,
|
||||
title: "Tickets",
|
||||
isActive: tickets == 0,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = false;
|
||||
allClaimsActive = 1;
|
||||
closedTrackActive = 1;
|
||||
tickets = 0;
|
||||
});
|
||||
// getTrackClaimsList();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
_buildTabButton(
|
||||
context: context,
|
||||
title: "All Claims",
|
||||
isActive: allClaimsActive == 0,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = true;
|
||||
allClaimsActive = 0;
|
||||
closedTrackActive = 1;
|
||||
tickets = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
_buildTabButton(
|
||||
context: context,
|
||||
title: "Closed claims",
|
||||
isActive: closedTrackActive == 0,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = false;
|
||||
allClaimsActive = 1;
|
||||
closedTrackActive = 0;
|
||||
tickets = 1;
|
||||
});
|
||||
getTrackClaimsList();
|
||||
},
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
_buildTabButton(
|
||||
context: context,
|
||||
title: "Tickets",
|
||||
isActive: tickets == 0,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isActive = false;
|
||||
allClaimsActive = 1;
|
||||
closedTrackActive = 1;
|
||||
tickets = 0;
|
||||
});
|
||||
getTrackClaimsList();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (allClaimsActive == 0)
|
||||
if (trackClaimsList == null || trackClaimsList.isEmpty)
|
||||
@ -1058,6 +1028,56 @@ class _helpState extends State<help> {
|
||||
];
|
||||
}
|
||||
|
||||
/// Reusable tab button widget
|
||||
Widget _buildTabButton({
|
||||
required BuildContext context,
|
||||
required String title,
|
||||
required bool isActive,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return Container(
|
||||
width:
|
||||
Responsive.isDesktop(context) ? null : 120, // fixed width on mobile
|
||||
child: isActive
|
||||
? Material(
|
||||
elevation: 5,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
child: TextButton(
|
||||
onPressed: onTap,
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: Responsive.isDesktop(context) ? 15 : 10,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: Responsive.isDesktop(context) ? 18 : 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: Responsive.isDesktop(context) ? 18 : 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFF636363),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> generateClaimsClosedList(List<dynamic> data) {
|
||||
return [
|
||||
ListView.builder(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
644
lib/pages/postEnrollment/tickets.dart
Normal file
644
lib/pages/postEnrollment/tickets.dart
Normal file
@ -0,0 +1,644 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:jwt_decode/jwt_decode.dart';
|
||||
import 'package:nhance_app_pwa/customAppBar/customAppBar.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/claimtracklist.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../customAppBar/customFooter.dart';
|
||||
import '../../customAppBar/responsive.dart';
|
||||
import '../../customAppBar/tabs.dart';
|
||||
import '../../customAppBar/toastHelper.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class tickets extends StatefulWidget {
|
||||
const tickets({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<tickets> createState() => _ticketsState();
|
||||
}
|
||||
|
||||
class _ticketsState extends State<tickets> {
|
||||
late ApiService apiService;
|
||||
bool isLoading = false;
|
||||
dynamic _token;
|
||||
dynamic empCodeString;
|
||||
dynamic empPrimaryId;
|
||||
dynamic client_id;
|
||||
List<Map<String, dynamic>> policyList = [];
|
||||
dynamic policyDataIsEmpty = 1;
|
||||
int? fromClaimsPage;
|
||||
dynamic decodedToken;
|
||||
List<Map<String, dynamic>> departmentList = [];
|
||||
List<Map<String, dynamic>> policyNumberList = [];
|
||||
dynamic serviceId;
|
||||
dynamic policyNumberId;
|
||||
String? selectedMemberName;
|
||||
String? selectedServiceName;
|
||||
String? selectedPolicyNo;
|
||||
dynamic client_branch_id;
|
||||
dynamic mobileNo;
|
||||
dynamic policyTypeCondition;
|
||||
dynamic client_policy_id;
|
||||
dynamic selfDetails;
|
||||
List<Map<String, dynamic>> employeePolicyList = [];
|
||||
|
||||
// Declare subjectController and bodyController as instance variables
|
||||
late TextEditingController subjectController;
|
||||
late TextEditingController messageController;
|
||||
|
||||
final List<Map<String, dynamic>> serviceList = [
|
||||
{"id": 1, "name": "Sales"},
|
||||
{"id": 2, "name": "Service"},
|
||||
];
|
||||
|
||||
List<Map<String, dynamic>> filteredPoliciesList = [];
|
||||
|
||||
// Create a unique form key for each accordion section
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
bool isServiceValid = true;
|
||||
bool isPolicyValid = true;
|
||||
bool isSubjectValid = true;
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
subjectController = TextEditingController();
|
||||
messageController = TextEditingController();
|
||||
apiService = ApiService(context); // Initialize ApiService here
|
||||
_loadToken();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Dispose the controllers to avoid memory leaks
|
||||
subjectController.dispose();
|
||||
messageController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final String? token = prefs.getString('_postToken');
|
||||
if (token != null && token.isNotEmpty) {
|
||||
setState(() {
|
||||
_token = token;
|
||||
});
|
||||
// Decode the JWT token received from the API response
|
||||
decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
mobileNo = decodedToken['mobile'];
|
||||
client_branch_id = decodedToken['client_branch_id'];
|
||||
empCodeString = prefs.getString('empCode');
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = prefs.getString('empPrimaryId');
|
||||
client_id = prefs.getString('client_id');
|
||||
print(client_id);
|
||||
getActiveAndInactivePolicyDetails();
|
||||
getSelfEmployeeProfile();
|
||||
} else {
|
||||
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
||||
ToastHelper.showErrorToast(context, 'Session Out');
|
||||
Navigator.pushReplacementNamed(context, 'login');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getActiveAndInactivePolicyDetails() async {
|
||||
if (client_id == null || empCodeString == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Call both APIs
|
||||
final responseActive = await apiService.getActiveAndInactivePolicyDetails(
|
||||
client_id!, empCodeString!, 'Active', client_branch_id,mobileNo
|
||||
);
|
||||
|
||||
final responseInactive = await apiService.getActiveAndInactivePolicyDetails(
|
||||
client_id!, empCodeString!, 'Inactive', client_branch_id,mobileNo
|
||||
);
|
||||
|
||||
final bool isActiveSuccess = responseActive['status'] == 'success' && responseActive['data'] != null;
|
||||
final bool isInactiveSuccess = responseInactive['status'] == 'success' && responseInactive['data'] != null;
|
||||
|
||||
final List<Map<String, dynamic>> activeData = isActiveSuccess
|
||||
? List<Map<String, dynamic>>.from(responseActive['data'])
|
||||
: [];
|
||||
|
||||
final List<Map<String, dynamic>> inactiveData = isInactiveSuccess
|
||||
? List<Map<String, dynamic>>.from(responseInactive['data'])
|
||||
: [];
|
||||
|
||||
final combinedPolicies = [...activeData, ...inactiveData];
|
||||
|
||||
setState(() {
|
||||
policyList = combinedPolicies;
|
||||
policyDataIsEmpty = combinedPolicies.isEmpty ? 0 : 1;
|
||||
});
|
||||
|
||||
print("Merged policyList: $policyList");
|
||||
} catch (e) {
|
||||
print('Error occurred while fetching policies: $e');
|
||||
setState(() {
|
||||
policyDataIsEmpty = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getSelfEmployeeProfile() async {
|
||||
print(getSelfEmployeeProfile);
|
||||
if (client_id == null || empCodeString == null) {
|
||||
return;
|
||||
}
|
||||
print('check 1');
|
||||
final response = await apiService.getSelfEmployeeProfileDetails(
|
||||
client_id!, empCodeString!, client_branch_id!);
|
||||
print('check 1');
|
||||
if (response['status'] == 'success') {
|
||||
if (response.containsKey('data')) {
|
||||
setState(() {
|
||||
selfDetails = response['data'];
|
||||
print(selfDetails);
|
||||
});
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
// ToastHelper.showErrorToast(
|
||||
// context, 'API request failed with status: ${data['status']}');
|
||||
print('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
print('API request failed with status: ${response['status']}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> sendFormDataToApi() async {
|
||||
setState(() {
|
||||
isServiceValid = serviceId != null;
|
||||
isPolicyValid = policyNumberId != null;
|
||||
isSubjectValid = subjectController.text.trim().isNotEmpty;
|
||||
});
|
||||
|
||||
if (isServiceValid &&
|
||||
isPolicyValid &&
|
||||
isSubjectValid) {
|
||||
// Proceed to submit
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, 'Please Fill Required Fields');
|
||||
return;
|
||||
}
|
||||
|
||||
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',
|
||||
'emp_id': emp_id,
|
||||
'client_policy_id': client_policy_id,
|
||||
'ticket_type_id': serviceId,
|
||||
'subject': subjectController.text,
|
||||
'message': messageController.text,
|
||||
// 'policy_id': fromClaimsPage == 0
|
||||
// ? claimsDetails['client_policy_id']
|
||||
// : policyNumberId,
|
||||
'emp_code':
|
||||
decodedToken['emp_code'] != null ? decodedToken['emp_code'] : '',
|
||||
'mobile_number':
|
||||
decodedToken['mobile'] != null ? decodedToken['mobile'] : '',
|
||||
'email': decodedToken['email_corporate'] != null
|
||||
? decodedToken['email_corporate']
|
||||
: '',
|
||||
'fullname': decodedToken['name'] != null ? decodedToken['name'] : '',
|
||||
'client_id': selfDetails['client_id'],
|
||||
'relationship': selfDetails['relationship'],
|
||||
'gender': selfDetails['gender'],
|
||||
|
||||
};
|
||||
|
||||
|
||||
if (policyTypeCondition == 1) {
|
||||
formData['policyholder_name'] = employeePolicyList[0]['name'];
|
||||
formData['member_name'] = selectedMemberName;
|
||||
} else {
|
||||
|
||||
formData['policyholder_name'] = employeePolicyList[0]['name'];
|
||||
formData['member_name'] = selectedMemberName;
|
||||
}
|
||||
|
||||
// Convert integer values to strings
|
||||
formData = formData.map((key, value) => MapEntry(key, value.toString()));
|
||||
|
||||
final response = await apiService.sendFormDataToApi(formData);
|
||||
|
||||
if (response['status'] == true) {
|
||||
ToastHelper.showSuccessToast(context, response['message']);
|
||||
serviceId = null;
|
||||
departmentList.clear();
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
Navigator.pushNamed(context, 'claims');
|
||||
print('Form data submitted successfully');
|
||||
} else {
|
||||
print('Failed to submit form data: ${response['status']}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error submitting form data: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: CustomAppBar(),
|
||||
body: Stack(children: [
|
||||
SingleChildScrollView(
|
||||
child: Container(
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: MediaQuery.of(context).size.width *
|
||||
0.2, // 30% of screen width as horizontal padding
|
||||
vertical: MediaQuery.of(context).size.height *
|
||||
0.05, // 5% of screen height as vertical padding
|
||||
)
|
||||
: EdgeInsets.all(10),
|
||||
color: Colors.white,
|
||||
child: Column(children: [
|
||||
Card(
|
||||
elevation: 5,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(15.0), // Set border radius here
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, // Set background color to white
|
||||
borderRadius: BorderRadius.circular(
|
||||
15.0), // Set border radius for Container
|
||||
),
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15)
|
||||
: EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
left: 10,
|
||||
right: 10), // Add padding to the container
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 12,
|
||||
child: Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(
|
||||
0xFFFFFCE5), // Set background color for the container
|
||||
borderRadius: BorderRadius.circular(
|
||||
10), // Set border radius for the container
|
||||
),
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.only(
|
||||
top: 20,
|
||||
bottom: 20,
|
||||
left: 0,
|
||||
right: 0)
|
||||
: EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
left: 10,
|
||||
right: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(
|
||||
context,'help');
|
||||
},
|
||||
child: Icon(
|
||||
Icons
|
||||
.chevron_left, // Replace with your desired icon
|
||||
color: Color(0xFF000000),
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 11,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
Responsive.isDesktop(context)
|
||||
? MainAxisAlignment.center
|
||||
: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text('Raise a Ticket',
|
||||
textAlign: TextAlign.start,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize:
|
||||
Responsive.isDesktop(
|
||||
context)
|
||||
? 20
|
||||
: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF000000),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
), // Space between rows
|
||||
// Add more rows as needed
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Form(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
buildDropdownField<int>(
|
||||
'Service',
|
||||
(value) {
|
||||
setState(() {
|
||||
serviceId = value;
|
||||
selectedServiceName = serviceList.firstWhere(
|
||||
(serList) => serList['id'] == value,
|
||||
orElse: () => {'name': ''},
|
||||
)['name'];
|
||||
isServiceValid = true;
|
||||
});
|
||||
},
|
||||
false,
|
||||
serviceList,
|
||||
'name',
|
||||
serviceId,
|
||||
valueKey: 'id',
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
if (selectedServiceName == "Service")
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
buildDropdownField<String>(
|
||||
'Policy Number',
|
||||
(value) {
|
||||
setState(() {
|
||||
policyNumberId = value;
|
||||
isPolicyValid = true;
|
||||
});
|
||||
},
|
||||
false,
|
||||
policyList,
|
||||
'policy_no',
|
||||
policyNumberId,
|
||||
valueKey: 'policy_no',
|
||||
),
|
||||
if (!isPolicyValid)
|
||||
Text('Please select a policy',
|
||||
style: TextStyle(color: Colors.red)),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: 15),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildTextField('Subject',
|
||||
subjectController),
|
||||
if (!isSubjectValid)
|
||||
Text('Please enter the Subject', style: TextStyle(color: Colors.red)),
|
||||
SizedBox(height: 15),
|
||||
buildTextAreaField(
|
||||
'Message',
|
||||
messageController),
|
||||
]
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 12,
|
||||
child: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
// sendFormDataToApi();
|
||||
},
|
||||
child: Text(
|
||||
'Send',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.white),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
Color(0xFFE26728),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
))),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: Responsive.isDesktop(context) ? 40 : 60),
|
||||
]),
|
||||
)),
|
||||
if (isLoading)
|
||||
Container(
|
||||
color: Color(0x98FFFCE5), // Semi-transparent background
|
||||
child: Center(
|
||||
child: // Your GIF loader widget
|
||||
Image.asset(
|
||||
height: 60,
|
||||
width: 60,
|
||||
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
||||
),
|
||||
),
|
||||
if (Responsive.isDesktop(context))
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
width: double.infinity, // Make the footer full width
|
||||
child: CustomFooter(),
|
||||
),
|
||||
),
|
||||
]),
|
||||
// floatingActionButton: Responsive.isDesktop(context)
|
||||
// ? null
|
||||
// : FloatingActionButton(
|
||||
// onPressed: () {
|
||||
// Navigator.pushNamed(context, 'chatbot');
|
||||
// },
|
||||
// child: Icon(Icons.chat),
|
||||
// ),
|
||||
floatingActionButtonLocation: Responsive.isDesktop(context)
|
||||
? null
|
||||
: FloatingActionButtonLocation.miniEndFloat,
|
||||
bottomNavigationBar: Responsive.isDesktop(context)
|
||||
? null
|
||||
: CustomBottomNavigationBar(
|
||||
onTabChanged: (index) {
|
||||
// repositionBotman();
|
||||
if (index == 0) {
|
||||
Navigator.pushNamed(context, 'home');
|
||||
} else if (index == 1) {
|
||||
Navigator.pushNamed(context, 'claims');
|
||||
} else if (index == 2) {
|
||||
Navigator.pushNamed(context, 'profile');
|
||||
} else if (index == 3) {
|
||||
Navigator.pushNamed(context, 'help');
|
||||
// Navigator.pushNamed(context, 'help');
|
||||
} else if (index == 4) {
|
||||
Navigator.pushNamed(context, 'wellness');
|
||||
}
|
||||
},
|
||||
icons: [
|
||||
Icons.home_outlined,
|
||||
Icons.sticky_note_2_outlined,
|
||||
Icons.person_outline_outlined,
|
||||
Icons.headset_mic_outlined,
|
||||
Icons.health_and_safety_outlined,
|
||||
],
|
||||
labels: [
|
||||
"Home",
|
||||
"Claim",
|
||||
"Profile",
|
||||
"Help",
|
||||
"Wellness",
|
||||
], // Initial index of the bottom navigation bar
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTextField(String label, TextEditingController controller,
|
||||
[TextInputType keyboardType = TextInputType.text]) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(labelText: label),
|
||||
keyboardType: keyboardType,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter the $label';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTextAreaField(String label, TextEditingController controller) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(labelText: label),
|
||||
maxLines: 5,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter the $label';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget buildDropdownField<T>(
|
||||
String label,
|
||||
void Function(T?) onChanged,
|
||||
bool readOnly,
|
||||
List<Map<String, dynamic>> itemsList,
|
||||
String displayField,
|
||||
T? selectedValue, {
|
||||
String valueKey = 'id',
|
||||
}) {
|
||||
return DropdownButtonFormField<T>(
|
||||
value: selectedValue,
|
||||
decoration: InputDecoration(labelText: label),
|
||||
items: itemsList.map<DropdownMenuItem<T>>((item) {
|
||||
return DropdownMenuItem<T>(
|
||||
value: item[valueKey] as T, // ✅ cast to generic type
|
||||
child: Text(item[displayField].toString()), // always display as String
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: readOnly ? null : onChanged,
|
||||
validator: (value) {
|
||||
if (value == null) {
|
||||
return 'Please select a $label';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
#version: 1.0.22+22
|
||||
version: 1.0.10+11
|
||||
#version: 1.0.23+23
|
||||
version: 1.0.11+12
|
||||
|
||||
environment:
|
||||
sdk: '>=3.3.3 <4.0.0'
|
||||
|
||||
BIN
web/assets/chat-bg.jpg
Normal file
BIN
web/assets/chat-bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 MiB |
457
web/index.html
457
web/index.html
@ -22,8 +22,12 @@
|
||||
|
||||
<style>
|
||||
#botmanWidgetRoot {
|
||||
display: none !important;
|
||||
}
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#botmanWidgetRoot .desktop-closed-message-avatar{
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
body.show-botman #botmanWidgetRoot {
|
||||
display: block !important;
|
||||
@ -87,204 +91,271 @@ body.show-botman #botmanWidgetRoot {
|
||||
<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">
|
||||
<img class="indicator" src="assets/nhance-loader.gif" alt="">
|
||||
</div>
|
||||
<script src="https://www.gstatic.com/firebasejs/10.7.0/firebase-app.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/10.7.0/firebase-auth.js"></script>
|
||||
<script type="module">
|
||||
// Import the functions you need from the SDKs you need
|
||||
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.4/firebase-app.js";
|
||||
<div id="loading_indicator" class="container overlay">
|
||||
<img class="indicator" src="assets/nhance-loader.gif" alt="">
|
||||
</div>
|
||||
<script src="https://www.gstatic.com/firebasejs/10.7.0/firebase-app.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/10.7.0/firebase-auth.js"></script>
|
||||
<script type="module">
|
||||
// Import the functions you need from the SDKs you need
|
||||
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.4/firebase-app.js";
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyC4yHbCX4mQu0jO81pJrDwxKLQlTQWofrc",
|
||||
authDomain: "nhance-ee8d1.firebaseapp.com",
|
||||
projectId: "nhance-ee8d1",
|
||||
storageBucket: "nhance-ee8d1.firebasestorage.app",
|
||||
messagingSenderId: "1084115316849",
|
||||
appId: "1:1084115316849:web:8fc3b1c886349ae86c6bd0"
|
||||
};
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyC4yHbCX4mQu0jO81pJrDwxKLQlTQWofrc",
|
||||
authDomain: "nhance-ee8d1.firebaseapp.com",
|
||||
projectId: "nhance-ee8d1",
|
||||
storageBucket: "nhance-ee8d1.firebasestorage.app",
|
||||
messagingSenderId: "1084115316849",
|
||||
appId: "1:1084115316849:web:8fc3b1c886349ae86c6bd0"
|
||||
};
|
||||
|
||||
// Initialize Firebase
|
||||
const app = initializeApp(firebaseConfig);
|
||||
</script>
|
||||
// Initialize Firebase
|
||||
const app = initializeApp(firebaseConfig);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', function(ev) {
|
||||
// Download main.dart.js
|
||||
_flutter.loader.loadEntrypoint({
|
||||
onEntrypointLoaded: function(engineInitializer) {
|
||||
engineInitializer.initializeEngine().then(function(appRunner) {
|
||||
appRunner.runApp();
|
||||
});
|
||||
}
|
||||
});
|
||||
<script>
|
||||
window.addEventListener('load', function(ev) {
|
||||
// Download main.dart.js
|
||||
_flutter.loader.loadEntrypoint({
|
||||
onEntrypointLoaded: function(engineInitializer) {
|
||||
engineInitializer.initializeEngine().then(function(appRunner) {
|
||||
appRunner.runApp();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
window.onLoad = function(){
|
||||
setTimeout(function () {
|
||||
var loadingIndicator = document.getElementById("loading_indicator");
|
||||
if(loadingIndicator){
|
||||
loadingIndicator.remove();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
window.onLoad = function(){
|
||||
setTimeout(function () {
|
||||
var loadingIndicator = document.getElementById("loading_indicator");
|
||||
if(loadingIndicator){
|
||||
loadingIndicator.remove();
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
<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;
|
||||
}
|
||||
|
||||
function getUpdatedParameters() {
|
||||
return {
|
||||
employee_id: localStorage.getItem('empPrimaryId') || '',
|
||||
session_id: generateSessionId(15),
|
||||
origin: "mobile",
|
||||
emp_code: localStorage.getItem('empCode') || '',
|
||||
client_id: localStorage.getItem('client_id') || '',
|
||||
client_branch_id: localStorage.getItem('empClientBranchId') || ''
|
||||
};
|
||||
}
|
||||
|
||||
function initializeBotman() {
|
||||
console.log("Initializing Botman Chat");
|
||||
|
||||
window.botmanWidget = {
|
||||
chatServer: 'https://venbait.in/nhance/chatbot/chat',
|
||||
frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
|
||||
title: "Ask ILA",
|
||||
introMessage: "",
|
||||
bubbleBackground: "#179a9f",
|
||||
mainColor: "#179a9f",
|
||||
placeholderText: "Type your message here...",
|
||||
aboutText: "Insurance Assistant ILA",
|
||||
enableAttachments: false,
|
||||
parameters: getUpdatedParameters()
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
watchBotmanState();
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
function repositionBotmanWidget() {
|
||||
const widget = document.querySelector('#botmanWidgetRoot > div');
|
||||
if (widget) {
|
||||
widget.style.bottom = "80px";
|
||||
widget.style.right = "10px";
|
||||
widget.style.minWidth = "90px";
|
||||
widget.style.minHeight = "120px";
|
||||
widget.style.zIndex = "9999";
|
||||
widget.style.pointerEvents = "auto";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function watchBotmanState() {
|
||||
const interval = setInterval(() => {
|
||||
const chatFrame = document.querySelector('iframe.botman-widget-frame');
|
||||
const widget = document.querySelector('#botmanWidgetRoot > div');
|
||||
|
||||
if (widget && chatFrame) {
|
||||
// Reposition on load (chat open)
|
||||
chatFrame.addEventListener('load', () => {
|
||||
setTimeout(repositionBotmanWidget, 300);
|
||||
});
|
||||
|
||||
// Observe DOM changes (chat close or resize)
|
||||
const observer = new MutationObserver(() => {
|
||||
repositionBotmanWidget();
|
||||
});
|
||||
|
||||
observer.observe(widget, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
repositionBotmanWidget(); // Also call initially
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
|
||||
function updateBotmanParameters() {
|
||||
console.log("Updating Botman parameters...");
|
||||
const updatedParams = getUpdatedParameters();
|
||||
|
||||
// Update Botman parameters
|
||||
if (window.botmanWidget) {
|
||||
window.botmanWidget.parameters = updatedParams;
|
||||
}
|
||||
|
||||
// Reload the Botman iframe with new parameters
|
||||
const chatFrame = document.querySelector('iframe.botman-widget-frame');
|
||||
if (chatFrame) {
|
||||
console.log("Reloading Botman iframe with new parameters...");
|
||||
chatFrame.src = `https://venbait.in/nhance/dev/widget?employee_id=${updatedParams.employee_id}&session_id=${updatedParams.session_id}&origin=mobile&emp_code=${updatedParams.emp_code}&client_id=${updatedParams.client_id}&client_branch_id=${updatedParams.client_branch_id}`;
|
||||
}
|
||||
}
|
||||
|
||||
function openBotmanChat() {
|
||||
const hiddenRoutes = ['/#login'];
|
||||
|
||||
function toggleBotmanVisibility() {
|
||||
const currentHash = window.location.hash;
|
||||
const shouldShow = !hiddenRoutes.includes(currentHash);
|
||||
document.body.classList.toggle('show-botman', shouldShow);
|
||||
console.log('Current hash:', currentHash, '| Botman visible:', shouldShow);
|
||||
}
|
||||
|
||||
// Initial check after load
|
||||
setTimeout(toggleBotmanVisibility, 500);
|
||||
|
||||
// React to route changes (Flutter uses hash-based routing)
|
||||
window.addEventListener('hashchange', () => {
|
||||
setTimeout(toggleBotmanVisibility, 300);
|
||||
});
|
||||
console.log("Opening chat...");
|
||||
// First, update Botman parameters with new values from localStorage
|
||||
updateBotmanParameters();
|
||||
|
||||
var checkBotman = setInterval(function () {
|
||||
if (typeof botmanChatWidget !== "undefined" && botmanChatWidget.open) {
|
||||
clearInterval(checkBotman);
|
||||
|
||||
const widget = document.getElementById('botmanWidgetRoot');
|
||||
if (widget) {
|
||||
widget.style.pointerEvents = 'auto'; // ✅ Enable interaction now
|
||||
}
|
||||
|
||||
botmanChatWidget.open();
|
||||
|
||||
setTimeout(function () {
|
||||
const emp_name = localStorage.getItem('gpaEmpName') || 'User';
|
||||
botmanChatWidget.sayAsBot(`Hi ${emp_name}, This is ILA, your Insurance Assistant. Please choose the following options.`);
|
||||
botmanChatWidget.whisper('Hi');
|
||||
}, 2000);
|
||||
} else {
|
||||
console.log("Waiting for Botman to initialize...");
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
// Initialize Botman on first load
|
||||
initializeBotman();
|
||||
// Optional: expose reposition function to Flutter
|
||||
window.repositionBotmanWidget = repositionBotmanWidget;
|
||||
</script>
|
||||
<script>
|
||||
(function () {
|
||||
// ✅ Set your background image here
|
||||
const IMAGE_URL = "$FLUTTER_BASE_HREFassets/chat-bg.jpg";
|
||||
|
||||
// Heuristic to find the BotMan iframe (works with default /botman/chat).
|
||||
// If you use a custom frameEndpoint, change the selector to match it.
|
||||
const iframeSelector = 'iframe[src*="/botman/chat"], iframe[src*="botman/chat"], iframe[src*="frameEndpoint"]';
|
||||
|
||||
// Apply styles inside the iframe
|
||||
function applyBackground(iframe) {
|
||||
try {
|
||||
const doc = iframe.contentDocument || iframe.contentWindow.document;
|
||||
if (!doc || !doc.head) return;
|
||||
|
||||
// Inject a <style> so it survives rerenders
|
||||
const style = doc.createElement('style');
|
||||
style.textContent = `
|
||||
html, body {
|
||||
background-image: url("${IMAGE_URL}") !important;
|
||||
background-size: cover !important;
|
||||
background-position: center !important;
|
||||
background-repeat: no-repeat !important;
|
||||
}
|
||||
/* Make common containers transparent so the image shows through.
|
||||
(Covers BotMan’s typical containers; harmless if some don’t exist.) */
|
||||
.chat, .chat-container, .bm-container, .bm-content, .messages, .message-container,
|
||||
.header, .footer {
|
||||
background: transparent !important;
|
||||
}
|
||||
`;
|
||||
doc.head.appendChild(style);
|
||||
} catch (e) {
|
||||
// Likely cross-origin; use Solution B instead.
|
||||
console.warn("Couldn't style BotMan iframe (cross-origin?). Use Solution B.", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Observe DOM for when the iframe is inserted/replaced
|
||||
const mo = new MutationObserver(() => {
|
||||
const iframe = document.querySelector(iframeSelector);
|
||||
if (!iframe) return;
|
||||
|
||||
// If iframe already loaded, apply now; also re-apply on every 'load'
|
||||
const maybeApply = () => applyBackground(iframe);
|
||||
if (iframe.contentDocument?.readyState === 'complete') {
|
||||
maybeApply();
|
||||
console.log("maybeApply");
|
||||
}
|
||||
iframe.addEventListener('load', maybeApply, { once: false });
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
// Start observing the whole document (BotMan injects the iframe dynamically)
|
||||
mo.observe(document.documentElement, { childList: true, subtree: true });
|
||||
|
||||
<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;
|
||||
// In case the iframe is already there by the time this runs
|
||||
const existing = document.querySelector(iframeSelector);
|
||||
if (existing) {
|
||||
if (existing.contentDocument?.readyState === 'complete') {
|
||||
applyBackground(existing);
|
||||
} else {
|
||||
existing.addEventListener('load', () => applyBackground(existing), { once: true });
|
||||
}
|
||||
}
|
||||
|
||||
function getUpdatedParameters() {
|
||||
return {
|
||||
employee_id: localStorage.getItem('empPrimaryId') || '',
|
||||
session_id: generateSessionId(15),
|
||||
origin: "mobile",
|
||||
emp_code: localStorage.getItem('empCode') || '',
|
||||
client_id: localStorage.getItem('client_id') || '',
|
||||
client_branch_id: localStorage.getItem('empClientBranchId') || ''
|
||||
};
|
||||
}
|
||||
|
||||
function initializeBotman() {
|
||||
console.log("Initializing Botman Chat");
|
||||
|
||||
window.botmanWidget = {
|
||||
chatServer: 'https://venbait.in/nhance/chatbot/chat',
|
||||
frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
|
||||
title: "Ask ILA",
|
||||
introMessage: "",
|
||||
bubbleBackground: "#007bff",
|
||||
mainColor: "#007bff",
|
||||
placeholderText: "Type your message here...",
|
||||
aboutText: "Insurance Assistant ILA",
|
||||
enableAttachments: false,
|
||||
parameters: getUpdatedParameters()
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
watchBotmanState();
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
function repositionBotmanWidget() {
|
||||
const widget = document.querySelector('#botmanWidgetRoot > div');
|
||||
if (widget) {
|
||||
widget.style.bottom = "80px";
|
||||
widget.style.right = "10px";
|
||||
widget.style.minWidth = "90px";
|
||||
widget.style.minHeight = "120px";
|
||||
widget.style.zIndex = "9999";
|
||||
widget.style.pointerEvents = "auto";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function watchBotmanState() {
|
||||
const interval = setInterval(() => {
|
||||
const chatFrame = document.querySelector('iframe.botman-widget-frame');
|
||||
const widget = document.querySelector('#botmanWidgetRoot > div');
|
||||
|
||||
if (widget && chatFrame) {
|
||||
// Reposition on load (chat open)
|
||||
chatFrame.addEventListener('load', () => {
|
||||
setTimeout(repositionBotmanWidget, 300);
|
||||
});
|
||||
|
||||
// Observe DOM changes (chat close or resize)
|
||||
const observer = new MutationObserver(() => {
|
||||
repositionBotmanWidget();
|
||||
});
|
||||
|
||||
observer.observe(widget, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
repositionBotmanWidget(); // Also call initially
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
|
||||
function updateBotmanParameters() {
|
||||
console.log("Updating Botman parameters...");
|
||||
const updatedParams = getUpdatedParameters();
|
||||
|
||||
// Update Botman parameters
|
||||
if (window.botmanWidget) {
|
||||
window.botmanWidget.parameters = updatedParams;
|
||||
}
|
||||
|
||||
// Reload the Botman iframe with new parameters
|
||||
const chatFrame = document.querySelector('iframe.botman-widget-frame');
|
||||
if (chatFrame) {
|
||||
console.log("Reloading Botman iframe with new parameters...");
|
||||
chatFrame.src = `https://venbait.in/nhance/dev/widget?employee_id=${updatedParams.employee_id}&session_id=${updatedParams.session_id}&origin=mobile&emp_code=${updatedParams.emp_code}&client_id=${updatedParams.client_id}&client_branch_id=${updatedParams.client_branch_id}`;
|
||||
}
|
||||
}
|
||||
|
||||
function openBotmanChat() {
|
||||
const hiddenRoutes = ['/#login'];
|
||||
|
||||
function toggleBotmanVisibility() {
|
||||
const currentHash = window.location.hash;
|
||||
const shouldShow = !hiddenRoutes.includes(currentHash);
|
||||
document.body.classList.toggle('show-botman', shouldShow);
|
||||
console.log('Current hash:', currentHash, '| Botman visible:', shouldShow);
|
||||
}
|
||||
|
||||
// Initial check after load
|
||||
setTimeout(toggleBotmanVisibility, 500);
|
||||
|
||||
// React to route changes (Flutter uses hash-based routing)
|
||||
window.addEventListener('hashchange', () => {
|
||||
setTimeout(toggleBotmanVisibility, 300);
|
||||
});
|
||||
console.log("Opening chat...");
|
||||
// First, update Botman parameters with new values from localStorage
|
||||
updateBotmanParameters();
|
||||
|
||||
var checkBotman = setInterval(function () {
|
||||
if (typeof botmanChatWidget !== "undefined" && botmanChatWidget.open) {
|
||||
clearInterval(checkBotman);
|
||||
|
||||
const widget = document.getElementById('botmanWidgetRoot');
|
||||
if (widget) {
|
||||
widget.style.pointerEvents = 'auto'; // ✅ Enable interaction now
|
||||
}
|
||||
|
||||
botmanChatWidget.open();
|
||||
|
||||
setTimeout(function () {
|
||||
const emp_name = localStorage.getItem('gpaEmpName') || 'User';
|
||||
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);
|
||||
}
|
||||
|
||||
// Initialize Botman on first load
|
||||
initializeBotman();
|
||||
// Optional: expose reposition function to Flutter
|
||||
window.repositionBotmanWidget = repositionBotmanWidget;
|
||||
</script>
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user