logs remove
This commit is contained in:
parent
edb8423099
commit
750a3becad
@ -19,12 +19,12 @@ if (project.hasProperty('google-services.json')) {
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '57'
|
||||
flutterVersionCode = '58'
|
||||
}
|
||||
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '2.0.19'
|
||||
flutterVersionName = '2.0.20'
|
||||
}
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
|
||||
BIN
assets/chatbot_icon.png
Normal file
BIN
assets/chatbot_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 665 KiB |
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
import 'package:adaptive_navbar/adaptive_navbar.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@ -7,6 +8,7 @@ import 'package:nhance_app_pwa/customAppBar/responsive.dart';
|
||||
|
||||
import '../pages/postEnrollment/service/api_service.dart';
|
||||
import '../pages/service/SessionManager.dart';
|
||||
import '../pages/service/TokenService.dart';
|
||||
import '../pages/service/popup_helper.dart';
|
||||
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
@override
|
||||
@ -32,7 +34,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
checkRetailOrNot() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
isRetailLoggedIn = prefs.getBool('isRetailLoggedIn') ?? false;
|
||||
print('isRetailLoggedIn Navbar $isRetailLoggedIn');
|
||||
logDebug('isRetailLoggedIn Navbar $isRetailLoggedIn');
|
||||
}
|
||||
|
||||
void handleMenuTap(VoidCallback? action) {
|
||||
@ -45,11 +47,10 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final String? token = prefs.getString('post_token');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
|
||||
if (token != null && token.isNotEmpty) {
|
||||
await prefs.clear();
|
||||
await SessionManager().clear();
|
||||
context.go('/login');
|
||||
// Navigator.pushNamed(context, 'phone');
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:adaptive_navbar/adaptive_navbar.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:nhance_app_pwa/customAppBar/responsive.dart';
|
||||
import '../features/chatbot/application/chatbot_reset_helper.dart';
|
||||
|
||||
class CustomAppBarChatbot extends StatelessWidget
|
||||
implements PreferredSizeWidget {
|
||||
@ -9,6 +10,7 @@ class CustomAppBarChatbot extends StatelessWidget
|
||||
Size get preferredSize => Size.fromHeight(kToolbarHeight);
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
ChatbotResetHelper.resetChatbot(context);
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final String? token = prefs.getString('token');
|
||||
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class CustomFooter extends StatelessWidget {
|
||||
@override
|
||||
|
||||
Future<String> _getAppVersion() async {
|
||||
try {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
print('App version: ${packageInfo.version}');
|
||||
logDebug('App version: ${packageInfo.version}');
|
||||
return packageInfo.version;
|
||||
} catch (e) {
|
||||
print('Error getting app version: $e');
|
||||
logDebug('Error getting app version: $e');
|
||||
return 'Unknown'; // Optional fallback
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:adaptive_navbar/adaptive_navbar.dart';
|
||||
@ -12,8 +11,10 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../config/environment.dart';
|
||||
import '../models/platform_helper_mobile.dart'
|
||||
if (dart.library.html) '../models/platform_helper_other.dart';
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
import '../pages/postEnrollment/service/api_service.dart';
|
||||
import '../pages/service/SessionManager.dart';
|
||||
import '../pages/service/TokenService.dart';
|
||||
import '../pages/service/popup_helper.dart';
|
||||
|
||||
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
@ -41,17 +42,14 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
}
|
||||
|
||||
Future<void> checkEnrollToken() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final pre = await TokenService.getPreToken();
|
||||
setState(() {
|
||||
isTokenAvailable = prefs.getString('pre_token') != null;
|
||||
isTokenAvailable = pre != null && pre.isNotEmpty;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getEmpStatus() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// final empStatusValue = prefs.getString('enrollmentEmp_status');
|
||||
final postTokenValue = prefs.getString('post_token');
|
||||
final postTokenValue = await TokenService.getPostToken();
|
||||
|
||||
setState(() {
|
||||
// // empStatus: null-safe + empty-safe
|
||||
@ -63,19 +61,19 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
isTokenAvailable =
|
||||
postTokenValue != null && postTokenValue.trim().isNotEmpty;
|
||||
|
||||
debugPrint('empStatus: $empStatus');
|
||||
debugPrint('isTokenAvailable: $isTokenAvailable');
|
||||
logDebug('empStatus: $empStatus');
|
||||
logDebug('isTokenAvailable: $isTokenAvailable');
|
||||
});
|
||||
}
|
||||
|
||||
Future<String?> checkLoginPin() async {
|
||||
print('checkLoginPin');
|
||||
logDebug('checkLoginPin');
|
||||
try {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final empMobileNo = prefs.getString('empMobileNo');
|
||||
final empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo $empMobileNo');
|
||||
print('empEmailid $empEmailid');
|
||||
logDebug('empMobileNo $empMobileNo');
|
||||
logDebug('empEmailid $empEmailid');
|
||||
|
||||
var params = {};
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
@ -84,13 +82,13 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
params = {'email_id': empEmailid};
|
||||
}
|
||||
|
||||
print('params $params');
|
||||
logDebug('params $params');
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrlEnrollment + 'checkMpin'),
|
||||
body: json.encode(params),
|
||||
headers: {
|
||||
HttpHeaders.contentTypeHeader: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'APP-SIGNATURE':
|
||||
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||
},
|
||||
@ -116,11 +114,11 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('❌ API failed: ${response.statusCode}');
|
||||
logDebug('❌ API failed: ${response.statusCode}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ Error: $e');
|
||||
logDebug('❌ Error: $e');
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
@ -138,40 +136,40 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
String? mobileNumber = prefs.getString('empMobileNo');
|
||||
String? mailID = prefs.getString('empEmailid');
|
||||
final isMpinSkipped = await checkLoginPin();
|
||||
print('isMpinSkipped $isMpinSkipped');
|
||||
logDebug('isMpinSkipped $isMpinSkipped');
|
||||
// bool? biometricStatus = prefs.getBool('biometricStatus') ?? false;
|
||||
// int? skipStatus = prefs.getInt('skipStatus') ?? 1;
|
||||
|
||||
// Clear all keys
|
||||
await SessionManager().clear();
|
||||
// await prefs.clear();
|
||||
print('Local Storage Clear');
|
||||
logDebug('Local Storage Clear');
|
||||
|
||||
// html.window.localStorage.clear();
|
||||
// Re-set the mobile_number key
|
||||
if (isMobilePlatform()) {
|
||||
if (mobileNumber != null) {
|
||||
await prefs.setString('empMobileNo', mobileNumber);
|
||||
print('empMobileNo $mobileNumber');
|
||||
logDebug('empMobileNo $mobileNumber');
|
||||
// await prefs.setBool('biometricStatus', biometricStatus!);
|
||||
// await prefs.setInt('skipStatus', skipStatus!);
|
||||
}
|
||||
if (mailID != null) {
|
||||
await prefs.setString('empEmailid', mailID);
|
||||
print('empEmailid $mailID');
|
||||
logDebug('empEmailid $mailID');
|
||||
// await prefs.setBool('biometricStatus', biometricStatus!);
|
||||
// await prefs.setInt('skipStatus', skipStatus!);
|
||||
}
|
||||
if (isMpinSkipped != null) {
|
||||
await prefs.setString('is_mpin_skipped', isMpinSkipped!);
|
||||
print('isMpinSkipped $isMpinSkipped');
|
||||
logDebug('isMpinSkipped $isMpinSkipped');
|
||||
}
|
||||
if (isMpinSkipped != null && isMpinSkipped == '0') {
|
||||
print('pinPage');
|
||||
logDebug('pinPage');
|
||||
// return;
|
||||
context.go('/pinPage');
|
||||
} else {
|
||||
print('login');
|
||||
logDebug('login');
|
||||
context.go('/login');
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
// import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:toastification/toastification.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class ToastHelper {
|
||||
static void showSuccessToast(BuildContext context, String message) {
|
||||
toastification.show(
|
||||
@ -44,12 +46,12 @@ class ToastHelper {
|
||||
dragToClose: true,
|
||||
applyBlurEffect: true,
|
||||
callbacks: ToastificationCallbacks(
|
||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
||||
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||
onCloseButtonTap: (toastItem) =>
|
||||
print('Toast ${toastItem.id} close button tapped'),
|
||||
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||
onAutoCompleteCompleted: (toastItem) =>
|
||||
print('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
||||
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -95,12 +97,12 @@ class ToastHelper {
|
||||
dragToClose: true,
|
||||
applyBlurEffect: true,
|
||||
callbacks: ToastificationCallbacks(
|
||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
||||
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||
onCloseButtonTap: (toastItem) =>
|
||||
print('Toast ${toastItem.id} close button tapped'),
|
||||
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||
onAutoCompleteCompleted: (toastItem) =>
|
||||
print('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
||||
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -146,12 +148,12 @@ class ToastHelper {
|
||||
dragToClose: true,
|
||||
applyBlurEffect: true,
|
||||
callbacks: ToastificationCallbacks(
|
||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
||||
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||
onCloseButtonTap: (toastItem) =>
|
||||
print('Toast ${toastItem.id} close button tapped'),
|
||||
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||
onAutoCompleteCompleted: (toastItem) =>
|
||||
print('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
||||
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||
),
|
||||
);
|
||||
// _showToast(context, message, Colors.red);
|
||||
@ -198,12 +200,12 @@ class ToastHelper {
|
||||
dragToClose: true,
|
||||
applyBlurEffect: true,
|
||||
callbacks: ToastificationCallbacks(
|
||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
||||
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||
onCloseButtonTap: (toastItem) =>
|
||||
print('Toast ${toastItem.id} close button tapped'),
|
||||
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||
onAutoCompleteCompleted: (toastItem) =>
|
||||
print('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
||||
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||
),
|
||||
);
|
||||
// _showToast(context, message, Colors.red);
|
||||
|
||||
411
lib/features/chatbot/application/chatbot_controller.dart
Normal file
411
lib/features/chatbot/application/chatbot_controller.dart
Normal file
@ -0,0 +1,411 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/data/chatbot_api_service.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/data/chatbot_repository.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/domain/models/chatbot_models.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
final chatbotRepositoryProvider = Provider<ChatbotRepository>((ref) {
|
||||
return ChatbotRepository(ChatbotApiService());
|
||||
});
|
||||
|
||||
final chatbotControllerProvider =
|
||||
StateNotifierProvider<ChatbotController, ChatbotUiState>((ref) {
|
||||
return ChatbotController(ref.read(chatbotRepositoryProvider));
|
||||
});
|
||||
|
||||
class ChatbotUiState {
|
||||
final bool isOpen;
|
||||
final bool isIntroAnimating;
|
||||
final bool isLoading;
|
||||
final String? errorMessage;
|
||||
final ChatbotFlowStep step;
|
||||
final List<ChatbotMessage> messages;
|
||||
final List<ChatbotOption> options;
|
||||
final List<ChatbotPolicy> policies;
|
||||
final ChatbotPolicy? selectedPolicy;
|
||||
final List<ClaimStatusItem> claimStatuses;
|
||||
|
||||
const ChatbotUiState({
|
||||
required this.isOpen,
|
||||
required this.isIntroAnimating,
|
||||
required this.isLoading,
|
||||
required this.errorMessage,
|
||||
required this.step,
|
||||
required this.messages,
|
||||
required this.options,
|
||||
required this.policies,
|
||||
required this.selectedPolicy,
|
||||
required this.claimStatuses,
|
||||
});
|
||||
|
||||
factory ChatbotUiState.initial() {
|
||||
return ChatbotUiState(
|
||||
isOpen: false,
|
||||
isIntroAnimating: false,
|
||||
isLoading: false,
|
||||
errorMessage: null,
|
||||
step: ChatbotFlowStep.rootMenu,
|
||||
messages: [
|
||||
ChatbotMessage(
|
||||
text: 'Welcome! I’m here to assist you with your policy services. Please choose an option to continue.',
|
||||
isBot: true,
|
||||
createdAt: DateTime.now(),
|
||||
),
|
||||
],
|
||||
options: const [
|
||||
ChatbotOption(id: 'my_policies', label: 'My Policies'),
|
||||
ChatbotOption(id: 'claims_procedure', label: 'Claims Procedure'),
|
||||
ChatbotOption(id: 'my_claims_status', label: 'My Claims Status'),
|
||||
ChatbotOption(id: 'help', label: 'Help'),
|
||||
],
|
||||
policies: const [],
|
||||
selectedPolicy: null,
|
||||
claimStatuses: const [],
|
||||
);
|
||||
}
|
||||
|
||||
ChatbotUiState copyWith({
|
||||
bool? isOpen,
|
||||
bool? isIntroAnimating,
|
||||
bool? isLoading,
|
||||
String? errorMessage,
|
||||
bool clearError = false,
|
||||
ChatbotFlowStep? step,
|
||||
List<ChatbotMessage>? messages,
|
||||
List<ChatbotOption>? options,
|
||||
List<ChatbotPolicy>? policies,
|
||||
ChatbotPolicy? selectedPolicy,
|
||||
bool clearSelectedPolicy = false,
|
||||
List<ClaimStatusItem>? claimStatuses,
|
||||
}) {
|
||||
return ChatbotUiState(
|
||||
isOpen: isOpen ?? this.isOpen,
|
||||
isIntroAnimating: isIntroAnimating ?? this.isIntroAnimating,
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
errorMessage: clearError ? null : (errorMessage ?? this.errorMessage),
|
||||
step: step ?? this.step,
|
||||
messages: messages ?? this.messages,
|
||||
options: options ?? this.options,
|
||||
policies: policies ?? this.policies,
|
||||
selectedPolicy:
|
||||
clearSelectedPolicy ? null : (selectedPolicy ?? this.selectedPolicy),
|
||||
claimStatuses: claimStatuses ?? this.claimStatuses,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChatbotController extends StateNotifier<ChatbotUiState> {
|
||||
final ChatbotRepository _repository;
|
||||
List<ChatbotPolicy>? _policiesCache;
|
||||
DateTime? _policiesCacheAt;
|
||||
static const Duration _cacheTtl = Duration(minutes: 10);
|
||||
|
||||
bool _didHomeIntroAnimation = false;
|
||||
|
||||
ChatbotController(this._repository) : super(ChatbotUiState.initial());
|
||||
|
||||
void toggleOpen() {
|
||||
state = state.copyWith(isOpen: !state.isOpen);
|
||||
}
|
||||
|
||||
void close() {
|
||||
state = state.copyWith(isOpen: false);
|
||||
}
|
||||
|
||||
void resetAll() {
|
||||
_policiesCache = null;
|
||||
_policiesCacheAt = null;
|
||||
_didHomeIntroAnimation = false;
|
||||
state = ChatbotUiState.initial();
|
||||
}
|
||||
|
||||
Future<void> triggerHomeIntroAnimation() async {
|
||||
if (_didHomeIntroAnimation) return;
|
||||
_didHomeIntroAnimation = true;
|
||||
|
||||
state = state.copyWith(isIntroAnimating: true);
|
||||
|
||||
await Future.delayed(const Duration(milliseconds: 900));
|
||||
state = state.copyWith(isIntroAnimating: false);
|
||||
}
|
||||
|
||||
List<ClaimStatusItem> _latestThreeClaims(List<ClaimStatusItem> claims) {
|
||||
if (claims.length <= 3) return List<ClaimStatusItem>.from(claims.reversed);
|
||||
return claims.reversed.take(3).toList();
|
||||
}
|
||||
|
||||
void _appendUserMessage(String text) {
|
||||
final updated = List<ChatbotMessage>.from(state.messages)
|
||||
..add(
|
||||
ChatbotMessage(
|
||||
text: text,
|
||||
isBot: false,
|
||||
createdAt: DateTime.now(),
|
||||
),
|
||||
);
|
||||
state = state.copyWith(messages: updated);
|
||||
}
|
||||
|
||||
void _appendBotMessage(String text) {
|
||||
final updated = List<ChatbotMessage>.from(state.messages)
|
||||
..add(
|
||||
ChatbotMessage(
|
||||
text: text,
|
||||
isBot: true,
|
||||
createdAt: DateTime.now(),
|
||||
),
|
||||
);
|
||||
state = state.copyWith(messages: updated);
|
||||
}
|
||||
|
||||
void _showRootMenu() {
|
||||
state = state.copyWith(
|
||||
step: ChatbotFlowStep.rootMenu,
|
||||
options: const [
|
||||
ChatbotOption(id: 'my_policies', label: 'My Policies'),
|
||||
ChatbotOption(id: 'claims_procedure', label: 'Claims Procedure'),
|
||||
ChatbotOption(id: 'my_claims_status', label: 'My Claims Status'),
|
||||
ChatbotOption(id: 'help', label: 'Help'),
|
||||
],
|
||||
clearSelectedPolicy: true,
|
||||
clearError: true,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> onOptionSelected(
|
||||
BuildContext context,
|
||||
ChatbotOption option,
|
||||
) async {
|
||||
_appendUserMessage(option.label);
|
||||
|
||||
switch (option.id) {
|
||||
case 'my_policies':
|
||||
await loadPolicies(context);
|
||||
return;
|
||||
case 'claims_procedure':
|
||||
_appendBotMessage('Opening claims page.');
|
||||
close();
|
||||
context.go('/claimprocess', extra: 2);
|
||||
return;
|
||||
case 'my_claims_status':
|
||||
await loadClaimsStatus(context);
|
||||
return;
|
||||
case 'help':
|
||||
_appendBotMessage('Opening help page.');
|
||||
close();
|
||||
context.go('/help');
|
||||
return;
|
||||
case 'covered_member_list':
|
||||
showCoveredMembers();
|
||||
return;
|
||||
case 'ecard_download':
|
||||
await openEcard();
|
||||
return;
|
||||
case 'covered_hospital_list':
|
||||
await openHospitalList();
|
||||
return;
|
||||
case 'back_to_root':
|
||||
_appendBotMessage('Back to main menu.');
|
||||
_showRootMenu();
|
||||
return;
|
||||
case 'back_to_policies':
|
||||
_appendBotMessage('Choose a policy.');
|
||||
state = state.copyWith(
|
||||
step: ChatbotFlowStep.policyList,
|
||||
options: _policyOptions(state.policies),
|
||||
clearSelectedPolicy: true,
|
||||
clearError: true,
|
||||
);
|
||||
return;
|
||||
default:
|
||||
if (option.id.startsWith('policy::')) {
|
||||
final policyId = option.id.replaceFirst('policy::', '');
|
||||
final selected = state.policies.firstWhere(
|
||||
(policy) => policy.clientPolicyId == policyId,
|
||||
orElse: () => state.policies.first,
|
||||
);
|
||||
selectPolicy(selected);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<ChatbotOption> _policyOptions(List<ChatbotPolicy> policies) {
|
||||
final policyOptions = policies
|
||||
.map((policy) => ChatbotOption(
|
||||
id: 'policy::${policy.clientPolicyId}',
|
||||
label: policy.policyName,
|
||||
))
|
||||
.toList();
|
||||
return [
|
||||
...policyOptions,
|
||||
const ChatbotOption(id: 'back_to_root', label: 'Back'),
|
||||
];
|
||||
}
|
||||
|
||||
Future<void> loadPolicies(BuildContext context) async {
|
||||
final now = DateTime.now();
|
||||
final canUseCache = _policiesCache != null &&
|
||||
_policiesCacheAt != null &&
|
||||
now.difference(_policiesCacheAt!) < _cacheTtl;
|
||||
|
||||
if (canUseCache) {
|
||||
final cachedPolicies = _policiesCache!;
|
||||
if (cachedPolicies.isEmpty) {
|
||||
_appendBotMessage('No active policies found.');
|
||||
_showRootMenu();
|
||||
} else {
|
||||
_appendBotMessage('Choose a policy.');
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
policies: cachedPolicies,
|
||||
step: ChatbotFlowStep.policyList,
|
||||
options: _policyOptions(cachedPolicies),
|
||||
clearError: true,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
state = state.copyWith(isLoading: true, clearError: true);
|
||||
try {
|
||||
final policies = await _repository.getPolicies(context);
|
||||
_policiesCache = policies;
|
||||
_policiesCacheAt = DateTime.now();
|
||||
if (policies.isEmpty) {
|
||||
_appendBotMessage('No active policies found.');
|
||||
_showRootMenu();
|
||||
} else {
|
||||
_appendBotMessage('Choose a policy.');
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
policies: policies,
|
||||
step: ChatbotFlowStep.policyList,
|
||||
options: _policyOptions(policies),
|
||||
);
|
||||
}
|
||||
} catch (_) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: 'Unable to load policies. Please try again.',
|
||||
);
|
||||
_appendBotMessage('Unable to load policies right now.');
|
||||
_showRootMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void selectPolicy(ChatbotPolicy policy) {
|
||||
_appendBotMessage('Selected ${policy.policyName}.');
|
||||
state = state.copyWith(
|
||||
selectedPolicy: policy,
|
||||
step: ChatbotFlowStep.policyActions,
|
||||
options: const [
|
||||
ChatbotOption(id: 'covered_member_list', label: 'Covered Member List'),
|
||||
ChatbotOption(id: 'ecard_download', label: 'E-Card Download'),
|
||||
ChatbotOption(id: 'covered_hospital_list', label: 'Covered Hospital List'),
|
||||
ChatbotOption(id: 'back_to_policies', label: 'Back to Policies'),
|
||||
],
|
||||
clearError: true,
|
||||
);
|
||||
}
|
||||
|
||||
void showCoveredMembers() {
|
||||
final policy = state.selectedPolicy;
|
||||
if (policy == null) {
|
||||
_appendBotMessage('Please choose a policy first.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (policy.members.isEmpty) {
|
||||
_appendBotMessage('No covered members found for this policy.');
|
||||
} else {
|
||||
final names = policy.members
|
||||
.map((member) => '${member.name} (${member.relationship})')
|
||||
.join('\n');
|
||||
_appendBotMessage('Covered members:\n$names');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> openEcard() async {
|
||||
final policy = state.selectedPolicy;
|
||||
if (policy == null) {
|
||||
_appendBotMessage('Please choose a policy first.');
|
||||
return;
|
||||
}
|
||||
|
||||
final url = policy.eCardDownloadUrl.trim();
|
||||
if (url.isEmpty) {
|
||||
_appendBotMessage('E-Card is not available for this policy.');
|
||||
return;
|
||||
}
|
||||
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri == null) {
|
||||
_appendBotMessage('E-Card link is invalid.');
|
||||
return;
|
||||
}
|
||||
|
||||
final launched = await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
if (!launched) {
|
||||
_appendBotMessage('Unable to open E-Card link.');
|
||||
return;
|
||||
}
|
||||
_appendBotMessage('Opened E-Card in browser.');
|
||||
}
|
||||
|
||||
Future<void> openHospitalList() async {
|
||||
final policy = state.selectedPolicy;
|
||||
if (policy == null) {
|
||||
_appendBotMessage('Please choose a policy first.');
|
||||
return;
|
||||
}
|
||||
|
||||
final url = policy.networkHospitalsUrl.trim();
|
||||
if (url.isEmpty) {
|
||||
_appendBotMessage('Hospital list link is not available.');
|
||||
return;
|
||||
}
|
||||
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri == null) {
|
||||
_appendBotMessage('Hospital list link is invalid.');
|
||||
return;
|
||||
}
|
||||
|
||||
final launched = await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
if (!launched) {
|
||||
_appendBotMessage('Unable to open hospital list link.');
|
||||
return;
|
||||
}
|
||||
_appendBotMessage('Opened hospital list in browser.');
|
||||
}
|
||||
|
||||
Future<void> loadClaimsStatus(BuildContext context) async {
|
||||
state = state.copyWith(isLoading: true, clearError: true);
|
||||
try {
|
||||
final claims = await _repository.getClaimStatuses(context);
|
||||
final latestClaims = _latestThreeClaims(claims);
|
||||
if (claims.isEmpty) {
|
||||
_appendBotMessage('No claims found.');
|
||||
} else {
|
||||
_appendBotMessage('Here is your latest claims status.');
|
||||
}
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
step: ChatbotFlowStep.claimStatusList,
|
||||
claimStatuses: latestClaims,
|
||||
options: const [ChatbotOption(id: 'back_to_root', label: 'Back')],
|
||||
);
|
||||
} catch (_) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: 'Unable to load claims status. Please try again.',
|
||||
);
|
||||
_appendBotMessage('Unable to load claims status right now.');
|
||||
_showRootMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
16
lib/features/chatbot/application/chatbot_reset_helper.dart
Normal file
16
lib/features/chatbot/application/chatbot_reset_helper.dart
Normal file
@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'chatbot_controller.dart';
|
||||
|
||||
class ChatbotResetHelper {
|
||||
static void resetChatbot(BuildContext context) {
|
||||
try {
|
||||
final container = ProviderScope.containerOf(context, listen: false);
|
||||
container.read(chatbotControllerProvider.notifier).resetAll();
|
||||
} catch (_) {
|
||||
// If no ProviderScope is found (or provider is unavailable), ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
lib/features/chatbot/data/chatbot_api_service.dart
Normal file
30
lib/features/chatbot/data/chatbot_api_service.dart
Normal file
@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
|
||||
import 'package:nhance_app_pwa/pages/service/SessionManager.dart';
|
||||
|
||||
class ChatbotApiService {
|
||||
Future<Map<String, dynamic>> fetchPolicies(BuildContext context) async {
|
||||
final session = SessionManager();
|
||||
final api = ApiService(context);
|
||||
|
||||
return api.getActiveAndInactivePolicyDetails(
|
||||
session.client_id,
|
||||
session.empCodeString,
|
||||
'Active',
|
||||
session.empClientBranchId,
|
||||
session.mobileNo,
|
||||
session.empEmailCorporate,
|
||||
);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchClaimsStatus(BuildContext context) async {
|
||||
final session = SessionManager();
|
||||
final api = ApiService(context);
|
||||
|
||||
return api.getTrackClaimsList(
|
||||
session.empPrimaryId ?? '',
|
||||
session.mobileNo ?? '',
|
||||
session.empEmailCorporate ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
28
lib/features/chatbot/data/chatbot_repository.dart
Normal file
28
lib/features/chatbot/data/chatbot_repository.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/data/chatbot_api_service.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/domain/models/chatbot_models.dart';
|
||||
|
||||
class ChatbotRepository {
|
||||
final ChatbotApiService _apiService;
|
||||
|
||||
const ChatbotRepository(this._apiService);
|
||||
|
||||
Future<List<ChatbotPolicy>> getPolicies(BuildContext context) async {
|
||||
final response = await _apiService.fetchPolicies(context);
|
||||
final data = (response['data'] as List?) ?? const [];
|
||||
return data
|
||||
.whereType<Map>()
|
||||
.map((item) => ChatbotPolicy.fromJson(Map<String, dynamic>.from(item)))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<List<ClaimStatusItem>> getClaimStatuses(BuildContext context) async {
|
||||
final response = await _apiService.fetchClaimsStatus(context);
|
||||
final data = (response['ticket_data'] as List?) ?? const [];
|
||||
return data
|
||||
.whereType<Map>()
|
||||
.map((item) =>
|
||||
ClaimStatusItem.fromJson(Map<String, dynamic>.from(item)))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
104
lib/features/chatbot/domain/models/chatbot_models.dart
Normal file
104
lib/features/chatbot/domain/models/chatbot_models.dart
Normal file
@ -0,0 +1,104 @@
|
||||
class PolicyMember {
|
||||
final String id;
|
||||
final String name;
|
||||
final String relationship;
|
||||
|
||||
const PolicyMember({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.relationship,
|
||||
});
|
||||
|
||||
factory PolicyMember.fromJson(Map<String, dynamic> json) {
|
||||
return PolicyMember(
|
||||
id: (json['id'] ?? json['employee_id'] ?? '').toString(),
|
||||
name: (json['name'] ?? '').toString(),
|
||||
relationship: (json['relationship'] ?? '').toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChatbotPolicy {
|
||||
final String clientPolicyId;
|
||||
final String policyName;
|
||||
final String eCardDownloadUrl;
|
||||
final String networkHospitalsUrl;
|
||||
final List<PolicyMember> members;
|
||||
|
||||
const ChatbotPolicy({
|
||||
required this.clientPolicyId,
|
||||
required this.policyName,
|
||||
required this.eCardDownloadUrl,
|
||||
required this.networkHospitalsUrl,
|
||||
required this.members,
|
||||
});
|
||||
|
||||
factory ChatbotPolicy.fromJson(Map<String, dynamic> json) {
|
||||
final membersRaw = (json['EmployeePolicy'] as List?) ?? const [];
|
||||
return ChatbotPolicy(
|
||||
clientPolicyId: (json['client_policy_id'] ?? '').toString(),
|
||||
policyName: (json['heading'] ?? 'Unnamed Policy').toString(),
|
||||
eCardDownloadUrl: (json['eCardDownload'] ?? '').toString(),
|
||||
networkHospitalsUrl: (json['network_hospitals_url'] ?? '').toString(),
|
||||
members: membersRaw
|
||||
.whereType<Map>()
|
||||
.map((item) => PolicyMember.fromJson(Map<String, dynamic>.from(item)))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ClaimStatusItem {
|
||||
final String claimNumber;
|
||||
final String status;
|
||||
final String amount;
|
||||
final String date;
|
||||
|
||||
const ClaimStatusItem({
|
||||
required this.claimNumber,
|
||||
required this.status,
|
||||
required this.amount,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
factory ClaimStatusItem.fromJson(Map<String, dynamic> json) {
|
||||
return ClaimStatusItem(
|
||||
claimNumber: (json['claim_no'] ?? json['ticket_id'] ?? json['id'] ?? '-')
|
||||
.toString(),
|
||||
status: (json['claim_status'] ?? json['status'] ?? 'Pending').toString(),
|
||||
amount: (json['claim_amount'] ?? json['amount'] ?? '0').toString(),
|
||||
date: (json['created_at'] ?? json['date'] ?? '-').toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum ChatbotFlowStep {
|
||||
rootMenu,
|
||||
policyList,
|
||||
policyActions,
|
||||
memberList,
|
||||
claimStatusList,
|
||||
helpMenu,
|
||||
}
|
||||
|
||||
class ChatbotMessage {
|
||||
final String text;
|
||||
final bool isBot;
|
||||
final DateTime createdAt;
|
||||
|
||||
const ChatbotMessage({
|
||||
required this.text,
|
||||
required this.isBot,
|
||||
required this.createdAt,
|
||||
});
|
||||
}
|
||||
|
||||
class ChatbotOption {
|
||||
final String id;
|
||||
final String label;
|
||||
|
||||
const ChatbotOption({
|
||||
required this.id,
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
83
lib/features/chatbot/presentation/chatbot_host.dart
Normal file
83
lib/features/chatbot/presentation/chatbot_host.dart
Normal file
@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:nhance_app_pwa/customAppBar/responsive.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/application/chatbot_controller.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/presentation/widgets/chatbot_fab.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/presentation/widgets/chatbot_window.dart';
|
||||
|
||||
class ChatbotHost extends ConsumerStatefulWidget {
|
||||
final Widget child;
|
||||
final bool triggerIntroOnHome;
|
||||
|
||||
const ChatbotHost({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.triggerIntroOnHome = false,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<ChatbotHost> createState() => _ChatbotHostState();
|
||||
}
|
||||
|
||||
class _ChatbotHostState extends ConsumerState<ChatbotHost> {
|
||||
bool _didFireIntro = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!widget.triggerIntroOnHome) return;
|
||||
if (_didFireIntro) return;
|
||||
_didFireIntro = true;
|
||||
ref.read(chatbotControllerProvider.notifier).triggerHomeIntroAnimation();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = ref.watch(chatbotControllerProvider);
|
||||
final controller = ref.read(chatbotControllerProvider.notifier);
|
||||
|
||||
final isMobile = Responsive.isMobile(context);
|
||||
final isTablet = Responsive.isTablet(context);
|
||||
|
||||
final mobileBottomInset =
|
||||
MediaQuery.of(context).padding.bottom + kBottomNavigationBarHeight + 10;
|
||||
final edgeInsets = isMobile
|
||||
? EdgeInsets.only(right: 12, bottom: mobileBottomInset)
|
||||
: isTablet
|
||||
? const EdgeInsets.only(right: 18, bottom: 22)
|
||||
: const EdgeInsets.only(right: 24, bottom: 24);
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
widget.child,
|
||||
if (!(isMobile && state.isOpen))
|
||||
Positioned(
|
||||
right: edgeInsets.right,
|
||||
bottom: edgeInsets.bottom,
|
||||
child: AnimatedScale(
|
||||
scale: state.isIntroAnimating ? 1.14 : 1.0,
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.easeOut,
|
||||
child: ChatbotFab(
|
||||
isOpen: state.isOpen,
|
||||
onTap: controller.toggleOpen,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.isOpen)
|
||||
isMobile
|
||||
? const Positioned.fill(
|
||||
child: ChatbotWindow(),
|
||||
)
|
||||
: Positioned(
|
||||
right: edgeInsets.right,
|
||||
bottom: edgeInsets.bottom + 70,
|
||||
child: const ChatbotWindow(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
31
lib/features/chatbot/presentation/widgets/chatbot_fab.dart
Normal file
31
lib/features/chatbot/presentation/widgets/chatbot_fab.dart
Normal file
@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatbotFab extends StatelessWidget {
|
||||
final VoidCallback onTap;
|
||||
final bool isOpen;
|
||||
|
||||
const ChatbotFab({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
required this.isOpen,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FloatingActionButton(
|
||||
heroTag: 'chatbot_fab',
|
||||
// backgroundColor: Color(0XFF00999E),
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 6,
|
||||
onPressed: onTap,
|
||||
child: ClipOval(
|
||||
child: Image.asset(
|
||||
'assets/chatbot_icon.png',
|
||||
width: 70,
|
||||
height: 70,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatbotMessageCard extends StatelessWidget {
|
||||
final String text;
|
||||
final bool isBot;
|
||||
final DateTime createdAt;
|
||||
|
||||
const ChatbotMessageCard({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.isBot,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final avatar = ClipOval(
|
||||
child: Image.asset(
|
||||
'assets/chatbot_icon.png',
|
||||
width: 30,
|
||||
height: 30,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
);
|
||||
|
||||
final bubbleBg =
|
||||
isBot ? const Color(0xFFFFFCE5) : const Color(0xFFEAF4FF);
|
||||
final bubbleBorder = isBot ? const Color(0xFFE6EEF5) : Colors.transparent;
|
||||
|
||||
if (!isBot) {
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 8, left: 60),
|
||||
padding: const EdgeInsets.fromLTRB(12, 10, 12, 10),
|
||||
constraints: const BoxConstraints(maxWidth: 280),
|
||||
decoration: BoxDecoration(
|
||||
color: bubbleBg,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: bubbleBorder),
|
||||
),
|
||||
child: Text(text),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4, right: 10, top: 2),
|
||||
child: avatar,
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 280),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 10, 12, 10),
|
||||
decoration: BoxDecoration(
|
||||
color: bubbleBg,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: bubbleBorder),
|
||||
),
|
||||
child: Text(text),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatbotOptionButton extends StatelessWidget {
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const ChatbotOptionButton({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton(
|
||||
onPressed: onTap,
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: const Color(0xFF00999E),
|
||||
side: const BorderSide(color: Color(0xFF00999E)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||
alignment: Alignment.centerLeft,
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatbotTypingIndicator extends StatefulWidget {
|
||||
const ChatbotTypingIndicator({super.key});
|
||||
|
||||
@override
|
||||
State<ChatbotTypingIndicator> createState() => _ChatbotTypingIndicatorState();
|
||||
}
|
||||
|
||||
class _ChatbotTypingIndicatorState extends State<ChatbotTypingIndicator>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 900),
|
||||
)..repeat(reverse: true);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 4, right: 10, top: 2),
|
||||
child: ClipOval(
|
||||
child: Image(
|
||||
image: AssetImage('assets/chatbot_icon.png'),
|
||||
width: 30,
|
||||
height: 30,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 280),
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFFCE5),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: const Color(0xFFE6EEF5)),
|
||||
),
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) {
|
||||
final t = _controller.value; // 0..1
|
||||
double dotOpacity(int i) {
|
||||
// Stagger the dots
|
||||
final phase = (t * 2.5) - i * 0.8;
|
||||
final s = (phase - phase.floor()).abs();
|
||||
return (0.3 + (1.0 - s) * 0.7).clamp(0.3, 1.0);
|
||||
}
|
||||
|
||||
double dotScale(int i) {
|
||||
final phase = (t * 2.5) - i * 0.8;
|
||||
final s = (phase - phase.floor()).abs();
|
||||
return (0.9 + (1.0 - s) * 0.35).clamp(0.9, 1.25);
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(
|
||||
3,
|
||||
(i) => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Transform.scale(
|
||||
scale: dotScale(i),
|
||||
child: Opacity(
|
||||
opacity: dotOpacity(i),
|
||||
child: Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF64748B),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
289
lib/features/chatbot/presentation/widgets/chatbot_window.dart
Normal file
289
lib/features/chatbot/presentation/widgets/chatbot_window.dart
Normal file
@ -0,0 +1,289 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:nhance_app_pwa/customAppBar/responsive.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/application/chatbot_controller.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/domain/models/chatbot_models.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/presentation/widgets/chatbot_message_card.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/presentation/widgets/chatbot_option_button.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/presentation/widgets/chatbot_typing_indicator.dart';
|
||||
|
||||
class ChatbotWindow extends ConsumerStatefulWidget {
|
||||
const ChatbotWindow({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ChatbotWindow> createState() => _ChatbotWindowState();
|
||||
}
|
||||
|
||||
class _ChatbotWindowState extends ConsumerState<ChatbotWindow> {
|
||||
final ScrollController _messagesScrollController = ScrollController();
|
||||
final Map<String, Color> statusColors = {
|
||||
'Claim Received': Colors.blueGrey,
|
||||
'Under Process': Colors.orangeAccent,
|
||||
'Information Required': Colors.deepOrange,
|
||||
'Approved': Colors.green,
|
||||
'Settled': Colors.teal,
|
||||
'Denial Review Awaited': Colors.redAccent,
|
||||
'Rejected': Colors.red,
|
||||
};
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_messagesScrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _scrollToLatestMessage() {
|
||||
if (!_messagesScrollController.hasClients) return;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!_messagesScrollController.hasClients) return;
|
||||
_messagesScrollController.animateTo(
|
||||
_messagesScrollController.position.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 220),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Color _statusColor(String status) {
|
||||
return statusColors[status.trim()] ?? const Color(0xFF6B7280);
|
||||
}
|
||||
|
||||
Widget _buildClaimStatusCard(ClaimStatusItem item) {
|
||||
final badgeColor = _statusColor(item.status);
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 4, right: 10, top: 2),
|
||||
child: ClipOval(
|
||||
child: Image(
|
||||
image: AssetImage('assets/chatbot_icon.png'),
|
||||
width: 30,
|
||||
height: 30,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 280),
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFFCE5),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x22000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
item.claimNumber,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 18,
|
||||
color: Color(0xFF111827),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: badgeColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Text(
|
||||
item.status,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
item.amount.isNotEmpty
|
||||
? 'Amount: ${item.amount}'
|
||||
: '-',
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF374151),
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
item.date,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF6B7280),
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = ref.watch(chatbotControllerProvider);
|
||||
final controller = ref.read(chatbotControllerProvider.notifier);
|
||||
_scrollToLatestMessage();
|
||||
|
||||
final isMobile = Responsive.isMobile(context);
|
||||
final isTablet = Responsive.isTablet(context);
|
||||
final topPadding = MediaQuery.of(context).padding.top;
|
||||
final bottomPadding = MediaQuery.of(context).padding.bottom;
|
||||
|
||||
final window = Material(
|
||||
elevation: isMobile ? 0 : 14,
|
||||
color: const Color(0xFFF3F7FB),
|
||||
borderRadius: BorderRadius.circular(isMobile ? 0 : 14),
|
||||
child: SizedBox(
|
||||
width: isMobile
|
||||
? MediaQuery.of(context).size.width
|
||||
: isTablet
|
||||
? 420
|
||||
: 420,
|
||||
height: isMobile
|
||||
? MediaQuery.of(context).size.height
|
||||
: 560,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF00999E),
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(isMobile ? 0 : 14),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.fromLTRB(14, isMobile ? topPadding + 8 : 12, 14, 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
ClipOval(
|
||||
child: Container(
|
||||
width: 28,
|
||||
height: 28,
|
||||
color: Colors.white,
|
||||
alignment: Alignment.center,
|
||||
child: Image.asset(
|
||||
'assets/chatbot_icon.png',
|
||||
width: 24,
|
||||
height: 24,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'Nhance Care',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: controller.close,
|
||||
child: const Icon(Icons.close, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 0),
|
||||
child: ListView(
|
||||
controller: _messagesScrollController,
|
||||
children: [
|
||||
...state.messages.map(
|
||||
(item) => ChatbotMessageCard(
|
||||
text: item.text,
|
||||
isBot: item.isBot,
|
||||
createdAt: item.createdAt,
|
||||
),
|
||||
),
|
||||
if (state.step == ChatbotFlowStep.claimStatusList &&
|
||||
state.claimStatuses.isNotEmpty)
|
||||
...state.claimStatuses.map(_buildClaimStatusCard),
|
||||
if (state.isLoading) const ChatbotTypingIndicator(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(12, 8, 12, 12 + (isMobile ? bottomPadding : 0)),
|
||||
child: Column(
|
||||
children: state.options
|
||||
.map(
|
||||
(option) => ChatbotOptionButton(
|
||||
label: option.label,
|
||||
onTap: state.isLoading
|
||||
? () {}
|
||||
: () => controller.onOptionSelected(context, option),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (isMobile) {
|
||||
return AnimatedSlide(
|
||||
duration: const Duration(milliseconds: 220),
|
||||
curve: Curves.easeOut,
|
||||
offset: state.isOpen ? Offset.zero : const Offset(0, 1),
|
||||
child: window,
|
||||
);
|
||||
}
|
||||
|
||||
return AnimatedScale(
|
||||
duration: const Duration(milliseconds: 180),
|
||||
scale: state.isOpen ? 1 : 0.9,
|
||||
alignment: Alignment.bottomRight,
|
||||
child: window,
|
||||
);
|
||||
}
|
||||
}
|
||||
78
lib/logger.dart
Normal file
78
lib/logger.dart
Normal file
@ -0,0 +1,78 @@
|
||||
import 'dart:developer' as developer;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
String _timestamp() => DateTime.now().toIso8601String();
|
||||
|
||||
enum LogLevel { debug, info, warning, error }
|
||||
|
||||
class LoggerConfig {
|
||||
// Logging is always disabled in non-debug builds.
|
||||
static bool enabled = true;
|
||||
|
||||
// Keep debug logs off by default to avoid local slowdown on noisy screens.
|
||||
static LogLevel minLevel = LogLevel.info;
|
||||
|
||||
// Stack parsing is expensive; keep it disabled unless specifically needed.
|
||||
static bool includeCallerFromStack = false;
|
||||
}
|
||||
|
||||
String? _inferCallerTag(StackTrace stackTrace) {
|
||||
final lines = stackTrace.toString().split('\n');
|
||||
|
||||
// Find the first stack frame that is not inside this logger file.
|
||||
for (final line in lines) {
|
||||
if (line.contains('logger.dart')) continue;
|
||||
|
||||
// Example formats vary by platform; we try to extract a readable symbol name.
|
||||
// Common patterns:
|
||||
// - "#0 foo.bar (package:.../file.dart:12:3)"
|
||||
// - "foo.bar (file.dart:12:3)"
|
||||
final match = RegExp(r'(?:(?:#\d+)\s+)?([A-Za-z0-9_$.<>]+)\s*\(').firstMatch(line);
|
||||
final symbol = match?.group(1);
|
||||
if (symbol != null && symbol.trim().isNotEmpty) return symbol.trim();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void _log(
|
||||
LogLevel level,
|
||||
Object? message, {
|
||||
String? tag,
|
||||
Object? error,
|
||||
StackTrace? stackTrace,
|
||||
}) {
|
||||
if (!kDebugMode || !LoggerConfig.enabled) return;
|
||||
if (level.index < LoggerConfig.minLevel.index) return;
|
||||
|
||||
final inferredTag = tag ??
|
||||
(LoggerConfig.includeCallerFromStack
|
||||
? _inferCallerTag(stackTrace ?? StackTrace.current)
|
||||
: null);
|
||||
final levelName = level.name.toUpperCase();
|
||||
final fullMessage = '[${_timestamp()}] [$levelName]${inferredTag != null ? ' [$inferredTag]' : ''} $message';
|
||||
|
||||
developer.log(
|
||||
fullMessage,
|
||||
name: inferredTag ?? 'app',
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
}
|
||||
|
||||
void logDebug(Object? message, {String? tag}) {
|
||||
_log(LogLevel.debug, message, tag: tag);
|
||||
}
|
||||
|
||||
void logInfo(Object? message, {String? tag}) {
|
||||
_log(LogLevel.info, message, tag: tag);
|
||||
}
|
||||
|
||||
void logWarning(Object? message, {String? tag}) {
|
||||
_log(LogLevel.warning, message, tag: tag);
|
||||
}
|
||||
|
||||
void logError(Object? message, {String? tag, Object? error, StackTrace? stackTrace}) {
|
||||
_log(LogLevel.error, message, tag: tag, error: error, stackTrace: stackTrace);
|
||||
}
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
// import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:nhance_app_pwa/customAppBar/toastHelper.dart';
|
||||
import 'package:nhance_app_pwa/features/chatbot/presentation/chatbot_host.dart';
|
||||
import 'package:nhance_app_pwa/pages/changePassword.dart';
|
||||
import 'package:nhance_app_pwa/pages/email_verify.dart';
|
||||
import 'package:nhance_app_pwa/pages/enrollment/addons.dart';
|
||||
@ -11,7 +13,6 @@ import 'package:nhance_app_pwa/pages/enrollment/empDetails.dart';
|
||||
import 'package:nhance_app_pwa/pages/enrollment/empReview.dart';
|
||||
import 'package:nhance_app_pwa/pages/login.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/AddPolicyScreen.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/botman_chat.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/claimprocess.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/claims.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/faqs.dart';
|
||||
@ -44,8 +45,13 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'config/environment.dart';
|
||||
import 'logger.dart';
|
||||
// import 'dart:html' as html;
|
||||
|
||||
Future<void> main() async {
|
||||
await startApp();
|
||||
}
|
||||
|
||||
// === Splash (only for mobile) ===
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
@ -89,7 +95,7 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
/// Middleware logic for tokens + mpin
|
||||
Future<String?> tokenRedirectLogic(
|
||||
BuildContext context, GoRouterState state) async {
|
||||
print('ABCDEFGH');
|
||||
logDebug('ABCDEFGH');
|
||||
const guestRoutes = [
|
||||
'/login',
|
||||
'/verify',
|
||||
@ -99,11 +105,11 @@ Future<String?> tokenRedirectLogic(
|
||||
];
|
||||
|
||||
final hasToken = await TokenService.hasValidToken();
|
||||
print('hasToken : $hasToken');
|
||||
logDebug('hasToken : $hasToken');
|
||||
final location = state.matchedLocation;
|
||||
|
||||
print('Location: $location');
|
||||
print('hasToken: $hasToken');
|
||||
logDebug('Location: $location');
|
||||
logDebug('hasToken: $hasToken');
|
||||
|
||||
// Already logged in → prevent guest pages
|
||||
if (hasToken && guestRoutes.contains(location)) {
|
||||
@ -134,6 +140,7 @@ Future<String?> tokenRedirectLogic(
|
||||
Future<void> startApp() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await TokenService.clearLegacyWebAuthFromSharedPreferences();
|
||||
|
||||
// await dotenv.load(fileName: Environment.fileName);
|
||||
|
||||
@ -190,7 +197,7 @@ Future<void> startApp() async {
|
||||
path: '/policies',
|
||||
builder: (context, state) {
|
||||
final arguments =
|
||||
state.extra as Map<String, dynamic>?; // 👈 receive here
|
||||
state.extra as Map<String, dynamic>?; // 👈 receive here
|
||||
return policies(arguments: arguments);
|
||||
},
|
||||
),
|
||||
@ -290,7 +297,11 @@ Future<void> startApp() async {
|
||||
await tokenRedirectLogic(context, state),
|
||||
);
|
||||
|
||||
runApp(MyApp(router: router));
|
||||
runApp(
|
||||
ProviderScope(
|
||||
child: MyApp(router: router),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
|
||||
@ -14,6 +14,8 @@ import '../config/environment.dart';
|
||||
import '../customAppBar/responsive.dart';
|
||||
import '../customAppBar/toastHelper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class changesPassword extends StatefulWidget {
|
||||
final String email;
|
||||
final String client_id;
|
||||
@ -126,7 +128,7 @@ class _changesPasswordState extends State<changesPassword> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, message!);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
setState(() {
|
||||
@ -172,7 +174,7 @@ class _changesPasswordState extends State<changesPassword> {
|
||||
_isLoading = false;
|
||||
});
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
|
||||
// 🔹 Password validation
|
||||
|
||||
@ -43,7 +43,6 @@ import '../enrollment/addons.dart';
|
||||
import '../enrollment/empDetails.dart';
|
||||
import '../enrollment/empReview.dart';
|
||||
import '../login.dart';
|
||||
import '../postEnrollment/chatbot.dart';
|
||||
import '../postEnrollment/claimprocess.dart';
|
||||
import '../postEnrollment/claims.dart';
|
||||
import '../postEnrollment/faqs.dart';
|
||||
@ -227,10 +226,10 @@ class AppRouter {
|
||||
path: '/tickets',
|
||||
builder: (context, state) => tickets(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/chatbot',
|
||||
builder: (context, state) => chatbot(),
|
||||
),
|
||||
// GoRoute(
|
||||
// path: '/chatbot',
|
||||
// builder: (context, state) => chatbot(),
|
||||
// ),
|
||||
GoRoute(
|
||||
path: '/wellnessWebView',
|
||||
builder: (context, state) {
|
||||
|
||||
@ -21,13 +21,15 @@ import 'package:jwt_decode/jwt_decode.dart';
|
||||
import '../config/environment.dart';
|
||||
import '../customAppBar/responsive.dart';
|
||||
import '../customAppBar/toastHelper.dart';
|
||||
import '../models/platform_helper_mobile.dart'
|
||||
import '../models/platform_helper_mobile.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 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
// import '../pages/helpers/html_stub.dart' if (dart.library.html) 'html_web.dart';
|
||||
|
||||
class MyEmailVerify extends StatefulWidget {
|
||||
@ -102,18 +104,18 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
// badge: true,
|
||||
// sound: true,
|
||||
// );
|
||||
// print('🔔 Permission: ${settings.authorizationStatus}');
|
||||
// logDebug('🔔 Permission: ${settings.authorizationStatus}');
|
||||
//
|
||||
// if (Platform.isIOS || Platform.isMacOS) {
|
||||
// // Get APNS token
|
||||
// apnsToken = await _firebaseMessaging.getAPNSToken();
|
||||
// print('📱 APNS Token (iOS): $apnsToken');
|
||||
// logDebug('📱 APNS Token (iOS): $apnsToken');
|
||||
//
|
||||
// // Retry if null
|
||||
// if (apnsToken == null) {
|
||||
// await Future.delayed(const Duration(seconds: 3));
|
||||
// apnsToken = await _firebaseMessaging.getAPNSToken();
|
||||
// print('🔁 Retried APNS Token: $apnsToken');
|
||||
// logDebug('🔁 Retried APNS Token: $apnsToken');
|
||||
// }
|
||||
//
|
||||
// if (apnsToken != null) {
|
||||
@ -122,7 +124,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
// } else if (Platform.isAndroid) {
|
||||
// // Get FCM token
|
||||
// fcmToken = await _firebaseMessaging.getToken();
|
||||
// print('🔥 FCM Token (Android): $fcmToken');
|
||||
// logDebug('🔥 FCM Token (Android): $fcmToken');
|
||||
//
|
||||
// if (fcmToken != null) {
|
||||
// await sendDeviceToken(fcmToken!);
|
||||
@ -134,28 +136,28 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
//
|
||||
// // Foreground listener
|
||||
// FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
// print('💬 Message: ${message.notification?.title}');
|
||||
// logDebug('💬 Message: ${message.notification?.title}');
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(content: Text(message.notification?.title ?? 'New Notification')),
|
||||
// );
|
||||
// });
|
||||
// } catch (e) {
|
||||
// print('❌ Notification init error: $e');
|
||||
// logDebug('❌ Notification init error: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<void> initNotification() async {
|
||||
// await _firebaseMessaging.requestPermission();
|
||||
// fCMToken = await _firebaseMessaging.getToken();
|
||||
// print('Token : $fCMToken');
|
||||
// logDebug('Token : $fCMToken');
|
||||
// sendDeviceToken(fCMToken);
|
||||
// FirebaseMessaging.onBackgroundMessage(handleBackgroundMessage);
|
||||
// }
|
||||
//
|
||||
// Future<void> handleBackgroundMessage(RemoteMessage message) async {
|
||||
// print('Title ${message.notification?.title}');
|
||||
// print('Body ${message.notification?.body}');
|
||||
// print('Playload ${message.data}');
|
||||
// logDebug('Title ${message.notification?.title}');
|
||||
// logDebug('Body ${message.notification?.body}');
|
||||
// logDebug('Playload ${message.data}');
|
||||
// }
|
||||
|
||||
Future<void> sendDeviceToken(deviceToken) async {
|
||||
@ -175,19 +177,19 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
print('data: $data');
|
||||
logDebug('data: $data');
|
||||
String status = data['status'];
|
||||
print(status);
|
||||
logDebug(status);
|
||||
if (status == 'success') {
|
||||
print('Token Store Successfully');
|
||||
logDebug('Token Store Successfully');
|
||||
} else {
|
||||
print('Please try again');
|
||||
logDebug('Please try again');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Failed to store');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +215,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
});
|
||||
try {
|
||||
|
||||
// print('EMAIL PARAMS : ${widget.email} - OTP : $otp');
|
||||
// logDebug('EMAIL PARAMS : ${widget.email} - OTP : $otp');
|
||||
final Map<String, dynamic> payload = (widget.type == 'mobile')
|
||||
? {'otp': _otpController.text, 'mobile_number': widget.value}
|
||||
: {'otp': _otpController.text, 'email_id': widget.value};
|
||||
@ -226,17 +228,17 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||
},
|
||||
);
|
||||
print('response : ${response.statusCode}');
|
||||
logDebug('response : ${response.statusCode}');
|
||||
if (response.statusCode == 200) {
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
print('data: $data');
|
||||
logDebug('data: $data');
|
||||
|
||||
/// Check API response status first
|
||||
if (data['status'] == 'Invalid OTP') {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.clear();
|
||||
ToastHelper.showErrorToast(context, data['message'] ?? 'Invalid OTP');
|
||||
print('API error → ${data['message']}');
|
||||
logDebug('API error → ${data['message']}');
|
||||
return; // stop execution
|
||||
}
|
||||
|
||||
@ -244,7 +246,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.clear();
|
||||
ToastHelper.showErrorToast(context, data['message'] ?? 'OTP is required');
|
||||
print('API error → ${data['message']}');
|
||||
logDebug('API error → ${data['message']}');
|
||||
return; // stop execution
|
||||
}
|
||||
|
||||
@ -262,7 +264,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
|
||||
// Save tokens
|
||||
await TokenService.saveTokens(preToken: preToken, postToken: postToken);
|
||||
print('Tokens saved → preToken: $preToken, postToken: $postToken');
|
||||
logDebug('Tokens saved → preToken: $preToken, postToken: $postToken');
|
||||
|
||||
_preToken = preToken;
|
||||
String status = data['status'];
|
||||
@ -275,7 +277,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
post = data['post_enrollment'];
|
||||
}
|
||||
|
||||
print('post: $post');
|
||||
logDebug('post: $post');
|
||||
|
||||
_postToken = postToken;
|
||||
|
||||
@ -294,7 +296,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
prefs.clear();
|
||||
ToastHelper.showErrorToast(context, 'OTP verification failed. Please try again.');
|
||||
// Show a Snackbar if the OTP is invalid
|
||||
print('OTP verification failed. Please try again.');
|
||||
logDebug('OTP verification failed. Please try again.');
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
setState(() {
|
||||
@ -337,10 +339,10 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
} catch (e) {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.clear();
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||
// Show a Snackbar if there's an error while verifying OTP
|
||||
print('Failed to verify OTP. Please try again.');
|
||||
logDebug('Failed to verify OTP. Please try again.');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -364,7 +366,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
'client_id': client_id,
|
||||
'empClientBranchId': empClientBranchId,
|
||||
});
|
||||
print('Successfully Login');
|
||||
logDebug('Successfully Login');
|
||||
}
|
||||
|
||||
void postSuccessData(post, data) async {
|
||||
@ -388,7 +390,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
|
||||
// // Decode the JWT token received from the API response
|
||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
||||
// print('PostdecodedToken : $decodedToken');
|
||||
// logDebug('PostdecodedToken : $decodedToken');
|
||||
// empClientBranchId = decodedToken['client_branch_id'];
|
||||
// prefs.setString('empClientBranchId', empClientBranchId);
|
||||
// empCodeString = decodedToken['emp_code'].toString();
|
||||
@ -403,7 +405,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
// prefs.setString('emp_status', emp_status);
|
||||
// // getClientLogoAndDetails();
|
||||
|
||||
print('Successfully Login');
|
||||
logDebug('Successfully Login');
|
||||
|
||||
// loginUser(
|
||||
// gpaEmpName: session.gpaEmpName,
|
||||
@ -426,9 +428,9 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
// html.window.dispatchEvent(
|
||||
// html.CustomEvent('userLoggedIn', detail: {'status': 'success'}));
|
||||
//
|
||||
// print("✅ User logged in! LocalStorage values set.");
|
||||
// logDebug("✅ User logged in! LocalStorage values set.");
|
||||
//
|
||||
// print('Successfully Login');
|
||||
// logDebug('Successfully Login');
|
||||
// }
|
||||
// getClientLogoAndDetails();
|
||||
// Redirect to another page
|
||||
@ -442,7 +444,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
session = await SessionManager();
|
||||
// Decode the JWT token received from the API response
|
||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
// print('enrolldecodedToken : $decodedToken');
|
||||
// logDebug('enrolldecodedToken : $decodedToken');
|
||||
// enrollmentEmpClientBranchId = decodedToken['client_branch_id'];
|
||||
// prefs.setString(
|
||||
// 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
@ -472,16 +474,16 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
// html.window.dispatchEvent(
|
||||
// html.CustomEvent('userLoggedIn', detail: {'status': 'success'}));
|
||||
//
|
||||
// print("✅ User logged in! LocalStorage values set.");
|
||||
// logDebug("✅ User logged in! LocalStorage values set.");
|
||||
//
|
||||
// print('Successfully Login');
|
||||
// logDebug('Successfully Login');
|
||||
// }
|
||||
|
||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// final _postToken = prefs.getString('_postToken');
|
||||
// int skipStatus = prefs.getInt('skipStatus') ?? 1;
|
||||
// final mpinText = prefs.getString('mpinText');
|
||||
// print(isMobilePlatform());
|
||||
// logDebug(isMobilePlatform());
|
||||
|
||||
|
||||
if (isMobilePlatform()) {
|
||||
@ -532,7 +534,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
session = await SessionManager();
|
||||
// // Decode the JWT token received from the API response
|
||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
// print('decodedToken : $decodedToken');
|
||||
// logDebug('decodedToken : $decodedToken');
|
||||
// enrollmentEmpClientBranchId = decodedToken['client_branch_id'];
|
||||
// prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
// enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
||||
@ -547,13 +549,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||
// getClientLogoAndDetails();
|
||||
|
||||
print('Successfully Login');
|
||||
logDebug('Successfully Login');
|
||||
|
||||
// Redirect to another page
|
||||
// final enrollToken = prefs.getString('enrollToken');
|
||||
// int skipStatus = prefs.getInt('skipStatus') ?? 1;
|
||||
// final mpinText = prefs.getString('mpinText');
|
||||
// print(isMobilePlatform());
|
||||
// logDebug(isMobilePlatform());
|
||||
if (isMobilePlatform()) {
|
||||
// if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') {
|
||||
if (_preToken != null && _preToken.isNotEmpty) {
|
||||
@ -626,7 +628,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
}
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, message);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
@ -634,18 +636,18 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
}
|
||||
} catch (e) {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> checkLoginPin(BuildContext context) async {
|
||||
print('checkLoginPin');
|
||||
logDebug('checkLoginPin');
|
||||
try {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empMobileNo = prefs.getString('empMobileNo');
|
||||
empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo $empMobileNo');
|
||||
print('empEmailid $empEmailid');
|
||||
logDebug('empMobileNo $empMobileNo');
|
||||
logDebug('empEmailid $empEmailid');
|
||||
// _token = prefs.getString('token');
|
||||
var params = {};
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
@ -654,7 +656,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
params = {'email_id': empEmailid};
|
||||
}
|
||||
|
||||
print('params $params');
|
||||
logDebug('params $params');
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrlEnrollment + 'checkMpin'),
|
||||
@ -720,16 +722,16 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
}
|
||||
} catch (e) {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> checkPassword(BuildContext context,email_id,client_id,route) async {
|
||||
print('checkLoginPin');
|
||||
logDebug('checkLoginPin');
|
||||
try {
|
||||
final params = {'email_id': email_id,'client_id':client_id};
|
||||
|
||||
print('params $params');
|
||||
logDebug('params $params');
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrlEnrollment + 'checkPassword'),
|
||||
@ -746,7 +748,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
context.replace('/${route}');
|
||||
// context.go('/${route}');
|
||||
} else if(data['status'] == 'failed'){
|
||||
print('setPassword');
|
||||
logDebug('setPassword');
|
||||
// goNamed
|
||||
context.replaceNamed(
|
||||
'setPassword',
|
||||
@ -763,7 +765,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
}
|
||||
} catch (e) {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -780,9 +782,9 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
// print('response.statusCode == 200');
|
||||
// logDebug('response.statusCode == 200');
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
// print(data);
|
||||
// logDebug(data);
|
||||
|
||||
if (data.containsKey('data')) {
|
||||
dynamic clientDetails = data['data'];
|
||||
@ -795,27 +797,27 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
'addon_subheading', clientDetails['client']['addon_subheading']);
|
||||
setState(() {
|
||||
// dynamic clientDetails = data['data'];
|
||||
// print(clientDetails);
|
||||
// logDebug(clientDetails);
|
||||
clientName = clientDetails['client']['client_name'];
|
||||
print(clientName);
|
||||
logDebug(clientName);
|
||||
clientLogo = clientDetails['client']['client_logo'];
|
||||
print(clientLogo);
|
||||
logDebug(clientLogo);
|
||||
});
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
// ToastHelper.showErrorToast(
|
||||
// context, 'API request failed with status: ${data['status']}');
|
||||
print('API request failed with status: ${data['status']}');
|
||||
logDebug('API request failed with status: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
// ToastHelper.showErrorToast(
|
||||
// context, 'Request failed with status: ${response.statusCode}');
|
||||
print('Request failed with status: ${response.statusCode}');
|
||||
logDebug('Request failed with status: ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1360,8 +1362,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
||||
// ✅ Must be outside any class — this fixes your error
|
||||
// @pragma('vm:entry-point')
|
||||
// Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
// print('📨 Handling background message: ${message.messageId}');
|
||||
// print('Title: ${message.notification?.title}');
|
||||
// print('Body: ${message.notification?.body}');
|
||||
// print('Data: ${message.data}');
|
||||
// logDebug('📨 Handling background message: ${message.messageId}');
|
||||
// logDebug('Title: ${message.notification?.title}');
|
||||
// logDebug('Body: ${message.notification?.body}');
|
||||
// logDebug('Data: ${message.data}');
|
||||
// }
|
||||
|
||||
@ -17,10 +17,11 @@ import 'dart:convert';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../postEnrollment/chatbot.dart';
|
||||
import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class addOnsDetails extends StatefulWidget {
|
||||
const addOnsDetails({Key? key}) : super(key: key);
|
||||
|
||||
@ -149,6 +150,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
bool isEnrollCompletedStatus = false;
|
||||
final session = SessionManager();
|
||||
|
||||
bool _hasValidECardDownload(dynamic eCardDownload) {
|
||||
if (eCardDownload == null) return false;
|
||||
final normalized = eCardDownload.toString().trim().toLowerCase();
|
||||
return normalized.isNotEmpty && normalized != 'null';
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -179,7 +186,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
|
||||
setState(() {
|
||||
isTokenAvailable = token != null && token.isNotEmpty;
|
||||
print('isTokenAvailable $isTokenAvailable');
|
||||
logDebug('isTokenAvailable $isTokenAvailable');
|
||||
});
|
||||
}
|
||||
|
||||
@ -202,7 +209,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final String? token = await TokenService.getPreToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
@ -296,15 +303,15 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
clientLogo = clientDetails['client']['client_logo'];
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +335,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
for (var item in gpaPolicies) {
|
||||
if (isPremiumEnabled(item['is_premium_summery'])) {
|
||||
gpahasPremiumSummary = true;
|
||||
print('gpahasPremiumSummary $gpahasPremiumSummary');
|
||||
logDebug('gpahasPremiumSummary $gpahasPremiumSummary');
|
||||
break;
|
||||
}
|
||||
// Extract disclaimer value from each object
|
||||
@ -359,7 +366,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print('Unexpected type for disclaimer');
|
||||
logDebug('Unexpected type for disclaimer');
|
||||
}
|
||||
|
||||
// Add new entries to the main list, ensuring no duplicate texts
|
||||
@ -382,11 +389,11 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
});
|
||||
// Handle other status codes
|
||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,10 +414,10 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
// setState(() {
|
||||
gmcPolicies = response['data'];
|
||||
for (var item in gmcPolicies) {
|
||||
print('checking is_premium_summery ${item['is_premium_summery']}');
|
||||
logDebug('checking is_premium_summery ${item['is_premium_summery']}');
|
||||
if (isPremiumEnabled(item['is_premium_summery'])) {
|
||||
gmchasPremiumSummary = true;
|
||||
print('gmchasPremiumSummary $gmchasPremiumSummary');
|
||||
logDebug('gmchasPremiumSummary $gmchasPremiumSummary');
|
||||
break;
|
||||
}
|
||||
if (item['OpenForEnrollment'] == '1') {
|
||||
@ -440,7 +447,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print('Unexpected type for disclaimer');
|
||||
logDebug('Unexpected type for disclaimer');
|
||||
}
|
||||
|
||||
// Add new entries to the main list, ensuring no duplicate texts
|
||||
@ -462,11 +469,11 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
gmcDataIsEmpty = 0;
|
||||
});
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,9 +514,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
|
||||
topUpECardDownload =
|
||||
topUpSiPolicies['gmc_si_topup']['eCardDownload'];
|
||||
String intOpenForEnrollment =
|
||||
final dynamic openForEnrollmentRaw =
|
||||
topUpSiPolicies['gmc_si_topup']['OpenForEnrollment'];
|
||||
topUpOpenForEnrollment = int.parse(intOpenForEnrollment);
|
||||
if (openForEnrollmentRaw is int) {
|
||||
topUpOpenForEnrollment = openForEnrollmentRaw;
|
||||
} else {
|
||||
topUpOpenForEnrollment =
|
||||
int.tryParse(openForEnrollmentRaw?.toString() ?? '0') ?? 0;
|
||||
}
|
||||
|
||||
topUpTypeName = topUpSiPolicies['gmc_si_topup']['type'];
|
||||
|
||||
@ -540,19 +552,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
}
|
||||
// });
|
||||
} else {
|
||||
print('No data found in the response');
|
||||
logDebug('No data found in the response');
|
||||
}
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -631,7 +643,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
|
||||
setState(() {
|
||||
topUpParentIsPremiumSummary = isPremiumEnabled(topUpSiParentPolicies['gmc_si_parent_topup']?['is_premium_summery']);
|
||||
print(topUpParentECardDownload);
|
||||
logDebug(topUpParentECardDownload);
|
||||
});
|
||||
|
||||
|
||||
@ -639,19 +651,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
}
|
||||
// });
|
||||
} else {
|
||||
print('No data found in the response');
|
||||
logDebug('No data found in the response');
|
||||
}
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -677,39 +689,39 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
addOnsDependentClientPolicyId =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['client_policy_id'];
|
||||
print('1 $addOnsDependentClientPolicyId');
|
||||
logDebug('1 $addOnsDependentClientPolicyId');
|
||||
|
||||
addOnsDependentSlabRates =
|
||||
await addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['SlabRates'];
|
||||
print('2 $addOnsDependentSlabRates');
|
||||
logDebug('2 $addOnsDependentSlabRates');
|
||||
addOnsDependentPolicyName =
|
||||
await addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['policy_name'];
|
||||
print('3 $addOnsDependentPolicyName');
|
||||
logDebug('3 $addOnsDependentPolicyName');
|
||||
addOnsDependentPolicyType =
|
||||
await addOnsDependentPolicies['gmc_dependent_addon']['type'];
|
||||
print('4 $addOnsDependentPolicyType');
|
||||
logDebug('4 $addOnsDependentPolicyType');
|
||||
addOnsDependentFamilyFloater =
|
||||
await addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['policy_terms']['family_floater'];
|
||||
print('5 $addOnsDependentFamilyFloater');
|
||||
logDebug('5 $addOnsDependentFamilyFloater');
|
||||
setState(() {
|
||||
addOnsDependentMappedFamilyFloatersDependent =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['family_floaters_of_dependent_and_si_array'];
|
||||
print('6 $addOnsDependentMappedFamilyFloatersDependent');
|
||||
logDebug('6 $addOnsDependentMappedFamilyFloatersDependent');
|
||||
String intOpenForEnrollment =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['OpenForEnrollment'];
|
||||
print('7 $intOpenForEnrollment');
|
||||
logDebug('7 $intOpenForEnrollment');
|
||||
addOnsDependentOpenForEnrollment =
|
||||
int.parse(intOpenForEnrollment);
|
||||
print('8 $addOnsDependentOpenForEnrollment');
|
||||
logDebug('8 $addOnsDependentOpenForEnrollment');
|
||||
addOnsdependentValue =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['family_floaters_of_dependent_and_si_value'];
|
||||
print('9 $addOnsdependentValue');
|
||||
logDebug('9 $addOnsdependentValue');
|
||||
// final checkValue = addOnsdependentValue +
|
||||
// addOnsDependentPolicies['gmc_dependent_addon']
|
||||
// ['family_floaters_of_dependent_and_si_premium_value'];
|
||||
@ -718,15 +730,15 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
['family_floaters_of_dependent_and_si_premium_value']
|
||||
.toString());
|
||||
|
||||
print('10 $checkValue');
|
||||
logDebug('10 $checkValue');
|
||||
if (checkValue == 0) {
|
||||
print('11');
|
||||
logDebug('11');
|
||||
addOnsSelectedDependent = null;
|
||||
_addOnsDependentSwitcher = false;
|
||||
} else {
|
||||
print('12 $addOnsdependentValue');
|
||||
logDebug('12 $addOnsdependentValue');
|
||||
addOnsSelectedDependent = addOnsdependentValue.toString();
|
||||
print('13 $addOnsSelectedDependent');
|
||||
logDebug('13 $addOnsSelectedDependent');
|
||||
}
|
||||
// addOnsSelectedDependent = await addOnsdependentValue != 0
|
||||
// ? addOnsdependentValue.toString()
|
||||
@ -758,32 +770,32 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
addOnsDependentIsPremiumSummary = isPremiumEnabled(addOnsDependentPolicies['gmc_dependent_addon']?['is_premium_summery']);
|
||||
});
|
||||
|
||||
print('addOnsDependentIsPremiumSummery $addOnsDependentIsPremiumSummary');
|
||||
logDebug('addOnsDependentIsPremiumSummery $addOnsDependentIsPremiumSummary');
|
||||
|
||||
addOnsDependentRelationShip = addOnsDependentPolicies['gmc_dependent_addon']['relationship'];
|
||||
// if(addOnsDependentIsPremiumSummery == 1){
|
||||
// print('isPremiumSummery true');
|
||||
// logDebug('isPremiumSummery true');
|
||||
// isPremiumSummery = true;
|
||||
// } else {
|
||||
// print('isPremiumSummery false');
|
||||
// logDebug('isPremiumSummery false');
|
||||
// isPremiumSummery = false;
|
||||
// }
|
||||
|
||||
});
|
||||
} else {
|
||||
print('No data found in the response');
|
||||
logDebug('No data found in the response');
|
||||
}
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -804,14 +816,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
throw Exception('Failed to fetch relationship list');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error fetching relationship list: $error');
|
||||
logDebug('Error fetching relationship list: $error');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDate(BuildContext context, formType) async {
|
||||
print(formType);
|
||||
logDebug(formType);
|
||||
var ageValidation = formType['age_validation'];
|
||||
print(ageValidation);
|
||||
logDebug(ageValidation);
|
||||
if (ageValidation is Map<String, dynamic>) {
|
||||
int min = ageValidation.containsKey('min')
|
||||
? int.tryParse(ageValidation['min'].toString()) ?? 0
|
||||
@ -820,17 +832,17 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
? int.tryParse(ageValidation['max'].toString()) ?? 100
|
||||
: 100;
|
||||
|
||||
print('Min age: $min');
|
||||
print('Max age: $max');
|
||||
logDebug('Min age: $min');
|
||||
logDebug('Max age: $max');
|
||||
late DateTime minDate;
|
||||
late DateTime maxDate;
|
||||
|
||||
final DateTime now = DateTime.now();
|
||||
|
||||
maxDate = DateTime(now.year - min, now.month, now.day);
|
||||
print(maxDate);
|
||||
logDebug(maxDate);
|
||||
minDate = DateTime(now.year - max, now.month, now.day);
|
||||
print(minDate);
|
||||
logDebug(minDate);
|
||||
|
||||
// Ensure initialDate is within the range of minDate and maxDate
|
||||
DateTime initialDate =
|
||||
@ -873,7 +885,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
print('Invalid age validation data');
|
||||
logDebug('Invalid age validation data');
|
||||
}
|
||||
}
|
||||
|
||||
@ -902,7 +914,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
}
|
||||
} catch (error) {
|
||||
// Handle network errors
|
||||
print('Error deleting item: $error');
|
||||
logDebug('Error deleting item: $error');
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,7 +959,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, 'Failed');
|
||||
print('Failed to send form data. Error: ${response}');
|
||||
logDebug('Failed to send form data. Error: ${response}');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1011,11 +1023,11 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
ToastHelper.showErrorToast(context, 'Failed to save');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error saving family members');
|
||||
logDebug('Error saving family members');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('');
|
||||
logDebug('');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1067,10 +1079,10 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
_memberNameController.clear();
|
||||
_dobController.clear();
|
||||
} else {
|
||||
print('Failed to Save...');
|
||||
logDebug('Failed to Save...');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error saving family members');
|
||||
logDebug('Error saving family members');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1126,10 +1138,10 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
_memberNameController.clear();
|
||||
_dobController.clear();
|
||||
} else {
|
||||
print('Failed to Save...');
|
||||
logDebug('Failed to Save...');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error saving family members');
|
||||
logDebug('Error saving family members');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1146,14 +1158,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
final response = await apiService.removeAddonsGmcDependentToAPI(
|
||||
enrollmentEmpCodeString!, addOnsDependentClientPolicyId!);
|
||||
if (response['status'] == 'success') {
|
||||
print(response['data']);
|
||||
logDebug(response['data']);
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1165,14 +1177,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
final response = await apiService.removeAddonsGmcSiToAPI(
|
||||
enrollmentEmpCodeString!, topUpClientPolicyId!);
|
||||
if (response['status'] == 'success') {
|
||||
print(response['data']);
|
||||
logDebug(response['data']);
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1185,14 +1197,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
final response = await apiService.removeAddonsGmcParentSiToAPI(
|
||||
enrollmentEmpCodeString!, topUpParentClientPolicyId!);
|
||||
if (response['status'] == 'success') {
|
||||
print(response['data']);
|
||||
logDebug(response['data']);
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1238,17 +1250,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
|
||||
topUpSiTotalAmt = topUpSiPremiumValue + topUpSiPremiumGst;
|
||||
|
||||
print('topUpSiTotalAmt $topUpSiTotalAmt');
|
||||
|
||||
// topUpSiTotalAmt = (topUpSum as double).toInt();
|
||||
});
|
||||
sendAddonsGmcSiToAPI();
|
||||
} else {
|
||||
print('Array not found for emp_code $enrollmentEmpCodeString');
|
||||
logDebug('Array not found for emp_code $enrollmentEmpCodeString');
|
||||
}
|
||||
} else {
|
||||
print('Operation Failed!');
|
||||
logDebug('Operation Failed!');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error saving family members');
|
||||
logDebug('Error saving family members');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1300,13 +1314,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
});
|
||||
sendAddonsGmcParentSiToAPI();
|
||||
} else {
|
||||
print('Array not found for emp_code $enrollmentEmpCodeString');
|
||||
logDebug('Array not found for emp_code $enrollmentEmpCodeString');
|
||||
}
|
||||
} else {
|
||||
print('Operation Failed!');
|
||||
logDebug('Operation Failed!');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error saving family members');
|
||||
logDebug('Error saving family members');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1357,13 +1371,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
addOnDependentPremiumValue + addOnsDependentPremiumGst;
|
||||
});
|
||||
} else {
|
||||
print('Array not found for emp_code $enrollmentEmpCodeString');
|
||||
logDebug('Array not found for emp_code $enrollmentEmpCodeString');
|
||||
}
|
||||
} else {
|
||||
print('Operation Failed!');
|
||||
logDebug('Operation Failed!');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error saving family members');
|
||||
logDebug('Error saving family members');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1415,14 +1429,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
// Handle other status codes
|
||||
ToastHelper.showErrorToast(context, 'Failed to Save');
|
||||
_showErrorDialog();
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1445,6 +1459,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
'topUpSiTotalAmt': topUpSiTotalAmt,
|
||||
}
|
||||
];
|
||||
print(siData);
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('siData', jsonEncode(siData));
|
||||
}
|
||||
@ -1560,8 +1575,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
// (int.tryParse(topUpParentOpenForEnrollment ?? '0') != 0) &&
|
||||
// (int.tryParse(addOnsDependentOpenForEnrollment ?? '0') != 0);
|
||||
//
|
||||
// print('enrollmentConditionsMet: $enrollmentConditionsMet');
|
||||
// print('gmcEnrollmentStatus: $gmcEnrollmentStatus');
|
||||
// logDebug('enrollmentConditionsMet: $enrollmentConditionsMet');
|
||||
// logDebug('gmcEnrollmentStatus: $gmcEnrollmentStatus');
|
||||
|
||||
// return isChecked &&
|
||||
// enrollmentConditionsMet &&
|
||||
@ -2897,8 +2912,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
0 ||
|
||||
(topUpOpenForEnrollment !=
|
||||
0 &&
|
||||
topUpECardDownload !=
|
||||
null)),
|
||||
_hasValidECardDownload(
|
||||
topUpECardDownload))),
|
||||
child:
|
||||
DropdownButtonFormField<
|
||||
String>(
|
||||
@ -2965,8 +2980,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
0 ||
|
||||
(topUpOpenForEnrollment !=
|
||||
0 &&
|
||||
topUpECardDownload !=
|
||||
null))
|
||||
_hasValidECardDownload(
|
||||
topUpECardDownload)))
|
||||
? null
|
||||
: (value) {
|
||||
setState(() {
|
||||
@ -3008,8 +3023,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
0 ||
|
||||
(topUpOpenForEnrollment !=
|
||||
0 &&
|
||||
topUpECardDownload !=
|
||||
null)),
|
||||
_hasValidECardDownload(
|
||||
topUpECardDownload))),
|
||||
child:
|
||||
DropdownButtonFormField<
|
||||
String>(
|
||||
@ -4362,7 +4377,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
allDisclaimer.firstWhere(
|
||||
(item) => item['id'] == id,
|
||||
)['checked'] = value!;
|
||||
print(allDisclaimer);
|
||||
logDebug(allDisclaimer);
|
||||
});
|
||||
},
|
||||
activeColor: const Color(0xFFE26728), // Custom color
|
||||
@ -4475,7 +4490,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
backFunction();
|
||||
// backFunction();
|
||||
context.go('/empDetails');
|
||||
},
|
||||
child: Text(
|
||||
'Back',
|
||||
@ -4643,8 +4659,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
}
|
||||
|
||||
void openAddFamilyMemberPopup(String action, Map<String, dynamic>? floaterData) {
|
||||
print('gmcRelationShip : $addOnsDependentRelationShip');
|
||||
print('editGmcRelationShip : $floaterData');
|
||||
logDebug('gmcRelationShip : $addOnsDependentRelationShip');
|
||||
logDebug('editGmcRelationShip : $floaterData');
|
||||
|
||||
Map<String, dynamic>? selectedFloaterData;
|
||||
String? dropdownValue;
|
||||
@ -4671,7 +4687,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
relationshipObjects = List<Map<String, dynamic>>.from(addOnsDependentRelationShip);
|
||||
}
|
||||
|
||||
print("Normalized relationship list: $relationshipObjects");
|
||||
logDebug("Normalized relationship list: $relationshipObjects");
|
||||
|
||||
// Reset UI Fields
|
||||
_relationShipController.clear();
|
||||
@ -4760,7 +4776,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
// assign selected relationship FULL OBJECT
|
||||
selectedFloaterData = relationshipObjects.firstWhere(
|
||||
(item) => item["relationship"] == value);
|
||||
print('selectedFloaterData1234 $selectedFloaterData');
|
||||
logDebug('selectedFloaterData1234 $selectedFloaterData');
|
||||
},
|
||||
),
|
||||
|
||||
@ -6021,7 +6037,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
(policy["si_gst_value"] ?? 0) + (policy["si_premium_value"] ?? 0))
|
||||
.fold(0.0, (sum, value) => sum + value);
|
||||
|
||||
print('Calculated gpaTotalAmt: $total'); // Debug print
|
||||
logDebug('Calculated gpaTotalAmt: $total'); // Debug print
|
||||
return total;
|
||||
}
|
||||
|
||||
@ -6031,7 +6047,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
}
|
||||
gpaTotalAmt = calculateGpaTotalAmt(policies.cast<Map<String, dynamic>>());
|
||||
|
||||
print('gpaTotalAmt $gpaTotalAmt');
|
||||
logDebug('gpaTotalAmt $gpaTotalAmt');
|
||||
return (policies as List)
|
||||
.where((policy) => policy is Map<String,
|
||||
dynamic>) // Ensure each item is a Map<String, dynamic>
|
||||
@ -6105,19 +6121,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
||||
(policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0))
|
||||
.fold(0.0, (sum, value) => sum + value);
|
||||
|
||||
print('Calculated gmcTotalAmt: $total'); // Debug print
|
||||
logDebug('Calculated gmcTotalAmt: $total'); // Debug print
|
||||
return total;
|
||||
}
|
||||
|
||||
List<TableRow> gmcBuildPolicyRows(dynamic policies, BuildContext context) {
|
||||
print('gmcBuildPolicyRows $policies');
|
||||
logDebug('gmcBuildPolicyRows $policies');
|
||||
|
||||
if (policies is! List) {
|
||||
return []; // Return empty list if policies is not a list
|
||||
}
|
||||
gmcTotalAmt = calculateGmcTotalAmt(policies.cast<Map<String, dynamic>>());
|
||||
|
||||
print('gmcTotalAmt $gmcTotalAmt');
|
||||
logDebug('gmcTotalAmt $gmcTotalAmt');
|
||||
return (policies as List)
|
||||
.where((policy) => policy is Map<String,
|
||||
dynamic>) // Ensure each item is a Map<String, dynamic>
|
||||
|
||||
@ -16,10 +16,11 @@ import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'dart:async';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../postEnrollment/chatbot.dart';
|
||||
import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class empDetails extends StatefulWidget {
|
||||
const empDetails({Key? key}) : super(key: key);
|
||||
|
||||
@ -121,7 +122,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
// setState(() async {
|
||||
// isTokenAvailable =
|
||||
// (await TokenService.getPostToken())?.isNotEmpty ?? false;
|
||||
// print('isTokenAvailable $isTokenAvailable');
|
||||
// logDebug('isTokenAvailable $isTokenAvailable');
|
||||
// });
|
||||
// }
|
||||
|
||||
@ -130,27 +131,27 @@ class _empDetailsState extends State<empDetails> {
|
||||
|
||||
setState(() {
|
||||
isTokenAvailable = token != null && token.isNotEmpty;
|
||||
print('isTokenAvailable $isTokenAvailable');
|
||||
logDebug('isTokenAvailable $isTokenAvailable');
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final String? token = await TokenService.getPreToken();
|
||||
print(token);
|
||||
logDebug(token);
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
// Decode the JWT token received from the API response
|
||||
enrollmentEmpClientBranchId = session.enrollmentEmpClientBranchId;
|
||||
enrollmentEmpCodeString = session.enrollmentEmpCodeString;
|
||||
print(
|
||||
logDebug(
|
||||
'enrollmentEmpCodeString : $enrollmentEmpCodeString'); // Check if emp_code is correct
|
||||
enrollmentEmpPrimaryId = session.enrollmentEmpPrimaryId;
|
||||
enrollmentGpaEmpName = session.enrollmentGpaEmpName;
|
||||
enrollmentClient_id = session.enrollmentClient_id;
|
||||
selfEmpStatus = prefs.getString('selfEmpStatus');
|
||||
print('client_id : $enrollmentClient_id');
|
||||
logDebug('client_id : $enrollmentClient_id');
|
||||
|
||||
final logo = await prefs.getString('clientLogo');
|
||||
final name = await prefs.getString('clientName');
|
||||
@ -161,7 +162,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
clientName = prefs.getString('clientName');
|
||||
});
|
||||
} else {
|
||||
print('getClientLogoAndDetails()');
|
||||
logDebug('getClientLogoAndDetails()');
|
||||
getClientLogoAndDetails();
|
||||
}
|
||||
|
||||
@ -174,7 +175,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
}
|
||||
|
||||
// Future<void> _loadToken() async {
|
||||
// print('_loadToken');
|
||||
// logDebug('_loadToken');
|
||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// final String? token = prefs.getString('enrollToken');
|
||||
// if (token != null && token.isNotEmpty) {
|
||||
@ -184,17 +185,17 @@ class _empDetailsState extends State<empDetails> {
|
||||
//
|
||||
// // Decode the JWT token received from the API response
|
||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
// print('decodedToken : $decodedToken');
|
||||
// logDebug('decodedToken : $decodedToken');
|
||||
// enrollmentEmpClientBranchId =
|
||||
// prefs.getString('enrollmentEmpClientBranchId');
|
||||
// enrollmentEmpCodeString = prefs.getString('enrollmentEmpCodeString');
|
||||
// print(
|
||||
// logDebug(
|
||||
// 'enrollmentEmpCodeString : $enrollmentEmpCodeString'); // Check if emp_code is correct
|
||||
// enrollmentEmpPrimaryId = prefs.getString('enrollmentEmpPrimaryId');
|
||||
// enrollmentGpaEmpName = prefs.getString('enrollmentGpaEmpName');
|
||||
// enrollmentClient_id = prefs.getString('enrollmentClient_id');
|
||||
// selfEmpStatus = prefs.getString('selfEmpStatus');
|
||||
// print('client_id : $enrollmentClient_id');
|
||||
// logDebug('client_id : $enrollmentClient_id');
|
||||
//
|
||||
// if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||
// clientLogo = prefs.getString('clientLogo');
|
||||
@ -231,7 +232,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
empClientBranchId,
|
||||
enrollmentClient_id!,
|
||||
enrollmentEmpClientBranchId!);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
|
||||
if (response['status'] == 'success') {
|
||||
if (response.containsKey('data')) {
|
||||
@ -241,21 +242,21 @@ class _empDetailsState extends State<empDetails> {
|
||||
prefs.setString('clientName', clientDetails['client']['client_name']);
|
||||
setState(() {
|
||||
clientName = clientDetails['client']['client_name'];
|
||||
print(clientName);
|
||||
logDebug(clientName);
|
||||
clientLogo = clientDetails['client']['client_logo'];
|
||||
print(clientLogo);
|
||||
logDebug(clientLogo);
|
||||
});
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +276,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
if (response.containsKey('data')) {
|
||||
setState(() {
|
||||
dynamic selfDetails = response['data'];
|
||||
print(selfDetails);
|
||||
logDebug(selfDetails);
|
||||
mobileNumber = selfDetails['relationship'];
|
||||
selfRelationship = selfDetails['relationship'];
|
||||
selfName = selfDetails['name'];
|
||||
@ -288,7 +289,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
selfEmailPersonal = selfDetails['email_personal'];
|
||||
selfEmpCode = selfDetails['emp_code'];
|
||||
selfFamilyFloaterKey = selfDetails['family_floater_key'];
|
||||
// print(clientDetails);
|
||||
// logDebug(clientDetails);
|
||||
selfEmpStatus = selfDetails['emp_status'];
|
||||
selfUnit = selfDetails['unit'];
|
||||
});
|
||||
@ -296,15 +297,15 @@ class _empDetailsState extends State<empDetails> {
|
||||
prefs.setString('selfEmpStatus', selfEmpStatus);
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +340,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
if (response['status'] == 'success') {
|
||||
setState(() {
|
||||
gpaPolicies = response['data'];
|
||||
print('gpaPolicies');
|
||||
logDebug('gpaPolicies');
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
@ -347,11 +348,11 @@ class _empDetailsState extends State<empDetails> {
|
||||
});
|
||||
// Handle other status codes
|
||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,20 +372,20 @@ class _empDetailsState extends State<empDetails> {
|
||||
if (response['status'] == 'success') {
|
||||
setState(() {
|
||||
gmcPolicies = response['data'];
|
||||
print('gmcPolicies');
|
||||
logDebug('gmcPolicies');
|
||||
});
|
||||
// Assuming data is a List
|
||||
print(gmcPolicies);
|
||||
logDebug(gmcPolicies);
|
||||
} else {
|
||||
setState(() {
|
||||
gmcDataIsEmpty = 0;
|
||||
});
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,14 +409,14 @@ class _empDetailsState extends State<empDetails> {
|
||||
throw Exception('Failed to fetch relationship list');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error fetching relationship list: $error');
|
||||
logDebug('Error fetching relationship list: $error');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDate(BuildContext context, formType) async {
|
||||
print(formType);
|
||||
logDebug(formType);
|
||||
var ageValidation = formType['age_validation'];
|
||||
print(ageValidation);
|
||||
logDebug(ageValidation);
|
||||
if (ageValidation is Map<String, dynamic>) {
|
||||
int min = ageValidation.containsKey('min')
|
||||
? int.tryParse(ageValidation['min'].toString()) ?? 0
|
||||
@ -424,17 +425,17 @@ class _empDetailsState extends State<empDetails> {
|
||||
? int.tryParse(ageValidation['max'].toString()) ?? 100
|
||||
: 100;
|
||||
|
||||
print('Min age: $min');
|
||||
print('Max age: $max');
|
||||
logDebug('Min age: $min');
|
||||
logDebug('Max age: $max');
|
||||
late DateTime minDate;
|
||||
late DateTime maxDate;
|
||||
|
||||
final DateTime now = DateTime.now();
|
||||
|
||||
maxDate = DateTime(now.year - min, now.month, now.day);
|
||||
print(maxDate);
|
||||
logDebug(maxDate);
|
||||
minDate = DateTime(now.year - max, now.month, now.day);
|
||||
print(minDate);
|
||||
logDebug(minDate);
|
||||
|
||||
// Ensure initialDate is within the range of minDate and maxDate
|
||||
DateTime initialDate =
|
||||
@ -477,7 +478,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
print('Invalid age validation data');
|
||||
logDebug('Invalid age validation data');
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,7 +493,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
}
|
||||
|
||||
Future<void> deleteItem(Map<String, dynamic> deletedItem,copyStatus,gmcClientPolicyId) async {
|
||||
print(deletedItem);
|
||||
logDebug(deletedItem);
|
||||
try {
|
||||
var id = deletedItem['employee_id'];
|
||||
final response = await apiService.deleteItemToApi(id,copyStatus,gmcClientPolicyId);
|
||||
@ -509,25 +510,25 @@ class _empDetailsState extends State<empDetails> {
|
||||
getGmcEmpPolicyDetails(enrollmentEmpPrimaryId);
|
||||
fetchRelationshipList();
|
||||
ToastHelper.showSuccessToast(context, 'Item deleted successfully');
|
||||
print('Item deleted successfully');
|
||||
logDebug('Item deleted successfully');
|
||||
} else {
|
||||
// Handle errors
|
||||
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
||||
print('Failed to delete item. Status code: ${response['code']}');
|
||||
print('Response body: ${response}');
|
||||
logDebug('Failed to delete item. Status code: ${response['code']}');
|
||||
logDebug('Response body: ${response}');
|
||||
}
|
||||
} catch (error) {
|
||||
// Handle network errors
|
||||
print('Error deleting item: $error');
|
||||
logDebug('Error deleting item: $error');
|
||||
}
|
||||
}
|
||||
|
||||
void saveFamilyMemberDetails(Map<String, dynamic> formData,
|
||||
Map<String, dynamic> floatedData, String action, gmcSumInsured) async {
|
||||
// Construct the array of objects
|
||||
print(formData);
|
||||
print('floatedData $floatedData');
|
||||
print(action);
|
||||
logDebug(formData);
|
||||
logDebug('floatedData $floatedData');
|
||||
logDebug(action);
|
||||
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
dynamic primaryId;
|
||||
@ -576,7 +577,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
getGmcEmpPolicyDetails(enrollmentEmpPrimaryId);
|
||||
fetchRelationshipList();
|
||||
ToastHelper.showSuccessToast(context, response['message']);
|
||||
print('Form data sent successfully.');
|
||||
logDebug('Form data sent successfully.');
|
||||
} else {
|
||||
formDataList.clear();
|
||||
selectedRelationships.clear();
|
||||
@ -586,7 +587,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
relationshipOptions.clear();
|
||||
// Request failed, handle error
|
||||
ToastHelper.showErrorToast(context, response['message']);
|
||||
print('Failed to send form data. Error: ${response}');
|
||||
logDebug('Failed to send form data. Error: ${response}');
|
||||
}
|
||||
}
|
||||
|
||||
@ -694,8 +695,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) {
|
||||
print('body if');
|
||||
print(gpaPolicies);
|
||||
logDebug('body if');
|
||||
logDebug(gpaPolicies);
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
@ -1087,12 +1088,12 @@ class _empDetailsState extends State<empDetails> {
|
||||
// Function to open URL in the default browser
|
||||
Future<void> _launchURL(String url) async {
|
||||
final Uri uri = Uri.parse(url); // Parse the URL properly
|
||||
print('_launchURL $uri');
|
||||
logDebug('_launchURL $uri');
|
||||
if (uri != null) {
|
||||
print('If $uri');
|
||||
logDebug('If $uri');
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} else {
|
||||
print('else $uri');
|
||||
logDebug('else $uri');
|
||||
throw 'Could not launch $url';
|
||||
}
|
||||
}
|
||||
@ -1130,8 +1131,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
List relationshipList,
|
||||
dynamic sumInsured,
|
||||
) {
|
||||
print('gmcRelationShip : $relationshipList');
|
||||
print('editGmcRelationShip : $floaterData');
|
||||
logDebug('gmcRelationShip : $relationshipList');
|
||||
logDebug('editGmcRelationShip : $floaterData');
|
||||
|
||||
Map<String, dynamic>? selectedFloaterData;
|
||||
String? dropdownValue;
|
||||
@ -1158,7 +1159,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
relationshipObjects = List<Map<String, dynamic>>.from(relationshipList);
|
||||
}
|
||||
|
||||
print("Normalized relationship list: $relationshipObjects");
|
||||
logDebug("Normalized relationship list: $relationshipObjects");
|
||||
|
||||
// Reset UI Fields
|
||||
_relationShipController.clear();
|
||||
@ -1169,8 +1170,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
// EDIT MODE
|
||||
// ============================
|
||||
if (action == "Edit" && floaterData != null) {
|
||||
print('Edit Floater');
|
||||
print(floaterData);
|
||||
logDebug('Edit Floater');
|
||||
logDebug(floaterData);
|
||||
|
||||
dropdownValue = floaterData["relationship"];
|
||||
|
||||
@ -1190,8 +1191,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
_dobController.text = floaterData["dob"];
|
||||
}
|
||||
// if (action == "Edit" && floaterData != null) {
|
||||
// print('Edit Floater');
|
||||
// print(floaterData);
|
||||
// logDebug('Edit Floater');
|
||||
// logDebug(floaterData);
|
||||
// String rel = floaterData["relationship"];
|
||||
//
|
||||
// dropdownValue = rel;
|
||||
@ -1337,9 +1338,9 @@ class _empDetailsState extends State<empDetails> {
|
||||
"dateOfBirth": _dobController.text,
|
||||
};
|
||||
|
||||
print('floaterDatafloaterData');
|
||||
print(floaterData);
|
||||
print(selectedFloaterData);
|
||||
logDebug('floaterDatafloaterData');
|
||||
logDebug(floaterData);
|
||||
logDebug(selectedFloaterData);
|
||||
|
||||
saveFamilyMemberDetails(
|
||||
formData,
|
||||
@ -1729,8 +1730,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
List<Widget> cards = [];
|
||||
|
||||
for (var item in data) {
|
||||
print('item');
|
||||
print(item);
|
||||
logDebug('item');
|
||||
logDebug(item);
|
||||
|
||||
String? gpaPolicyName = item['Policy_Name'];
|
||||
String? gpaPolicyType = item['type'];
|
||||
@ -2225,27 +2226,27 @@ class _empDetailsState extends State<empDetails> {
|
||||
List<Widget> cards = [];
|
||||
|
||||
for (var item in data) {
|
||||
print('item');
|
||||
print(item);
|
||||
logDebug('item');
|
||||
logDebug(item);
|
||||
|
||||
String gmcPolicyName = item['Policy_Name'];
|
||||
print('gmcPolicyName $gmcPolicyName');
|
||||
logDebug('gmcPolicyName $gmcPolicyName');
|
||||
String gmcPolicyType = item['type'];
|
||||
print('gmcPolicyType $gmcPolicyType');
|
||||
logDebug('gmcPolicyType $gmcPolicyType');
|
||||
String gmcClientPolicyId = item['ClientPolicyId'];
|
||||
print('gmcClientPolicyId $gmcClientPolicyId');
|
||||
logDebug('gmcClientPolicyId $gmcClientPolicyId');
|
||||
String gmcFloaterTextHeading = item['floter_text_heading'];
|
||||
print('gmcFloaterTextHeading $gmcFloaterTextHeading');
|
||||
logDebug('gmcFloaterTextHeading $gmcFloaterTextHeading');
|
||||
String gmcFloaterTextDescription = item['floter_text_description'];
|
||||
print('gmcFloaterTextDescription $gmcFloaterTextDescription');
|
||||
logDebug('gmcFloaterTextDescription $gmcFloaterTextDescription');
|
||||
String gmcNotes = item['notes'];
|
||||
print('gmcNotes $gmcNotes');
|
||||
logDebug('gmcNotes $gmcNotes');
|
||||
String cleanedNotes = gmcNotes?.toString().toLowerCase().replaceAll(' ', '') ?? '';
|
||||
print('gmcNotes cleaned: $cleanedNotes');
|
||||
logDebug('gmcNotes cleaned: $cleanedNotes');
|
||||
dynamic gmcECardDownload = item['eCardDownload'];
|
||||
print('gmcECardDownload $gmcECardDownload');
|
||||
logDebug('gmcECardDownload $gmcECardDownload');
|
||||
bool gmcCopyDependenceDataEnable = item['copy_dependence_data_enable'];
|
||||
print('gmcCopyDependenceDataEnable $gmcCopyDependenceDataEnable');
|
||||
logDebug('gmcCopyDependenceDataEnable $gmcCopyDependenceDataEnable');
|
||||
// double gmcGstValue = (item['family_floaters_of_dependent_and_gst_value'] ?? 0).toDouble();
|
||||
double gmcGstValue =
|
||||
double.tryParse(item['family_floaters_of_dependent_and_gst_value']?.toString() ?? '0') ?? 0.0;
|
||||
@ -2260,7 +2261,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
|
||||
List gmcRelationShip = item['relationship'];
|
||||
List gmcMappedFamilyFloaters = item['mapped_family_floaters'];
|
||||
print('gmcMappedFamilyFloaters $gmcMappedFamilyFloaters');
|
||||
logDebug('gmcMappedFamilyFloaters $gmcMappedFamilyFloaters');
|
||||
List getTrueObjects = gmcMappedFamilyFloaters
|
||||
.where((element) => element['is_value_exist'] == true)
|
||||
.toList();
|
||||
@ -2268,19 +2269,19 @@ class _empDetailsState extends State<empDetails> {
|
||||
List getFalseObjects = gmcMappedFamilyFloaters
|
||||
.where((element) => element['is_value_exist'] == false)
|
||||
.toList();
|
||||
print('getTrueObjects');
|
||||
print(getTrueObjects);
|
||||
logDebug('getTrueObjects');
|
||||
logDebug(getTrueObjects);
|
||||
dynamic gmcSumInsured;
|
||||
if (getTrueObjects.length > 0) {
|
||||
print('true');
|
||||
logDebug('true');
|
||||
gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"];
|
||||
} else {
|
||||
print('false');
|
||||
logDebug('false');
|
||||
gmcSumInsured = item['Policy_Terms']['sum_insured'];
|
||||
}
|
||||
String intOpenForEnrollment = item['OpenForEnrollment'];
|
||||
int gmcOpenForEnrollment = int.parse(intOpenForEnrollment);
|
||||
print('gmcOpenForEnrollment $gmcOpenForEnrollment');
|
||||
logDebug('gmcOpenForEnrollment $gmcOpenForEnrollment');
|
||||
String gmcTypeName = item['type'];
|
||||
|
||||
|
||||
@ -2289,7 +2290,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
for (var floater in gmcMappedFamilyFloaters) {
|
||||
bool isValueExist = floater['is_value_exist'];
|
||||
Map<String, dynamic> floaterData = floater['data'];
|
||||
print('floaterData123456 $floaterData');
|
||||
logDebug('floaterData123456 $floaterData');
|
||||
final dobDate = floaterData['dob'] ?? '';
|
||||
|
||||
if (isValueExist) {
|
||||
@ -2649,7 +2650,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
// gmcRelationShip.any((rel) =>
|
||||
// (rel?.toString().toLowerCase() ?? '') != 'self')) ...[
|
||||
// Builder(builder: (context) {
|
||||
// print("*** Condition is TRUE");
|
||||
// logDebug("*** Condition is TRUE");
|
||||
// GestureDetector(
|
||||
// onTap: () {
|
||||
// if (getFalseObjects.length == 0) {
|
||||
@ -2697,13 +2698,13 @@ class _empDetailsState extends State<empDetails> {
|
||||
? rel['relationship']?.toString().toLowerCase()
|
||||
: rel?.toString().toLowerCase() ?? '') != 'self')) ...<Widget>[
|
||||
Builder(builder: (context) {
|
||||
print("*** IF - Condition is TRUE");
|
||||
print("*** gmcOpenForEnrollment: $gmcOpenForEnrollment");
|
||||
print("*** gmcECardDownload: $gmcECardDownload");
|
||||
print("*** getFalseObjects length: ${getFalseObjects.length}");
|
||||
print("*** gmcRelationShip full: $gmcRelationShip");
|
||||
print("*** gmcNotes original: $gmcNotes");
|
||||
print("*** gmcNotes cleaned: $cleanedNotes");
|
||||
logDebug("*** IF - Condition is TRUE");
|
||||
logDebug("*** gmcOpenForEnrollment: $gmcOpenForEnrollment");
|
||||
logDebug("*** gmcECardDownload: $gmcECardDownload");
|
||||
logDebug("*** getFalseObjects length: ${getFalseObjects.length}");
|
||||
logDebug("*** gmcRelationShip full: $gmcRelationShip");
|
||||
logDebug("*** gmcNotes original: $gmcNotes");
|
||||
logDebug("*** gmcNotes cleaned: $cleanedNotes");
|
||||
|
||||
|
||||
return GestureDetector(
|
||||
@ -2746,21 +2747,21 @@ class _empDetailsState extends State<empDetails> {
|
||||
}),
|
||||
] else ...<Widget>[
|
||||
Builder(builder: (context) {
|
||||
print("*** ELSE - Condition is FALSE");
|
||||
print("*** gmcOpenForEnrollment: $gmcOpenForEnrollment → pass: ${gmcOpenForEnrollment != 0}");
|
||||
print("*** gmcECardDownload: $gmcECardDownload → pass: ${gmcECardDownload == null}");
|
||||
print("*** getFalseObjects length: ${getFalseObjects.length} → pass: ${getFalseObjects.isNotEmpty}");
|
||||
print("*** gmcRelationShip full list: $gmcRelationShip");
|
||||
print("*** gmcNotes original: $gmcNotes");
|
||||
print("*** gmcNotes cleaned: $cleanedNotes");
|
||||
logDebug("*** ELSE - Condition is FALSE");
|
||||
logDebug("*** gmcOpenForEnrollment: $gmcOpenForEnrollment → pass: ${gmcOpenForEnrollment != 0}");
|
||||
logDebug("*** gmcECardDownload: $gmcECardDownload → pass: ${gmcECardDownload == null}");
|
||||
logDebug("*** getFalseObjects length: ${getFalseObjects.length} → pass: ${getFalseObjects.isNotEmpty}");
|
||||
logDebug("*** gmcRelationShip full list: $gmcRelationShip");
|
||||
logDebug("*** gmcNotes original: $gmcNotes");
|
||||
logDebug("*** gmcNotes cleaned: $cleanedNotes");
|
||||
return SizedBox.shrink(); // no widget shown in else
|
||||
}),
|
||||
],
|
||||
]else ...<Widget>[
|
||||
Builder(builder: (context) {
|
||||
print("*** OUTER ELSE - Condition is FALSE");
|
||||
print("*** gmcNotes original: $gmcNotes");
|
||||
print("*** gmcNotes cleaned: $cleanedNotes");
|
||||
logDebug("*** OUTER ELSE - Condition is FALSE");
|
||||
logDebug("*** gmcNotes original: $gmcNotes");
|
||||
logDebug("*** gmcNotes cleaned: $cleanedNotes");
|
||||
return SizedBox.shrink();
|
||||
}),
|
||||
|
||||
@ -2996,10 +2997,10 @@ class _empDetailsState extends State<empDetails> {
|
||||
}
|
||||
|
||||
Future<void> copyPreviousPolicy(gmcMappedFamilyFloaters,gmcClientPolicyId,sumInsured) async {
|
||||
print('gmcClientPolicyId1234 $gmcClientPolicyId');
|
||||
logDebug('gmcClientPolicyId1234 $gmcClientPolicyId');
|
||||
try {
|
||||
final response = await apiService.copyActivePolicy(enrollmentClient_id,enrollmentEmpCodeString,gmcClientPolicyId);
|
||||
print('ABCDEF ${response['status']}');
|
||||
logDebug('ABCDEF ${response['status']}');
|
||||
if (response['status'] == 'success') {
|
||||
List<dynamic> dependents = response['data'];
|
||||
|
||||
@ -3020,7 +3021,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
throw Exception('Failed to fetch relationship list');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error fetching relationship list: $error');
|
||||
logDebug('Error fetching relationship list: $error');
|
||||
}
|
||||
|
||||
}
|
||||
@ -3262,7 +3263,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
"basic_cover_si": sumInsured,
|
||||
};
|
||||
|
||||
print("SENDING TO API → $body");
|
||||
logDebug("SENDING TO API → $body");
|
||||
|
||||
final response =
|
||||
await apiService.saveFamilyMemberDetailsToApi([body]); // API expects a list
|
||||
@ -3321,8 +3322,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
// };
|
||||
// }).toList();
|
||||
//
|
||||
// print("FINAL JSON TO API:");
|
||||
// print(finalList);
|
||||
// logDebug("FINAL JSON TO API:");
|
||||
// logDebug(finalList);
|
||||
//
|
||||
// final response = await apiService.saveFamilyMemberDetailsToApi(finalList);
|
||||
//
|
||||
|
||||
@ -16,10 +16,11 @@ import '../../customAppBar/customFooter.dart';
|
||||
import '../../customAppBar/responsive.dart';
|
||||
import '../../customAppBar/tabs.dart';
|
||||
import '../../customAppBar/toastHelper.dart';
|
||||
import '../postEnrollment/chatbot.dart';
|
||||
import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class empReviewDetails extends StatefulWidget {
|
||||
const empReviewDetails({Key? key}) : super(key: key);
|
||||
|
||||
@ -41,8 +42,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
bool disclaimeStatus = false; // Declare the _isSwitched variable here
|
||||
bool topUpSiIsChecked = false; // Declare the _isSwitched variable here
|
||||
bool topUpParentIsChecked = false; // Declare the _isSwitched variable here
|
||||
bool addOnsDependentIsChecked =
|
||||
false; // Declare the _isSwitched variable here
|
||||
bool addOnsDependentIsChecked = false; // Declare the _isSwitched variable here
|
||||
|
||||
dynamic _token;
|
||||
dynamic enrollmentEmpCodeString;
|
||||
@ -174,7 +174,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
|
||||
setState(() {
|
||||
isTokenAvailable = token != null && token.isNotEmpty;
|
||||
print('isTokenAvailable $isTokenAvailable');
|
||||
logDebug('isTokenAvailable $isTokenAvailable');
|
||||
});
|
||||
}
|
||||
|
||||
@ -194,18 +194,18 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final String? token = await TokenService.getPreToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
selfEmpStatus = prefs.getString('selfEmpStatus');
|
||||
enrollmentEmpClientBranchId = session.enrollmentEmpClientBranchId;
|
||||
enrollmentEmpCodeString = session.enrollmentEmpCodeString;
|
||||
print(enrollmentEmpCodeString); // Check if emp_code is correct
|
||||
logDebug(enrollmentEmpCodeString); // Check if emp_code is correct
|
||||
enrollmentEmpPrimaryId = session.enrollmentEmpPrimaryId;
|
||||
enrollmentGpaEmpName = session.enrollmentGpaEmpName;
|
||||
enrollmentClient_id = session.enrollmentClient_id;
|
||||
print(enrollmentClient_id);
|
||||
logDebug(enrollmentClient_id);
|
||||
|
||||
// Call the API when the page enters
|
||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||
@ -235,11 +235,11 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
// enrollmentEmpClientBranchId =
|
||||
// prefs.getString('enrollmentEmpClientBranchId');
|
||||
// enrollmentEmpCodeString = prefs.getString('enrollmentEmpCodeString');
|
||||
// print(enrollmentEmpCodeString); // Check if emp_code is correct
|
||||
// logDebug(enrollmentEmpCodeString); // Check if emp_code is correct
|
||||
// enrollmentEmpPrimaryId = prefs.getString('enrollmentEmpPrimaryId');
|
||||
// enrollmentGpaEmpName = prefs.getString('enrollmentGpaEmpName');
|
||||
// enrollmentClient_id = prefs.getString('enrollmentClient_id');
|
||||
// print(enrollmentClient_id);
|
||||
// logDebug(enrollmentClient_id);
|
||||
//
|
||||
// // Call the API when the page enters
|
||||
// if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||
@ -273,8 +273,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (prefs.containsKey('siData')) {
|
||||
activeSiData = 1;
|
||||
String? siDataJson = prefs.getString('siData');
|
||||
print('siDataJson');
|
||||
print(siDataJson);
|
||||
logDebug('siDataJson');
|
||||
logDebug(siDataJson);
|
||||
|
||||
List<dynamic> siDataList = jsonDecode(siDataJson!);
|
||||
if (siDataList.isNotEmpty) {
|
||||
@ -289,8 +289,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (prefs.containsKey('siParentData')) {
|
||||
activeSiParentData = 1;
|
||||
String? siParentDataJson = prefs.getString('siParentData');
|
||||
print('siParentDataJson');
|
||||
print(siParentDataJson);
|
||||
logDebug('siParentDataJson');
|
||||
logDebug(siParentDataJson);
|
||||
|
||||
List<dynamic> siParentDataList = jsonDecode(siParentDataJson!);
|
||||
if (siParentDataList.isNotEmpty) {
|
||||
@ -306,25 +306,25 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (prefs.containsKey('dependentData')) {
|
||||
activeDependentData = 1;
|
||||
String? dependentDataJson = prefs.getString('dependentData');
|
||||
print('dependentDataJson');
|
||||
print('activeDependentData $activeDependentData');
|
||||
print(dependentDataJson);
|
||||
logDebug('dependentDataJson');
|
||||
logDebug('activeDependentData $activeDependentData');
|
||||
logDebug(dependentDataJson);
|
||||
|
||||
List<dynamic> dependentDataList = jsonDecode(dependentDataJson!);
|
||||
if (dependentDataList.isNotEmpty) {
|
||||
// Access the first map in the list
|
||||
Map<String, dynamic> firstDependentListData = dependentDataList.first;
|
||||
// Get the value of topUpSiPremiumValue
|
||||
print('150000000000');
|
||||
logDebug('150000000000');
|
||||
addOnDependentPremiumValue =
|
||||
firstDependentListData['addOnDependentPremiumValue'];
|
||||
print(addOnDependentPremiumValue);
|
||||
logDebug(addOnDependentPremiumValue);
|
||||
addOnsDependentPremiumGst =
|
||||
firstDependentListData['addOnsDependentPremiumGst'];
|
||||
print(addOnsDependentPremiumGst);
|
||||
logDebug(addOnsDependentPremiumGst);
|
||||
addOnsDependentTotalAmt =
|
||||
firstDependentListData['addOnsDependentTotalAmt'];
|
||||
print(addOnsDependentTotalAmt);
|
||||
logDebug(addOnsDependentTotalAmt);
|
||||
}
|
||||
}
|
||||
if (prefs.containsKey('siData') &&
|
||||
@ -336,18 +336,18 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
}
|
||||
// Calculate the sum, skipping any missing values
|
||||
|
||||
print('topUpSiTotalAmt: $topUpSiTotalAmt');
|
||||
print('topUpParentSiTotalAmt: $topUpParentSiTotalAmt');
|
||||
print('addOnsDependentTotalAmt: $addOnsDependentTotalAmt');
|
||||
print('gpaTotalAmt: $gpaTotalAmt');
|
||||
print('gmcTotalAmt: $gmcTotalAmt');
|
||||
logDebug('topUpSiTotalAmt: $topUpSiTotalAmt');
|
||||
logDebug('topUpParentSiTotalAmt: $topUpParentSiTotalAmt');
|
||||
logDebug('addOnsDependentTotalAmt: $addOnsDependentTotalAmt');
|
||||
logDebug('gpaTotalAmt: $gpaTotalAmt');
|
||||
logDebug('gmcTotalAmt: $gmcTotalAmt');
|
||||
|
||||
if (topUpSiTotalAmt != null) totalPayableAmt += topUpSiTotalAmt;
|
||||
if (topUpParentSiTotalAmt != null) totalPayableAmt += topUpParentSiTotalAmt;
|
||||
if (addOnsDependentTotalAmt != null)
|
||||
totalPayableAmt += addOnsDependentTotalAmt;
|
||||
|
||||
print('Final Total Payable Amount: $totalPayableAmt');
|
||||
logDebug('Final Total Payable Amount: $totalPayableAmt');
|
||||
}
|
||||
|
||||
void _sortDisclaimerByTypeOrder() {
|
||||
@ -375,22 +375,22 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (response['status'] == 'success') {
|
||||
if (response.containsKey('data')) {
|
||||
dynamic clientDetails = response['data'];
|
||||
print(clientDetails);
|
||||
logDebug(clientDetails);
|
||||
clientName = clientDetails['client']['client_name'];
|
||||
print(clientName);
|
||||
logDebug(clientName);
|
||||
clientLogo = clientDetails['client']['client_logo'];
|
||||
print(clientLogo);
|
||||
logDebug(clientLogo);
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,12 +411,12 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (response['status'] == 'success') {
|
||||
setState(() {
|
||||
gpaPolicies = response['data'];
|
||||
print('gpaPolicies');
|
||||
logDebug('gpaPolicies');
|
||||
|
||||
for (var policy in gpaPolicies) {
|
||||
if (isPremiumEnabled(policy['is_premium_summery'])) {
|
||||
gpahasPremiumSummary = true;
|
||||
print('gpahasPremiumSummary $gpahasPremiumSummary');
|
||||
logDebug('gpahasPremiumSummary $gpahasPremiumSummary');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -450,7 +450,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print('Unexpected type for disclaimer');
|
||||
logDebug('Unexpected type for disclaimer');
|
||||
}
|
||||
|
||||
// Add new entries to the main list, ensuring no duplicate texts
|
||||
@ -473,11 +473,11 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
});
|
||||
// Handle other status codes
|
||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,12 +497,12 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (response['status'] == 'success') {
|
||||
setState(() {
|
||||
gmcPolicies = response['data'];
|
||||
print('gmcPolicies $gmcPolicies');
|
||||
logDebug('gmcPolicies $gmcPolicies');
|
||||
|
||||
for (var policy in gmcPolicies) {
|
||||
if (isPremiumEnabled(policy['is_premium_summery'])) {
|
||||
gmchasPremiumSummary = true;
|
||||
print('gmchasPremiumSummary $gmchasPremiumSummary');
|
||||
logDebug('gmchasPremiumSummary $gmchasPremiumSummary');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -535,7 +535,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print('Unexpected type for disclaimer');
|
||||
logDebug('Unexpected type for disclaimer');
|
||||
}
|
||||
|
||||
// Add new entries to the main list, ensuring no duplicate texts
|
||||
@ -552,17 +552,17 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
}
|
||||
});
|
||||
// Assuming data is a List
|
||||
print(gmcPolicies);
|
||||
logDebug(gmcPolicies);
|
||||
} else {
|
||||
setState(() {
|
||||
gmcDataIsEmpty = 0;
|
||||
});
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -581,16 +581,16 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (response['status'] == 'success') {
|
||||
if (response.containsKey('data')) {
|
||||
dynamic topUpSiPolicies = response['data'];
|
||||
print(topUpSiPolicies);
|
||||
logDebug(topUpSiPolicies);
|
||||
if (topUpSiPolicies.isNotEmpty) {
|
||||
// setState(() {
|
||||
topUpClientPolicyId =
|
||||
topUpSiPolicies['gmc_si_topup']['client_policy_id'];
|
||||
print('topUpClientPolicyId12345 $topUpClientPolicyId');
|
||||
logDebug('topUpClientPolicyId12345 $topUpClientPolicyId');
|
||||
|
||||
topUpSumInsured = topUpSiPolicies['gmc_si_topup']
|
||||
['family_floaters_of_only_si_value'];
|
||||
print(topUpSumInsured);
|
||||
logDebug(topUpSumInsured);
|
||||
|
||||
if (topUpSumInsured == 0) {
|
||||
showHideTopUpCard = 0;
|
||||
@ -608,8 +608,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
|
||||
topUpMappedFamilyFloatersSiArray = topUpSiPolicies['gmc_si_topup']
|
||||
['family_floaters_of_only_si_array'];
|
||||
print('topUpMappedFamilyFloatersSiArray');
|
||||
print(topUpMappedFamilyFloatersSiArray);
|
||||
logDebug('topUpMappedFamilyFloatersSiArray');
|
||||
logDebug(topUpMappedFamilyFloatersSiArray);
|
||||
|
||||
topUpTypeName = topUpSiPolicies['gmc_si_topup']['type'];
|
||||
|
||||
@ -658,7 +658,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print('Unexpected type for disclaimer');
|
||||
logDebug('Unexpected type for disclaimer');
|
||||
}
|
||||
|
||||
// Add new entries to the main list, ensuring no duplicate texts
|
||||
@ -677,19 +677,19 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
// allDisclaimer = allDisclaimer.toSet().toList();
|
||||
// });
|
||||
} else {
|
||||
print('No data found in the response');
|
||||
logDebug('No data found in the response');
|
||||
}
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -709,8 +709,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (response.containsKey('data')) {
|
||||
setState(() {
|
||||
topUpSiParentPolicies = response['data'];
|
||||
print('topUpSiParentPolicies');
|
||||
print(topUpSiParentPolicies);
|
||||
logDebug('topUpSiParentPolicies');
|
||||
logDebug(topUpSiParentPolicies);
|
||||
});
|
||||
if (topUpSiParentPolicies.isNotEmpty) {
|
||||
topUpParentClientPolicyId =
|
||||
@ -719,8 +719,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
|
||||
topUpParentSlabRates =
|
||||
await topUpSiParentPolicies['gmc_si_parent_topup']['SlabRates'];
|
||||
print('topUpParentSlabRates');
|
||||
print(topUpParentSlabRates);
|
||||
logDebug('topUpParentSlabRates');
|
||||
logDebug(topUpParentSlabRates);
|
||||
|
||||
topUpParentPolicyName =
|
||||
await topUpSiParentPolicies['gmc_si_parent_topup']
|
||||
@ -732,22 +732,22 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
topUpParentFamilyFloater =
|
||||
await topUpSiParentPolicies['gmc_si_parent_topup']
|
||||
['policy_terms']['family_floater'];
|
||||
print('topUpParentFamilyFloater');
|
||||
print(topUpParentFamilyFloater);
|
||||
logDebug('topUpParentFamilyFloater');
|
||||
logDebug(topUpParentFamilyFloater);
|
||||
|
||||
topUpParentMappedFamilyFloatersSi =
|
||||
await topUpSiParentPolicies['gmc_si_parent_topup']
|
||||
['family_floaters_of_only_si_array'];
|
||||
print('topUpParentMappedFamilyFloatersSi');
|
||||
print(topUpParentMappedFamilyFloatersSi);
|
||||
logDebug('topUpParentMappedFamilyFloatersSi');
|
||||
logDebug(topUpParentMappedFamilyFloatersSi);
|
||||
|
||||
print('topUpECardDownload');
|
||||
logDebug('topUpECardDownload');
|
||||
topUpParentECardDownload =
|
||||
topUpSiParentPolicies['gmc_si_parent_topup']['eCardDownload'];
|
||||
|
||||
setState(() {
|
||||
topUpParentIsPremiumSummary = isPremiumEnabled(topUpSiParentPolicies['gmc_si_parent_topup']?['is_premium_summery']);
|
||||
print(topUpParentECardDownload);
|
||||
logDebug(topUpParentECardDownload);
|
||||
});
|
||||
|
||||
|
||||
@ -759,7 +759,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
// topUpSiParentPolicies['gmc_si_parent_topup']
|
||||
// ['OpenForEnrollment'];
|
||||
// topUpParentOpenForEnrollment = int.parse(intOpenForEnrollment);
|
||||
// print(topUpParentOpenForEnrollment);
|
||||
// logDebug(topUpParentOpenForEnrollment);
|
||||
|
||||
topUpParentTypeName =
|
||||
topUpSiParentPolicies['gmc_si_parent_topup']['type'];
|
||||
@ -814,7 +814,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print('Unexpected type for disclaimer');
|
||||
logDebug('Unexpected type for disclaimer');
|
||||
}
|
||||
|
||||
// Add new entries to the main list, ensuring no duplicate texts
|
||||
@ -830,19 +830,19 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('No data found in the response');
|
||||
logDebug('No data found in the response');
|
||||
}
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -861,27 +861,27 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
if (response['status'] == 'success') {
|
||||
if (response.containsKey('data')) {
|
||||
dynamic addOnsDependentPolicies = response['data'];
|
||||
print('addOnsDependentPolicies');
|
||||
print(addOnsDependentPolicies);
|
||||
logDebug('addOnsDependentPolicies');
|
||||
logDebug(addOnsDependentPolicies);
|
||||
if (addOnsDependentPolicies.isNotEmpty) {
|
||||
addOnsDependentClientPolicyId =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['client_policy_id'];
|
||||
print(addOnsDependentClientPolicyId);
|
||||
logDebug(addOnsDependentClientPolicyId);
|
||||
|
||||
addOnsDependentSumInsured = int.parse(
|
||||
addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['family_floaters_of_dependent_and_si_value']
|
||||
.toString());
|
||||
print('addOnsDependentSumInsured $addOnsDependentSumInsured');
|
||||
logDebug('addOnsDependentSumInsured $addOnsDependentSumInsured');
|
||||
|
||||
var value = int.parse(addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['family_floaters_of_dependent_and_si_premium_value']
|
||||
.toString());
|
||||
print(value);
|
||||
logDebug(value);
|
||||
|
||||
final checkValue = addOnsDependentSumInsured + value;
|
||||
print('checkValue $checkValue');
|
||||
logDebug('checkValue $checkValue');
|
||||
if (checkValue == 0) {
|
||||
showHideAddOnsCard = 0;
|
||||
} else {
|
||||
@ -896,17 +896,17 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
|
||||
addOnsDependentPolicyName =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']['policy_name'];
|
||||
print(addOnsDependentPolicyName);
|
||||
logDebug(addOnsDependentPolicyName);
|
||||
|
||||
addOnsDependentPolicyType =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']['type'];
|
||||
print(addOnsDependentPolicyType);
|
||||
logDebug(addOnsDependentPolicyType);
|
||||
|
||||
addOnsDependentMappedFamilyFloatersArray =
|
||||
await addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['family_floaters_of_dependent_and_si_array'];
|
||||
print('addOnsDependentMappedFamilyFloatersArray');
|
||||
print(addOnsDependentMappedFamilyFloatersArray);
|
||||
logDebug('addOnsDependentMappedFamilyFloatersArray');
|
||||
logDebug(addOnsDependentMappedFamilyFloatersArray);
|
||||
|
||||
addOnsFloaterTextHeading =
|
||||
addOnsDependentPolicies['gmc_dependent_addon']
|
||||
@ -918,7 +918,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
addOnsDependentDisclaimer =
|
||||
await addOnsDependentPolicies['gmc_dependent_addon']
|
||||
['disclaimer'];
|
||||
print(
|
||||
logDebug(
|
||||
'addOnsDependentOpenForEnrollment $addOnsDependentDisclaimer');
|
||||
addOnsDependentOpenForEnrollment =
|
||||
await addOnsDependentPolicies['gmc_dependent_addon']
|
||||
@ -933,12 +933,12 @@ setState(() {
|
||||
// if(addOnsDependentIsPremiumSummary == '1'){
|
||||
// tabHide = '0';
|
||||
// }
|
||||
print(
|
||||
logDebug(
|
||||
'addOnsDependentOpenForEnrollment $addOnsDependentOpenForEnrollment');
|
||||
print('activeDependentData $activeDependentData');
|
||||
logDebug('activeDependentData $activeDependentData');
|
||||
if (addOnsDependentOpenForEnrollment == '1' &&
|
||||
activeDependentData == 1) {
|
||||
print('addOnsDependentOpenForEnrollment');
|
||||
logDebug('addOnsDependentOpenForEnrollment');
|
||||
if (addOnsDependentDisclaimer != null &&
|
||||
addOnsDependentDisclaimer.isNotEmpty) {
|
||||
// Temporary list to hold new entries
|
||||
@ -965,7 +965,7 @@ setState(() {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print('Unexpected type for disclaimer');
|
||||
logDebug('Unexpected type for disclaimer');
|
||||
}
|
||||
|
||||
// Add new entries to the main list, ensuring no duplicate texts
|
||||
@ -981,19 +981,19 @@ setState(() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('No data found in the response');
|
||||
logDebug('No data found in the response');
|
||||
}
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1006,7 +1006,7 @@ setState(() {
|
||||
.where((element) => element['is_value_exist'] == true)
|
||||
.toList();
|
||||
|
||||
print('getDependentTrueObjects : $getDependentTrueObjects');
|
||||
logDebug('getDependentTrueObjects : $getDependentTrueObjects');
|
||||
|
||||
if (getDependentTrueObjects.isNotEmpty) {
|
||||
iAgreeForAddOn.add(int.parse(addOnsDependentClientPolicyId));
|
||||
@ -1018,7 +1018,7 @@ setState(() {
|
||||
.where((element) => element['is_value_exist'] == true)
|
||||
.toList();
|
||||
|
||||
print('getSiTrueObjects : $getSiTrueObjects');
|
||||
logDebug('getSiTrueObjects : $getSiTrueObjects');
|
||||
|
||||
if (getSiTrueObjects.isNotEmpty) {
|
||||
iAgreeForAddOn.add(int.parse(topUpClientPolicyId));
|
||||
@ -1030,50 +1030,50 @@ setState(() {
|
||||
.where((element) => element['is_value_exist'] == true)
|
||||
.toList();
|
||||
|
||||
print('getSiTrueObjects $getSiTrueObjects');
|
||||
logDebug('getSiTrueObjects $getSiTrueObjects');
|
||||
|
||||
if (getSiTrueObjects.isNotEmpty) {
|
||||
iAgreeForAddOn.add(int.parse(topUpParentClientPolicyId));
|
||||
}
|
||||
}
|
||||
|
||||
print('gpaPolicies');
|
||||
print(gpaPolicies);
|
||||
print('gmcPolicies');
|
||||
print(gmcPolicies);
|
||||
print('iAgreeForAddOn $iAgreeForAddOn');
|
||||
logDebug('gpaPolicies');
|
||||
logDebug(gpaPolicies);
|
||||
logDebug('gmcPolicies');
|
||||
logDebug(gmcPolicies);
|
||||
logDebug('iAgreeForAddOn $iAgreeForAddOn');
|
||||
|
||||
if (gpaDataIsEmpty != 0) {
|
||||
print('gpaDataIsEmpty : $gpaDataIsEmpty');
|
||||
logDebug('gpaDataIsEmpty : $gpaDataIsEmpty');
|
||||
for (var item in gpaPolicies) {
|
||||
print('ClientPolicyId');
|
||||
logDebug('ClientPolicyId');
|
||||
// Extract ClientPolicyId value from each object
|
||||
String clientPolicyId = item['ClientPolicyId'];
|
||||
// Convert to integer and add to iAgreeForAddOn list
|
||||
iAgreeForAddOn.add(int.parse(clientPolicyId));
|
||||
}
|
||||
}
|
||||
print('iAgreeForAddOn $iAgreeForAddOn');
|
||||
logDebug('iAgreeForAddOn $iAgreeForAddOn');
|
||||
|
||||
if (gmcDataIsEmpty != 0) {
|
||||
for (var item in gmcPolicies) {
|
||||
print('ClientPolicyId');
|
||||
logDebug('ClientPolicyId');
|
||||
// Extract ClientPolicyId value from each object
|
||||
String clientPolicyId = item['ClientPolicyId'];
|
||||
// Convert to integer and add to iAgreeForAddOn list
|
||||
iAgreeForAddOn.add(int.parse(clientPolicyId));
|
||||
}
|
||||
}
|
||||
print('iAgreeForAddOn');
|
||||
logDebug('iAgreeForAddOn');
|
||||
iAgreeForAddOn = iAgreeForAddOn.toSet().toList();
|
||||
print(iAgreeForAddOn); // Output: [90, 92, 88, 89]
|
||||
logDebug(iAgreeForAddOn); // Output: [90, 92, 88, 89]
|
||||
|
||||
Map<String, dynamic> apiParams = {
|
||||
'emp_code': enrollmentEmpCodeString,
|
||||
'client_policy_id': iAgreeForAddOn,
|
||||
'client_id': enrollmentClient_id,
|
||||
};
|
||||
print(apiParams);
|
||||
logDebug(apiParams);
|
||||
|
||||
// Convert the list of objects to JSON
|
||||
String formDataJson = jsonEncode(apiParams);
|
||||
@ -1089,7 +1089,7 @@ setState(() {
|
||||
topUpParentIsChecked = false;
|
||||
addOnsDependentIsChecked = false;
|
||||
});
|
||||
print('response.statusCode == 200');
|
||||
logDebug('response.statusCode == 200');
|
||||
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||
_showSuccessDialog();
|
||||
} else {
|
||||
@ -1099,14 +1099,14 @@ setState(() {
|
||||
// Handle other status codes
|
||||
ToastHelper.showErrorToast(context, 'Failed to Save');
|
||||
_showErrorDialog();
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1195,12 +1195,12 @@ setState(() {
|
||||
// Function to open URL in the default browser
|
||||
Future<void> _launchURL(String url) async {
|
||||
final Uri uri = Uri.parse(url); // Parse the URL properly
|
||||
print('_launchURL $uri');
|
||||
logDebug('_launchURL $uri');
|
||||
if (uri != null) {
|
||||
print('If $uri');
|
||||
logDebug('If $uri');
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} else {
|
||||
print('else $uri');
|
||||
logDebug('else $uri');
|
||||
throw 'Could not launch $url';
|
||||
}
|
||||
}
|
||||
@ -1212,8 +1212,8 @@ setState(() {
|
||||
// (int.tryParse(topUpParentOpenForEnrollment ?? '0') != 0) &&
|
||||
// (int.tryParse(addOnsDependentOpenForEnrollment ?? '0') != 0);
|
||||
//
|
||||
// print('enrollmentConditionsMet: $enrollmentConditionsMet');
|
||||
// print('gmcEnrollmentStatus: $gmcEnrollmentStatus');
|
||||
// logDebug('enrollmentConditionsMet: $enrollmentConditionsMet');
|
||||
// logDebug('gmcEnrollmentStatus: $gmcEnrollmentStatus');
|
||||
|
||||
// return isChecked &&
|
||||
// enrollmentConditionsMet &&
|
||||
@ -1442,7 +1442,7 @@ setState(() {
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
Text(
|
||||
'You have completed your enrolment. You can now close this tab',
|
||||
'You have completed your enrolment. You can now close this Page',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
@ -2711,8 +2711,7 @@ setState(() {
|
||||
...gmcBuildPolicyRows(
|
||||
gmcPolicies, context),
|
||||
if (activeSiData == 1 &&
|
||||
topUpIsPremiumSummary ==
|
||||
'1')
|
||||
topUpIsPremiumSummary)
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
@ -2807,8 +2806,7 @@ setState(() {
|
||||
),
|
||||
if (activeSiParentData ==
|
||||
1 &&
|
||||
topUpParentIsPremiumSummary ==
|
||||
'1')
|
||||
topUpParentIsPremiumSummary)
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
@ -2903,8 +2901,7 @@ setState(() {
|
||||
),
|
||||
if (activeDependentData ==
|
||||
1 &&
|
||||
addOnsDependentIsPremiumSummary ==
|
||||
'1')
|
||||
addOnsDependentIsPremiumSummary)
|
||||
TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
@ -3154,7 +3151,7 @@ setState(() {
|
||||
id,
|
||||
)['checked'] =
|
||||
value!;
|
||||
print(
|
||||
logDebug(
|
||||
allDisclaimer);
|
||||
});
|
||||
},
|
||||
@ -3370,8 +3367,8 @@ setState(() {
|
||||
List<Widget> cards = [];
|
||||
|
||||
for (var item in data) {
|
||||
print('item');
|
||||
print(item);
|
||||
logDebug('item');
|
||||
logDebug(item);
|
||||
|
||||
String? gpaPolicyName = item['Policy_Name'];
|
||||
String? gpaPolicyType = item['type'];
|
||||
@ -3399,7 +3396,7 @@ setState(() {
|
||||
|
||||
String? gpaSumInsured;
|
||||
|
||||
print('GPA Disclaimer $allDisclaimer');
|
||||
logDebug('GPA Disclaimer $allDisclaimer');
|
||||
|
||||
// local checkbox list
|
||||
List<bool> checkboxValues =
|
||||
@ -3876,7 +3873,7 @@ setState(() {
|
||||
? item['mapped_family_floaters']
|
||||
: [];
|
||||
|
||||
print('GPA Disclaimer $allDisclaimer');
|
||||
logDebug('GPA Disclaimer $allDisclaimer');
|
||||
|
||||
// -------------------------------
|
||||
// Find objects where is_value_exist == true
|
||||
@ -3898,8 +3895,8 @@ setState(() {
|
||||
|
||||
String gmcTypeName = gmcPolicyType;
|
||||
|
||||
print("gmcMappedFamilyFloaters: $gmcMappedFamilyFloaters");
|
||||
print("trueObjects: $trueObjects");
|
||||
logDebug("gmcMappedFamilyFloaters: $gmcMappedFamilyFloaters");
|
||||
logDebug("trueObjects: $trueObjects");
|
||||
|
||||
Widget card = trueObjects.length > 0
|
||||
? Card(
|
||||
@ -4296,7 +4293,7 @@ setState(() {
|
||||
(policy["si_gst_value"] ?? 0) + (policy["si_premium_value"] ?? 0))
|
||||
.fold(0.0, (sum, value) => sum + value);
|
||||
|
||||
print('Calculated gpaTotalAmt: $total'); // Debug print
|
||||
logDebug('Calculated gpaTotalAmt: $total'); // Debug print
|
||||
return total;
|
||||
}
|
||||
|
||||
@ -4308,7 +4305,7 @@ setState(() {
|
||||
(policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0))
|
||||
.fold(0.0, (sum, value) => sum + value);
|
||||
|
||||
print('Calculated gmcTotalAmt: $total'); // Debug print
|
||||
logDebug('Calculated gmcTotalAmt: $total'); // Debug print
|
||||
return total;
|
||||
}
|
||||
|
||||
@ -4318,7 +4315,7 @@ setState(() {
|
||||
}
|
||||
gpaTotalAmt = calculateGpaTotalAmt(policies.cast<Map<String, dynamic>>());
|
||||
|
||||
print('gpaTotalAmt $gpaTotalAmt');
|
||||
logDebug('gpaTotalAmt $gpaTotalAmt');
|
||||
return (policies as List)
|
||||
.where((policy) => policy is Map<String,
|
||||
dynamic>) // Ensure each item is a Map<String, dynamic>
|
||||
@ -4386,14 +4383,14 @@ setState(() {
|
||||
}
|
||||
|
||||
List<TableRow> gmcBuildPolicyRows(dynamic policies, BuildContext context) {
|
||||
print('gmcBuildPolicyRows $policies');
|
||||
logDebug('gmcBuildPolicyRows $policies');
|
||||
|
||||
if (policies is! List) {
|
||||
return []; // Return empty list if policies is not a list
|
||||
}
|
||||
gmcTotalAmt = calculateGmcTotalAmt(policies.cast<Map<String, dynamic>>());
|
||||
|
||||
print('gmcTotalAmt $gmcTotalAmt');
|
||||
logDebug('gmcTotalAmt $gmcTotalAmt');
|
||||
return (policies as List)
|
||||
.where((policy) => policy is Map<String,
|
||||
dynamic>) // Ensure each item is a Map<String, dynamic>
|
||||
|
||||
@ -8,6 +8,8 @@ import '../../../customAppBar/toastHelper.dart';
|
||||
|
||||
import '../../service/TokenService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class ApiService {
|
||||
final BuildContext context;
|
||||
String? _token;
|
||||
@ -23,7 +25,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getClientLogoAndDetailsToApi(empClientId,empClientBranchId,
|
||||
String clientId, String branchID) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -41,7 +43,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getSelfEmployeeProfileToApi(
|
||||
String clientId, String empCode, String branchID) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -55,7 +57,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchRelationshipListToApi() async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -69,7 +71,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getGpaEmpPolicyDetailsToApi(String empPrimaryId,
|
||||
String empCode, String clientId, String policy, String branchID) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -84,7 +86,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getGmcEmpPolicyDetailsToApi(String empPrimaryId,
|
||||
String empCode, String clientId, String policy, String branchID) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -99,7 +101,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getGmcSiTopUpToApi(
|
||||
String client_id, String emp_code, String policy, String branchID) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -114,7 +116,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getGmcSiParentTopUpToApi(
|
||||
String client_id, String emp_code, String policy, String branchID) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -129,7 +131,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getGmcDependentAddOnsToApi(
|
||||
String client_id, String emp_code, String policy, String branchID) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -144,7 +146,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> removeAddonsGmcDependentToAPI(
|
||||
String empCodeString, String addOnsDependentClientPolicyId) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -159,7 +161,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> removeAddonsGmcSiToAPI(
|
||||
String empCodeString, String topUpClientPolicyId) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -174,7 +176,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> removeAddonsGmcParentSiToAPI(
|
||||
String empCodeString, String topUpParentClientPolicyId) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -188,7 +190,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> deleteItemToApi(id,copyStatus,gmcClientPolicyId) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -202,7 +204,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> copyActivePolicy(enrollmentClient_id,enrollmentEmpCodeString,newClientPolicy) async {
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -217,7 +219,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> saveFamilyMemberDetailsToApi(
|
||||
List<Map<String, dynamic>> formDataList) async {
|
||||
print('saveFamilyMemberDetailsToApi API SERVICE');
|
||||
logDebug('saveFamilyMemberDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -239,7 +241,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> saveAddOnsDetailsToApi(
|
||||
List<Map<String, dynamic>> formDataList) async {
|
||||
print('saveAddOnsDetailsToApi API SERVICE');
|
||||
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -261,7 +263,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> sendAddonsGmcDependentToAPI(
|
||||
List<Map<String, dynamic>> formDataList) async {
|
||||
print('saveAddOnsDetailsToApi API SERVICE');
|
||||
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -283,7 +285,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> sendAddonsGmcSiToAPI(
|
||||
List<Map<String, dynamic>> formDataList) async {
|
||||
print('saveAddOnsDetailsToApi API SERVICE');
|
||||
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -305,7 +307,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> sendAddonsGmcParentSiToAPI(
|
||||
List<Map<String, dynamic>> formDataList) async {
|
||||
print('saveAddOnsDetailsToApi API SERVICE');
|
||||
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -327,7 +329,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> sendAddOnToAPI(
|
||||
Map<String, dynamic> formData) async {
|
||||
print('sendAddOnToAPI API SERVICE');
|
||||
logDebug('sendAddOnToAPI API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -347,7 +349,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> topUpSiCalculationToAPI(formDataList) async {
|
||||
print('saveAddOnsDetailsToApi API SERVICE');
|
||||
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -367,7 +369,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> topUpParentSiCalculationToAPI(
|
||||
formDataList) async {
|
||||
print('saveAddOnsDetailsToApi API SERVICE');
|
||||
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -388,7 +390,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> addOnsDependentCalculationToAPI(
|
||||
formDataList) async {
|
||||
print('saveAddOnsDetailsToApi API SERVICE');
|
||||
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -411,7 +413,7 @@ class ApiService {
|
||||
|
||||
// Future<Map<String, dynamic>> getCashDepositDetailsToApi(
|
||||
// String clintID, String empRefId) async {
|
||||
// print(_hrtoken);
|
||||
// logDebug(_hrtoken);
|
||||
// if (_hrtoken == null) {
|
||||
// await _initializeToken();
|
||||
// }
|
||||
@ -426,7 +428,7 @@ class ApiService {
|
||||
//
|
||||
// Future<Map<String, dynamic>> getEmployeeAndDependenceToApi(
|
||||
// String clintID, String getPolicyNo, String empRefId) async {
|
||||
// print(_hrtoken);
|
||||
// logDebug(_hrtoken);
|
||||
// if (_hrtoken == null) {
|
||||
// await _initializeToken();
|
||||
// }
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
// html_web.dart
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class HtmlHelper {
|
||||
static void saveLoginData(Map<String, String> data) {
|
||||
data.forEach((key, value) {
|
||||
@ -11,6 +13,6 @@ class HtmlHelper {
|
||||
html.CustomEvent('userLoggedIn', detail: {'status': 'success'}),
|
||||
);
|
||||
|
||||
print("✅ User logged in! LocalStorage values set (web).");
|
||||
logDebug("✅ User logged in! LocalStorage values set (web).");
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ import '../models/platform_helper_mobile.dart'
|
||||
if (dart.library.html) '../models/platform_helper_other.dart';
|
||||
import 'package:pinput/pinput.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class login extends StatefulWidget {
|
||||
const login({Key? key});
|
||||
|
||||
@ -112,19 +114,19 @@ class _loginState extends State<login> {
|
||||
if (kIsWeb) {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.clear();
|
||||
print('Local Storage Clear');
|
||||
logDebug('Local Storage Clear');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> checkLoginPin(BuildContext context) async {
|
||||
print('checkLoginPin');
|
||||
logDebug('checkLoginPin');
|
||||
try {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empMobileNo = prefs.getString('empMobileNo');
|
||||
empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo $empMobileNo');
|
||||
print('empEmailid $empEmailid');
|
||||
logDebug('empMobileNo $empMobileNo');
|
||||
logDebug('empEmailid $empEmailid');
|
||||
// _token = prefs.getString('token');
|
||||
var params = {};
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
@ -145,7 +147,7 @@ class _loginState extends State<login> {
|
||||
if (response.statusCode == 200) {
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
if (data['status'] == 'success') {
|
||||
print('data');
|
||||
logDebug('data');
|
||||
if (data['data'] != null) {
|
||||
prefs.setString('mpinText', data['data']);
|
||||
}
|
||||
@ -204,7 +206,7 @@ class _loginState extends State<login> {
|
||||
}
|
||||
} catch (e) {
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,10 +239,10 @@ class _loginState extends State<login> {
|
||||
setState(() {
|
||||
isEmailFieldVisible = true;
|
||||
});
|
||||
print("User entered Email: $input");
|
||||
logDebug("User entered Email: $input");
|
||||
} else if (isMobile) {
|
||||
isEmailFieldVisible = false;
|
||||
print("User entered Mobile: $input");
|
||||
logDebug("User entered Mobile: $input");
|
||||
}
|
||||
|
||||
|
||||
@ -275,9 +277,9 @@ class _loginState extends State<login> {
|
||||
ToastHelper.showSuccessToast(
|
||||
context, 'Verification code sent to ${emailMobileController.text}');
|
||||
if (isEmailFieldVisible) {
|
||||
print('isEmailFieldVisible $isEmailFieldVisible');
|
||||
logDebug('isEmailFieldVisible $isEmailFieldVisible');
|
||||
// prefs.setString('empEmail', emailController.text);
|
||||
print('${emailMobileController.text}');
|
||||
logDebug('${emailMobileController.text}');
|
||||
context.go(
|
||||
'/mailVerify',
|
||||
extra: {
|
||||
@ -304,7 +306,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, message);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else if (response.statusCode == 429) {
|
||||
setState(() {
|
||||
@ -326,14 +328,14 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Future<void> _verifyPhoneNumber() async {
|
||||
// var enteredMobileNumber = mobileController.text;
|
||||
// var countryCode = countryController.text;
|
||||
// print('${countryCode + enteredMobileNumber}');
|
||||
// logDebug('${countryCode + enteredMobileNumber}');
|
||||
// await _auth.verifyPhoneNumber(
|
||||
// phoneNumber: '${countryCode + enteredMobileNumber}',
|
||||
// timeout: const Duration(seconds: 60),
|
||||
@ -345,7 +347,7 @@ class _loginState extends State<login> {
|
||||
// // });
|
||||
// },
|
||||
// verificationFailed: (FirebaseAuthException e) {
|
||||
// print('Verification Failed: ${e.code} - ${e.message}');
|
||||
// logDebug('Verification Failed: ${e.code} - ${e.message}');
|
||||
// String errorMessage;
|
||||
// if (e.code == 'invalid-app-credential') {
|
||||
// errorMessage = 'Invalid Credential. Please try again.';
|
||||
@ -431,7 +433,7 @@ class _loginState extends State<login> {
|
||||
// },
|
||||
// verificationFailed: (FirebaseAuthException e) {
|
||||
// if (e.code == 'invalid-phone-number') {
|
||||
// print('The provided phone number is not valid.');
|
||||
// logDebug('The provided phone number is not valid.');
|
||||
// }
|
||||
// },
|
||||
// codeSent: (String verificationId, int? resendToken) async{
|
||||
@ -484,7 +486,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
// print('EMAIL PARAMS : ${widget.email} - OTP : $otp');
|
||||
// logDebug('EMAIL PARAMS : ${widget.email} - OTP : $otp');
|
||||
final Map<String, dynamic> payload = {
|
||||
'email_id': emailController.text,
|
||||
'password': passwordController.text
|
||||
@ -498,13 +500,13 @@ class _loginState extends State<login> {
|
||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||
},
|
||||
);
|
||||
print('response : ${response.statusCode}');
|
||||
logDebug('response : ${response.statusCode}');
|
||||
if (response.statusCode == 200) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
print('data: $data');
|
||||
logDebug('data: $data');
|
||||
|
||||
/// Check API response status first
|
||||
if (data['status'] == 'Invalid Password') {
|
||||
@ -513,7 +515,7 @@ class _loginState extends State<login> {
|
||||
prefs.clear();
|
||||
ToastHelper.showErrorToast(
|
||||
context, data['message'] ?? 'Invalid Password');
|
||||
print('API error → ${data['message']}');
|
||||
logDebug('API error → ${data['message']}');
|
||||
return; // stop execution
|
||||
}
|
||||
|
||||
@ -532,14 +534,14 @@ class _loginState extends State<login> {
|
||||
// Save tokens
|
||||
await TokenService.saveTokens(
|
||||
preToken: preToken, postToken: postToken);
|
||||
print('Tokens saved → preToken: $preToken, postToken: $postToken');
|
||||
logDebug('Tokens saved → preToken: $preToken, postToken: $postToken');
|
||||
|
||||
_preToken = preToken;
|
||||
String status = data['status'];
|
||||
|
||||
// Directly access the post_enrollment data
|
||||
Map<String, dynamic> post = data['post_enrollment'];
|
||||
print('post: $post');
|
||||
logDebug('post: $post');
|
||||
|
||||
_postToken = postToken;
|
||||
String postStatus = post['status'];
|
||||
@ -564,7 +566,7 @@ class _loginState extends State<login> {
|
||||
ToastHelper.showErrorToast(
|
||||
context, 'Invalid Passsword. Please try again');
|
||||
// Show a Snackbar if the OTP is invalid
|
||||
print('Invalid Password. Please try again');
|
||||
logDebug('Invalid Password. Please try again');
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
@ -582,10 +584,10 @@ class _loginState extends State<login> {
|
||||
});
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.clear();
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||
// Show a Snackbar if there's an error while verifying OTP
|
||||
print('Failed to verify OTP. Please try again.');
|
||||
logDebug('Failed to verify OTP. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -597,7 +599,7 @@ class _loginState extends State<login> {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await SessionManager().initializeFromPostToken(post['data']);
|
||||
session = await SessionManager();
|
||||
print('Successfully Login');
|
||||
logDebug('Successfully Login');
|
||||
}
|
||||
|
||||
if (status == 'success') {
|
||||
@ -621,8 +623,8 @@ class _loginState extends State<login> {
|
||||
await SessionManager().initializeFromPreToken(data['data']);
|
||||
session = await SessionManager();
|
||||
getClientLogoAndDetails();
|
||||
print('Successfully Login');
|
||||
print(isMobilePlatform());
|
||||
logDebug('Successfully Login');
|
||||
logDebug(isMobilePlatform());
|
||||
if (_preToken != null && _preToken.isNotEmpty) {
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Logged In');
|
||||
context.go('/home');
|
||||
@ -646,9 +648,9 @@ class _loginState extends State<login> {
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
// print('response.statusCode == 200');
|
||||
// logDebug('response.statusCode == 200');
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
// print(data);
|
||||
// logDebug(data);
|
||||
|
||||
if (data.containsKey('data')) {
|
||||
dynamic clientDetails = data['data'];
|
||||
@ -661,27 +663,27 @@ class _loginState extends State<login> {
|
||||
'addon_subheading', clientDetails['client']['addon_subheading']);
|
||||
setState(() {
|
||||
// dynamic clientDetails = data['data'];
|
||||
// print(clientDetails);
|
||||
// logDebug(clientDetails);
|
||||
clientName = clientDetails['client']['client_name'];
|
||||
print(clientName);
|
||||
logDebug(clientName);
|
||||
clientLogo = clientDetails['client']['client_logo'];
|
||||
print(clientLogo);
|
||||
logDebug(clientLogo);
|
||||
});
|
||||
} else {
|
||||
// Handle other status messages if needed
|
||||
// ToastHelper.showErrorToast(
|
||||
// context, 'API request failed with status: ${data['status']}');
|
||||
print('API request failed with status: ${data['status']}');
|
||||
logDebug('API request failed with status: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
// Handle other status codes
|
||||
// ToastHelper.showErrorToast(
|
||||
// context, 'Request failed with status: ${response.statusCode}');
|
||||
print('Request failed with status: ${response.statusCode}');
|
||||
logDebug('Request failed with status: ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle exceptions
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,7 +748,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, message);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
@ -761,7 +763,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
|
||||
}
|
||||
@ -792,11 +794,11 @@ class _loginState extends State<login> {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
print(data);
|
||||
logDebug(data);
|
||||
String? verificationStatus = data['status'];
|
||||
print(verificationStatus);
|
||||
logDebug(verificationStatus);
|
||||
String? message = data['message'];
|
||||
print(message);
|
||||
logDebug(message);
|
||||
if (verificationStatus == 'success') {
|
||||
final SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
@ -827,7 +829,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, message!);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
@ -842,7 +844,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -907,7 +909,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, message!);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
@ -921,7 +923,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
|
||||
// 🔹 Password validation
|
||||
@ -991,7 +993,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, message);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
@ -1006,7 +1008,7 @@ class _loginState extends State<login> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ import '../../customAppBar/toastHelper.dart';
|
||||
import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class AddPolicyScreen extends StatefulWidget {
|
||||
const AddPolicyScreen({super.key});
|
||||
|
||||
@ -100,7 +102,7 @@ class _AddPolicyScreenState extends State<AddPolicyScreen> {
|
||||
throw Exception('Failed to fetch master data');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error fetching list: $error');
|
||||
logDebug('Error fetching list: $error');
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +133,7 @@ class _AddPolicyScreenState extends State<AddPolicyScreen> {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Submit error: $e');
|
||||
logDebug('Submit error: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => isLoading = false);
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:nhance_app_pwa/models/environment.dart';
|
||||
// import 'package:webview_flutter/webview_flutter.dart';
|
||||
// import 'package:url_launcher/url_launcher.dart';
|
||||
//
|
||||
// class ChatbotWebViewPage extends StatefulWidget {
|
||||
// final String client_branch_id;
|
||||
// final String empCodeString;
|
||||
// final String empName;
|
||||
// final String empPrimaryId;
|
||||
// final String client_id;
|
||||
//
|
||||
// const ChatbotWebViewPage({
|
||||
// Key? key,
|
||||
// required this.client_branch_id,
|
||||
// required this.empCodeString,
|
||||
// required this.empName,
|
||||
// required this.empPrimaryId,
|
||||
// required this.client_id,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<ChatbotWebViewPage> createState() => _ChatbotWebViewPageState();
|
||||
// }
|
||||
//
|
||||
// class _ChatbotWebViewPageState extends State<ChatbotWebViewPage> {
|
||||
// late final WebViewController _controller;
|
||||
// late final String chatbotDomain;
|
||||
// late final String initialUrl;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// final chatbotURL = Environment.chatBotUrl;
|
||||
// print('chatbotURL $chatbotURL');
|
||||
//
|
||||
// initialUrl = Uri.parse(
|
||||
// '$chatbotURL'
|
||||
// '?employee_id=${widget.empPrimaryId}'
|
||||
// '&emp_code=${widget.empCodeString}'
|
||||
// '&origin=mob'
|
||||
// '&name=${Uri.encodeComponent(widget.empName)}'
|
||||
// '&client_id=${widget.client_id}'
|
||||
// '&client_branch_id=${widget.client_branch_id}',
|
||||
// ).toString();
|
||||
//
|
||||
// // Extract the domain for comparison
|
||||
// final uri = Uri.parse(chatbotURL);
|
||||
// chatbotDomain = '${uri.scheme}://${uri.host}';
|
||||
//
|
||||
// _controller = WebViewController()
|
||||
// ..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
// ..setBackgroundColor(Colors.transparent)
|
||||
// ..setNavigationDelegate(
|
||||
// NavigationDelegate(
|
||||
// onNavigationRequest: (NavigationRequest request) {
|
||||
// debugPrint("Navigation requested: ${request.url}");
|
||||
// debugPrint("Is main frame: ${request.isMainFrame}");
|
||||
//
|
||||
// // Allow navigation within the chatbot domain
|
||||
// if (request.url.startsWith(chatbotDomain)) {
|
||||
// return NavigationDecision.navigate;
|
||||
// } else {
|
||||
// // Open external links in browser
|
||||
// _launchInExternalBrowser(Uri.parse(request.url));
|
||||
// return NavigationDecision.prevent;
|
||||
// }
|
||||
// },
|
||||
// onWebResourceError: (error) {
|
||||
// debugPrint("WebView error: ${error.description}");
|
||||
// },
|
||||
// onPageStarted: (String url) {
|
||||
// debugPrint("Page started loading: $url");
|
||||
// },
|
||||
// onPageFinished: (String url) {
|
||||
// debugPrint("Page finished loading: $url");
|
||||
// },
|
||||
// ),
|
||||
// )
|
||||
// ..loadRequest(Uri.parse(initialUrl));
|
||||
// }
|
||||
//
|
||||
// Future<void> _launchInExternalBrowser(Uri url) async {
|
||||
// if (await canLaunchUrl(url)) {
|
||||
// await launchUrl(url, mode: LaunchMode.externalApplication);
|
||||
// } else {
|
||||
// debugPrint("Could not launch $url");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(title: const Text('Ask ILA')),
|
||||
// body: WebViewWidget(controller: _controller),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@ -1,536 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dash_chat_2/dash_chat_2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../customAppBar/customAppBar.dart';
|
||||
import '../../customAppBar/customAppBarChatbot.dart';
|
||||
import '../../customAppBar/responsive.dart';
|
||||
import 'data.dart';
|
||||
|
||||
class chatbot extends StatefulWidget {
|
||||
@override
|
||||
_chatbotState createState() => _chatbotState();
|
||||
}
|
||||
|
||||
class _chatbotState extends State<chatbot> {
|
||||
late ApiService apiService;
|
||||
List<ChatMessage> messages = <ChatMessage>[];
|
||||
Map<String, String> firstApiOptions = {};
|
||||
dynamic isOptionStatus;
|
||||
dynamic requestStatus;
|
||||
dynamic returnMessage;
|
||||
dynamic mobileNo;
|
||||
dynamic policyID;
|
||||
dynamic empCode;
|
||||
dynamic empClientBranchId;
|
||||
dynamic client_id;
|
||||
dynamic navigation_type;
|
||||
dynamic navigation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
apiService = ApiService(context); // Initialize ApiService here
|
||||
checkMessageBackup();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// saveChatMessages();
|
||||
clearChatMessages(); // Save chat messages when closing
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> checkMessageBackup() async {
|
||||
print('checkMessageBackup');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.containsKey('chat_messages') &&
|
||||
prefs.containsKey('chat_messages') != []) {
|
||||
print('loadChatMessages');
|
||||
loadChatMessages(); // Load stored messages
|
||||
} else {
|
||||
print('quickReplyOptions');
|
||||
quickReplyOptions();
|
||||
}
|
||||
}
|
||||
|
||||
// Save chat messages to SharedPreferences
|
||||
Future<void> saveChatMessages() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
List<String> chatMessages =
|
||||
messages.map((message) => jsonEncode(message.toJson())).toList();
|
||||
await prefs.setStringList('chat_messages', chatMessages);
|
||||
}
|
||||
|
||||
// Load chat messages from SharedPreferences
|
||||
Future<void> loadChatMessages() async {
|
||||
print('quickReplyOptions Function');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.containsKey('chat_messages')) {
|
||||
List<String>? chatMessages = prefs.getStringList('chat_messages');
|
||||
print('chatMessages $chatMessages');
|
||||
if (chatMessages != null) {
|
||||
print('chatMessages');
|
||||
setState(() {
|
||||
messages = chatMessages
|
||||
.map((message) => ChatMessage.fromJson(jsonDecode(message)))
|
||||
.toList();
|
||||
isOptionStatus = 1;
|
||||
requestStatus = 'Start';
|
||||
// final storedDataString = prefs.getString('messageBackDetails');
|
||||
// print('Stored Data String: $storedDataString'); // Debugging step
|
||||
|
||||
// if (storedDataString != null) {
|
||||
// try {
|
||||
// // dynamic chatApiData = response['data'];
|
||||
// dynamic chatApiData =
|
||||
// jsonDecode(storedDataString); // Decode the JSON string
|
||||
// print('Decoded Data: $chatApiData'); // Debugging step
|
||||
// isOptionStatus = 1;
|
||||
// requestStatus = 'Start';
|
||||
// // Proceed with your logic if the string is valid JSON
|
||||
// returnMessage = chatApiData['text'];
|
||||
// isOptionStatus = chatApiData['is_option'];
|
||||
// requestStatus = chatApiData['request_for'];
|
||||
// navigation = chatApiData['navigation'];
|
||||
// navigation_type = chatApiData['navigation_type'];
|
||||
// empCode = prefs.getString('empCode');
|
||||
// empClientBranchId = prefs.getString('empClientBranchId');
|
||||
// client_id = prefs.getString('client_id');
|
||||
//
|
||||
// if (chatApiData.containsKey('mobile_no')) {
|
||||
// mobileNo = chatApiData['mobile_no'];
|
||||
// }
|
||||
// if (chatApiData.containsKey('policy_id')) {
|
||||
// policyID = chatApiData['policy_id'];
|
||||
// }
|
||||
// print(
|
||||
// '$returnMessage,$isOptionStatus,$requestStatus,$navigation,$navigation_type,$empCode,$empClientBranchId,$client_id,$mobileNo,$policyID');
|
||||
// } catch (e) {
|
||||
// print('Error decoding JSON: $e'); // Handle JSON parsing errors
|
||||
// }
|
||||
// } else {
|
||||
// print('No data found in SharedPreferences');
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear chat messages
|
||||
Future<void> clearChatMessages() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove('chat_messages');
|
||||
setState(() {
|
||||
messages.clear();
|
||||
});
|
||||
}
|
||||
|
||||
void quickReplyOptions() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empCode = prefs.getString('empCode');
|
||||
empClientBranchId = prefs.getString('empClientBranchId');
|
||||
client_id = prefs.getString('client_id');
|
||||
Map<String, dynamic> chatBotDataApi = {
|
||||
'request_for': 'Start',
|
||||
'is_option': '1',
|
||||
'option': '0',
|
||||
'mobile_no': '',
|
||||
'policy_id': '',
|
||||
'emp_code': empCode,
|
||||
'client_id': client_id,
|
||||
'client_branch_id': empClientBranchId
|
||||
};
|
||||
chatBotDataApi =
|
||||
chatBotDataApi.map((key, value) => MapEntry(key, value.toString()));
|
||||
// final url;
|
||||
// if (is_option != '0') {
|
||||
// url = Uri.parse(
|
||||
// '${Environment.apiUrl}getChatResponse?request_for=$requestFor&is_option=$is_option&option=$option&mobile_no=$mobileNo&policy_id=$policyID');
|
||||
// } else {
|
||||
// url = Uri.parse(
|
||||
// '${Environment.apiUrl}getChatResponse?request_for=$requestFor&is_option=$is_option&text=$returnMessage&value=$option&mobile_no=$mobileNo&policy_id=$policyID');
|
||||
// }
|
||||
final response = await apiService.getBotDetails(chatBotDataApi);
|
||||
print(response);
|
||||
if (response['status'] == 'success') {
|
||||
print('check 2');
|
||||
dynamic data = response['data'];
|
||||
print('data: $data');
|
||||
dynamic optionsData = data['options'];
|
||||
print('optionsData: $optionsData');
|
||||
isOptionStatus = data['is_option'];
|
||||
print('isOptionStatus: $isOptionStatus');
|
||||
requestStatus = data['request_for'];
|
||||
print('requestStatus: $requestStatus');
|
||||
navigation = data['navigation'];
|
||||
navigation_type = data['navigation_type'];
|
||||
|
||||
setState(() {
|
||||
firstApiOptions = Map<String, String>.from(optionsData);
|
||||
print('firstApiOptions: $firstApiOptions');
|
||||
addInitialMessage();
|
||||
});
|
||||
} else {
|
||||
// Handle the error accordingly
|
||||
print('Failed to load quick reply options');
|
||||
}
|
||||
}
|
||||
|
||||
void addInitialMessage() {
|
||||
List<QuickReply> quickReplies = firstApiOptions.entries
|
||||
.map((entry) => QuickReply(title: entry.value, value: entry.key))
|
||||
.toList();
|
||||
|
||||
final ChatMessage initialMessage = ChatMessage(
|
||||
text: 'Welcome to our service. How can we assist you today?',
|
||||
user: user4,
|
||||
createdAt: DateTime.now(),
|
||||
quickReplies: quickReplies,
|
||||
);
|
||||
|
||||
setState(() {
|
||||
messages.add(initialMessage);
|
||||
});
|
||||
}
|
||||
|
||||
void handleQuickReply(QuickReply quickReply) async {
|
||||
print('QuickReply value: ${quickReply.value}');
|
||||
print('QuickReply title: ${quickReply.title}');
|
||||
|
||||
final ChatMessage replyMessage = ChatMessage(
|
||||
user: user,
|
||||
text: quickReply.title,
|
||||
createdAt: DateTime.now(),
|
||||
);
|
||||
|
||||
setState(() {
|
||||
messages.insert(0, replyMessage);
|
||||
});
|
||||
|
||||
await processMessage(quickReply.value ?? quickReply.title);
|
||||
}
|
||||
|
||||
Future<void> processMessage(String messageText) async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove('messageBackDetails');
|
||||
print('Processing message: $messageText');
|
||||
|
||||
// Add a placeholder loading message with an animated loader
|
||||
final ChatMessage loadingMessage = ChatMessage(
|
||||
user: user4,
|
||||
text: 'Loading...',
|
||||
createdAt: DateTime.now(),
|
||||
customProperties: {
|
||||
'isLoading': true,
|
||||
},
|
||||
);
|
||||
|
||||
setState(() {
|
||||
messages.insert(0, loadingMessage);
|
||||
});
|
||||
|
||||
Map<String, dynamic> chatBotDataApi;
|
||||
if (isOptionStatus != '0') {
|
||||
chatBotDataApi = {
|
||||
'request_for': requestStatus,
|
||||
'is_option': isOptionStatus,
|
||||
'option': messageText,
|
||||
'mobile_no': '',
|
||||
'policy_id': '',
|
||||
'emp_code': empCode,
|
||||
'client_id': client_id,
|
||||
'client_branch_id': empClientBranchId
|
||||
};
|
||||
} else {
|
||||
chatBotDataApi = {
|
||||
'request_for': requestStatus,
|
||||
'is_option': isOptionStatus,
|
||||
'text': returnMessage,
|
||||
'value': messageText,
|
||||
'mobile_no': mobileNo,
|
||||
'policy_id': policyID,
|
||||
'emp_code': empCode,
|
||||
'client_id': client_id,
|
||||
'client_branch_id': empClientBranchId
|
||||
};
|
||||
}
|
||||
|
||||
chatBotDataApi =
|
||||
chatBotDataApi.map((key, value) => MapEntry(key, value.toString()));
|
||||
|
||||
print('chatBotDataApi $chatBotDataApi');
|
||||
|
||||
// Simulate API call with a delay of 2 seconds
|
||||
await Future.delayed(Duration(seconds: 2));
|
||||
// final response = await apiService.getBotDetails(requestStatus,
|
||||
// isOptionStatus, messageText, returnMessage, mobileNo, policyID);
|
||||
// Future<Map<String, dynamic>> getBotDetails(String requestFor, is_option,
|
||||
// option, returnMessage, mobileNo, policyID)
|
||||
// final url;
|
||||
// if (is_option != '0') {
|
||||
// url = Uri.parse(
|
||||
// '${Environment.apiUrl}getChatResponse?request_for=$requestFor&is_option=$is_option&option=$option&mobile_no=$mobileNo&policy_id=$policyID');
|
||||
// } else {
|
||||
// url = Uri.parse(
|
||||
// '${Environment.apiUrl}getChatResponse?request_for=$requestFor&is_option=$is_option&text=$returnMessage&value=$option&mobile_no=$mobileNo&policy_id=$policyID');
|
||||
// }
|
||||
|
||||
final response = await apiService.getBotDetails(chatBotDataApi);
|
||||
|
||||
if (response['status'] == 'success') {
|
||||
dynamic chatApiData = response['data'];
|
||||
print('chatApiData : $chatApiData');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('messageBackDetails', jsonEncode(chatApiData));
|
||||
|
||||
dynamic optionsData = chatApiData['options'];
|
||||
returnMessage = chatApiData['text'];
|
||||
isOptionStatus = chatApiData['is_option'];
|
||||
requestStatus = chatApiData['request_for'];
|
||||
navigation = chatApiData['navigation'];
|
||||
navigation_type = chatApiData['navigation_type'];
|
||||
|
||||
if (chatApiData.containsKey('mobile_no')) {
|
||||
mobileNo = chatApiData['mobile_no'];
|
||||
}
|
||||
if (chatApiData.containsKey('policy_id')) {
|
||||
policyID = chatApiData['policy_id'];
|
||||
}
|
||||
|
||||
setState(() {
|
||||
print(returnMessage);
|
||||
// Split and format the returnMessage
|
||||
String formattedMessage = '';
|
||||
if (returnMessage != null) {
|
||||
if (navigation == '1') {
|
||||
if (navigation_type == 'form') {
|
||||
if (returnMessage == 'open_service_form' ||
|
||||
returnMessage == 'open_sales_form' ||
|
||||
returnMessage == 'open_gmc_form' ||
|
||||
returnMessage == 'open_gpa_form') {
|
||||
saveChatMessages();
|
||||
var details = {'claimsDetails': '', 'fromClaimPage': 1};
|
||||
Navigator.pushNamed(context, 'planclaimsform',
|
||||
arguments: details);
|
||||
}
|
||||
} else if (navigation_type == 'view') {
|
||||
print(returnMessage);
|
||||
saveChatMessages();
|
||||
Navigator.pushNamed(context, 'help');
|
||||
} else if (navigation_type == 'dialpad') {
|
||||
print(returnMessage);
|
||||
saveChatMessages();
|
||||
_openDialPad(returnMessage);
|
||||
} else if (navigation_type == 'mail') {
|
||||
print(returnMessage);
|
||||
saveChatMessages();
|
||||
_openEmail(returnMessage);
|
||||
}
|
||||
} else {
|
||||
if (returnMessage.contains('%')) {
|
||||
try {
|
||||
List<String> messageParts = returnMessage
|
||||
.split('%')
|
||||
.map((part) => part.trim())
|
||||
.cast<String>()
|
||||
.toList();
|
||||
formattedMessage = messageParts
|
||||
.asMap()
|
||||
.map(
|
||||
(index, part) => MapEntry(index, '${index + 1}. $part'))
|
||||
.values
|
||||
.join('\n');
|
||||
} catch (e) {
|
||||
print('Error splitting returnMessage: $e');
|
||||
formattedMessage =
|
||||
returnMessage; // Fallback to original message
|
||||
}
|
||||
} else {
|
||||
formattedMessage = returnMessage;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('returnMessage is null');
|
||||
}
|
||||
print('formattedMessage: $formattedMessage');
|
||||
|
||||
firstApiOptions =
|
||||
optionsData != null ? Map<String, String>.from(optionsData) : {};
|
||||
|
||||
final ChatMessage apiResponseMessage = ChatMessage(
|
||||
user: user4,
|
||||
text: formattedMessage ?? '',
|
||||
createdAt: DateTime.now(),
|
||||
customProperties: {
|
||||
'isLoading': false,
|
||||
},
|
||||
quickReplies: firstApiOptions.entries
|
||||
.map((entry) => QuickReply(title: entry.value, value: entry.key))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
// Remove the loading message and add the actual response
|
||||
messages.removeAt(0);
|
||||
messages.insert(0, apiResponseMessage);
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
// Remove the loading message and add an error message
|
||||
messages.removeAt(0);
|
||||
messages.insert(
|
||||
0,
|
||||
ChatMessage(
|
||||
user: user4,
|
||||
text: 'Failed to load data from API',
|
||||
createdAt: DateTime.now(),
|
||||
customProperties: {
|
||||
'isLoading': false,
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _openDialPad(String phoneNumber) async {
|
||||
final Uri dialUri = Uri(
|
||||
scheme: 'tel',
|
||||
path: phoneNumber,
|
||||
);
|
||||
|
||||
print('Trying to open dial pad: $dialUri');
|
||||
|
||||
if (await canLaunchUrl(dialUri)) {
|
||||
await launchUrl(dialUri);
|
||||
} else {
|
||||
print('Could not open dial pad for $phoneNumber');
|
||||
}
|
||||
}
|
||||
|
||||
void _openEmail(String email) async {
|
||||
final Uri emailUri = Uri(
|
||||
scheme: 'mailto',
|
||||
path: email,
|
||||
query: Uri.encodeFull(
|
||||
'subject=Your Subject&body=Hello'), // Add default subject and body
|
||||
);
|
||||
|
||||
try {
|
||||
if (await canLaunchUrl(emailUri)) {
|
||||
await launchUrl(emailUri);
|
||||
} else {
|
||||
print('Could not open email client for $email');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(32.0),
|
||||
bottomRight: Radius.circular(32.0),
|
||||
),
|
||||
child: AppBar(
|
||||
backgroundColor: const Color(0xFFFFFBDE),
|
||||
elevation: 0, // Set background color for AppBar
|
||||
toolbarHeight: kToolbarHeight,
|
||||
titleSpacing: 0.0,
|
||||
automaticallyImplyLeading: false,
|
||||
title: Padding(
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.symmetric(horizontal: 16.0)
|
||||
: EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
// Logo Column
|
||||
Expanded(
|
||||
flex: Responsive.isDesktop(context) ? 3 : 9,
|
||||
child: Row(
|
||||
mainAxisAlignment: Responsive.isDesktop(context)
|
||||
? MainAxisAlignment.spaceEvenly
|
||||
: MainAxisAlignment
|
||||
.start, // Adjust the alignment as needed
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 10, bottom: 10, left: 10, right: 10),
|
||||
width: Responsive.isDesktop(context) ? 150 : 130,
|
||||
height: Responsive.isDesktop(context) ? 150 : 130,
|
||||
child: Image.asset(
|
||||
'assets/nhance_client_logo.png',
|
||||
fit: BoxFit.contain, // Adjust the fit as needed
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// AdaptiveNavBar Column
|
||||
|
||||
Expanded(
|
||||
flex: Responsive.isDesktop(context) ? 11 : 1,
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
final SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
await prefs.remove('messageBackDetails');
|
||||
clearChatMessages();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Icon(
|
||||
Icons
|
||||
.close_outlined, // Replace with your desired icon
|
||||
size: 24.0, // Adjust the icon size
|
||||
color: Colors.black, // Adjust the icon color
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
) // CustomAppBar implementation here
|
||||
),
|
||||
body: DashChat(
|
||||
currentUser: user,
|
||||
onSend: (ChatMessage m) {
|
||||
setState(() {
|
||||
messages.insert(0, m);
|
||||
});
|
||||
processMessage(m.text);
|
||||
},
|
||||
quickReplyOptions: QuickReplyOptions(onTapQuickReply: handleQuickReply),
|
||||
messages: messages,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// late WebViewController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _controller = WebViewController()
|
||||
// ..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
// ..loadRequest(Uri.parse(
|
||||
// 'https://mediafiles.botpress.cloud/0439df41-8f0c-4bfd-ad85-340462deebc0/webchat/bot.html'));
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// backgroundColor: Colors.white,
|
||||
// appBar: CustomAppBar(),
|
||||
// body: WebViewWidget(controller: _controller),
|
||||
// );
|
||||
// }
|
||||
}
|
||||
@ -20,6 +20,8 @@ import 'package:video_player/video_player.dart';
|
||||
import '../service/multi_video_player.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class claimprocess extends StatefulWidget {
|
||||
const claimprocess({Key? key}) : super(key: key);
|
||||
|
||||
@ -79,17 +81,17 @@ import '../service/popup_helper.dart';
|
||||
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getCashlessAndReimbursement();
|
||||
}
|
||||
}
|
||||
@ -99,9 +101,9 @@ import '../service/popup_helper.dart';
|
||||
isLoading = true;
|
||||
});
|
||||
final response = await apiService.getCashlessAndReimbursementToApi();
|
||||
print('check 1 getCashlessAndReimbursement');
|
||||
logDebug('check 1 getCashlessAndReimbursement');
|
||||
if (response['status'] == 'success') {
|
||||
print(response['data']);
|
||||
logDebug(response['data']);
|
||||
setState(() {
|
||||
cashLessClaimsDetails = response['data'][0];
|
||||
cashLessSectionName = cashLessClaimsDetails['content_section'];
|
||||
@ -145,7 +147,7 @@ import '../service/popup_helper.dart';
|
||||
|
||||
|
||||
} else {
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ import '../service/TokenService.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
import 'claimshistory.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class claims extends StatefulWidget {
|
||||
final int initialTab;
|
||||
|
||||
@ -103,24 +105,24 @@ class _claimsState extends State<claims> {
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
dynamic arguments = widget.initialTab;
|
||||
print('arguments $arguments');
|
||||
logDebug('arguments $arguments');
|
||||
if (arguments == 0) {
|
||||
print(arguments);
|
||||
logDebug(arguments);
|
||||
trackClaimsActive = 0;
|
||||
yourPlanActive = 1;
|
||||
isActive = false;
|
||||
} else if (arguments == 2) {
|
||||
print(arguments);
|
||||
logDebug(arguments);
|
||||
trackClaimsActive = 0;
|
||||
yourPlanActive = 1;
|
||||
isActive = false;
|
||||
} else {
|
||||
print("Arguments are null or not in the expected format");
|
||||
logDebug("Arguments are null or not in the expected format");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
@ -128,11 +130,11 @@ class _claimsState extends State<claims> {
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
empName = session.gpaEmpName;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
emailId = session.empEmailCorporate ?? '';
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getActiveAndInactivePolicyDetails();
|
||||
getTrackClaimsList();
|
||||
}
|
||||
@ -183,9 +185,9 @@ class _claimsState extends State<claims> {
|
||||
policyDataIsEmpty = combinedPolicies.isEmpty ? 0 : 1;
|
||||
});
|
||||
|
||||
print("Merged policyList: $policyList");
|
||||
logDebug("Merged policyList: $policyList");
|
||||
} catch (e) {
|
||||
print('Error occurred while fetching policies: $e');
|
||||
logDebug('Error occurred while fetching policies: $e');
|
||||
setState(() {
|
||||
policyDataIsEmpty = 0;
|
||||
});
|
||||
@ -200,14 +202,14 @@ class _claimsState extends State<claims> {
|
||||
if (client_id == null || empCodeString == null) {
|
||||
return;
|
||||
}
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
final response = await apiService.getTrackClaimsList(empPrimaryId!,mobileNo,emailId);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
// if (response['success'] == true) {
|
||||
setState(() {
|
||||
List<dynamic> data = response['ticket_data'];
|
||||
|
||||
print('Data from response: $data');
|
||||
logDebug('Data from response: $data');
|
||||
|
||||
// trackClaimsList = data.where((item) {
|
||||
// // Check if item is a Map and has the departmentId key
|
||||
@ -215,7 +217,7 @@ class _claimsState extends State<claims> {
|
||||
// final departmentId = item['department_id'];
|
||||
//
|
||||
// // Print each departmentId for debugging
|
||||
// print('Item department_id: $departmentId');
|
||||
// logDebug('Item department_id: $departmentId');
|
||||
//
|
||||
// // Ensure departmentId is an int or string, and compare
|
||||
// if (departmentId is int) {
|
||||
@ -228,18 +230,18 @@ class _claimsState extends State<claims> {
|
||||
// return false;
|
||||
// }).toList();
|
||||
|
||||
print('Filtered trackClaimsList: $data');
|
||||
logDebug('Filtered trackClaimsList: $data');
|
||||
reversedClaimsList = List<Map<String, dynamic>>.from(data);
|
||||
print('reversedClaimsList $reversedClaimsList');
|
||||
logDebug('reversedClaimsList $reversedClaimsList');
|
||||
trackClaimsList = reversedClaimsList.reversed.toList();
|
||||
print('trackClaimsList $trackClaimsList');
|
||||
logDebug('trackClaimsList $trackClaimsList');
|
||||
});
|
||||
print(trackClaimsList);
|
||||
logDebug(trackClaimsList);
|
||||
// } else {
|
||||
// setState(() {
|
||||
// trackClaimsIsEmpty = 0;
|
||||
// });
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
}
|
||||
|
||||
@ -259,16 +261,16 @@ class _claimsState extends State<claims> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
||||
// print('arguments');
|
||||
// logDebug('arguments');
|
||||
// dynamic arguments = widget.initialTab;
|
||||
// print('arguments $arguments');
|
||||
// logDebug('arguments $arguments');
|
||||
// if (arguments == 0) {
|
||||
// print(arguments);
|
||||
// logDebug(arguments);
|
||||
// trackClaimsActive = 0;
|
||||
// yourPlanActive = 1;
|
||||
// isActive = false;
|
||||
// } else {
|
||||
// print("Arguments are null or not in the expected format");
|
||||
// logDebug("Arguments are null or not in the expected format");
|
||||
// }
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
@ -307,7 +309,7 @@ class _claimsState extends State<claims> {
|
||||
flex: 12,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
print("CACLAIMS - ${widget.initialTab}");
|
||||
logDebug("CACLAIMS - ${widget.initialTab}");
|
||||
if (widget.initialTab == 2) {
|
||||
context.go('/home');
|
||||
}
|
||||
@ -1136,13 +1138,13 @@ class _claimsState extends State<claims> {
|
||||
// String claimsReplies = item['replies'];
|
||||
// List<dynamic> messageList = item['message_list'];
|
||||
|
||||
print('generateTrackList');
|
||||
print('generateTrackList- $data');
|
||||
print('generateTrackList- $ticketId');
|
||||
print(claimsSubject);
|
||||
print(claimsDate);
|
||||
print(claimStatus);
|
||||
print(claimsDepartmentName);
|
||||
logDebug('generateTrackList');
|
||||
logDebug('generateTrackList- $data');
|
||||
logDebug('generateTrackList- $ticketId');
|
||||
logDebug(claimsSubject);
|
||||
logDebug(claimsDate);
|
||||
logDebug(claimStatus);
|
||||
logDebug(claimsDepartmentName);
|
||||
|
||||
|
||||
|
||||
@ -1185,7 +1187,7 @@ class _claimsState extends State<claims> {
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
print("Tappp - $ticketId");
|
||||
logDebug("Tappp - $ticketId");
|
||||
// Navigator.pushNamed(context, 'claimtracklist', arguments: item);
|
||||
|
||||
showDialog(
|
||||
|
||||
@ -16,6 +16,8 @@ import '../../customAppBar/responsive.dart';
|
||||
import '../../customAppBar/toastHelper.dart';
|
||||
import '../service/TokenService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class ClaimHistoryPopup extends StatefulWidget {
|
||||
final String ticket_id;
|
||||
final String empName;
|
||||
@ -79,13 +81,13 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
||||
apiService = ApiService(context);
|
||||
|
||||
// debug prints kept
|
||||
print("CLAIMHISTORY");
|
||||
print(widget.claimAmount);
|
||||
print(widget.claimNo);
|
||||
print(widget.clientPolicyNo);
|
||||
print(widget.empCode);
|
||||
print(widget.policyType);
|
||||
print(widget.ticket_id);
|
||||
logDebug("CLAIMHISTORY");
|
||||
logDebug(widget.claimAmount);
|
||||
logDebug(widget.claimNo);
|
||||
logDebug(widget.clientPolicyNo);
|
||||
logDebug(widget.empCode);
|
||||
logDebug(widget.policyType);
|
||||
logDebug(widget.ticket_id);
|
||||
getClaimsHistoryDetails();
|
||||
}
|
||||
|
||||
@ -146,7 +148,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
||||
setState(() => isSubmitting = true); // 🔥 start loader
|
||||
|
||||
try {
|
||||
print('enter');
|
||||
logDebug('enter');
|
||||
_token = await TokenService.getPostToken();
|
||||
|
||||
// STEP 1: Must select at least one document type
|
||||
@ -237,9 +239,9 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
||||
request.fields['claim_doc_names'] = jsonEncode(labels);
|
||||
|
||||
// Debug
|
||||
print(
|
||||
logDebug(
|
||||
"Files uploaded: ${fileService.files.map((e) => e.file.name).toList()}");
|
||||
print("Labels: $labels");
|
||||
logDebug("Labels: $labels");
|
||||
|
||||
// STEP 7: Send the request
|
||||
final response = await request.send();
|
||||
@ -300,8 +302,8 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
||||
})
|
||||
.toList();
|
||||
|
||||
print(isActionFreeze);
|
||||
print('requiredDocsList $requiredDocsList');
|
||||
logDebug(isActionFreeze);
|
||||
logDebug('requiredDocsList $requiredDocsList');
|
||||
|
||||
for (var d in requiredDocsList) {
|
||||
_assignedFiles[d['document_name']] = null;
|
||||
@ -309,11 +311,11 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
||||
});
|
||||
} else {
|
||||
setState(() => isLoading = false);
|
||||
print('Request failed with status: ${response['code']}');
|
||||
logDebug('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() => isLoading = false);
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +324,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
||||
try {
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} catch (e) {
|
||||
print('Could not launch URL: $e');
|
||||
logDebug('Could not launch URL: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,194 +0,0 @@
|
||||
import 'package:dash_chat_2/dash_chat_2.dart';
|
||||
|
||||
// String profileImage =
|
||||
// 'https://e7.pngegg.com/pngimages/811/700/png-clipart-chatbot-internet-bot-business-natural-language-processing-facebook-messenger-business-people-logo-thumbnail.png';
|
||||
String profileImage =
|
||||
'https://app.nhanceindia.in/zenith/public/assets/images/chatbot.png';
|
||||
|
||||
// We have all the possibilities for users
|
||||
ChatUser user = ChatUser(id: '0');
|
||||
ChatUser user1 = ChatUser(id: '1');
|
||||
ChatUser user2 = ChatUser(id: '2', firstName: 'Niki Lauda');
|
||||
ChatUser user3 = ChatUser(id: '3', lastName: 'Clark');
|
||||
ChatUser user4 = ChatUser(id: '4', profileImage: profileImage);
|
||||
ChatUser user5 = ChatUser(id: '5', firstName: 'Charles', lastName: 'Leclerc');
|
||||
ChatUser user6 =
|
||||
ChatUser(id: '6', firstName: 'Max', profileImage: profileImage);
|
||||
ChatUser user7 =
|
||||
ChatUser(id: '7', lastName: 'Toto', profileImage: profileImage);
|
||||
ChatUser user8 = ChatUser(
|
||||
id: '8', firstName: 'Toto', lastName: 'Clark', profileImage: profileImage);
|
||||
|
||||
List<ChatMessage> allUsersSample = <ChatMessage>[
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user1,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user2,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user3,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user4,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user5,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user6,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user7,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Test',
|
||||
user: user8,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
];
|
||||
|
||||
List<ChatMessage> basicSample = <ChatMessage>[
|
||||
ChatMessage(
|
||||
text: 'google.com hello you @Marc is it &you okay?',
|
||||
user: user2,
|
||||
createdAt: DateTime(2021, 01, 31, 16, 45),
|
||||
mentions: [
|
||||
Mention(title: '@Marc'),
|
||||
Mention(title: '&you'),
|
||||
],
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'google.com',
|
||||
user: user2,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: "Oh what's up guys?",
|
||||
user: user2,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'How you doin?',
|
||||
user: user8,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 34),
|
||||
),
|
||||
ChatMessage(
|
||||
isMarkdown: true,
|
||||
text:
|
||||
"```dart\nvoid main() {\n print('Hello World');\n}\n```\nThe above code will print \"Hello World\" to the console when run.\n\nHere's a breakdown of the code:\n\n* The `main()` function is the entry point of the program. It's where execution begins.\n* `print('Hello World')` prints \"Hello World\" to the console. The `print()` function is a built-in function in Dart that outputs data to the console.\n\nYou can run this code by creating a new Dart file (e.g., `hello_world.dart`) and pasting the code into it. Then, open a terminal window, navigate to the directory where the file is saved, and run the following command:\n\n```\ndart hello_world.dart\n```\n\nThis will compile and run the Dart program, and you should see \"Hello World\" printed to the console. Know more: www.google.com ",
|
||||
user: user2,
|
||||
createdAt: DateTime(2021, 01, 30, 15, 50),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Hey!',
|
||||
user: user,
|
||||
createdAt: DateTime(2021, 01, 30, 15, 50),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Hey!',
|
||||
user: user,
|
||||
createdAt: DateTime(2021, 01, 28, 15, 50),
|
||||
),
|
||||
ChatMessage(
|
||||
text: 'Hey!',
|
||||
user: user,
|
||||
createdAt: DateTime(2021, 01, 28, 15, 50),
|
||||
),
|
||||
];
|
||||
|
||||
List<ChatMessage> media = <ChatMessage>[
|
||||
ChatMessage(
|
||||
medias: <ChatMedia>[
|
||||
ChatMedia(
|
||||
url:
|
||||
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
|
||||
type: MediaType.image,
|
||||
fileName: 'image.png',
|
||||
isUploading: true,
|
||||
),
|
||||
ChatMedia(
|
||||
url:
|
||||
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
|
||||
type: MediaType.image,
|
||||
fileName: 'image.png',
|
||||
),
|
||||
ChatMedia(
|
||||
url:
|
||||
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/chat_medias%2F2GFlPkj94hKCqonpEdf1%2F20210526_162318.mp4?alt=media&token=01b814b9-d93a-4bf1-8be1-cf9a49058f97',
|
||||
type: MediaType.video,
|
||||
fileName: 'video.mp4',
|
||||
isUploading: false,
|
||||
),
|
||||
ChatMedia(
|
||||
url:
|
||||
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/chat_medias%2F2GFlPkj94hKCqonpEdf1%2F20210526_162318.mp4?alt=media&token=01b814b9-d93a-4bf1-8be1-cf9a49058f97',
|
||||
type: MediaType.video,
|
||||
fileName: 'video.mp4',
|
||||
isUploading: false,
|
||||
),
|
||||
ChatMedia(
|
||||
url:
|
||||
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
|
||||
type: MediaType.file,
|
||||
fileName: 'image.png',
|
||||
),
|
||||
ChatMedia(
|
||||
url:
|
||||
'https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/memes%2F155512641_3864499247004975_4028017188079714246_n.jpg?alt=media&token=0b335455-93ed-4529-9055-9a2c741e0189',
|
||||
type: MediaType.image,
|
||||
fileName: 'image.png',
|
||||
)
|
||||
],
|
||||
user: user3,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 34),
|
||||
),
|
||||
];
|
||||
|
||||
List<ChatMessage> quickReplies = <ChatMessage>[
|
||||
ChatMessage(
|
||||
text: 'How you doin?',
|
||||
user: user3,
|
||||
createdAt: DateTime.now(),
|
||||
quickReplies: <QuickReply>[
|
||||
QuickReply(title: 'Great!'),
|
||||
QuickReply(title: 'Awesome'),
|
||||
QuickReply(title: 'Hello'),
|
||||
QuickReply(title: 'Hava a nice day'),
|
||||
QuickReply(title: 'Hello @Niki, you should check #channel'),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
List<ChatMessage> mentionSample = <ChatMessage>[
|
||||
ChatMessage(
|
||||
text: 'Hello @Niki, you should check #channel',
|
||||
user: user2,
|
||||
createdAt: DateTime(2021, 01, 31, 16, 45),
|
||||
mentions: [
|
||||
Mention(title: '@Niki', customProperties: {'userId': user5.id}),
|
||||
Mention(title: '#channel'),
|
||||
],
|
||||
),
|
||||
ChatMessage(
|
||||
text: "Oh what's up guys?",
|
||||
user: user5,
|
||||
createdAt: DateTime(2021, 01, 30, 16, 45),
|
||||
),
|
||||
];
|
||||
|
||||
List<ChatMessage> d = <ChatMessage>[];
|
||||
@ -16,6 +16,8 @@ import 'package:flutter_html/flutter_html.dart';
|
||||
|
||||
import '../service/video_player_widget.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class faqs extends StatefulWidget {
|
||||
const faqs({super.key});
|
||||
|
||||
@ -79,20 +81,20 @@ class _faqsState extends State<faqs> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
empMobileNo = session.mobileNo ?? '';
|
||||
empEmailID = session.empEmailCorporate ?? '';
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getFAQsDetails();
|
||||
}
|
||||
}
|
||||
@ -132,7 +134,7 @@ class _faqsState extends State<faqs> {
|
||||
ToastHelper.showErrorToast(context, 'No FAQs found');
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('FAQ Error: $e');
|
||||
logDebug('FAQ Error: $e');
|
||||
ToastHelper.showErrorToast(context, 'Failed to load FAQs');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
||||
@ -16,6 +16,8 @@ import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class generalExclusionsDeductibles extends StatefulWidget {
|
||||
const generalExclusionsDeductibles({Key? key}) : super(key: key);
|
||||
|
||||
@ -70,17 +72,17 @@ class _generalExclusionsDeductiblesState
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getCashlessAndReimbursement();
|
||||
}
|
||||
}
|
||||
@ -154,7 +156,7 @@ class _generalExclusionsDeductiblesState
|
||||
isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
debugPrint('API ERROR: $e');
|
||||
logDebug('API ERROR: $e');
|
||||
setState(() => isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
import '../service/data_manager.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class help extends StatefulWidget {
|
||||
const help({Key? key}) : super(key: key);
|
||||
@ -84,7 +85,7 @@ class _helpState extends State<help> {
|
||||
super.initState();
|
||||
apiService = ApiService(context); // Initialize ApiService here
|
||||
_loadToken();
|
||||
print('initState');
|
||||
logDebug('initState');
|
||||
// getTicketList();
|
||||
}
|
||||
|
||||
@ -104,18 +105,18 @@ class _helpState extends State<help> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
print('didChangeDependencies');
|
||||
logDebug('didChangeDependencies');
|
||||
|
||||
// if (!_isArgsHandled) {
|
||||
final args =
|
||||
ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>?;
|
||||
print('args - $args');
|
||||
logDebug('args - $args');
|
||||
if (args != null && args.containsKey('ticketTabSelected')) {
|
||||
print('args1');
|
||||
logDebug('args1');
|
||||
setState(() {
|
||||
tickets = args['ticketTabSelected']; // e.g. 0 from TicketForm
|
||||
|
||||
print('args2- $tickets');
|
||||
logDebug('args2- $tickets');
|
||||
closedTrackActive = 1;
|
||||
allClaimsActive = 1;
|
||||
tickets = 0;
|
||||
@ -130,48 +131,48 @@ class _helpState extends State<help> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
empMobileNo = session.mobileNo ?? '';
|
||||
empEmailID = session.empEmailCorporate ?? '';
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getSelfEmployeeProfile();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getSelfEmployeeProfile() async {
|
||||
// print(getSelfEmployeeProfile);
|
||||
// logDebug(getSelfEmployeeProfile);
|
||||
// if (client_id == null || empCodeString == null) {
|
||||
// return;
|
||||
// }
|
||||
// setState(() {
|
||||
// isLoading = true;
|
||||
// });
|
||||
// print('check 1');
|
||||
// logDebug('check 1');
|
||||
// final response = await apiService.getSelfEmployeeProfileDetails(
|
||||
// client_id!, empCodeString!, client_branch_id!);
|
||||
// print('check 1');
|
||||
// logDebug('check 1');
|
||||
// if (response['status'] == 'success') {
|
||||
// print(response);
|
||||
// logDebug(response);
|
||||
setState(() {
|
||||
// accountManagerDetails = response['AccountManagerDetails'];
|
||||
final accountManager = dataManager.accountManagerDetails;
|
||||
accountManagerDetails = accountManager;
|
||||
print('accountManagerDetails');
|
||||
print(accountManagerDetails);
|
||||
logDebug('accountManagerDetails');
|
||||
logDebug(accountManagerDetails);
|
||||
accountManagerEmail = accountManagerDetails['email'];
|
||||
print(accountManagerEmail);
|
||||
logDebug(accountManagerEmail);
|
||||
accountManagerMobileNo = accountManagerDetails['mobile'];
|
||||
print(accountManagerMobileNo);
|
||||
logDebug(accountManagerMobileNo);
|
||||
});
|
||||
// setState(() {
|
||||
// isLoading = false;
|
||||
@ -180,7 +181,7 @@ class _helpState extends State<help> {
|
||||
// setState(() {
|
||||
// isLoading = false;
|
||||
// });
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
}
|
||||
|
||||
@ -191,10 +192,10 @@ class _helpState extends State<help> {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
final response = await apiService.getTrackClaimsList(
|
||||
empPrimaryId!, empMobileNo, empEmailID);
|
||||
print('check 2');
|
||||
logDebug('check 2');
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
@ -222,7 +223,7 @@ class _helpState extends State<help> {
|
||||
// });
|
||||
// } else {
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
}
|
||||
|
||||
@ -235,22 +236,22 @@ class _helpState extends State<help> {
|
||||
});
|
||||
|
||||
try {
|
||||
print('check getTicketList 1');
|
||||
logDebug('check getTicketList 1');
|
||||
final response = await apiService.getTicketListByMobile(empMobileNo!);
|
||||
print('check getTicketList 2');
|
||||
logDebug('check getTicketList 2');
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
// if (response['success'] == true && response['data'] is List) {
|
||||
setState(() {
|
||||
ticketList = response['data'].toList();
|
||||
print("TC1 - $ticketList");
|
||||
logDebug("TC1 - $ticketList");
|
||||
reversedTicketList = List<Map<String, dynamic>>.from(ticketList);
|
||||
reversedTicketList = List<Map<String, dynamic>>.from(ticketList);
|
||||
print("TC2 - $ticketList");
|
||||
logDebug("TC2 - $ticketList");
|
||||
// ticketList = reversedTicketList.reversed.toList();
|
||||
ticketList = reversedTicketList.toList();
|
||||
print("TC3 - $ticketList");
|
||||
logDebug("TC3 - $ticketList");
|
||||
});
|
||||
// }
|
||||
// else if (response['status'] == "error" &&
|
||||
@ -266,11 +267,11 @@ class _helpState extends State<help> {
|
||||
// isLoading = false;
|
||||
// });
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
} catch (e) {
|
||||
// ToastHelper.showErrorToast(context, 'Failed to load data');
|
||||
print('Error in getTicketList: $e');
|
||||
logDebug('Error in getTicketList: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -1130,11 +1131,11 @@ class _helpState extends State<help> {
|
||||
// String claimsReplies = item['replies'];
|
||||
// List<dynamic> messageList = item['message_list'];
|
||||
|
||||
print('generateTrackList');
|
||||
print(claimsSubject);
|
||||
print(claimsDate);
|
||||
print(claimStatus);
|
||||
print(claimsDepartmentName);
|
||||
logDebug('generateTrackList');
|
||||
logDebug(claimsSubject);
|
||||
logDebug(claimsDate);
|
||||
logDebug(claimStatus);
|
||||
logDebug(claimsDepartmentName);
|
||||
|
||||
final Map<String, Color> statusColors = {
|
||||
'Received': Colors.amber,
|
||||
@ -1563,12 +1564,12 @@ class _helpState extends State<help> {
|
||||
String claimsDepartmentName = item['ticket_type'] ?? '';
|
||||
// String claimsReplies = item['replies'];
|
||||
// List<dynamic> messageList = item['message_list'];
|
||||
print("item - $item");
|
||||
print('generateTrackList');
|
||||
print(claimsSubject);
|
||||
print(claimsDate);
|
||||
print(claimStatus);
|
||||
print(claimsDepartmentName);
|
||||
logDebug("item - $item");
|
||||
logDebug('generateTrackList');
|
||||
logDebug(claimsSubject);
|
||||
logDebug(claimsDate);
|
||||
logDebug(claimStatus);
|
||||
logDebug(claimsDepartmentName);
|
||||
|
||||
final Map<String, Color> statusColors = {
|
||||
'Received': Colors.amber,
|
||||
@ -1599,7 +1600,7 @@ class _helpState extends State<help> {
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
print("Navigating with thz_id: ${item['thz_id']}");
|
||||
logDebug("Navigating with thz_id: ${item['thz_id']}");
|
||||
|
||||
context.go('/tickettracklist', extra: item['thz_id']);
|
||||
|
||||
|
||||
@ -30,8 +30,6 @@ import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
import '../service/data_manager.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
import 'botman_chat.dart';
|
||||
import 'chatbot.dart';
|
||||
// import 'dart:js' as js;
|
||||
// import 'dart:html' as html;
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
@ -45,6 +43,8 @@ import '/../pages/helpers/mobile_helpers.dart'
|
||||
import 'package:webview_flutter_android/webview_flutter_android.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
const Home({Key? key}) : super(key: key);
|
||||
|
||||
@ -142,9 +142,9 @@ class _HomeState extends State<Home> {
|
||||
});
|
||||
});
|
||||
|
||||
print('starts');
|
||||
print(advertisementImages);
|
||||
print('Ends');
|
||||
logDebug('starts');
|
||||
logDebug(advertisementImages);
|
||||
logDebug('Ends');
|
||||
|
||||
// // 🔹 Load policies (Active ones)
|
||||
// activePoliciesDetails = dataManager.loadPolicies(
|
||||
@ -155,8 +155,8 @@ class _HomeState extends State<Home> {
|
||||
// mobileNo: session.mobileNo ?? '',
|
||||
// );
|
||||
//
|
||||
// print('activePoliciesDetails');
|
||||
// print(activePoliciesDetails);
|
||||
// logDebug('activePoliciesDetails');
|
||||
// logDebug(activePoliciesDetails);
|
||||
|
||||
// if (kIsWeb) {
|
||||
// openBotmanChat();
|
||||
@ -170,7 +170,7 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
|
||||
// void openBotmanChat() {
|
||||
// print('openBotmanChat');
|
||||
// logDebug('openBotmanChat');
|
||||
// if (kIsWeb) {
|
||||
// js.context
|
||||
// .callMethod('openBotmanChat'); // Correct way to call JS function
|
||||
@ -222,8 +222,8 @@ class _HomeState extends State<Home> {
|
||||
|
||||
Future<void> checkEnrollToken() async {
|
||||
final preToken = TokenService.getPreToken();
|
||||
print('preToken');
|
||||
print(preToken);
|
||||
logDebug('preToken');
|
||||
logDebug(preToken);
|
||||
setState(() {
|
||||
isTokenAvailable = preToken != null;
|
||||
});
|
||||
@ -238,20 +238,20 @@ class _HomeState extends State<Home> {
|
||||
// }
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
mobileNo = session.mobileNo ?? '';
|
||||
client_branch_id = session.empClientBranchId ?? null;
|
||||
empCodeString = session.empCodeString?? null;
|
||||
empName = session.gpaEmpName?? null;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId?? null;
|
||||
client_id = session.client_id?? null;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
emailId = session.empEmailCorporate?? null;
|
||||
// getAdvertisementSliderImage();
|
||||
getActiveAndInactivePolicyDetails('Active');
|
||||
@ -259,17 +259,17 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
|
||||
Future<void> getActiveAndInactivePolicyDetails(String status) async {
|
||||
print(getActiveAndInactivePolicyDetails);
|
||||
logDebug(getActiveAndInactivePolicyDetails);
|
||||
// if (client_id == null || empCodeString == null) {
|
||||
// return;
|
||||
// }
|
||||
setState(() {
|
||||
isLoadingGif = true;
|
||||
});
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
final response = await apiService.getActiveAndInactivePolicyDetails(
|
||||
client_id, empCodeString, status, client_branch_id, mobileNo,emailId);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
if (response['status'] == 'success') {
|
||||
setState(() {
|
||||
isLoadingGif = false;
|
||||
@ -277,11 +277,11 @@ class _HomeState extends State<Home> {
|
||||
emp_name = response['emp_name'];
|
||||
policyList = List.from(response['data'] ?? []);
|
||||
retailPolicyDetails = List.from(response['retail_policy_data'] ?? []);
|
||||
print('policyList $policyList');
|
||||
logDebug('policyList $policyList');
|
||||
pre_policy_count = response['pre_policy_count'] ?? '';
|
||||
final empNotEnrolledCount = response['emp_not_enrolled_count'] ?? '';
|
||||
final wellnessStatus = response['wellness_data']['status'] ?? 'failed';
|
||||
print('wellnessStatus $wellnessStatus');
|
||||
logDebug('wellnessStatus $wellnessStatus');
|
||||
if (wellnessStatus == 'success') {
|
||||
wellnessURL = response['wellness_data']['data'];
|
||||
}
|
||||
@ -295,7 +295,7 @@ class _HomeState extends State<Home> {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
bool? cancelFlag = prefs.getBool('cancel_flag');
|
||||
|
||||
print('cancelFlag $cancelFlag');
|
||||
logDebug('cancelFlag $cancelFlag');
|
||||
|
||||
// Show popup only when flag is NOT true
|
||||
if (cancelFlag != true) {
|
||||
@ -303,29 +303,29 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
}
|
||||
|
||||
print(policyList);
|
||||
logDebug(policyList);
|
||||
} else {
|
||||
setState(() {
|
||||
policyDataIsEmpty = 0;
|
||||
isLoadingGif = false;
|
||||
});
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getAdvertisementSliderImage() async {
|
||||
final response = await apiService.getAdvertisementImageToApi(session.client_id);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
if (response['status'] == 'success') {
|
||||
setState(() {
|
||||
advertisementImages = List<String>.from(response['data']);
|
||||
print('advertisementImages');
|
||||
print(advertisementImages);
|
||||
logDebug('advertisementImages');
|
||||
logDebug(advertisementImages);
|
||||
isLoading = false;
|
||||
});
|
||||
// print(policyList);
|
||||
// logDebug(policyList);
|
||||
} else {
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
@ -773,7 +773,7 @@ class _HomeState extends State<Home> {
|
||||
|
||||
/// Called whenever the page in the center of the viewport changes.
|
||||
onPageChanged: (value) {
|
||||
print(
|
||||
logDebug(
|
||||
'Page changed: $value');
|
||||
},
|
||||
|
||||
@ -1082,12 +1082,12 @@ class _HomeState extends State<Home> {
|
||||
// final client_id = prefs.getString('client_id') ?? '';
|
||||
// final gpaEmpName = prefs.getString('gpaEmpName') ?? '';
|
||||
//
|
||||
// print('param check from home');
|
||||
// print(gpaEmpName);
|
||||
// print(empCodeString);
|
||||
// print(empClientBranchId);
|
||||
// print(client_id);
|
||||
// print(empPrimaryId);
|
||||
// logDebug('param check from home');
|
||||
// logDebug(gpaEmpName);
|
||||
// logDebug(empCodeString);
|
||||
// logDebug(empClientBranchId);
|
||||
// logDebug(client_id);
|
||||
// logDebug(empPrimaryId);
|
||||
//
|
||||
// Navigator.of(context).push(
|
||||
// MaterialPageRoute(
|
||||
@ -1256,8 +1256,8 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
|
||||
// List<Widget> generateCards(List<dynamic> data) {
|
||||
// print('generateCards');
|
||||
// print(data);
|
||||
// logDebug('generateCards');
|
||||
// logDebug(data);
|
||||
// return [
|
||||
// GridView.builder(
|
||||
// shrinkWrap: true,
|
||||
@ -1282,7 +1282,7 @@ class _HomeState extends State<Home> {
|
||||
// // Main logic
|
||||
// double finalValue = (settled == 0) ? siValue : (siValue - settled);
|
||||
//
|
||||
// print("Final Value: $finalValue");
|
||||
// logDebug("Final Value: $finalValue");
|
||||
// String policyEndDate = item['policy_end_date'];
|
||||
// List<dynamic> employeePolicy = item['EmployeePolicy'];
|
||||
// String memberNames = getMemberNames(employeePolicy);
|
||||
@ -1792,7 +1792,7 @@ class _HomeState extends State<Home> {
|
||||
|
||||
String policyEndDate = item['policy_end_date'];
|
||||
List<dynamic> employeePolicy = item['EmployeePolicy'];
|
||||
print('employeePolicy $employeePolicy');
|
||||
logDebug('employeePolicy $employeePolicy');
|
||||
String memberNames = formatMemberNames(employeePolicy);
|
||||
|
||||
DateTime parsedDate = DateFormat('dd-MMM-yyyy').parse(policyEndDate);
|
||||
@ -1830,7 +1830,7 @@ class _HomeState extends State<Home> {
|
||||
cards.add(
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
print("Retail policy clicked: ${retail['policy_no']}");
|
||||
logDebug("Retail policy clicked: ${retail['policy_no']}");
|
||||
},
|
||||
child: _buildRetailPolicyCard(retail),
|
||||
),
|
||||
@ -1858,7 +1858,7 @@ class _HomeState extends State<Home> {
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// TODO: navigate to retail policy details page
|
||||
print("Retail policy clicked: ${retail['policy_no']}");
|
||||
logDebug("Retail policy clicked: ${retail['policy_no']}");
|
||||
},
|
||||
child: _buildRetailPolicyCard(retail),
|
||||
),
|
||||
|
||||
@ -28,6 +28,8 @@ import 'package:pdf/widgets.dart' as pw;
|
||||
import 'package:printing/printing.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class planclaimsform extends StatefulWidget {
|
||||
final Map<String, dynamic>? details;
|
||||
const planclaimsform({Key? key, this.details}) : super(key: key);
|
||||
@ -197,36 +199,36 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
print('didChangeDependencies');
|
||||
logDebug('didChangeDependencies');
|
||||
super.didChangeDependencies();
|
||||
// dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
||||
dynamic arguments = widget.details;
|
||||
if (arguments != null && arguments is Map<String, dynamic>) {
|
||||
argumentsData = arguments;
|
||||
claimsDetails = argumentsData['claimsDetails'];
|
||||
print('claimsDetails $claimsDetails');
|
||||
logDebug('claimsDetails $claimsDetails');
|
||||
|
||||
if (argumentsData.containsKey('fromClaimPage')) {
|
||||
fromClaimsPage = argumentsData['fromClaimPage'];
|
||||
print('fromClaimsPage $fromClaimsPage');
|
||||
logDebug('fromClaimsPage $fromClaimsPage');
|
||||
}
|
||||
if (fromClaimsPage == 0) {
|
||||
setState(() {
|
||||
claimSubject = claimsDetails['claim_subject'];
|
||||
print('claimSubject $claimSubject');
|
||||
logDebug('claimSubject $claimSubject');
|
||||
claimsDepartmentId = claimsDetails['ticket_type_id'];
|
||||
rawPolicyStartDate = claimsDetails['policy_start_date'];
|
||||
print('rawPolicyStartDate $rawPolicyStartDate');
|
||||
logDebug('rawPolicyStartDate $rawPolicyStartDate');
|
||||
rawPolicyEndDate = claimsDetails['claims_grace_date'];
|
||||
print('rawpolicyEndDate $rawPolicyEndDate');
|
||||
print('claimsDepartmentId $claimsDepartmentId');
|
||||
logDebug('rawpolicyEndDate $rawPolicyEndDate');
|
||||
logDebug('claimsDepartmentId $claimsDepartmentId');
|
||||
claimsPolicyNo = claimsDetails['policy_no'];
|
||||
client_policy_id = claimsDetails['client_policy_id'];
|
||||
print('Current Client ID : ${client_policy_id}');
|
||||
logDebug('Current Client ID : ${client_policy_id}');
|
||||
});
|
||||
|
||||
// employeePolicyList = claimsDetails['EmployeePolicy'];
|
||||
// print('employeePolicyList : $employeePolicyList');
|
||||
// logDebug('employeePolicyList : $employeePolicyList');
|
||||
List<dynamic> empList = claimsDetails['EmployeePolicy'];
|
||||
setState(() {
|
||||
subjectController.text = claimSubject;
|
||||
@ -236,7 +238,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
'name': memberList['name'],
|
||||
};
|
||||
}).toList();
|
||||
print('employeePolicyList : $employeePolicyList');
|
||||
logDebug('employeePolicyList : $employeePolicyList');
|
||||
});
|
||||
|
||||
// if (claimsDetails['ticket_type_id'] == 3 ||
|
||||
@ -245,7 +247,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
// } else {
|
||||
// String policyType = claimsDetails['policy_type'];
|
||||
// policyTypeCondition = policyType.split('-')[0].trim();
|
||||
// print('Output : $policyTypeCondition'); // Output: GMC
|
||||
// logDebug('Output : $policyTypeCondition'); // Output: GMC
|
||||
// }
|
||||
}
|
||||
}
|
||||
@ -253,9 +255,9 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
void
|
||||
setInitialServiceId(departmentListDetails) {
|
||||
print('departmentList : $departmentListDetails');
|
||||
logDebug('departmentList : $departmentListDetails');
|
||||
for (var department in departmentListDetails) {
|
||||
print(department['id'] == claimsDepartmentId);
|
||||
logDebug(department['id'] == claimsDepartmentId);
|
||||
if (department['id'] == claimsDepartmentId) {
|
||||
setState(() {
|
||||
serviceId = department['id'];
|
||||
@ -266,20 +268,20 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
mobileNo = session.mobileNo;
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
emailId = session.empEmailCorporate;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getActiveAndInactivePolicyDetails();
|
||||
fetchDepartmentList();
|
||||
getSelfEmployeeProfile();
|
||||
@ -319,13 +321,13 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
policyDataIsEmpty = combinedPolicies.isEmpty ? 0 : 1;
|
||||
});
|
||||
if (fromClaimsPage == 0) {
|
||||
print('fromClaimsPage == 0');
|
||||
logDebug('fromClaimsPage == 0');
|
||||
fetchPoliciesBasedOnService(claimsDepartmentId);
|
||||
}
|
||||
|
||||
print("Merged policyList: $policyList");
|
||||
logDebug("Merged policyList: $policyList");
|
||||
} catch (e) {
|
||||
print('Error occurred while fetching policies: $e');
|
||||
logDebug('Error occurred while fetching policies: $e');
|
||||
setState(() {
|
||||
policyDataIsEmpty = 0;
|
||||
});
|
||||
@ -333,28 +335,28 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
}
|
||||
|
||||
Future<void> getSelfEmployeeProfile() async {
|
||||
print(getSelfEmployeeProfile);
|
||||
logDebug(getSelfEmployeeProfile);
|
||||
if (client_id == null || empCodeString == null) {
|
||||
return;
|
||||
}
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
final response = await apiService.getSelfEmployeeProfileDetails(
|
||||
client_id!, empCodeString!, client_branch_id!);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
if (response['status'] == 'success') {
|
||||
if (response.containsKey('data')) {
|
||||
setState(() {
|
||||
selfDetails = response['data'];
|
||||
print(selfDetails);
|
||||
logDebug(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']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
} else {
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,9 +366,9 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
});
|
||||
try {
|
||||
final response = await apiService.fetchDepartmentList(client_id!, empCodeString!);
|
||||
print(response);
|
||||
logDebug(response);
|
||||
if (response['ticket_type'] != null) {
|
||||
print(response['ticket_type']);
|
||||
logDebug(response['ticket_type']);
|
||||
List<dynamic> departments = response['ticket_type'];
|
||||
setState(() {
|
||||
departmentList = departments.map((department) {
|
||||
@ -397,7 +399,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
throw Exception('Failed to fetch department list');
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error fetching department list: $error');
|
||||
logDebug('Error fetching department list: $error');
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,7 +434,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
void fetchPoliciesBasedOnService(int? serviceId) {
|
||||
if (policyList.isEmpty) {
|
||||
print('Policy list is empty. Ensure data is fetched before filtering.');
|
||||
logDebug('Policy list is empty. Ensure data is fetched before filtering.');
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
@ -440,15 +442,15 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
policyTypeCondition = null;
|
||||
// client_policy_id = null;
|
||||
});
|
||||
print('1111 serviceId : $serviceId');
|
||||
logDebug('1111 serviceId : $serviceId');
|
||||
if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4 || serviceId == 72) {
|
||||
print('2222');
|
||||
logDebug('2222');
|
||||
// Filter policies based on the ticket_type_id
|
||||
List<Map<String, dynamic>> filteredPolicies = policyList.where((policy) {
|
||||
return policy['ticket_type_id'] == serviceId;
|
||||
}).toList();
|
||||
|
||||
print('Filtered matching policies: $filteredPolicies');
|
||||
logDebug('Filtered matching policies: $filteredPolicies');
|
||||
// if (filteredPolicies[0]['ticket_type_id'] == 3 ||
|
||||
// filteredPolicies[0]['ticket_type_id'] == 4) {
|
||||
setState(() {
|
||||
@ -469,7 +471,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
};
|
||||
}).toList();
|
||||
|
||||
print('policyNumberList : $policyNumberList');
|
||||
logDebug('policyNumberList : $policyNumberList');
|
||||
|
||||
|
||||
if (fromClaimsPage == 0) {
|
||||
@ -496,7 +498,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
policyTypeCondition = filteredPolicies[0]['ticket_type_id'];
|
||||
// client_policy_id = filteredPolicies[0]['client_policy_id'];
|
||||
print('Output : $policyTypeCondition'); // Output: GMC
|
||||
logDebug('Output : $policyTypeCondition'); // Output: GMC
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
@ -518,10 +520,10 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
// };
|
||||
// }).toList();
|
||||
//
|
||||
// print('policyNumberList : $policyNumberList');
|
||||
// logDebug('policyNumberList : $policyNumberList');
|
||||
//
|
||||
// policyTypeCondition = serviceId;
|
||||
// print('Output : $policyTypeCondition');
|
||||
// logDebug('Output : $policyTypeCondition');
|
||||
// });
|
||||
// } else {
|
||||
// setState(() {
|
||||
@ -532,19 +534,19 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
void fetchMemberBasedOnPolicy(selectedPolicyNo) {
|
||||
if (policyList.isEmpty) {
|
||||
print('Policy list is empty. Ensure data is fetched before filtering.');
|
||||
logDebug('Policy list is empty. Ensure data is fetched before filtering.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4) {
|
||||
// Filter policies based on the ticket_type_id
|
||||
print('policyNumberId : $policyNumberId');
|
||||
logDebug('policyNumberId : $policyNumberId');
|
||||
|
||||
filteredPoliciesList = policyList.where((policy) {
|
||||
return policy['policy_no'] == selectedPolicyNo;
|
||||
}).toList();
|
||||
|
||||
print('Filtered matching policy_no: $filteredPoliciesList');
|
||||
logDebug('Filtered matching policy_no: $filteredPoliciesList');
|
||||
|
||||
// client_policy_id = filteredPoliciesList[0]['client_policy_id'];
|
||||
subjectController.text = filteredPoliciesList[0]['claim_subject'];
|
||||
@ -566,16 +568,16 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
'name': memberList['name'],
|
||||
};
|
||||
}).toList();
|
||||
print('employeePolicyList : $employeePolicyList');
|
||||
logDebug('employeePolicyList : $employeePolicyList');
|
||||
});
|
||||
} else {
|
||||
print('No EmployeePolicy found in the filtered policy.');
|
||||
logDebug('No EmployeePolicy found in the filtered policy.');
|
||||
setState(() {
|
||||
employeePolicyList = []; // Clear the list or handle it as needed
|
||||
});
|
||||
}
|
||||
} else {
|
||||
print('No policies matched the selected policy number.');
|
||||
logDebug('No policies matched the selected policy number.');
|
||||
setState(() {
|
||||
employeePolicyList = []; // Clear the list or handle it as needed
|
||||
});
|
||||
@ -586,7 +588,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
// return policy['policy_no'] == selectedPolicyNo;
|
||||
// }).toList();
|
||||
//
|
||||
// print('Filtered matching policy_no: $filteredPoliciesList');
|
||||
// logDebug('Filtered matching policy_no: $filteredPoliciesList');
|
||||
// }
|
||||
}
|
||||
|
||||
@ -660,10 +662,10 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final String? emp_id = session.empPrimaryId;
|
||||
print('Check One $client_policy_id');
|
||||
logDebug('Check One $client_policy_id');
|
||||
|
||||
try {
|
||||
print('Check One');
|
||||
logDebug('Check One');
|
||||
Map<String, dynamic> fields = {
|
||||
|
||||
'emp_id': emp_id,
|
||||
@ -729,17 +731,17 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
request.headers['Authorization'] = 'Bearer $_token';
|
||||
request.headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
||||
final stringFields = fields.map((key, value) => MapEntry(key, value?.toString() ?? ''));
|
||||
print("📁 stringFields: ${stringFields}");
|
||||
logDebug("📁 stringFields: ${stringFields}");
|
||||
request.fields.addAll(stringFields);
|
||||
|
||||
// get uploaded files
|
||||
final uploadedFiles = FileUploadService().files;
|
||||
print("📁 Total uploaded files: ${uploadedFiles.length}");
|
||||
print("📂 File list (original names): ${uploadedFiles.map((f) => f.file.name).toList()}");
|
||||
logDebug("📁 Total uploaded files: ${uploadedFiles.length}");
|
||||
logDebug("📂 File list (original names): ${uploadedFiles.map((f) => f.file.name).toList()}");
|
||||
|
||||
// Validate all labels present (optional but recommended)
|
||||
for (final uf in uploadedFiles) {
|
||||
print("📝 Checking label for file: ${uf.file.name}, current label: '${uf.label}'");
|
||||
logDebug("📝 Checking label for file: ${uf.file.name}, current label: '${uf.label}'");
|
||||
if ((uf.label ?? '').trim().isEmpty) {
|
||||
ToastHelper.showErrorToast(context, 'Please enter name for all uploaded documents');
|
||||
setState(() {
|
||||
@ -793,7 +795,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
fileBytes = await pdf.save();
|
||||
final pdfFileName = pf.name.replaceAll(RegExp(r'\.\w+$'), '.pdf');
|
||||
|
||||
print('📄 Converted image ${pf.name} → PDF ($pdfFileName)');
|
||||
logDebug('📄 Converted image ${pf.name} → PDF ($pdfFileName)');
|
||||
request.files.add(http.MultipartFile.fromBytes(
|
||||
'claim_docs[]', fileBytes, filename: pdfFileName));
|
||||
} else {
|
||||
@ -811,9 +813,9 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
request.fields['claim_doc_names'] = encodedNames;
|
||||
|
||||
// ✅ Debug print
|
||||
print("Payload being sent:");
|
||||
print("Files: ${uploadedFiles.map((f) => f.file.name).toList()}");
|
||||
print("Names (JSON): $encodedNames");
|
||||
logDebug("Payload being sent:");
|
||||
logDebug("Files: ${uploadedFiles.map((f) => f.file.name).toList()}");
|
||||
logDebug("Names (JSON): $encodedNames");
|
||||
|
||||
|
||||
final response = await request.send();
|
||||
@ -827,7 +829,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
departmentList.clear();
|
||||
setState(() => isLoading = false);
|
||||
context.go('/claims', extra: 2);
|
||||
print('Form data submitted successfully');
|
||||
logDebug('Form data submitted successfully');
|
||||
fileService.clearAll();
|
||||
} else {
|
||||
setState(() => isLoading = false);
|
||||
@ -836,7 +838,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
|
||||
} catch (e) {
|
||||
setState(() => isLoading = false);
|
||||
print('Error submitting form data: $e');
|
||||
logDebug('Error submitting form data: $e');
|
||||
} finally {
|
||||
setState(() => isSubmitting = false); // 🔥 always stop loader
|
||||
}
|
||||
@ -1475,7 +1477,7 @@ class _planclaimsformState extends State<planclaimsform> {
|
||||
// : MediaQuery.of(context).size.width * 0.26, // 26% on desktop
|
||||
// txtheight: 45,
|
||||
// onFilesSelected: (files) {
|
||||
// print("Picked files: ${files.map((f) => f.name).toList()}");
|
||||
// logDebug("Picked files: ${files.map((f) => f.name).toList()}");
|
||||
// setState(() {
|
||||
// uploadedFiles = files; // store all selected files
|
||||
// });
|
||||
|
||||
@ -21,6 +21,8 @@ import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class policies extends StatefulWidget {
|
||||
final Map<String, dynamic>? arguments;
|
||||
const policies({super.key, this.arguments});
|
||||
@ -76,7 +78,7 @@ class _policiesState extends State<policies> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
@ -85,7 +87,7 @@ class _policiesState extends State<policies> {
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
empName = session.gpaEmpName;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
}
|
||||
@ -102,27 +104,27 @@ class _policiesState extends State<policies> {
|
||||
'policy_no': policyNo
|
||||
};
|
||||
final response = await apiService.getEcardRequest(eCarDParams);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
final ecardDownloadUrl = response['data']['eCardDownload'];
|
||||
final message = response['data']['message'];
|
||||
if (ecardDownloadUrl != null) {
|
||||
print('✅ Link: $ecardDownloadUrl');
|
||||
logDebug('✅ Link: $ecardDownloadUrl');
|
||||
await _launchURL(ecardDownloadUrl,context); // Only launch if status is success
|
||||
// ToastHelper.showSuccessToast(context, message);
|
||||
} else {
|
||||
print('❌ Error: $message');
|
||||
logDebug('❌ Error: $message');
|
||||
ToastHelper.showErrorToast(context, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> _launchURL(String url, BuildContext context) async {
|
||||
print('url $url');
|
||||
logDebug('url $url');
|
||||
try {
|
||||
final Uri uri = Uri.parse(url);
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} catch (e) {
|
||||
print('Could not launch URL: $e');
|
||||
logDebug('Could not launch URL: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +157,7 @@ class _policiesState extends State<policies> {
|
||||
webOnlyWindowName: '_blank'); // Opens in a new tab (web only)
|
||||
} else {
|
||||
// Handle invalid or null URL
|
||||
print('Could not launch URL');
|
||||
logDebug('Could not launch URL');
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,8 +258,8 @@ class _policiesState extends State<policies> {
|
||||
Widget build(BuildContext context) {
|
||||
// dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
||||
final arguments = widget.arguments;
|
||||
print('arguments');
|
||||
print(arguments);
|
||||
logDebug('arguments');
|
||||
logDebug(arguments);
|
||||
if (arguments != null && arguments is Map<String, dynamic>) {
|
||||
argumentsData = arguments;
|
||||
if (argumentsData.containsKey('EmployeePolicy') &&
|
||||
@ -284,8 +286,8 @@ class _policiesState extends State<policies> {
|
||||
});
|
||||
|
||||
sortEmployeeDetails(employeeDetails);
|
||||
print('employeeDetails');
|
||||
print(employeeDetails);
|
||||
logDebug('employeeDetails');
|
||||
logDebug(employeeDetails);
|
||||
}
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
@ -1147,7 +1149,7 @@ class _policiesState extends State<policies> {
|
||||
if (url != null && url.isNotEmpty) {
|
||||
_openUrl(url);
|
||||
} else {
|
||||
print('No URL provided');
|
||||
logDebug('No URL provided');
|
||||
}
|
||||
},
|
||||
child: Card(
|
||||
|
||||
@ -25,8 +25,11 @@ import '../service/appVersionService.dart';
|
||||
import '../service/common_update_mobile_dialog.dart';
|
||||
import '../service/data_manager.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
import '../../features/chatbot/application/chatbot_reset_helper.dart';
|
||||
import '../session/authenticationService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class profile extends StatefulWidget {
|
||||
const profile({Key? key}) : super(key: key);
|
||||
|
||||
@ -95,23 +98,23 @@ class _profileState extends State<profile> {
|
||||
}
|
||||
|
||||
Future<void> _checkMpinStatus() async {
|
||||
print('check Mpin Status');
|
||||
logDebug('check Mpin Status');
|
||||
// if (kIsWeb) return; // ❌ skip web
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final String? isMpinSkipped = prefs.getString('is_mpin_skipped');
|
||||
print('check Mpin Status');
|
||||
print(isMpinSkipped);
|
||||
logDebug('check Mpin Status');
|
||||
logDebug(isMpinSkipped);
|
||||
|
||||
setState(() {
|
||||
showSetMpin = isMpinSkipped == "1";
|
||||
print('check Mpin Status');
|
||||
print(showSetMpin);
|
||||
logDebug('check Mpin Status');
|
||||
logDebug(showSetMpin);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> loadVersionInfo() async {
|
||||
print('App version:}');
|
||||
logDebug('App version:}');
|
||||
installedVersion = await AppVersionService.getInstalledVersion();
|
||||
|
||||
storeVersion = await AppVersionService.getLatestStoreVersion(
|
||||
@ -125,27 +128,27 @@ class _profileState extends State<profile> {
|
||||
Future<String> _getAppVersion() async {
|
||||
try {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
print('App version: ${packageInfo.version}');
|
||||
logDebug('App version: ${packageInfo.version}');
|
||||
return packageInfo.version;
|
||||
} catch (e) {
|
||||
print('Error getting app version: $e');
|
||||
logDebug('Error getting app version: $e');
|
||||
return 'Unknown'; // Optional fallback
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
await dataManager.loadSelfEmployeeProfile(
|
||||
clientId: session.client_id!,
|
||||
empCode: session.empCodeString!,
|
||||
@ -153,7 +156,7 @@ class _profileState extends State<profile> {
|
||||
)
|
||||
.then((_) {
|
||||
selfDetails = dataManager.selfProfile;
|
||||
print('selfDetails $selfDetails');
|
||||
logDebug('selfDetails $selfDetails');
|
||||
});
|
||||
getSelfEmployeeProfile();
|
||||
}
|
||||
@ -167,24 +170,24 @@ class _profileState extends State<profile> {
|
||||
|
||||
Future<void> getSelfEmployeeProfile() async {
|
||||
// final selfDetails = dataManager.selfProfile;
|
||||
print('profile');
|
||||
print(profile);
|
||||
logDebug('profile');
|
||||
logDebug(profile);
|
||||
// if (client_id == null || empCodeString == null) {
|
||||
// return;
|
||||
// }
|
||||
// setState(() {
|
||||
// isLoading = true;
|
||||
// });
|
||||
// print('check 1');
|
||||
// logDebug('check 1');
|
||||
// final response = await apiService.getSelfEmployeeProfileDetails(
|
||||
// client_id!, empCodeString!, client_branch_id!);
|
||||
// print('check 1');
|
||||
// logDebug('check 1');
|
||||
// if (response['status'] == 'success') {
|
||||
// if (response.containsKey('data')) {
|
||||
setState(() {
|
||||
// dynamic selfDetails = response['data'];
|
||||
//
|
||||
print(selfDetails);
|
||||
logDebug(selfDetails);
|
||||
selfRelationship = selfDetails?['relationship'];
|
||||
selfName = selfDetails?['name'];
|
||||
selfMobile = selfDetails?['mobile'];
|
||||
@ -196,7 +199,7 @@ class _profileState extends State<profile> {
|
||||
selfEmailPersonal = selfDetails?['email_personal'];
|
||||
selfEmpCode = selfDetails?['emp_code'];
|
||||
selfFamilyFloaterKey = selfDetails?['family_floater_key'];
|
||||
// print(clientDetails);
|
||||
// logDebug(clientDetails);
|
||||
selfEmpStatus = selfDetails?['emp_status'];
|
||||
// isLoading = false;
|
||||
});
|
||||
@ -206,21 +209,21 @@ class _profileState extends State<profile> {
|
||||
// // Handle other status messages if needed
|
||||
// // ToastHelper.showErrorToast(
|
||||
// // context, 'API request failed with status: ${data['status']}');
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
// } else {
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
}
|
||||
|
||||
Future<String?> checkLoginPin() async {
|
||||
print('checkLoginPin');
|
||||
logDebug('checkLoginPin');
|
||||
try {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final empMobileNo = prefs.getString('empMobileNo');
|
||||
final empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo $empMobileNo');
|
||||
print('empEmailid $empEmailid');
|
||||
logDebug('empMobileNo $empMobileNo');
|
||||
logDebug('empEmailid $empEmailid');
|
||||
|
||||
var params = {};
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
@ -229,7 +232,7 @@ class _profileState extends State<profile> {
|
||||
params = {'email_id': empEmailid};
|
||||
}
|
||||
|
||||
print('params $params');
|
||||
logDebug('params $params');
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrlEnrollment + 'checkMpin'),
|
||||
@ -260,17 +263,18 @@ class _profileState extends State<profile> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('❌ API failed: ${response.statusCode}');
|
||||
logDebug('❌ API failed: ${response.statusCode}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ Error: $e');
|
||||
logDebug('❌ Error: $e');
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
ChatbotResetHelper.resetChatbot(context);
|
||||
// if (isMobilePlatform()) {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
@ -279,40 +283,40 @@ class _profileState extends State<profile> {
|
||||
String? mobileNumber = prefs.getString('empMobileNo');
|
||||
String? mailID = prefs.getString('empEmailid');
|
||||
final isMpinSkipped = await checkLoginPin();
|
||||
print('isMpinSkipped $isMpinSkipped');
|
||||
logDebug('isMpinSkipped $isMpinSkipped');
|
||||
// bool? biometricStatus = prefs.getBool('biometricStatus') ?? false;
|
||||
// int? skipStatus = prefs.getInt('skipStatus') ?? 1;
|
||||
|
||||
// Clear all keys
|
||||
await SessionManager().clear();
|
||||
// await prefs.clear();
|
||||
print('Local Storage Clear');
|
||||
logDebug('Local Storage Clear');
|
||||
|
||||
// html.window.localStorage.clear();
|
||||
// Re-set the mobile_number key
|
||||
if (isMobilePlatform()) {
|
||||
if (mobileNumber != null) {
|
||||
await prefs.setString('empMobileNo', mobileNumber);
|
||||
print('empMobileNo $mobileNumber');
|
||||
logDebug('empMobileNo $mobileNumber');
|
||||
// await prefs.setBool('biometricStatus', biometricStatus!);
|
||||
// await prefs.setInt('skipStatus', skipStatus!);
|
||||
}
|
||||
if (mailID != null) {
|
||||
await prefs.setString('empEmailid', mailID);
|
||||
print('empEmailid $mailID');
|
||||
logDebug('empEmailid $mailID');
|
||||
// await prefs.setBool('biometricStatus', biometricStatus!);
|
||||
// await prefs.setInt('skipStatus', skipStatus!);
|
||||
}
|
||||
if (isMpinSkipped != null) {
|
||||
await prefs.setString('is_mpin_skipped', isMpinSkipped!);
|
||||
print('isMpinSkipped $isMpinSkipped');
|
||||
logDebug('isMpinSkipped $isMpinSkipped');
|
||||
}
|
||||
if (isMpinSkipped != null && isMpinSkipped == '0') {
|
||||
print('pinPage');
|
||||
logDebug('pinPage');
|
||||
// return;
|
||||
context.go('/pinPage');
|
||||
} else {
|
||||
print('login');
|
||||
logDebug('login');
|
||||
context.go('/login');
|
||||
}
|
||||
} else {
|
||||
@ -782,10 +786,10 @@ class _profileState extends State<profile> {
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
if (showSetMpin) {
|
||||
print('pinSettingPage');
|
||||
logDebug('pinSettingPage');
|
||||
context.go('/pinSettingPage'); // ✅ Set MPIN page
|
||||
} else {
|
||||
print('changePin');
|
||||
logDebug('changePin');
|
||||
context.go('/changePin'); // ✅ Change PIN page
|
||||
}
|
||||
},
|
||||
|
||||
@ -20,6 +20,8 @@ import '../../customAppBar/toastHelper.dart';
|
||||
import '../service/TokenService.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class raisedTicketHistory extends StatefulWidget {
|
||||
const raisedTicketHistory({Key? key}) : super(key: key);
|
||||
|
||||
@ -81,21 +83,21 @@ class _raisedTicketHistoryState extends State<raisedTicketHistory> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
empMobileNo = session.mobileNo;
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
empName = session.gpaEmpName;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
print(client_id);
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
logDebug(client_id);
|
||||
getTicketList();
|
||||
}
|
||||
}
|
||||
@ -109,22 +111,22 @@ class _raisedTicketHistoryState extends State<raisedTicketHistory> {
|
||||
});
|
||||
|
||||
try {
|
||||
print('check getTicketList 1');
|
||||
logDebug('check getTicketList 1');
|
||||
final response = await apiService.getTicketListByMobile(empMobileNo!);
|
||||
print('check getTicketList 2');
|
||||
logDebug('check getTicketList 2');
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
// if (response['success'] == true && response['data'] is List) {
|
||||
setState(() {
|
||||
ticketList = response['data'].toList();
|
||||
print("TC1 - $ticketList");
|
||||
logDebug("TC1 - $ticketList");
|
||||
reversedTicketList = List<Map<String, dynamic>>.from(ticketList);
|
||||
reversedTicketList = List<Map<String, dynamic>>.from(ticketList);
|
||||
print("TC2 - $ticketList");
|
||||
logDebug("TC2 - $ticketList");
|
||||
// ticketList = reversedTicketList.reversed.toList();
|
||||
ticketList = reversedTicketList.toList();
|
||||
print("TC3 - $ticketList");
|
||||
logDebug("TC3 - $ticketList");
|
||||
});
|
||||
// }
|
||||
// else if (response['status'] == "error" &&
|
||||
@ -140,11 +142,11 @@ class _raisedTicketHistoryState extends State<raisedTicketHistory> {
|
||||
// isLoading = false;
|
||||
// });
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
} catch (e) {
|
||||
// ToastHelper.showErrorToast(context, 'Failed to load data');
|
||||
print('Error in getTicketList: $e');
|
||||
logDebug('Error in getTicketList: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -360,12 +362,12 @@ class _raisedTicketHistoryState extends State<raisedTicketHistory> {
|
||||
String claimsDepartmentName = item['ticket_type'] ?? '';
|
||||
// String claimsReplies = item['replies'];
|
||||
// List<dynamic> messageList = item['message_list'];
|
||||
print("item - $item");
|
||||
print('generateTrackList');
|
||||
print(claimsSubject);
|
||||
print(claimsDate);
|
||||
print(claimStatus);
|
||||
print(claimsDepartmentName);
|
||||
logDebug("item - $item");
|
||||
logDebug('generateTrackList');
|
||||
logDebug(claimsSubject);
|
||||
logDebug(claimsDate);
|
||||
logDebug(claimStatus);
|
||||
logDebug(claimsDepartmentName);
|
||||
|
||||
final Map<String, Color> statusColors = {
|
||||
'Received': Colors.amber,
|
||||
@ -396,7 +398,7 @@ class _raisedTicketHistoryState extends State<raisedTicketHistory> {
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
print("Navigating with thz_id: ${item['thz_id']}");
|
||||
logDebug("Navigating with thz_id: ${item['thz_id']}");
|
||||
context.go('/tickettracklist/${item['thz_id']}');
|
||||
// context.go('/tickettracklist', extra: item['thz_id']);
|
||||
},
|
||||
|
||||
@ -20,6 +20,8 @@ import 'package:http/http.dart' as http;
|
||||
import '../service/TokenService.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class retailClaimForm extends StatefulWidget {
|
||||
final Map<String, dynamic>? details;
|
||||
const retailClaimForm({Key? key, this.details}) : super(key: key);
|
||||
@ -77,7 +79,7 @@ class _retailClaimFormsState extends State<retailClaimForm> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
setState(() {
|
||||
@ -85,15 +87,15 @@ class _retailClaimFormsState extends State<retailClaimForm> {
|
||||
});
|
||||
// Decode the JWT token received from the API response
|
||||
decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
mobileNo = session.mobileNo;
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
emailId = session.empEmailCorporate;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getClaimTypeMasterList();
|
||||
}
|
||||
}
|
||||
@ -136,7 +138,7 @@ class _retailClaimFormsState extends State<retailClaimForm> {
|
||||
"claim_description": descriptionController.text,
|
||||
};
|
||||
|
||||
print("Retail Claim FormData: $formData");
|
||||
logDebug("Retail Claim FormData: $formData");
|
||||
|
||||
// ------------------------------
|
||||
// Prepare MultipartRequest
|
||||
@ -162,7 +164,7 @@ class _retailClaimFormsState extends State<retailClaimForm> {
|
||||
final response = await request.send();
|
||||
final responseBody = await response.stream.bytesToString();
|
||||
|
||||
print("Retail Claim API Response: $responseBody");
|
||||
logDebug("Retail Claim API Response: $responseBody");
|
||||
|
||||
final decoded = jsonDecode(responseBody);
|
||||
|
||||
@ -190,7 +192,7 @@ class _retailClaimFormsState extends State<retailClaimForm> {
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
print("Retail claim submit ERROR: $e");
|
||||
logDebug("Retail claim submit ERROR: $e");
|
||||
ToastHelper.showErrorToast(context, "Something went wrong");
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@ import 'dart:convert';
|
||||
|
||||
import '../../../config/environment.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class ApiService {
|
||||
final BuildContext context;
|
||||
String? _postToken;
|
||||
@ -27,7 +29,7 @@ class ApiService {
|
||||
String? branchID,
|
||||
String? mobileNo,
|
||||
String? emailId) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -42,8 +44,8 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getClaimsHistoryToApi(
|
||||
String ticket_type_id) async {
|
||||
print("getCashDepositDetailsToApi1");
|
||||
print(_postToken);
|
||||
logDebug("getCashDepositDetailsToApi1");
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -58,7 +60,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getAdvertisementImageToApi(clientID) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -72,7 +74,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getCashlessAndReimbursementToApi() async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -86,7 +88,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getSelfEmployeeProfileDetails(
|
||||
String clientId, String empCode, String branchID) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -100,7 +102,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getFAQsApiData() async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -114,7 +116,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getTrackClaimsList(
|
||||
String empPrimaryId, mobileNo, emailID) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -128,7 +130,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getTicketListByMobile(String empMobileNo) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -145,7 +147,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getTicketConverList(String thz_id) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -163,7 +165,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> getWellnessLink(
|
||||
empPrimaryId, client_policy_id) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -178,7 +180,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getEcardRequest(eCardParam) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -195,7 +197,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> sendRetailPolicyDetails(formData) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -235,7 +237,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchPolicyTypeAndInsurer() async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -249,7 +251,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> fetchDepartmentList(
|
||||
String clientId, String empCode) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -263,7 +265,7 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getClaimTypeMasterApi() async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -277,7 +279,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> sendTicketFormDataToApi(
|
||||
Map<String, dynamic> formData) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -294,7 +296,7 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> sendClaimsFormDataToApi(
|
||||
Map<String, dynamic> formData) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
@ -311,15 +313,15 @@ class ApiService {
|
||||
|
||||
Future<Map<String, dynamic>> sendClaimsMessageToApi(
|
||||
Map<String, dynamic> formData) async {
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
print("sendClaimsMessageToApi");
|
||||
logDebug("sendClaimsMessageToApi");
|
||||
final url = Uri.parse('${Environment.apiUrl}ticketConversationSave');
|
||||
// final url = Uri.parse('${Environment.apiUrlTicket}/messages/create');
|
||||
// Convert formData to Map<String, String>
|
||||
print("sendClaimsMessageToApi1");
|
||||
logDebug("sendClaimsMessageToApi1");
|
||||
Map<String, String> stringFormData =
|
||||
formData.map((key, value) => MapEntry(key, value.toString()));
|
||||
final response = await _makePostRequest(url, stringFormData, {
|
||||
@ -343,7 +345,7 @@ class ApiService {
|
||||
// Convert formData to Map<String, String>
|
||||
Map<String, String> stringFormData =
|
||||
formData.map((key, value) => MapEntry(key, value.toString()));
|
||||
print(url);
|
||||
logDebug(url);
|
||||
final response = await _makePostRequest(url, stringFormData, {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': 'Bearer $_postToken' ?? '',
|
||||
@ -353,12 +355,12 @@ class ApiService {
|
||||
|
||||
// Future<Map<String, dynamic>> getBotDetails(String requestFor, is_option,
|
||||
// option, returnMessage, mobileNo, policyID) async {
|
||||
// print('requestFor: $requestFor');
|
||||
// print('is_option: $is_option');
|
||||
// print('option: $option');
|
||||
// print('returnMessage: $returnMessage');
|
||||
// print('mobileNo: $mobileNo');
|
||||
// print('policyID: $policyID');
|
||||
// logDebug('requestFor: $requestFor');
|
||||
// logDebug('is_option: $is_option');
|
||||
// logDebug('option: $option');
|
||||
// logDebug('returnMessage: $returnMessage');
|
||||
// logDebug('mobileNo: $mobileNo');
|
||||
// logDebug('policyID: $policyID');
|
||||
// if (_postToken == null) {
|
||||
// await _initializeToken();
|
||||
// }
|
||||
@ -370,7 +372,7 @@ class ApiService {
|
||||
// url = Uri.parse(
|
||||
// '${Environment.apiUrl}getChatResponse?request_for=$requestFor&is_option=$is_option&text=$returnMessage&value=$option&mobile_no=$mobileNo&policy_id=$policyID');
|
||||
// }
|
||||
// print(url);
|
||||
// logDebug(url);
|
||||
//
|
||||
// final headers = {
|
||||
// 'Authorization': 'Bearer $_postToken' ?? '',
|
||||
|
||||
@ -3561,6 +3561,10 @@ OCswMDowMGyI4BIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjUtMTItMDJUMTA6NDM6NTgrMDA6MDAd
|
||||
</svg>
|
||||
''';
|
||||
|
||||
static const String chatbot = '''
|
||||
<svg id="Layer_1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1"><path d="m504 175.245v-108.986c0-25.2-20.515-45.702-45.73-45.702h-216.811c-25.216 0-45.73 20.502-45.73 45.702v107.389h-40.399v-43.308c13.224-4.893 22.676-17.629 22.676-32.533 0-19.105-15.556-34.648-34.676-34.648s-34.648 15.543-34.648 34.648c0 14.9 9.44 27.633 22.648 32.529v44.086c-41.403 5.367-74.331 38.117-79.977 79.433-24.723 5.164-43.352 27.114-43.352 53.335v50.709c0 26.221 18.629 48.172 43.352 53.335 6.182 45.237 45.07 80.208 91.977 80.208h219.758c46.603 0 85.291-34.517 91.853-79.328 27.508-2.746 49.059-26.011 49.059-54.215v-50.709c0-28.202-21.548-51.466-49.053-54.215-1.651-11.313-5.371-22.124-10.976-32h14.298c25.216 0 45.73-20.515 45.73-45.73z" fill="#d5dae0"/><path d="m458.27 20.557h-216.811c-25.216 0-45.73 20.502-45.73 45.702v108.986c0 25.256 20.474 45.73 45.73 45.73h23.941v53.019c0 5.345 6.461 8.022 10.241 4.244l57.295-57.262h125.333c25.256 0 45.73-20.474 45.73-45.73v-108.986c0-25.2-20.515-45.702-45.73-45.702z" fill="#2de6a8"/><g fill="#26d395"><path d="m265.4 271.483v2.511c0 5.345 6.461 8.022 10.241 4.244l57.295-57.262h-17l-50.536 50.508z"/><path d="m458.27 20.557h-17c25.216 0 45.73 20.502 45.73 45.702v108.986c0 25.256-20.474 45.73-45.73 45.73h17c25.256 0 45.73-20.474 45.73-45.73v-108.986c0-25.2-20.515-45.702-45.73-45.702z"/></g><path d="m343.331 236.857h-26.285l-41.404 41.381c-3.78 3.778-10.241 1.101-10.241-4.244v-37.137h-102.315c-32.015 0-58.061 26.045-58.061 58.06v75.256c0 32.015 26.046 58.061 58.061 58.061h180.246c32.015 0 58.061-26.046 58.061-58.061v-75.256c0-32.015-26.046-58.06-58.061-58.06z" fill="#77787f"/><path d="m315.439 361.567c-6.627 0-12-5.373-12-12v-34.042c0-6.627 5.373-12 12-12s12 5.373 12 12v34.042c0 6.627-5.373 12-12 12z" fill="#80d4ff"/><path d="m190.977 361.567c-6.627 0-12-5.373-12-12v-34.042c0-6.627 5.373-12 12-12s12 5.373 12 12v34.042c0 6.627-5.373 12-12 12z" fill="#80d4ff"/><g fill="#eff1f4"><path d="m436.671 173.81h-173.613c-6.627 0-12-5.373-12-12s5.373-12 12-12h173.613c6.627 0 12 5.373 12 12s-5.373 12-12 12z"/><path d="m383.581 91.723h-120.522c-6.627 0-12-5.373-12-12s5.373-12 12-12h120.522c6.627 0 12 5.373 12 12s-5.373 12-12 12z"/><path d="m436.671 132.766h-173.613c-6.627 0-12-5.373-12-12s5.373-12 12-12h173.613c6.627 0 12 5.373 12 12s-5.373 12-12 12z"/></g><path d="m143.329 63.159c-19.105 0-34.648 15.543-34.648 34.648s15.543 34.676 34.648 34.676 34.676-15.556 34.676-34.676-15.556-34.648-34.676-34.648z" fill="#80d4ff"/><path d="m143.329 63.159c-1.871 0-3.706.154-5.498.441 16.514 2.643 29.174 16.973 29.174 34.207s-12.66 31.59-29.174 34.235c1.792.287 3.627.441 5.498.441 19.12 0 34.676-15.556 34.676-34.676s-15.556-34.648-34.676-34.648z" fill="#61c2e0"/><g fill="#abb4ba"><path d="m50.489 398.603v-132.116c0-4.285.298-8.5.863-12.632-24.723 5.164-43.352 27.114-43.352 53.335v50.709c0 26.221 18.629 48.172 43.352 53.335-.565-4.132-.863-8.348-.863-12.632z"/><path d="m454.947 252.976c.647 4.436.98 8.948.98 13.512v132.116c0 4.589-.34 9.1-.986 13.512 27.508-2.746 49.059-26.011 49.059-54.215v-50.709c0-28.202-21.548-51.466-49.053-54.215z"/></g><path d="m155.329 173.648v-43.308c-3.741 1.384-7.783 2.143-12 2.143s-8.259-.76-12-2.147v44.086c3.929-.509 7.934-.774 12-.774z" fill="#abb4ba"/></svg>
|
||||
''';
|
||||
|
||||
static String getSvg(String svgName) {
|
||||
switch (svgName) {
|
||||
case 'ECard':
|
||||
@ -3589,6 +3593,8 @@ OCswMDowMGyI4BIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjUtMTItMDJUMTA6NDM6NTgrMDA6MDAd
|
||||
return help;
|
||||
case 'email':
|
||||
return email;
|
||||
case 'chatbot':
|
||||
return chatbot;
|
||||
case 'smartphone':
|
||||
return smartphone;
|
||||
case 'mpin':
|
||||
|
||||
@ -18,6 +18,8 @@ import '../../customAppBar/toastHelper.dart';
|
||||
import '../service/TokenService.dart';
|
||||
import '../service/popup_helper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class tickettracklist extends StatefulWidget {
|
||||
final String ticketID;
|
||||
const tickettracklist({Key? key, required this.ticketID}) : super(key: key);
|
||||
@ -82,7 +84,7 @@ class _tickettracklistState extends State<tickettracklist> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
ticketID = widget.ticketID;
|
||||
print('ticketID: $ticketID');
|
||||
logDebug('ticketID: $ticketID');
|
||||
apiService = ApiService(context); // Initialize ApiService here
|
||||
_loadToken();
|
||||
|
||||
@ -98,26 +100,26 @@ class _tickettracklistState extends State<tickettracklist> {
|
||||
@override
|
||||
// void didChangeDependencies() {
|
||||
// super.didChangeDependencies();
|
||||
// print('ticket');
|
||||
// logDebug('ticket');
|
||||
// dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
||||
// if (arguments != null && arguments is int) {
|
||||
// ticketID = arguments;
|
||||
// print('ticketID: $ticketID');
|
||||
// logDebug('ticketID: $ticketID');
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
empCodeString = session.empCodeString;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
getTicketConvoList();
|
||||
}
|
||||
}
|
||||
@ -127,11 +129,11 @@ class _tickettracklistState extends State<tickettracklist> {
|
||||
isLoading = true;
|
||||
});
|
||||
try {
|
||||
print("FORMDATA - $formData");
|
||||
logDebug("FORMDATA - $formData");
|
||||
formData = formData.map((key, value) => MapEntry(key, value.toString()));
|
||||
print("FORMDATA1 - $formData");
|
||||
logDebug("FORMDATA1 - $formData");
|
||||
final response = await apiService.sendClaimsMessageToApi(formData);
|
||||
print("REs - $response");
|
||||
logDebug("REs - $response");
|
||||
if (response['status'] == 'success') {
|
||||
messageController.clear();
|
||||
// ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||
@ -141,12 +143,12 @@ class _tickettracklistState extends State<tickettracklist> {
|
||||
});
|
||||
// Navigator.pushNamed(context, 'claims', arguments: 0);
|
||||
getTicketConvoList();
|
||||
print('Form data sent successfully.');
|
||||
logDebug('Form data sent successfully.');
|
||||
} else {
|
||||
print('Failed to submit form data: ${response['status']}');
|
||||
logDebug('Failed to submit form data: ${response['status']}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error submitting form data: $e');
|
||||
logDebug('Error submitting form data: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,24 +166,24 @@ class _tickettracklistState extends State<tickettracklist> {
|
||||
});
|
||||
|
||||
try {
|
||||
print('check getTicketList 1');
|
||||
logDebug('check getTicketList 1');
|
||||
final response = await apiService.getTicketConverList(ticketID);
|
||||
print('check getTicketList 2');
|
||||
logDebug('check getTicketList 2');
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
// if (response['success'] == true && response['data'] is List) {
|
||||
setState(() {
|
||||
claimTrackList = response['data'];
|
||||
print("TCtt1 - $claimTrackList");
|
||||
logDebug("TCtt1 - $claimTrackList");
|
||||
claimTrackMasterList = response['data']['master'];
|
||||
print("TCtt2 - $claimTrackMasterList");
|
||||
logDebug("TCtt2 - $claimTrackMasterList");
|
||||
claimTrackMsgList = response['data']['notes'];
|
||||
print("TCtt3 - $claimTrackMsgList");
|
||||
logDebug("TCtt3 - $claimTrackMsgList");
|
||||
|
||||
if (claimTrackMasterList != []) {
|
||||
print("ClaimLST - ");
|
||||
print(claimTrackMasterList[0]['thz_id']);
|
||||
logDebug("ClaimLST - ");
|
||||
logDebug(claimTrackMasterList[0]['thz_id']);
|
||||
policyTickID = claimTrackMasterList[0]['thz_id'];
|
||||
policyName = claimTrackMasterList[0]['policy_no'];
|
||||
// name = claimTrackMasterList[0]['name'];
|
||||
@ -190,12 +192,12 @@ class _tickettracklistState extends State<tickettracklist> {
|
||||
member = claimTrackMasterList[0]['assignee_name'];
|
||||
policySubject = claimTrackMasterList[0]['subject'];
|
||||
policyMessage = claimTrackMasterList[0]['message'];
|
||||
// print("ClaimLST - ${claimTrackMasterList['thz_id'].toString()}");
|
||||
// logDebug("ClaimLST - ${claimTrackMasterList['thz_id'].toString()}");
|
||||
}
|
||||
// reversedTicketList = List<Map<String, dynamic>>.from(ticketList);
|
||||
// print("TC2 - $ticketList");
|
||||
// logDebug("TC2 - $ticketList");
|
||||
// ticketList = reversedTicketList.reversed.toList();
|
||||
// print("TC3 - $ticketList");
|
||||
// logDebug("TC3 - $ticketList");
|
||||
});
|
||||
// }
|
||||
// else if (response['status'] == "error" &&
|
||||
@ -211,11 +213,11 @@ class _tickettracklistState extends State<tickettracklist> {
|
||||
// isLoading = false;
|
||||
// });
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
// print('API request failed with status: ${response['status']}');
|
||||
// logDebug('API request failed with status: ${response['status']}');
|
||||
// }
|
||||
} catch (e) {
|
||||
// ToastHelper.showErrorToast(context, 'Failed to load data');
|
||||
print('Error in getTicketList: $e');
|
||||
logDebug('Error in getTicketList: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
||||
@ -18,6 +18,8 @@ import '../../customAppBar/toastHelper.dart';
|
||||
import '../service/SessionManager.dart';
|
||||
import '../service/TokenService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class wellness extends StatefulWidget {
|
||||
const wellness({Key? key}) : super(key: key);
|
||||
|
||||
@ -55,41 +57,41 @@ class _wellnessState extends State<wellness> {
|
||||
}
|
||||
|
||||
Future<void> _loadToken() async {
|
||||
print('_loadToken');
|
||||
logDebug('_loadToken');
|
||||
final String? token = await TokenService.getPostToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||
print(decodedToken);
|
||||
logDebug(decodedToken);
|
||||
mobileNo = session.mobileNo;
|
||||
client_branch_id = session.empClientBranchId;
|
||||
empCodeString = session.empCodeString;
|
||||
empName = session.gpaEmpName;
|
||||
print(empCodeString); // Check if emp_code is correct
|
||||
logDebug(empCodeString); // Check if emp_code is correct
|
||||
empPrimaryId = session.empPrimaryId;
|
||||
client_id = session.client_id;
|
||||
emailId = session.empEmailCorporate;
|
||||
print(client_id);
|
||||
logDebug(client_id);
|
||||
// getAdvertisementSliderImage();
|
||||
getActiveAndInactivePolicyDetails('Active');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getActiveAndInactivePolicyDetails(String status) async {
|
||||
print(getActiveAndInactivePolicyDetails);
|
||||
logDebug(getActiveAndInactivePolicyDetails);
|
||||
if (client_id == null || empCodeString == null) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
isLoadingGif = true;
|
||||
});
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
final response = await apiService.getActiveAndInactivePolicyDetails(
|
||||
client_id!, empCodeString!, status, client_branch_id, mobileNo,emailId);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
if (response['status'] == 'success') {
|
||||
policyList = response['data'];
|
||||
print('policyList $policyList');
|
||||
logDebug('policyList $policyList');
|
||||
|
||||
// -------------------------------------------
|
||||
// 1️⃣ CHECK FOR GMC OR GMC-PARENT
|
||||
@ -99,18 +101,18 @@ class _wellnessState extends State<wellness> {
|
||||
return type == 'GMC' || type == 'GMC - Parents';
|
||||
}).toList();
|
||||
|
||||
print('gmcPolicies $gmcPolicies');
|
||||
logDebug('gmcPolicies $gmcPolicies');
|
||||
|
||||
if (gmcPolicies.isNotEmpty) {
|
||||
final mergedEmployeeDetails = getMergedEmployeeDetails(gmcPolicies);
|
||||
|
||||
print("🟢 Merged Employee Details: $mergedEmployeeDetails");
|
||||
logDebug("🟢 Merged Employee Details: $mergedEmployeeDetails");
|
||||
|
||||
setState(() {
|
||||
employeeDetailsList = mergedEmployeeDetails;
|
||||
});
|
||||
|
||||
print('mergedEmployeeDetails $employeeDetailsList');
|
||||
logDebug('mergedEmployeeDetails $employeeDetailsList');
|
||||
|
||||
setState(() => isLoadingGif = false);
|
||||
|
||||
@ -127,15 +129,15 @@ class _wellnessState extends State<wellness> {
|
||||
}).toList();
|
||||
|
||||
if (gpaPolicies.isNotEmpty) {
|
||||
print("🟠 GPA FOUND — calling Wellness API directly");
|
||||
logDebug("🟠 GPA FOUND — calling Wellness API directly");
|
||||
|
||||
final firstPolicy = gpaPolicies[0];
|
||||
|
||||
final empID = firstPolicy['EmployeePolicy'][0]['employee_id'];
|
||||
final clientPolicyId = firstPolicy['client_policy_id'];
|
||||
|
||||
print("EMPLOYEE ID: $empID");
|
||||
print("CLIENT POLICY ID: $clientPolicyId");
|
||||
logDebug("EMPLOYEE ID: $empID");
|
||||
logDebug("CLIENT POLICY ID: $clientPolicyId");
|
||||
|
||||
setState(() => isLoadingGif = false);
|
||||
|
||||
@ -147,7 +149,7 @@ class _wellnessState extends State<wellness> {
|
||||
// -------------------------------------------
|
||||
// 3️⃣ NO GMC, NO GPA
|
||||
// -------------------------------------------
|
||||
print("❌ No valid policy found");
|
||||
logDebug("❌ No valid policy found");
|
||||
ToastHelper.showErrorToast(context, "No valid policies found.");
|
||||
setState(() => isLoadingGif = false);
|
||||
|
||||
@ -156,14 +158,14 @@ class _wellnessState extends State<wellness> {
|
||||
setState(() {
|
||||
isLoadingGif = false;
|
||||
});
|
||||
print('API request failed with status: ${response['status']}');
|
||||
logDebug('API request failed with status: ${response['status']}');
|
||||
}
|
||||
}
|
||||
|
||||
List<dynamic> getMergedEmployeeDetails(List<dynamic>? gmcPolicies) {
|
||||
print('123');
|
||||
logDebug('123');
|
||||
if (gmcPolicies == null || gmcPolicies.isEmpty) return [];
|
||||
print('getMergedEmployeeDetails $gmcPolicies');
|
||||
logDebug('getMergedEmployeeDetails $gmcPolicies');
|
||||
|
||||
List<dynamic> finalList = [];
|
||||
|
||||
@ -198,29 +200,29 @@ class _wellnessState extends State<wellness> {
|
||||
Future<void> getWellnessLink(employee_id,client_policy_id) async {
|
||||
|
||||
final response = await apiService.getWellnessLink(employee_id,client_policy_id);
|
||||
print('check 1');
|
||||
logDebug('check 1');
|
||||
if (response['status'] == 'success') {
|
||||
wellnessURL = response['data'];
|
||||
print('✅ Link: $wellnessURL');
|
||||
logDebug('✅ Link: $wellnessURL');
|
||||
openInWebView(context,wellnessURL);
|
||||
// await _launchURL(wellnessURL); // Only launch if status is success
|
||||
} else if (response['status'] == 'failed') {
|
||||
wellnessMessage = response['message'];
|
||||
print('❌ Error: $wellnessMessage');
|
||||
logDebug('❌ Error: $wellnessMessage');
|
||||
ToastHelper.showErrorToast(context, wellnessMessage);
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, '⚠️ Unknown response format');
|
||||
print('⚠️ Unknown response format');
|
||||
logDebug('⚠️ Unknown response format');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _launchURL(String url, BuildContext context) async {
|
||||
print('url $url');
|
||||
logDebug('url $url');
|
||||
try {
|
||||
final Uri uri = Uri.parse(url);
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} catch (e) {
|
||||
print('Could not launch URL: $e');
|
||||
logDebug('Could not launch URL: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,7 +423,7 @@ class _wellnessState extends State<wellness> {
|
||||
String employee_id = item['employee_id'] ?? '';
|
||||
String client_policy_id = item['client_policy_id'] ?? '';
|
||||
|
||||
print('${name} - ${employee_id}--${client_policy_id}');
|
||||
logDebug('${name} - ${employee_id}--${client_policy_id}');
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
|
||||
@ -143,9 +143,9 @@
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:jwt_decode/jwt_decode.dart';
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
import 'package:nhance_app_pwa/pages/service/data_manager.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
import 'TokenService.dart';
|
||||
|
||||
@ -179,8 +179,6 @@ class SessionManager {
|
||||
Future<void> initializeFromPostToken(String token) async {
|
||||
Map<String, dynamic> decoded = Jwt.parseJwt(token);
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
mobileNo = decoded['mobile'];
|
||||
empClientBranchId = decoded['client_branch_id'];
|
||||
empCodeString = decoded['emp_code']?.toString();
|
||||
@ -190,25 +188,26 @@ class SessionManager {
|
||||
emp_status = decoded['emp_status']?.toString();
|
||||
empEmailCorporate = decoded['email_corporate']?.toString();
|
||||
|
||||
// persist
|
||||
prefs.setString('mobileNo', mobileNo ?? '');
|
||||
prefs.setString('empCodeString', empCodeString ?? '');
|
||||
prefs.setString('gpaEmpName', gpaEmpName ?? '');
|
||||
prefs.setString('empPrimaryId', empPrimaryId ?? '');
|
||||
prefs.setString('client_id', client_id ?? '');
|
||||
prefs.setString('empClientBranchId', empClientBranchId ?? '');
|
||||
prefs.setString('emp_status', emp_status ?? '');
|
||||
prefs.setString('empEmailCorporate', empEmailCorporate ?? '');
|
||||
// Web: keep session in memory + JWT in sessionStorage only (no SharedPreferences).
|
||||
if (!kIsWeb) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString('mobileNo', mobileNo ?? '');
|
||||
prefs.setString('empCodeString', empCodeString ?? '');
|
||||
prefs.setString('gpaEmpName', gpaEmpName ?? '');
|
||||
prefs.setString('empPrimaryId', empPrimaryId ?? '');
|
||||
prefs.setString('client_id', client_id ?? '');
|
||||
prefs.setString('empClientBranchId', empClientBranchId ?? '');
|
||||
prefs.setString('emp_status', emp_status ?? '');
|
||||
prefs.setString('empEmailCorporate', empEmailCorporate ?? '');
|
||||
}
|
||||
|
||||
debugPrint('Post Session initialized: $decoded');
|
||||
logDebug('Post Session initialized: $decoded');
|
||||
}
|
||||
|
||||
/// Save Pre Enrollment Token
|
||||
Future<void> initializeFromPreToken(String token) async {
|
||||
Map<String, dynamic> decoded = Jwt.parseJwt(token);
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
enrollmentEmpClientBranchId = decoded['client_branch_id'];
|
||||
enrollmentEmpCodeString = decoded['emp_code']?.toString();
|
||||
enrollmentEmpPrimaryId = decoded['id']?.toString();
|
||||
@ -217,16 +216,22 @@ class SessionManager {
|
||||
enrollmentEmp_status = decoded['emp_status']?.toString();
|
||||
enrollmentEmailCorporate = decoded['email_corporate']?.toString();
|
||||
|
||||
// persist
|
||||
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId ?? '');
|
||||
prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString ?? '');
|
||||
prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId ?? '');
|
||||
prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName ?? '');
|
||||
prefs.setString('enrollmentClient_id', enrollmentClient_id ?? '');
|
||||
prefs.setString('enrollmentEmp_status', enrollmentEmp_status ?? '');
|
||||
prefs.setString('enrollmentEmailCorporate', enrollmentEmailCorporate ?? '');
|
||||
if (!kIsWeb) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString(
|
||||
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId ?? '');
|
||||
prefs.setString(
|
||||
'enrollmentEmpCodeString', enrollmentEmpCodeString ?? '');
|
||||
prefs.setString(
|
||||
'enrollmentEmpPrimaryId', enrollmentEmpPrimaryId ?? '');
|
||||
prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName ?? '');
|
||||
prefs.setString('enrollmentClient_id', enrollmentClient_id ?? '');
|
||||
prefs.setString('enrollmentEmp_status', enrollmentEmp_status ?? '');
|
||||
prefs.setString(
|
||||
'enrollmentEmailCorporate', enrollmentEmailCorporate ?? '');
|
||||
}
|
||||
|
||||
debugPrint('Pre Session initialized: $decoded');
|
||||
logDebug('Pre Session initialized: $decoded');
|
||||
}
|
||||
|
||||
/// Restore session at startup
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -10,8 +9,10 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../config/environment.dart';
|
||||
import '../../customAppBar/toastHelper.dart';
|
||||
import '../../logger.dart';
|
||||
import '../../models/platform_helper_mobile.dart';
|
||||
import 'SessionManager.dart';
|
||||
import 'web_session_storage.dart';
|
||||
|
||||
class TokenService {
|
||||
static const postTokenKey = 'post_token';
|
||||
@ -19,44 +20,43 @@ class TokenService {
|
||||
|
||||
static final _secureStorage = FlutterSecureStorage();
|
||||
|
||||
/// Web: tokens live only in [sessionStorage] (tab-scoped). Mobile: secure storage.
|
||||
static Future<void> saveTokens({String? postToken, String? preToken}) async {
|
||||
if (kIsWeb) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
if (postToken != null) await prefs.setString(postTokenKey, postToken);
|
||||
if (preToken != null) await prefs.setString(preTokenKey, preToken);
|
||||
if (postToken != null) {
|
||||
WebSessionStorage.write(postTokenKey, postToken);
|
||||
}
|
||||
if (preToken != null) {
|
||||
WebSessionStorage.write(preTokenKey, preToken);
|
||||
}
|
||||
} else {
|
||||
if (postToken != null) await _secureStorage.write(key: postTokenKey, value: postToken);
|
||||
if (preToken != null) await _secureStorage.write(key: preTokenKey, value: preToken);
|
||||
if (postToken != null) {
|
||||
await _secureStorage.write(key: postTokenKey, value: postToken);
|
||||
}
|
||||
if (preToken != null) {
|
||||
await _secureStorage.write(key: preTokenKey, value: preToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String?> getPostToken() async {
|
||||
if (kIsWeb) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final token = prefs.getString(postTokenKey);
|
||||
print('Web getPostToken: $token');
|
||||
return token;
|
||||
} else {
|
||||
return _secureStorage.read(key: postTokenKey);
|
||||
return WebSessionStorage.read(postTokenKey);
|
||||
}
|
||||
return _secureStorage.read(key: postTokenKey);
|
||||
}
|
||||
|
||||
static Future<String?> getPreToken() async {
|
||||
if (kIsWeb) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final token = prefs.getString(preTokenKey);
|
||||
print('Web getPreToken: $token');
|
||||
return token;
|
||||
} else {
|
||||
return _secureStorage.read(key: preTokenKey);
|
||||
return WebSessionStorage.read(preTokenKey);
|
||||
}
|
||||
return _secureStorage.read(key: preTokenKey);
|
||||
}
|
||||
|
||||
/// Clears auth tokens. On web, clears entire [sessionStorage] (logout / session end).
|
||||
static Future<void> clearTokens() async {
|
||||
if (kIsWeb) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove(postTokenKey);
|
||||
await prefs.remove(preTokenKey);
|
||||
WebSessionStorage.clearAll();
|
||||
} else {
|
||||
await _secureStorage.delete(key: postTokenKey);
|
||||
await _secureStorage.delete(key: preTokenKey);
|
||||
@ -64,38 +64,39 @@ class TokenService {
|
||||
}
|
||||
|
||||
static Future<bool> hasValidToken() async {
|
||||
print('hasToken123');
|
||||
final post = await getPostToken();
|
||||
final pre = await getPreToken();
|
||||
print('hasToken');
|
||||
print('postToken: $post, preToken: $pre');
|
||||
return (post != null && post.isNotEmpty) ||
|
||||
(pre != null && pre.isNotEmpty);
|
||||
}
|
||||
|
||||
return (post != null && post.isNotEmpty) || (pre != null && pre.isNotEmpty);
|
||||
/// Clears auth tokens that older web builds stored in SharedPreferences (localStorage).
|
||||
/// Call once at startup so they cannot be mistaken for a valid session.
|
||||
static Future<void> clearLegacyWebAuthFromSharedPreferences() async {
|
||||
if (!kIsWeb) return;
|
||||
final p = await SharedPreferences.getInstance();
|
||||
await p.remove(postTokenKey);
|
||||
await p.remove(preTokenKey);
|
||||
}
|
||||
|
||||
Future<String?> checkLoginPin() async {
|
||||
print('checkLoginPin');
|
||||
try {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final empMobileNo = prefs.getString('empMobileNo');
|
||||
final empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo $empMobileNo');
|
||||
print('empEmailid $empEmailid');
|
||||
|
||||
var params = {};
|
||||
var params = <String, dynamic>{};
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
params = {'mobile_number': empMobileNo};
|
||||
} else if (empEmailid != null && empEmailid.isNotEmpty) {
|
||||
params = {'email_id': empEmailid};
|
||||
}
|
||||
|
||||
print('params $params');
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrlEnrollment + 'checkMpin'),
|
||||
body: json.encode(params),
|
||||
headers: {
|
||||
HttpHeaders.contentTypeHeader: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||
},
|
||||
);
|
||||
@ -111,7 +112,8 @@ class TokenService {
|
||||
prefs.setString('mpin', data['Mpin']);
|
||||
}
|
||||
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']);
|
||||
@ -119,78 +121,45 @@ class TokenService {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('❌ API failed: ${response.statusCode}');
|
||||
logDebug('checkLoginPin API failed: ${response.statusCode}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ Error: $e');
|
||||
logDebug('checkLoginPin error: $e');
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
// if (isMobilePlatform()) {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// Get the value of the mobile_number key
|
||||
|
||||
String? mobileNumber = prefs.getString('empMobileNo');
|
||||
String? mailID = prefs.getString('empEmailid');
|
||||
final isMpinSkipped = await checkLoginPin();
|
||||
print('isMpinSkipped $isMpinSkipped');
|
||||
// bool? biometricStatus = prefs.getBool('biometricStatus') ?? false;
|
||||
// int? skipStatus = prefs.getInt('skipStatus') ?? 1;
|
||||
logDebug('isMpinSkipped $isMpinSkipped');
|
||||
|
||||
// Clear all keys
|
||||
await SessionManager().clear();
|
||||
// await prefs.clear();
|
||||
print('Local Storage Clear');
|
||||
|
||||
// html.window.localStorage.clear();
|
||||
// Re-set the mobile_number key
|
||||
if (isMobilePlatform()) {
|
||||
if (mobileNumber != null) {
|
||||
await prefs.setString('empMobileNo', mobileNumber);
|
||||
print('empMobileNo $mobileNumber');
|
||||
// await prefs.setBool('biometricStatus', biometricStatus!);
|
||||
// await prefs.setInt('skipStatus', skipStatus!);
|
||||
}
|
||||
if (mailID != null) {
|
||||
await prefs.setString('empEmailid', mailID);
|
||||
print('empEmailid $mailID');
|
||||
// await prefs.setBool('biometricStatus', biometricStatus!);
|
||||
// await prefs.setInt('skipStatus', skipStatus!);
|
||||
}
|
||||
if (isMpinSkipped != null) {
|
||||
await prefs.setString('is_mpin_skipped', isMpinSkipped!);
|
||||
print('isMpinSkipped $isMpinSkipped');
|
||||
await prefs.setString('is_mpin_skipped', isMpinSkipped);
|
||||
}
|
||||
if (isMpinSkipped != null && isMpinSkipped == '0') {
|
||||
print('pinPage');
|
||||
// return;
|
||||
context.go('/pinPage');
|
||||
} else {
|
||||
print('login');
|
||||
context.go('/login');
|
||||
}
|
||||
} else {
|
||||
await prefs.clear();
|
||||
ToastHelper.showSuccessToast(context, 'logout');
|
||||
// Navigate to login page
|
||||
context.go('/login');
|
||||
}
|
||||
|
||||
|
||||
// } else {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.clear();
|
||||
// Navigator.pushNamed(context, 'login');
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class AppVersionService {
|
||||
/// ✅ Get installed app version (Android + iOS)
|
||||
static Future<String> getInstalledVersion() async {
|
||||
@ -30,33 +32,33 @@ class AppVersionService {
|
||||
/// ✅ Get Play Store version (Android)
|
||||
/// NOTE: Play Store has no official API. This scrapes the HTML page.
|
||||
static Future<String?> getPlayStoreVersion(String packageName) async {
|
||||
print(Platform.isAndroid);
|
||||
logDebug(Platform.isAndroid);
|
||||
try {
|
||||
print('Platform.isAndroid');
|
||||
logDebug('Platform.isAndroid');
|
||||
final url = Uri.parse(
|
||||
"https://play.google.com/store/apps/details?id=$packageName&hl=en&gl=US",
|
||||
);
|
||||
print(url);
|
||||
logDebug(url);
|
||||
final response = await http.get(url);
|
||||
print('Get Version Response $response');
|
||||
logDebug('Get Version Response $response');
|
||||
if (response.statusCode == 200) {
|
||||
final html = response.body;
|
||||
print('Get Version Response $html');
|
||||
logDebug('Get Version Response $html');
|
||||
// Android version usually appears near: "Current Version"
|
||||
final versionRegEx = RegExp(
|
||||
r'Current Version.*?<\/span><span[^>]*>(.*?)<\/span>',
|
||||
caseSensitive: false,
|
||||
dotAll: true,
|
||||
);
|
||||
print('versionRegEx $versionRegEx');
|
||||
logDebug('versionRegEx $versionRegEx');
|
||||
final match = versionRegEx.firstMatch(html);
|
||||
print('match $match');
|
||||
logDebug('match $match');
|
||||
if (match != null) {
|
||||
return match.group(1)?.trim();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint("Play Store error: $e");
|
||||
logDebug("Play Store error: $e");
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -71,7 +73,7 @@ class AppVersionService {
|
||||
if (kIsWeb) return null;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
print('Platform.isAndroid');
|
||||
logDebug('Platform.isAndroid');
|
||||
return await getPlayStoreVersion(androidPackage);
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
|
||||
import '../postEnrollment/service/api_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class DataManager extends ChangeNotifier {
|
||||
static final DataManager _instance = DataManager._internal();
|
||||
@ -52,7 +53,7 @@ class DataManager extends ChangeNotifier {
|
||||
_advertisementImages = await List<String>.from(response['data']);
|
||||
_adsLoaded = true;
|
||||
notifyListeners();
|
||||
debugPrint("✅ Advertisement images loaded: $_advertisementImages");
|
||||
logDebug("✅ Advertisement images loaded: $_advertisementImages");
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,9 +82,9 @@ class DataManager extends ChangeNotifier {
|
||||
_prePolicyCount = response['pre_policy_count'] ?? 0;
|
||||
_policyLoaded = true;
|
||||
notifyListeners();
|
||||
debugPrint("✅ Policy list loaded: $_policyList");
|
||||
logDebug("✅ Policy list loaded: $_policyList");
|
||||
} else {
|
||||
debugPrint("❌ Failed to load policies: ${response['status']}");
|
||||
logDebug("❌ Failed to load policies: ${response['status']}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,9 +116,9 @@ class DataManager extends ChangeNotifier {
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
debugPrint("✅ Self Employee Profile loaded: $_selfProfile");
|
||||
logDebug("✅ Self Employee Profile loaded: $_selfProfile");
|
||||
} else {
|
||||
debugPrint("❌ Failed to load self profile: ${response['status']}");
|
||||
logDebug("❌ Failed to load self profile: ${response['status']}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,11 +171,11 @@ class DataManager extends ChangeNotifier {
|
||||
// final response = await _apiService.getAdvertisementImageToApi();
|
||||
// if (response['status'] == 'success') {
|
||||
// _advertisementImages = List<String>.from(response['data']);
|
||||
// debugPrint("✅ Advertisement images loaded: ${_advertisementImages}");
|
||||
// logDebug("✅ Advertisement images loaded: ${_advertisementImages}");
|
||||
// _isLoaded = true;
|
||||
// notifyListeners();
|
||||
// } else {
|
||||
// debugPrint("❌ Failed to load advertisement images: ${response['message']}");
|
||||
// logDebug("❌ Failed to load advertisement images: ${response['message']}");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
@ -5,6 +5,8 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../customAppBar/toastHelper.dart';
|
||||
import '../postEnrollment/service/api_service.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class PopupHelper {
|
||||
/// 🔹 Launch URL safely
|
||||
static Future<void> launchURL(String url, BuildContext context) async {
|
||||
@ -30,7 +32,7 @@ class PopupHelper {
|
||||
// 🔹 Fetch link using API
|
||||
final response = await apiService.getWellnessLink(empPrimaryId,'');
|
||||
|
||||
print('Wellness response : $response');
|
||||
logDebug('Wellness response : $response');
|
||||
|
||||
if (response['status'] == 'success') {
|
||||
wellnessURL = response['data'];
|
||||
|
||||
@ -3,6 +3,8 @@ library ribbon;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
const TextStyle _kTextStyle = TextStyle(
|
||||
color: Color(0xFFFFFFFF),
|
||||
fontSize: 12,
|
||||
@ -277,7 +279,7 @@ class _RibbonPainter extends CustomPainter {
|
||||
path.close();
|
||||
List<Offset> vec2 = vec.toSet().toList();
|
||||
offsetRibbon = _center(vec2);
|
||||
// print('cx = ${offsetRibbon.dx},cy = ${offsetRibbon.dy}');
|
||||
// logDebug('cx = ${offsetRibbon.dx},cy = ${offsetRibbon.dy}');
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
15
lib/pages/service/web_session_storage.dart
Normal file
15
lib/pages/service/web_session_storage.dart
Normal file
@ -0,0 +1,15 @@
|
||||
import 'web_session_storage_stub.dart'
|
||||
if (dart.library.html) 'web_session_storage_html.dart';
|
||||
|
||||
/// Web-only session storage API (backed by `window.sessionStorage`).
|
||||
/// On mobile/desktop native this is a no-op; use [TokenService] paths instead.
|
||||
class WebSessionStorage {
|
||||
WebSessionStorage._();
|
||||
|
||||
static String? read(String key) => webSessionStorageRead(key);
|
||||
|
||||
static void write(String key, String? value) =>
|
||||
webSessionStorageWrite(key, value);
|
||||
|
||||
static void clearAll() => webSessionStorageClearAll();
|
||||
}
|
||||
16
lib/pages/service/web_session_storage_html.dart
Normal file
16
lib/pages/service/web_session_storage_html.dart
Normal file
@ -0,0 +1,16 @@
|
||||
import 'dart:html' as html;
|
||||
|
||||
/// Web: `sessionStorage` — cleared when the tab/window is closed; survives refresh.
|
||||
String? webSessionStorageRead(String key) => html.window.sessionStorage[key];
|
||||
|
||||
void webSessionStorageWrite(String key, String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
html.window.sessionStorage.remove(key);
|
||||
} else {
|
||||
html.window.sessionStorage[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void webSessionStorageClearAll() {
|
||||
html.window.sessionStorage.clear();
|
||||
}
|
||||
6
lib/pages/service/web_session_storage_stub.dart
Normal file
6
lib/pages/service/web_session_storage_stub.dart
Normal file
@ -0,0 +1,6 @@
|
||||
/// Non-web stub: session storage is not used (tokens use secure storage / prefs).
|
||||
String? webSessionStorageRead(String key) => null;
|
||||
|
||||
void webSessionStorageWrite(String key, String? value) {}
|
||||
|
||||
void webSessionStorageClearAll() {}
|
||||
@ -16,6 +16,8 @@
|
||||
import '../service/TokenService.dart';
|
||||
import 'authenticationService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class pinPage extends StatefulWidget {
|
||||
const pinPage({Key? key}) : super(key: key);
|
||||
|
||||
@ -71,13 +73,13 @@
|
||||
}
|
||||
|
||||
Future<void> checkLoginPin(BuildContext context) async {
|
||||
print('checkLoginPin');
|
||||
logDebug('checkLoginPin');
|
||||
try {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empMobileNo = prefs.getString('empMobileNo');
|
||||
empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo $empMobileNo');
|
||||
print('empEmailid $empEmailid');
|
||||
logDebug('empMobileNo $empMobileNo');
|
||||
logDebug('empEmailid $empEmailid');
|
||||
// _preToken = prefs.getString('token');
|
||||
var params = {};
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
@ -96,10 +98,10 @@
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print('checkLoginPin response');
|
||||
logDebug('checkLoginPin response');
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
if (data['status'] == 'success') {
|
||||
print('checkLoginPin success');
|
||||
logDebug('checkLoginPin success');
|
||||
if (data['data'] != null) {
|
||||
prefs.setString('mpinText', data['data']);
|
||||
}
|
||||
@ -118,13 +120,13 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('checkLoginPin Something went wrong');
|
||||
logDebug('checkLoginPin Something went wrong');
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
throw Exception('Failed to verify pin number');
|
||||
}
|
||||
} catch (e) {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,8 +136,8 @@
|
||||
bioMetricMpin = prefs.getString('mpin');
|
||||
biometricStatus = prefs.getString('is_biometric_enabled');
|
||||
isMpinSkippedStatus = prefs.getString('is_mpin_skipped');
|
||||
print('biometricStatus');
|
||||
print(biometricStatus);
|
||||
logDebug('biometricStatus');
|
||||
logDebug(biometricStatus);
|
||||
|
||||
if(biometricStatus == '1' && !_isVerifyingPin && !_isPinVerified) {
|
||||
bool authenticated = await _authService.authenticateWithBiometrics();
|
||||
@ -149,7 +151,7 @@
|
||||
}
|
||||
|
||||
Future<void> enterPinApi(mpin) async {
|
||||
print('mpin $mpin');
|
||||
logDebug('mpin $mpin');
|
||||
try {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empMobileNo = prefs.getString('empMobileNo');
|
||||
@ -158,10 +160,10 @@
|
||||
if(mpin != null && mpin.isNotEmpty){
|
||||
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
print('mpin empMobileNo');
|
||||
logDebug('mpin empMobileNo');
|
||||
params = {'mobile_number': empMobileNo, 'mpin': mpin};
|
||||
} else if(empEmailid != null && empEmailid.isNotEmpty){
|
||||
print('mpin empEmailid');
|
||||
logDebug('mpin empEmailid');
|
||||
params = {'email_id': empEmailid, 'mpin': mpin};
|
||||
}
|
||||
} else {
|
||||
@ -185,19 +187,19 @@
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
print('data: $data');
|
||||
logDebug('data: $data');
|
||||
_token = data['data'];
|
||||
String status = data['status'];
|
||||
|
||||
// Directly access the post_enrollment data
|
||||
Map<String, dynamic> post = data['post_enrollment'];
|
||||
print('post: $post');
|
||||
logDebug('post: $post');
|
||||
_postToken = post['data'];
|
||||
String postStatus = post['status'];
|
||||
|
||||
// Save tokens
|
||||
await TokenService.saveTokens(preToken: _token, postToken: _postToken);
|
||||
print('Tokens saved → preToken: $_token, postToken: $_postToken');
|
||||
logDebug('Tokens saved → preToken: $_token, postToken: $_postToken');
|
||||
|
||||
if (postStatus == 'success') {
|
||||
postSuccessData(post, data);
|
||||
@ -205,7 +207,7 @@
|
||||
enrollmentSuccessData(data);
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, 'Invalid Pin Number');
|
||||
print('Invalid Pin Number');
|
||||
logDebug('Invalid Pin Number');
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
await SessionManager().clear();
|
||||
@ -233,7 +235,7 @@
|
||||
} catch (e) {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
context.go('/login');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +252,7 @@
|
||||
session = await SessionManager();
|
||||
// Decode the JWT token received from the API response
|
||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
||||
// print('postdecodedToken : $decodedToken');
|
||||
// logDebug('postdecodedToken : $decodedToken');
|
||||
// empClientBranchId = decodedToken['client_branch_id'];
|
||||
// prefs.setString('empClientBranchId', empClientBranchId);
|
||||
// empCodeString = decodedToken['emp_code'].toString();
|
||||
@ -265,7 +267,7 @@
|
||||
// prefs.setString('emp_status', emp_status);
|
||||
// getClientLogoAndDetails();
|
||||
|
||||
print('Successfully Login');
|
||||
logDebug('Successfully Login');
|
||||
|
||||
// Redirect to another page
|
||||
}
|
||||
@ -276,7 +278,7 @@
|
||||
await SessionManager().initializeFromPreToken(data['data']);
|
||||
// // Decode the JWT token received from the API response
|
||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
// print('enrolldecodedToken : $decodedToken');
|
||||
// logDebug('enrolldecodedToken : $decodedToken');
|
||||
// enrollmentEmpClientBranchId = decodedToken['client_branch_id'];
|
||||
// prefs.setString(
|
||||
// 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
@ -295,7 +297,7 @@
|
||||
|
||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
print(_postToken);
|
||||
logDebug(_postToken);
|
||||
if (_postToken != null && _postToken.isNotEmpty) {
|
||||
setState(() {
|
||||
_isPinVerified = true; // 🔒 HARD LOCK
|
||||
@ -304,8 +306,8 @@
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Logged In');
|
||||
// if (enrollmentEmp_status == 'enrolled' ||
|
||||
// enrollmentEmp_status == 'active') {
|
||||
print('Token12345: ${await TokenService.getPostToken()}');
|
||||
print('Token00000');
|
||||
logDebug('Token12345: ${await TokenService.getPostToken()}');
|
||||
logDebug('Token00000');
|
||||
// if (context.mounted) {
|
||||
context.go('/home');
|
||||
// }
|
||||
@ -323,7 +325,7 @@
|
||||
|
||||
// // Decode the JWT token received from the API response
|
||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
// print('decodedToken : $decodedToken');
|
||||
// logDebug('decodedToken : $decodedToken');
|
||||
// enrollmentEmpClientBranchId = decodedToken['client_branch_id'];
|
||||
// prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
// enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
||||
@ -338,7 +340,7 @@
|
||||
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||
getClientLogoAndDetails();
|
||||
|
||||
print('Successfully Login');
|
||||
logDebug('Successfully Login');
|
||||
|
||||
// Redirect to another page
|
||||
final token = await TokenService.getPreToken();
|
||||
@ -369,7 +371,7 @@
|
||||
await enterPinApi(_pinController.text);
|
||||
} catch (e) {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -402,8 +404,8 @@
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empMobileNo = prefs.getString('empMobileNo');
|
||||
empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo $empMobileNo' );
|
||||
print('empEmailid $empEmailid');
|
||||
logDebug('empMobileNo $empMobileNo' );
|
||||
logDebug('empEmailid $empEmailid');
|
||||
// _token = prefs.getString('token');
|
||||
var params = {};
|
||||
if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
@ -411,7 +413,7 @@
|
||||
} else if(empEmailid != null && empEmailid.isNotEmpty){
|
||||
params = {'email_id': empEmailid};
|
||||
}
|
||||
print(params);
|
||||
logDebug(params);
|
||||
final response = await http.post(
|
||||
Uri.parse(Environment.apiUrlEnrollment + 'forgotMPIN'),
|
||||
body: json.encode(params),
|
||||
@ -433,7 +435,7 @@
|
||||
// await SessionManager().mobileSessionClear();
|
||||
context.go('/login');
|
||||
// Navigator.pushNamed(context, 'login');
|
||||
// print('data');
|
||||
// logDebug('data');
|
||||
// prefs.setString('mpinText', data['data']);
|
||||
// prefs.setString('mpin', data['Mpin']);
|
||||
// prefs.setString('is_biometric_enabled', data['is_biometric_enabled']);
|
||||
@ -468,7 +470,7 @@
|
||||
}
|
||||
} catch (e) {
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -494,9 +496,9 @@
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
// print('response.statusCode == 200');
|
||||
// logDebug('response.statusCode == 200');
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
// print(data);
|
||||
// logDebug(data);
|
||||
|
||||
if (data.containsKey('data')) {
|
||||
dynamic clientDetails = data['data'];
|
||||
@ -505,18 +507,18 @@
|
||||
prefs.setString('clientName', clientDetails['client']['client_name']);
|
||||
setState(() {
|
||||
clientName = clientDetails['client']['client_name'];
|
||||
print(clientName);
|
||||
logDebug(clientName);
|
||||
clientLogo = clientDetails['client']['client_logo'];
|
||||
print(clientLogo);
|
||||
logDebug(clientLogo);
|
||||
});
|
||||
} else {
|
||||
print('API request failed with status: ${data['status']}');
|
||||
logDebug('API request failed with status: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
print('Request failed with status: ${response.statusCode}');
|
||||
logDebug('Request failed with status: ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception occurred: $e');
|
||||
logDebug('Exception occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@ -765,11 +767,11 @@
|
||||
HapticFeedbackType
|
||||
.lightImpact,
|
||||
onCompleted: (pin) {
|
||||
debugPrint(
|
||||
logDebug(
|
||||
'onCompleted: $pin');
|
||||
},
|
||||
onChanged: (value) {
|
||||
debugPrint(
|
||||
logDebug(
|
||||
'onChanged: $value');
|
||||
},
|
||||
cursor: Column(
|
||||
|
||||
@ -15,6 +15,8 @@ import '../postEnrollment/service/svg_service.dart';
|
||||
import '../service/SessionManager.dart';
|
||||
import 'authenticationService.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class changePin extends StatefulWidget {
|
||||
const changePin({Key? key}) : super(key: key);
|
||||
|
||||
@ -47,8 +49,8 @@ class _changePinState extends State<changePin> {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empMobileNo = prefs.getString('empMobileNo');
|
||||
empEmailid = prefs.getString('empEmailid');
|
||||
print('empMobileNo: $empMobileNo');
|
||||
print('empEmailid: $empEmailid');
|
||||
logDebug('empMobileNo: $empMobileNo');
|
||||
logDebug('empEmailid: $empEmailid');
|
||||
}
|
||||
|
||||
@override
|
||||
@ -69,7 +71,7 @@ class _changePinState extends State<changePin> {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
_token = await TokenService.getPostToken();
|
||||
print(_token);
|
||||
logDebug(_token);
|
||||
// empMobileNo = prefs.getString('empMobileNo');
|
||||
// empEmailid = 'surendar.m@venbainfotech.com';
|
||||
var params = {};
|
||||
@ -93,7 +95,7 @@ class _changePinState extends State<changePin> {
|
||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||
},
|
||||
);
|
||||
print('response $response');
|
||||
logDebug('response $response');
|
||||
if (response.statusCode == 200) {
|
||||
Map<String, dynamic> data = json.decode(response.body);
|
||||
bool pinVerification = data['data']['mpin_verification'];
|
||||
@ -106,7 +108,7 @@ class _changePinState extends State<changePin> {
|
||||
context.go('/profile');
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, message);
|
||||
print('Invalid Pin Number');
|
||||
logDebug('Invalid Pin Number');
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
await SessionManager().clear();
|
||||
@ -134,7 +136,7 @@ class _changePinState extends State<changePin> {
|
||||
}
|
||||
} catch (e) {
|
||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -401,11 +403,11 @@ class _changePinState extends State<changePin> {
|
||||
HapticFeedbackType
|
||||
.lightImpact,
|
||||
onCompleted: (pin) {
|
||||
debugPrint(
|
||||
logDebug(
|
||||
'onCompleted: $pin');
|
||||
},
|
||||
onChanged: (value) {
|
||||
debugPrint(
|
||||
logDebug(
|
||||
'onChanged: $value');
|
||||
},
|
||||
cursor: Column(
|
||||
@ -505,11 +507,11 @@ class _changePinState extends State<changePin> {
|
||||
HapticFeedbackType
|
||||
.lightImpact,
|
||||
onCompleted: (pin) {
|
||||
debugPrint(
|
||||
logDebug(
|
||||
'onCompleted: $pin');
|
||||
},
|
||||
onChanged: (value) {
|
||||
debugPrint(
|
||||
logDebug(
|
||||
'onChanged: $value');
|
||||
},
|
||||
cursor: Column(
|
||||
|
||||
@ -14,6 +14,8 @@ import '../config/environment.dart';
|
||||
import '../customAppBar/responsive.dart';
|
||||
import '../customAppBar/toastHelper.dart';
|
||||
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
|
||||
class setPassword extends StatefulWidget {
|
||||
final String email;
|
||||
final String client_id;
|
||||
@ -116,7 +118,7 @@ class _setPasswordState extends State<setPassword> {
|
||||
_isLoading = false;
|
||||
});
|
||||
ToastHelper.showErrorToast(context, message!);
|
||||
print('Invalid mobile number');
|
||||
logDebug('Invalid mobile number');
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
setState(() {
|
||||
@ -162,7 +164,7 @@ class _setPasswordState extends State<setPassword> {
|
||||
_isLoading = false;
|
||||
});
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
print('Error: $e');
|
||||
logDebug('Error: $e');
|
||||
}
|
||||
|
||||
// 🔹 Password validation
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import 'package:nhance_app_pwa/logger.dart';
|
||||
// import 'package:firebase_auth/firebase_auth.dart';
|
||||
// import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
// import 'package:flutter/foundation.dart';
|
||||
@ -95,8 +96,8 @@
|
||||
// // checkTokenAvailability();
|
||||
// verificationId = widget.verificationId;
|
||||
// mobileNumber = widget.mobileNumber;
|
||||
// print('Received verificationId: $verificationId');
|
||||
// print('Received mobileNumber: $mobileNumber');
|
||||
// logDebug('Received verificationId: $verificationId');
|
||||
// logDebug('Received mobileNumber: $mobileNumber');
|
||||
// if (verificationId.isEmpty) {
|
||||
// // Handle the case where verificationId is not provided
|
||||
// // Navigator.pop(context);
|
||||
@ -114,7 +115,7 @@
|
||||
//
|
||||
// void logOutFirebase() async {
|
||||
// await _auth.signOut();
|
||||
// print('User signed out');
|
||||
// logDebug('User signed out');
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
@ -133,18 +134,18 @@
|
||||
// badge: true,
|
||||
// sound: true,
|
||||
// );
|
||||
// print('🔔 Permission: ${settings.authorizationStatus}');
|
||||
// logDebug('🔔 Permission: ${settings.authorizationStatus}');
|
||||
//
|
||||
// if (Platform.isIOS || Platform.isMacOS) {
|
||||
// // Get APNS token
|
||||
// apnsToken = await _firebaseMessaging.getAPNSToken();
|
||||
// print('📱 APNS Token (iOS): $apnsToken');
|
||||
// logDebug('📱 APNS Token (iOS): $apnsToken');
|
||||
//
|
||||
// // Retry if null
|
||||
// if (apnsToken == null) {
|
||||
// await Future.delayed(const Duration(seconds: 3));
|
||||
// apnsToken = await _firebaseMessaging.getAPNSToken();
|
||||
// print('🔁 Retried APNS Token: $apnsToken');
|
||||
// logDebug('🔁 Retried APNS Token: $apnsToken');
|
||||
// }
|
||||
//
|
||||
// if (apnsToken != null) {
|
||||
@ -153,7 +154,7 @@
|
||||
// } else if (Platform.isAndroid) {
|
||||
// // Get FCM token
|
||||
// fcmToken = await _firebaseMessaging.getToken();
|
||||
// print('🔥 FCM Token (Android): $fcmToken');
|
||||
// logDebug('🔥 FCM Token (Android): $fcmToken');
|
||||
//
|
||||
// if (fcmToken != null) {
|
||||
// await sendDeviceToken(fcmToken!);
|
||||
@ -165,13 +166,13 @@
|
||||
//
|
||||
// // Foreground listener
|
||||
// FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
// print('💬 Message: ${message.notification?.title}');
|
||||
// logDebug('💬 Message: ${message.notification?.title}');
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(content: Text(message.notification?.title ?? 'New Notification')),
|
||||
// );
|
||||
// });
|
||||
// } catch (e) {
|
||||
// print('❌ Notification init error: $e');
|
||||
// logDebug('❌ Notification init error: $e');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@ -179,20 +180,20 @@
|
||||
// // try {
|
||||
// // // await _firebaseMessaging.requestPermission();
|
||||
// // fCMToken = await FirebaseMessaging.instance.getToken();
|
||||
// // print('Token : $fCMToken');
|
||||
// // logDebug('Token : $fCMToken');
|
||||
// //
|
||||
// // if (fCMToken != null) {
|
||||
// // await sendDeviceToken(fCMToken);
|
||||
// // }
|
||||
// // } catch (e) {
|
||||
// // print("Error getting FCM Token: $e");
|
||||
// // logDebug("Error getting FCM Token: $e");
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// // Future<void> handleBackgroundMessage(RemoteMessage message) async {
|
||||
// // print('Title ${message.notification?.title}');
|
||||
// // print('Body ${message.notification?.body}');
|
||||
// // print('Playload ${message.data}');
|
||||
// // logDebug('Title ${message.notification?.title}');
|
||||
// // logDebug('Body ${message.notification?.body}');
|
||||
// // logDebug('Playload ${message.data}');
|
||||
// // }
|
||||
//
|
||||
// Future<void> sendDeviceToken(deviceToken) async {
|
||||
@ -211,19 +212,19 @@
|
||||
//
|
||||
// if (response.statusCode == 200) {
|
||||
// Map<String, dynamic> data = json.decode(response.body);
|
||||
// print('data: $data');
|
||||
// logDebug('data: $data');
|
||||
// String status = data['status'];
|
||||
// print(status);
|
||||
// logDebug(status);
|
||||
// if (status == 'success') {
|
||||
// print('Token Store Successfully');
|
||||
// logDebug('Token Store Successfully');
|
||||
// } else {
|
||||
// print('Please try again');
|
||||
// logDebug('Please try again');
|
||||
// }
|
||||
// } else {
|
||||
// throw Exception('Failed to store');
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print('Error: $e');
|
||||
// logDebug('Error: $e');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@ -259,7 +260,7 @@
|
||||
// _isLoading = false;
|
||||
// });
|
||||
// Map<String, dynamic> data = json.decode(response.body);
|
||||
// print('data: $data');
|
||||
// logDebug('data: $data');
|
||||
//
|
||||
// // --- Extract tokens safely ---
|
||||
// String? preToken;
|
||||
@ -274,14 +275,14 @@
|
||||
//
|
||||
// // Save tokens
|
||||
// await TokenService.saveTokens(preToken: preToken, postToken: postToken);
|
||||
// print('Tokens saved → preToken: $preToken, postToken: $postToken');
|
||||
// logDebug('Tokens saved → preToken: $preToken, postToken: $postToken');
|
||||
//
|
||||
// _preToken = preToken;
|
||||
// String status = data['status'];
|
||||
//
|
||||
// // Directly access the post_enrollment data
|
||||
// Map<String, dynamic> post = data['post_enrollment'];
|
||||
// print('post: $post');
|
||||
// logDebug('post: $post');
|
||||
//
|
||||
// _postToken = postToken;
|
||||
// String postStatus = post['status'];
|
||||
@ -304,7 +305,7 @@
|
||||
// prefs.clear();
|
||||
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
||||
// // Show a Snackbar if the OTP is invalid
|
||||
// print('Invalid OTP. Please try again');
|
||||
// logDebug('Invalid OTP. Please try again');
|
||||
// }
|
||||
// } else {
|
||||
// setState(() {
|
||||
@ -319,12 +320,12 @@
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
// print('Error: $e');
|
||||
// logDebug('Error: $e');
|
||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// prefs.clear();
|
||||
// ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||
// // Show a Snackbar if there's an error while verifying OTP
|
||||
// print('Failed to verify OTP. Please try again.');
|
||||
// logDebug('Failed to verify OTP. Please try again.');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@ -342,7 +343,7 @@
|
||||
// 'client_id': client_id,
|
||||
// 'empClientBranchId': empClientBranchId,
|
||||
// });
|
||||
// print('Successfully Login');
|
||||
// logDebug('Successfully Login');
|
||||
// }
|
||||
//
|
||||
// void postSuccessData(post, data) async {
|
||||
@ -357,7 +358,7 @@
|
||||
// session = await SessionManager();
|
||||
// // // Decode the JWT token received from the API response
|
||||
// // Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
||||
// // print('decodedToken : $decodedToken');
|
||||
// // logDebug('decodedToken : $decodedToken');
|
||||
// // empClientBranchId = decodedToken['client_branch_id'];
|
||||
// // prefs.setString('empClientBranchId', empClientBranchId);
|
||||
// // empCodeString = decodedToken['emp_code'].toString();
|
||||
@ -393,9 +394,9 @@
|
||||
// // html.window.dispatchEvent(
|
||||
// // html.CustomEvent('userLoggedIn', detail: {'status': 'success'}));
|
||||
// //
|
||||
// // print("✅ User logged in! LocalStorage values set.");
|
||||
// // logDebug("✅ User logged in! LocalStorage values set.");
|
||||
// //
|
||||
// // print('Successfully Login');
|
||||
// // logDebug('Successfully Login');
|
||||
// // }
|
||||
//
|
||||
// // Redirect to another page
|
||||
@ -407,7 +408,7 @@
|
||||
// await SessionManager().initializeFromPreToken(data['data']);
|
||||
// // // Decode the JWT token received from the API response
|
||||
// // Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
// // print('decodedToken : $decodedToken');
|
||||
// // logDebug('decodedToken : $decodedToken');
|
||||
// // enrollmentEmpClientBranchId = decodedToken['client_branch_id'];
|
||||
// // prefs.setString(
|
||||
// // 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
@ -428,7 +429,7 @@
|
||||
// // final _postToken = prefs.getString('_postToken');
|
||||
// // int skipStatus = prefs.getInt('skipStatus') ?? 1;
|
||||
// // final mpinText = prefs.getString('mpinText');
|
||||
// // print(isMobilePlatform());
|
||||
// // logDebug(isMobilePlatform());
|
||||
// if (isMobilePlatform()) {
|
||||
// // if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') {
|
||||
// if (_postToken != null && _postToken.isNotEmpty) {
|
||||
@ -459,7 +460,7 @@
|
||||
//
|
||||
// // // Decode the JWT token received from the API response
|
||||
// // Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
// // print('decodedToken : $decodedToken');
|
||||
// // logDebug('decodedToken : $decodedToken');
|
||||
// // enrollmentEmpClientBranchId = decodedToken['client_branch_id'];
|
||||
// // prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
// // enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
||||
@ -474,13 +475,13 @@
|
||||
// // prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||
// getClientLogoAndDetails();
|
||||
//
|
||||
// print('Successfully Login');
|
||||
// logDebug('Successfully Login');
|
||||
//
|
||||
// // Redirect to another page
|
||||
// // final enrollToken = prefs.getString('enrollToken');
|
||||
// // int skipStatus = prefs.getInt('skipStatus') ?? 1;
|
||||
// // final mpinText = prefs.getString('mpinText');
|
||||
// print(isMobilePlatform());
|
||||
// logDebug(isMobilePlatform());
|
||||
// if (isMobilePlatform()) {
|
||||
// // if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') {
|
||||
// if (_preToken != null && _preToken.isNotEmpty) {
|
||||
@ -517,15 +518,15 @@
|
||||
// smsCode: otp,
|
||||
// );
|
||||
//
|
||||
// print('credential $credential');
|
||||
// logDebug('credential $credential');
|
||||
//
|
||||
// final userCredential =
|
||||
// await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
// // await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
// print('otp firebase check');
|
||||
// logDebug('otp firebase check');
|
||||
//
|
||||
// if (userCredential.user != null) {
|
||||
// print('otp firebase check done');
|
||||
// logDebug('otp firebase check done');
|
||||
// bool otpVerifyStatus = true;
|
||||
// generateToken(otpVerifyStatus);
|
||||
// } else {
|
||||
@ -584,7 +585,7 @@
|
||||
// // setState(() {
|
||||
// // _isLoading = false;
|
||||
// // });
|
||||
// print('Error: $e');
|
||||
// logDebug('Error: $e');
|
||||
// ToastHelper.showErrorToast(
|
||||
// context, 'Failed to verify OTP. Please try again.');
|
||||
// }
|
||||
@ -600,13 +601,13 @@
|
||||
// }
|
||||
//
|
||||
// Future<void> checkLoginPin(BuildContext context) async {
|
||||
// print('checkLoginPin');
|
||||
// logDebug('checkLoginPin');
|
||||
// try {
|
||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// empMobileNo = prefs.getString('empMobileNo');
|
||||
// empEmailid = prefs.getString('empEmailid');
|
||||
// print('empMobileNo $empMobileNo');
|
||||
// print('empEmailid $empEmailid');
|
||||
// logDebug('empMobileNo $empMobileNo');
|
||||
// logDebug('empEmailid $empEmailid');
|
||||
// // _preToken = prefs.getString('token');
|
||||
// var params = {};
|
||||
// if (empMobileNo != null && empMobileNo.isNotEmpty) {
|
||||
@ -624,10 +625,10 @@
|
||||
// );
|
||||
//
|
||||
// if (response.statusCode == 200) {
|
||||
// print('checkLoginPin $response');
|
||||
// logDebug('checkLoginPin $response');
|
||||
// Map<String, dynamic> data = json.decode(response.body);
|
||||
// if (data['status'] == 'success') {
|
||||
// print('checkLoginPin success');
|
||||
// logDebug('checkLoginPin success');
|
||||
// if (data['data'] != null) {
|
||||
// prefs.setString('mpinText', data['data']);
|
||||
// }
|
||||
@ -673,18 +674,18 @@
|
||||
// // Navigator.pushReplacementNamed(context, 'pinSettingPage');
|
||||
// }
|
||||
// } else {
|
||||
// print('checkLoginPin Something went wrong');
|
||||
// logDebug('checkLoginPin Something went wrong');
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
// throw Exception('Failed to verify pin number');
|
||||
// }
|
||||
// } catch (e) {
|
||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||
// print('Error: $e');
|
||||
// logDebug('Error: $e');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<void> getClientLogoAndDetails() async {
|
||||
// print('getClientLogoAndDetails');
|
||||
// logDebug('getClientLogoAndDetails');
|
||||
// var url = Uri.parse(Environment.apiUrlEnrollment + 'getClientDetails?post_client_id=${session.client_id}&post_branch_id=${session.empClientBranchId}&pre_client_id=${session.enrollmentClient_id}&pre_branch_id=${session.enrollmentEmpClientBranchId}');
|
||||
// try {
|
||||
// var response = await http.get(
|
||||
@ -695,9 +696,9 @@
|
||||
// },
|
||||
// );
|
||||
// if (response.statusCode == 200) {
|
||||
// // print('response.statusCode == 200');
|
||||
// // logDebug('response.statusCode == 200');
|
||||
// Map<String, dynamic> data = json.decode(response.body);
|
||||
// // print(data);
|
||||
// // logDebug(data);
|
||||
//
|
||||
// if (data.containsKey('data')) {
|
||||
// dynamic clientDetails = data['data'];
|
||||
@ -708,27 +709,27 @@
|
||||
// 'addon_subheading', clientDetails['client']['addon_subheading']);
|
||||
// setState(() {
|
||||
// // dynamic clientDetails = data['data'];
|
||||
// // print(clientDetails);
|
||||
// // logDebug(clientDetails);
|
||||
// clientName = clientDetails['client']['client_name'];
|
||||
// print(clientName);
|
||||
// logDebug(clientName);
|
||||
// clientLogo = clientDetails['client']['client_logo'];
|
||||
// print(clientLogo);
|
||||
// logDebug(clientLogo);
|
||||
// });
|
||||
// } else {
|
||||
// // Handle other status messages if needed
|
||||
// // ToastHelper.showErrorToast(
|
||||
// // context, 'API request failed with status: ${data['status']}');
|
||||
// print('API request failed with status: ${data['status']}');
|
||||
// logDebug('API request failed with status: ${data['status']}');
|
||||
// }
|
||||
// } else {
|
||||
// // Handle other status codes
|
||||
// // ToastHelper.showErrorToast(
|
||||
// // context, 'Request failed with status: ${response.statusCode}');
|
||||
// print('Request failed with status: ${response.statusCode}');
|
||||
// logDebug('Request failed with status: ${response.statusCode}');
|
||||
// }
|
||||
// } catch (e) {
|
||||
// // Handle exceptions
|
||||
// print('Exception occurred: $e');
|
||||
// logDebug('Exception occurred: $e');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@ -1278,8 +1279,8 @@
|
||||
// // ✅ Must be outside any class — this fixes your error
|
||||
// @pragma('vm:entry-point')
|
||||
// Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
// print('📨 Handling background message: ${message.messageId}');
|
||||
// print('Title: ${message.notification?.title}');
|
||||
// print('Body: ${message.notification?.body}');
|
||||
// print('Data: ${message.data}');
|
||||
// logDebug('📨 Handling background message: ${message.messageId}');
|
||||
// logDebug('Title: ${message.notification?.title}');
|
||||
// logDebug('Body: ${message.notification?.body}');
|
||||
// logDebug('Data: ${message.data}');
|
||||
// }
|
||||
|
||||
@ -16,9 +16,9 @@ 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.32+32
|
||||
version: 1.0.31+37
|
||||
#version: 2.0.19+57
|
||||
#version: 1.2.41+98
|
||||
version: 1.0.32+38
|
||||
#version: 2.0.20+58
|
||||
|
||||
environment:
|
||||
sdk: '>=3.3.3 <4.0.0'
|
||||
@ -66,6 +66,7 @@ dependencies:
|
||||
file_selector: ^1.0.3
|
||||
universal_html: ^2.2.4
|
||||
go_router: ^16.2.2
|
||||
flutter_riverpod: ^2.6.1
|
||||
flutter_secure_storage: ^9.2.4
|
||||
printing: ^5.14.2
|
||||
flutter_animate: ^4.5.2
|
||||
|
||||
298
web/index.html
298
web/index.html
@ -21,33 +21,6 @@
|
||||
<link rel="manifest" href="manifest.json">
|
||||
|
||||
<style>
|
||||
#botmanWidgetRoot {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#botmanWidgetRoot .desktop-closed-message-avatar{
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
body.show-botman #botmanWidgetRoot {
|
||||
display: block !important;
|
||||
}
|
||||
#botmanWidgetRoot > div{
|
||||
bottom: 80px !important;
|
||||
right: 10px !important;
|
||||
z-index: 9999 !important;
|
||||
min-width: 80px !important;
|
||||
min-height: 100px !important;
|
||||
}
|
||||
.content {
|
||||
width: 10%;
|
||||
height: 10vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@ -66,67 +39,18 @@ body.show-botman #botmanWidgetRoot {
|
||||
}
|
||||
|
||||
</style>
|
||||
<script>
|
||||
// This script runs before the Flutter app initializes.
|
||||
|
||||
// Check if the current URL has the unwanted fragment
|
||||
if (window.location.hash === '#login') {
|
||||
|
||||
// Construct the clean URL (origin + path)
|
||||
const cleanUrl = window.location.origin + window.location.pathname;
|
||||
|
||||
// Replace the current history state to clear the fragment and
|
||||
// immediately navigate to the target URL (https://app.nhanceindia.in/app)
|
||||
// without creating an extra history entry.
|
||||
window.location.replace(cleanUrl);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
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);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<!-- This script adds the flutter initialization JS code -->
|
||||
<script src="flutter.js" defer></script>
|
||||
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
|
||||
</head>
|
||||
<body style="overflow:hidden">
|
||||
<div id="loading_indicator" class="container overlay">
|
||||
<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"
|
||||
};
|
||||
|
||||
// Initialize Firebase
|
||||
const app = initializeApp(firebaseConfig);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', function(ev) {
|
||||
@ -151,227 +75,5 @@ body.show-botman #botmanWidgetRoot {
|
||||
};
|
||||
</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://app.nhanceindia.in/zenith/chat',
|
||||
frameEndpoint: 'https://app.nhanceindia.in/zenith/widget',
|
||||
title: "Ask ILA",
|
||||
introMessage: "",
|
||||
bubbleBackground: "#179a9f",
|
||||
mainColor: "#179a9f",
|
||||
bubbleAvatarUrl:"https://botman.io/img/logo.png",
|
||||
placeholderText: "Type your message here...",
|
||||
aboutText: "Press Enter to send the message",
|
||||
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 });
|
||||
});
|
||||
|
||||
// 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>
|
||||
Loading…
Reference in New Issue
Block a user