ticket flow add

This commit is contained in:
Surendiran 2025-08-19 09:28:41 +05:30
parent f063c3ac08
commit 9f4241fc9d
17 changed files with 2650 additions and 1780 deletions

View File

@ -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()

View File

@ -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(),
},
);
}

View File

@ -17,9 +17,13 @@ import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import '../models/platform_helper_mobile.dart'
if (dart.library.html) '../models/platform_helper_other.dart';
if (dart.library.html) '../models/platform_helper_other.dart';
// import 'dart:html' as html;
import '../pages/helpers/html_stub.dart'
if (dart.library.html) '../pages/helpers/html_web.dart';
// import '../pages/helpers/html_stub.dart' if (dart.library.html) 'html_web.dart';
class MyEmailVerify extends StatefulWidget {
final String email;
@ -146,7 +150,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
print('EMAIL PARAMS : ${widget.email} - OTP : $otp');
final response = await http.post(
Uri.parse(Environment.apiUrlEnrollment + 'getVerifiedUserData'),
body: json.encode({'email_id': widget.email, 'otp': _otpController.text}),
body:
json.encode({'email_id': widget.email, 'otp': _otpController.text}),
headers: {
HttpHeaders.contentTypeHeader: 'application/json',
},
@ -210,6 +215,23 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
}
}
void loginUser({
required String gpaEmpName,
required String empPrimaryId,
required String empCodeString,
required String client_id,
required String empClientBranchId,
}) {
HtmlHelper.saveLoginData({
'gpaEmpName': gpaEmpName,
'empPrimaryId': empPrimaryId,
'empCode': empCodeString,
'client_id': client_id,
'empClientBranchId': empClientBranchId,
});
print('Successfully Login');
}
void postSuccessData(post, data) async {
String status = data['status'];
String postStatus = post['status'];
@ -237,7 +259,15 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
print('Successfully Login');
// if(kIsWeb) {
loginUser(
gpaEmpName: gpaEmpName,
empPrimaryId: empPrimaryId,
empCodeString: empCodeString,
client_id: client_id,
empClientBranchId: empClientBranchId,
);
// if (kIsWeb) {
// html.window.localStorage['gpaEmpName'] = gpaEmpName;
// html.window.localStorage['empPrimaryId'] = empPrimaryId;
// html.window.localStorage['empCode'] = empCodeString;
@ -421,13 +451,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
final SharedPreferences prefs = await SharedPreferences.getInstance();
empMobileNo = prefs.getString('empMobileNo');
empEmailid = prefs.getString('empEmailid');
print('empMobileNo $empMobileNo' );
print('empMobileNo $empMobileNo');
print('empEmailid $empEmailid');
// _token = prefs.getString('token');
var params = {};
if (empMobileNo != null && empMobileNo.isNotEmpty) {
params = {'mobile_number': empMobileNo};
} else if(empEmailid != null && empEmailid.isNotEmpty){
} else if (empEmailid != null && empEmailid.isNotEmpty) {
params = {'email_id': empEmailid};
}
@ -453,14 +483,16 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
}
if (data['is_biometric_enabled'] != null) {
prefs.setString('is_biometric_enabled', data['is_biometric_enabled']);
prefs.setString(
'is_biometric_enabled', data['is_biometric_enabled']);
}
if (data['is_mpin_skipped'] != null) {
prefs.setString('is_mpin_skipped', data['is_mpin_skipped']);
}
if (data['is_mpin_skipped'] != null && data['is_mpin_skipped'] == '0') {
if (data['is_mpin_skipped'] != null &&
data['is_mpin_skipped'] == '0') {
Navigator.pushReplacementNamed(context, 'pinPage');
} else {
if (_postToken != null && _postToken.isNotEmpty) {
@ -470,7 +502,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
Navigator.pushReplacementNamed(context, 'empDetails');
}
}
} else {
Navigator.pushReplacementNamed(context, 'pinSettingPage');
}

View File

@ -0,0 +1 @@
export 'botman_stub.dart' if (dart.library.js) 'botman_web.dart';

View File

@ -0,0 +1,7 @@
void openBotmanChat() {
// No-op on mobile
}
void repositionBotman() {
// No-op on mobile
}

View 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');
}
}

View File

@ -0,0 +1,6 @@
// html_stub.dart
class HtmlHelper {
static void saveLoginData(Map<String, String> data) {
// No-op for non-web platforms
}
}

View 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).");
}
}

View File

@ -0,0 +1,3 @@
void setupBackButtonHandler(Function showDialogCallback) {
// No-op on mobile
}

View 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);
});
}

View File

@ -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,171 +424,142 @@ class _helpState extends State<help> {
),
),
)),
],
),
),
SizedBox(height: 5),
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: [
SizedBox(width: 10),
Expanded(
flex: 6,
child: Container(
alignment: Alignment.center,
child: GestureDetector(
onTap: () {
setState(() {
isActive = true;
// policyList.clear();
allClaimsActive = 0;
closedTrackActive = 1;
});
width: 300,
height: 150,
alignment: Alignment.centerLeft,
child: ElevatedButton(
onPressed: () {
Navigator.pushNamed(context, 'tickets');
},
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)),
'Raise a Ticket',
style: GoogleFonts.poppins(color: Colors.white),
),
),
)
: Text(
'All Claims',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
fontWeight: FontWeight.w400,
color: Color(0xFF636363),
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFFE26728),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
),
),
)),
],
),
),
SizedBox(height: 20),
// SizedBox(height: 15),
Container(
decoration: BoxDecoration(
color: Color(0xFFF6FAFF),
borderRadius: BorderRadius.circular(5),
),
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Responsive.isDesktop(context)
? Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
flex: 6,
child: Container(
alignment: Alignment.center,
child: GestureDetector(
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;
// trackClaimsList.clear();
allClaimsActive = 1;
closedTrackActive = 0;
tickets = 1;
});
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),
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)
@ -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(

View File

@ -18,14 +18,20 @@ import '../../customAppBar/customFooter.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/tabs.dart';
import '../../customAppBar/toastHelper.dart';
import 'botman_chat.dart';
import 'botman_ios_chat.dart';
import 'botman_widget_app.dart';
import 'chatbot.dart';
// import 'dart:js' as js;
// import 'dart:html' as html;
import 'package:webview_flutter_android/webview_flutter_android.dart';
import '/pages/helpers/botman_stub.dart'
if (dart.library.html) '/pages/helpers/botman_web.dart';
import '/../pages/helpers/mobile_helpers.dart'
if (dart.library.html) '/../pages/helpers/web_helpers.dart';
import 'package:webview_flutter_android/webview_flutter_android.dart';
class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
@ -64,6 +70,7 @@ class _HomeState extends State<Home> {
_currentIndex = index;
});
}
late final WebViewController _controller;
@override
@ -73,13 +80,16 @@ class _HomeState extends State<Home> {
_loadToken();
checkEnrollToken();
// if(kIsWeb){
// openBotmanChat();
//
//
// // Push a dummy state so back button triggers popstate instead of navigating
if (kIsWeb) {
openBotmanChat();
setupBackButtonHandler(() {
if (!_dialogShown) _showBackConfirmationDialog();
});
// 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) {
// if (!_dialogShown) {
// _showBackConfirmationDialog();
@ -87,11 +97,11 @@ class _HomeState extends State<Home> {
// // Re-push to prevent leaving
// html.window.history.pushState(null, 'home', html.window.location.href);
// });
// }
}
// if (Platform.isAndroid) {
// WebViewPlatform.instance = AndroidWebViewPlatform();
// }
//
// _controller = WebViewController()
// ..setJavaScriptMode(JavaScriptMode.unrestricted)
// ..loadFlutterAsset('assets/botman_chat.html'); // or loadHtmlString
@ -105,8 +115,8 @@ class _HomeState extends State<Home> {
// void openBotmanChat() {
// print('openBotmanChat');
// if (kIsWeb) {
// js.context.callMethod(
// 'openBotmanChat'); // Correct way to call JS function
// js.context
// .callMethod('openBotmanChat'); // Correct way to call JS function
// }
// }
//
@ -206,7 +216,7 @@ class _HomeState extends State<Home> {
});
print('check 1');
final response = await apiService.getActiveAndInactivePolicyDetails(
client_id!, empCodeString!, status, client_branch_id,mobileNo);
client_id!, empCodeString!, status, client_branch_id, mobileNo);
print('check 1');
if (response['status'] == 'success') {
setState(() {
@ -270,9 +280,12 @@ class _HomeState extends State<Home> {
}
String generateSessionId([int length = 15]) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
final random = Random.secure();
return List.generate(length, (index) => characters[random.nextInt(characters.length)]).join();
return List.generate(
length, (index) => characters[random.nextInt(characters.length)])
.join();
}
@override
@ -830,14 +843,14 @@ class _HomeState extends State<Home> {
Navigator.push(
context,
// MaterialPageRoute(builder: (context) => const BotmanChatPage()),
MaterialPageRoute(builder: (context) => ChatbotWebViewPage(
MaterialPageRoute(
builder: (context) => ChatbotWebViewPage(
client_branch_id: client_branch_id,
empCodeString: empCodeString,
empName:empName,
empPrimaryId:empPrimaryId,
client_id:client_id,
)
),
empName: empName,
empPrimaryId: empPrimaryId,
client_id: client_id,
)),
)
},
child: Icon(Icons.chat),
@ -1109,4 +1122,4 @@ class _HomeState extends State<Home> {
),
);
}
}
}

View 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;
},
);
}
}

View File

@ -18,10 +18,13 @@ import '../customAppBar/responsive.dart';
import '../customAppBar/toastHelper.dart';
import '../models/environment.dart';
import '../models/platform_helper_mobile.dart'
if (dart.library.html) '../models/platform_helper_other.dart';
if (dart.library.html) '../models/platform_helper_other.dart';
// import 'dart:html' as html;
import '../pages/helpers/html_stub.dart'
if (dart.library.html) '../pages/helpers/html_web.dart';
class MyVerify extends StatefulWidget {
final String verificationId;
final String mobileNumber;
@ -114,16 +117,12 @@ class _MyVerifyState extends State<MyVerify> {
super.dispose();
}
Future<void> initNotification() async {
try {
// await _firebaseMessaging.requestPermission();
fCMToken = await FirebaseMessaging.instance.getToken();
print('Token : $fCMToken');
if (fCMToken != null) {
await sendDeviceToken(fCMToken);
@ -294,6 +293,24 @@ class _MyVerifyState extends State<MyVerify> {
}
}
void loginUser({
required String gpaEmpName,
required String empPrimaryId,
required String empCodeString,
required String client_id,
required String empClientBranchId,
}) {
HtmlHelper.saveLoginData({
'gpaEmpName': gpaEmpName,
'empPrimaryId': empPrimaryId,
'empCode': empCodeString,
'client_id': client_id,
'empClientBranchId': empClientBranchId,
});
print('Successfully Login');
}
void postSuccessData(post, data) async {
String status = data['status'];
String postStatus = post['status'];
@ -319,7 +336,15 @@ class _MyVerifyState extends State<MyVerify> {
prefs.setString('emp_status', emp_status);
// getClientLogoAndDetails();
// if(kIsWeb) {
loginUser(
gpaEmpName: gpaEmpName,
empPrimaryId: empPrimaryId,
empCodeString: empCodeString,
client_id: client_id,
empClientBranchId: empClientBranchId,
);
// if (kIsWeb) {
// html.window.localStorage['gpaEmpName'] = gpaEmpName;
// html.window.localStorage['empPrimaryId'] = empPrimaryId;
// html.window.localStorage['empCode'] = empCodeString;
@ -454,7 +479,8 @@ class _MyVerifyState extends State<MyVerify> {
print('credential $credential');
final userCredential = await FirebaseAuth.instance.signInWithCredential(credential);
final userCredential =
await FirebaseAuth.instance.signInWithCredential(credential);
// await FirebaseAuth.instance.signInWithCredential(credential);
print('otp firebase check');
@ -485,7 +511,8 @@ class _MyVerifyState extends State<MyVerify> {
duration: Duration(seconds: 2),
),
);
ToastHelper.showErrorToast(context, 'OTP expired. Please request a new one.');
ToastHelper.showErrorToast(
context, 'OTP expired. Please request a new one.');
} else if (e.code == 'invalid-verification-code') {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@ -493,7 +520,8 @@ class _MyVerifyState extends State<MyVerify> {
duration: Duration(seconds: 2),
),
);
ToastHelper.showErrorToast(context, 'Invalid OTP entered. Please try again.');
ToastHelper.showErrorToast(
context, 'Invalid OTP entered. Please try again.');
} else if (e.code == 'session-expired') {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@ -501,7 +529,8 @@ class _MyVerifyState extends State<MyVerify> {
duration: Duration(seconds: 2),
),
);
ToastHelper.showErrorToast(context, 'Session expired. Try restarting the verification.');
ToastHelper.showErrorToast(
context, 'Session expired. Try restarting the verification.');
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@ -516,11 +545,11 @@ class _MyVerifyState extends State<MyVerify> {
// _isLoading = false;
// });
print('Error: $e');
ToastHelper.showErrorToast(context, 'Failed to verify OTP. Please try again.');
ToastHelper.showErrorToast(
context, 'Failed to verify OTP. Please try again.');
}
}
void _resendOTP() {
setState(() {
_secondsRemaining = 60;
@ -530,20 +559,19 @@ class _MyVerifyState extends State<MyVerify> {
widget.onResendCode(widget.mobileNumber, widget.resendToken);
}
Future<void> checkLoginPin(BuildContext context) async {
print('checkLoginPin');
try {
final SharedPreferences prefs = await SharedPreferences.getInstance();
empMobileNo = prefs.getString('empMobileNo');
empEmailid = prefs.getString('empEmailid');
print('empMobileNo $empMobileNo' );
print('empMobileNo $empMobileNo');
print('empEmailid $empEmailid');
// _token = prefs.getString('token');
var params = {};
if (empMobileNo != null && empMobileNo.isNotEmpty) {
params = {'mobile_number': empMobileNo};
} else if(empEmailid != null && empEmailid.isNotEmpty){
} else if (empEmailid != null && empEmailid.isNotEmpty) {
params = {'email_id': empEmailid};
}
@ -569,14 +597,16 @@ class _MyVerifyState extends State<MyVerify> {
}
if (data['is_biometric_enabled'] != null) {
prefs.setString('is_biometric_enabled', data['is_biometric_enabled']);
prefs.setString(
'is_biometric_enabled', data['is_biometric_enabled']);
}
if (data['is_mpin_skipped'] != null) {
prefs.setString('is_mpin_skipped', data['is_mpin_skipped']);
}
if (data['is_mpin_skipped'] != null && data['is_mpin_skipped'] == '0') {
if (data['is_mpin_skipped'] != null &&
data['is_mpin_skipped'] == '0') {
Navigator.pushReplacementNamed(context, 'pinPage');
} else {
if (_postToken != null && _postToken.isNotEmpty) {

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

View File

@ -23,7 +23,11 @@
<style>
#botmanWidgetRoot {
display: none !important;
}
}
#botmanWidgetRoot .desktop-closed-message-avatar{
box-shadow: none !important;
}
body.show-botman #botmanWidgetRoot {
display: block !important;
@ -87,12 +91,12 @@ 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">
<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">
</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";
@ -107,9 +111,9 @@ body.show-botman #botmanWidgetRoot {
// Initialize Firebase
const app = initializeApp(firebaseConfig);
</script>
</script>
<script>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
@ -120,8 +124,8 @@ body.show-botman #botmanWidgetRoot {
}
});
});
</script>
<script>
</script>
<script>
window.onLoad = function(){
setTimeout(function () {
var loadingIndicator = document.getElementById("loading_indicator");
@ -130,10 +134,10 @@ body.show-botman #botmanWidgetRoot {
}
});
};
</script>
</script>
<script>
<script>
@ -165,8 +169,8 @@ body.show-botman #botmanWidgetRoot {
frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
title: "Ask ILA",
introMessage: "",
bubbleBackground: "#007bff",
mainColor: "#007bff",
bubbleBackground: "#179a9f",
mainColor: "#179a9f",
placeholderText: "Type your message here...",
aboutText: "Insurance Assistant ILA",
enableAttachments: false,
@ -273,6 +277,7 @@ body.show-botman #botmanWidgetRoot {
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...");
@ -284,7 +289,73 @@ body.show-botman #botmanWidgetRoot {
initializeBotman();
// Optional: expose reposition function to Flutter
window.repositionBotmanWidget = repositionBotmanWidget;
</script>
</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 BotMans typical containers; harmless if some dont 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 });
});
// Start observing the whole document (BotMan injects the iframe dynamically)
mo.observe(document.documentElement, { childList: true, subtree: true });
// 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 });
}
}
})();
</script>
</body>
</html>
</html>