log clear
This commit is contained in:
parent
72b253918a
commit
9a3367e802
411
lib/addons.dart
411
lib/addons.dart
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,8 @@ class BranchCard extends StatelessWidget {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isSelected ? const Color(0xFF00999E) : const Color(0xFFF0F9F9),
|
color:
|
||||||
|
isSelected ? const Color(0xFF00999E) : const Color(0xFFF0F9F9),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: const Color(0xFF00999E),
|
color: const Color(0xFF00999E),
|
||||||
@ -44,8 +45,7 @@ class BranchCard extends StatelessWidget {
|
|||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color:
|
color: isSelected ? Colors.white : const Color(0xFF00999E),
|
||||||
isSelected ? Colors.white : const Color(0xFF00999E),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
@ -55,8 +55,7 @@ class BranchCard extends StatelessWidget {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color:
|
color: isSelected ? Colors.white70 : Colors.black87,
|
||||||
isSelected ? Colors.white70 : Colors.black87,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -164,8 +164,7 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemCount: branches.length,
|
itemCount: branches.length,
|
||||||
gridDelegate:
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: crossAxisCount,
|
crossAxisCount: crossAxisCount,
|
||||||
mainAxisExtent: 90, // 🔥 FIXED HEIGHT
|
mainAxisExtent: 90, // 🔥 FIXED HEIGHT
|
||||||
mainAxisSpacing: 15,
|
mainAxisSpacing: 15,
|
||||||
@ -176,8 +175,7 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
|||||||
return BranchCard(
|
return BranchCard(
|
||||||
clientName: branch['client_name'] ??
|
clientName: branch['client_name'] ??
|
||||||
'Unknown Client kjbgjsk jsdhbjbf sdjfjbds fdjsgjdbs gdsjbgjds',
|
'Unknown Client kjbgjsk jsdhbjbf sdjfjbds fdjsgjdbs gdsjbgjds',
|
||||||
branchName:
|
branchName: branch['branch_name'] ?? 'Unknown Branch',
|
||||||
branch['branch_name'] ?? 'Unknown Branch',
|
|
||||||
isSelected: selectedIndex == index,
|
isSelected: selectedIndex == index,
|
||||||
onTap: () => _selectBranch(index),
|
onTap: () => _selectBranch(index),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// lib/environment.dart
|
// lib/environment.dart
|
||||||
enum Flavor { dev, uat, prod, prod1}
|
enum Flavor { dev, uat, prod, prod1 }
|
||||||
|
|
||||||
class Environment {
|
class Environment {
|
||||||
static Flavor flavor = Flavor.dev; // overwritten by each main_*.dart
|
static Flavor flavor = Flavor.dev; // overwritten by each main_*.dart
|
||||||
@ -44,6 +44,7 @@ class Environment {
|
|||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getPageTitle(String? routeName) {
|
static String getPageTitle(String? routeName) {
|
||||||
String base = "Nhance HR";
|
String base = "Nhance HR";
|
||||||
if (isProd) base = "Nhance HR"; // You can differentiate names if needed
|
if (isProd) base = "Nhance HR"; // You can differentiate names if needed
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
import 'environment.dart';
|
import 'environment.dart';
|
||||||
|
|
||||||
@ -6,4 +5,3 @@ Future<void> main() async {
|
|||||||
Environment.flavor = Flavor.dev;
|
Environment.flavor = Flavor.dev;
|
||||||
await startApp();
|
await startApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
import 'environment.dart';
|
import 'environment.dart';
|
||||||
|
|
||||||
@ -7,4 +5,3 @@ Future<void> main() async {
|
|||||||
Environment.flavor = Flavor.prod;
|
Environment.flavor = Flavor.prod;
|
||||||
await startApp();
|
await startApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
import 'environment.dart';
|
import 'environment.dart';
|
||||||
|
|
||||||
@ -7,4 +5,3 @@ Future<void> main() async {
|
|||||||
Environment.flavor = Flavor.prod1;
|
Environment.flavor = Flavor.prod1;
|
||||||
await startApp();
|
await startApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
import 'environment.dart';
|
import 'environment.dart';
|
||||||
|
|
||||||
@ -7,4 +5,3 @@ Future<void> main() async {
|
|||||||
Environment.flavor = Flavor.uat;
|
Environment.flavor = Flavor.uat;
|
||||||
await startApp();
|
await startApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,6 @@ class BaseLayout extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
) );
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import 'package:nhancepolicy/responsive.dart';
|
|||||||
|
|
||||||
import '../service/api_service.dart';
|
import '../service/api_service.dart';
|
||||||
import '../service/token_storage_service.dart';
|
import '../service/token_storage_service.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||||
@override
|
@override
|
||||||
@ -37,12 +38,11 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
// final String? hrtoken = prefs.getString('_postToken');
|
// final String? hrtoken = prefs.getString('_postToken');
|
||||||
// final String? token = prefs.getString('enrollToken');
|
// final String? token = prefs.getString('enrollToken');
|
||||||
// prefs.clear();
|
// prefs.clear();
|
||||||
print('LocalStorage Cleared');
|
logDebug('LocalStorage Cleared');
|
||||||
apiService.logout();
|
apiService.logout();
|
||||||
// Navigator.pushNamed(context, 'hrLogin');
|
// Navigator.pushNamed(context, 'hrLogin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final sw = MediaQuery.of(context).size.width;
|
final sw = MediaQuery.of(context).size.width;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
|||||||
import 'package:nhancepolicy/responsive.dart';
|
import 'package:nhancepolicy/responsive.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:nhancepolicy/responsive.dart';
|
import 'package:nhancepolicy/responsive.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||||
@override
|
@override
|
||||||
@ -35,9 +36,9 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
showBackToHR = prefs.getBool('showBackToHR')!;
|
showBackToHR = prefs.getBool('showBackToHR')!;
|
||||||
// showBackToHR = (hrtoken != null && hrtoken.isNotEmpty) &&
|
// showBackToHR = (hrtoken != null && hrtoken.isNotEmpty) &&
|
||||||
// (token != null && token.isNotEmpty);
|
// (token != null && token.isNotEmpty);
|
||||||
// print((hrtoken != null && hrtoken.isNotEmpty));
|
// logDebug((hrtoken != null && hrtoken.isNotEmpty));
|
||||||
// print((token != null && token.isNotEmpty));
|
// logDebug((token != null && token.isNotEmpty));
|
||||||
// print('showBackToHR $showBackToHR');
|
// logDebug('showBackToHR $showBackToHR');
|
||||||
|
|
||||||
// hideInactiveStatus = token != null && token.isNotEmpty;
|
// hideInactiveStatus = token != null && token.isNotEmpty;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:flutter_svg/svg.dart';
|
|||||||
import 'package:nhancepolicy/service/api_service.dart';
|
import 'package:nhancepolicy/service/api_service.dart';
|
||||||
import 'package:nhancepolicy/service/svg_service.dart';
|
import 'package:nhancepolicy/service/svg_service.dart';
|
||||||
import 'package:nhancepolicy/service/token_storage_service.dart';
|
import 'package:nhancepolicy/service/token_storage_service.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class NhanceSideBar extends StatefulWidget {
|
class NhanceSideBar extends StatefulWidget {
|
||||||
const NhanceSideBar({super.key});
|
const NhanceSideBar({super.key});
|
||||||
@ -26,7 +27,6 @@ class _NhanceSideBarState extends State<NhanceSideBar> {
|
|||||||
List<int> postModules = [];
|
List<int> postModules = [];
|
||||||
List<int> enrollmentModules = [];
|
List<int> enrollmentModules = [];
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -35,31 +35,26 @@ class _NhanceSideBarState extends State<NhanceSideBar> {
|
|||||||
// _checkTokens();
|
// _checkTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _buildSideMenu() async {
|
Future<void> _buildSideMenu() async {
|
||||||
final enrollmentRaw =
|
final enrollmentRaw =
|
||||||
await tokenService.readValue('enrollmentAllowed_modules'); // "[1]"
|
await tokenService.readValue('enrollmentAllowed_modules'); // "[1]"
|
||||||
final postRaw =
|
final postRaw =
|
||||||
await tokenService.readValue('empAllowed_modules'); // "[2,3,4]"
|
await tokenService.readValue('empAllowed_modules'); // "[2,3,4]"
|
||||||
|
|
||||||
print('enrollmentRaw $enrollmentRaw');
|
logDebug('enrollmentRaw $enrollmentRaw');
|
||||||
print('postRaw $postRaw');
|
logDebug('postRaw $postRaw');
|
||||||
|
|
||||||
// ✅ Decode safely
|
// ✅ Decode safely
|
||||||
enrollmentModules =
|
enrollmentModules = enrollmentRaw != null && enrollmentRaw.isNotEmpty
|
||||||
enrollmentRaw != null && enrollmentRaw.isNotEmpty
|
|
||||||
? List<int>.from(jsonDecode(enrollmentRaw))
|
? List<int>.from(jsonDecode(enrollmentRaw))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
postModules =
|
postModules = postRaw != null && postRaw.isNotEmpty
|
||||||
postRaw != null && postRaw.isNotEmpty
|
|
||||||
? List<int>.from(jsonDecode(postRaw))
|
? List<int>.from(jsonDecode(postRaw))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
print('enrollmentModules $enrollmentModules');
|
logDebug('enrollmentModules $enrollmentModules');
|
||||||
print('postModules $postModules');
|
logDebug('postModules $postModules');
|
||||||
|
|
||||||
final List<Map<String, dynamic>> items = [];
|
final List<Map<String, dynamic>> items = [];
|
||||||
|
|
||||||
@ -95,13 +90,12 @@ class _NhanceSideBarState extends State<NhanceSideBar> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> logout(BuildContext context) async {
|
Future<void> logout(BuildContext context) async {
|
||||||
// final prefs = await SharedPreferences.getInstance();
|
// final prefs = await SharedPreferences.getInstance();
|
||||||
// final String? hrtoken = prefs.getString('_postToken');
|
// final String? hrtoken = prefs.getString('_postToken');
|
||||||
// final String? token = prefs.getString('enrollToken');
|
// final String? token = prefs.getString('enrollToken');
|
||||||
// prefs.clear();
|
// prefs.clear();
|
||||||
print('LocalStorage Cleared');
|
logDebug('LocalStorage Cleared');
|
||||||
apiService.logout();
|
apiService.logout();
|
||||||
// Navigator.pushNamed(context, 'hrLogin');
|
// Navigator.pushNamed(context, 'hrLogin');
|
||||||
}
|
}
|
||||||
@ -220,7 +214,7 @@ class _NhanceSideBarState extends State<NhanceSideBar> {
|
|||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
|
||||||
if(postModules.isNotEmpty && postModules.contains(5))
|
if (postModules.isNotEmpty && postModules.contains(5))
|
||||||
_SideItem(
|
_SideItem(
|
||||||
// icon: Icons.dashboard,
|
// icon: Icons.dashboard,
|
||||||
icon: SvgPicture.string(
|
icon: SvgPicture.string(
|
||||||
@ -260,7 +254,6 @@ class _NhanceSideBarState extends State<NhanceSideBar> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _SideItem extends StatelessWidget {
|
class _SideItem extends StatelessWidget {
|
||||||
// final IconData icon;
|
// final IconData icon;
|
||||||
final Widget icon; // 👈 changed
|
final Widget icon; // 👈 changed
|
||||||
@ -308,5 +301,3 @@ class _SideItem extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
// import 'package:fluttertoast/fluttertoast.dart';
|
// import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:toastification/toastification.dart';
|
import 'package:toastification/toastification.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class ToastHelper {
|
class ToastHelper {
|
||||||
static void showSuccessToast(BuildContext context, String message) {
|
static void showSuccessToast(BuildContext context, String message) {
|
||||||
@ -49,12 +50,12 @@ class ToastHelper {
|
|||||||
dragToClose: true,
|
dragToClose: true,
|
||||||
applyBlurEffect: true,
|
applyBlurEffect: true,
|
||||||
callbacks: ToastificationCallbacks(
|
callbacks: ToastificationCallbacks(
|
||||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||||
onCloseButtonTap: (toastItem) =>
|
onCloseButtonTap: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} close button tapped'),
|
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||||
onAutoCompleteCompleted: (toastItem) =>
|
onAutoCompleteCompleted: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} auto complete completed'),
|
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -100,12 +101,12 @@ class ToastHelper {
|
|||||||
dragToClose: true,
|
dragToClose: true,
|
||||||
applyBlurEffect: true,
|
applyBlurEffect: true,
|
||||||
callbacks: ToastificationCallbacks(
|
callbacks: ToastificationCallbacks(
|
||||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||||
onCloseButtonTap: (toastItem) =>
|
onCloseButtonTap: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} close button tapped'),
|
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||||
onAutoCompleteCompleted: (toastItem) =>
|
onAutoCompleteCompleted: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} auto complete completed'),
|
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -156,18 +157,19 @@ class ToastHelper {
|
|||||||
dragToClose: true,
|
dragToClose: true,
|
||||||
applyBlurEffect: true,
|
applyBlurEffect: true,
|
||||||
callbacks: ToastificationCallbacks(
|
callbacks: ToastificationCallbacks(
|
||||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||||
onCloseButtonTap: (toastItem) =>
|
onCloseButtonTap: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} close button tapped'),
|
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||||
onAutoCompleteCompleted: (toastItem) =>
|
onAutoCompleteCompleted: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} auto complete completed'),
|
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// _showToast(context, message, Colors.red);
|
// _showToast(context, message, Colors.red);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showErrorToast2(BuildContext context, String message,String decmessage) {
|
static void showErrorToast2(
|
||||||
|
BuildContext context, String message, String decmessage) {
|
||||||
toastification.show(
|
toastification.show(
|
||||||
context: context,
|
context: context,
|
||||||
type: ToastificationType.error,
|
type: ToastificationType.error,
|
||||||
@ -175,8 +177,7 @@ class ToastHelper {
|
|||||||
autoCloseDuration: const Duration(seconds: 2),
|
autoCloseDuration: const Duration(seconds: 2),
|
||||||
title: Text(message),
|
title: Text(message),
|
||||||
// you can also use RichText widget for title and description parameters
|
// you can also use RichText widget for title and description parameters
|
||||||
description: RichText(
|
description: RichText(text: TextSpan(text: decmessage)),
|
||||||
text: TextSpan(text: decmessage)),
|
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
direction: TextDirection.ltr,
|
direction: TextDirection.ltr,
|
||||||
animationDuration: const Duration(milliseconds: 100),
|
animationDuration: const Duration(milliseconds: 100),
|
||||||
@ -208,12 +209,12 @@ class ToastHelper {
|
|||||||
dragToClose: true,
|
dragToClose: true,
|
||||||
applyBlurEffect: true,
|
applyBlurEffect: true,
|
||||||
callbacks: ToastificationCallbacks(
|
callbacks: ToastificationCallbacks(
|
||||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||||
onCloseButtonTap: (toastItem) =>
|
onCloseButtonTap: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} close button tapped'),
|
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||||
onAutoCompleteCompleted: (toastItem) =>
|
onAutoCompleteCompleted: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} auto complete completed'),
|
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// _showToast(context, message, Colors.red);
|
// _showToast(context, message, Colors.red);
|
||||||
@ -260,12 +261,12 @@ class ToastHelper {
|
|||||||
dragToClose: true,
|
dragToClose: true,
|
||||||
applyBlurEffect: true,
|
applyBlurEffect: true,
|
||||||
callbacks: ToastificationCallbacks(
|
callbacks: ToastificationCallbacks(
|
||||||
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
|
onTap: (toastItem) => logDebug('Toast ${toastItem.id} tapped'),
|
||||||
onCloseButtonTap: (toastItem) =>
|
onCloseButtonTap: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} close button tapped'),
|
logDebug('Toast ${toastItem.id} close button tapped'),
|
||||||
onAutoCompleteCompleted: (toastItem) =>
|
onAutoCompleteCompleted: (toastItem) =>
|
||||||
print('Toast ${toastItem.id} auto complete completed'),
|
logDebug('Toast ${toastItem.id} auto complete completed'),
|
||||||
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
|
onDismissed: (toastItem) => logDebug('Toast ${toastItem.id} dismissed'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// _showToast(context, message, Colors.red);
|
// _showToast(context, message, Colors.red);
|
||||||
|
|||||||
@ -42,7 +42,6 @@ class _NhanceTopBarState extends State<NhanceTopBar> {
|
|||||||
Navigator.pushReplacementNamed(context, route);
|
Navigator.pushReplacementNamed(context, route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AppBar(
|
return AppBar(
|
||||||
@ -53,7 +52,6 @@ class _NhanceTopBarState extends State<NhanceTopBar> {
|
|||||||
children: [
|
children: [
|
||||||
Image.asset('assets/nhance_client_logo.png', height: 36),
|
Image.asset('assets/nhance_client_logo.png', height: 36),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
|
||||||
if (selectedBranch != null)
|
if (selectedBranch != null)
|
||||||
_BranchPopup(
|
_BranchPopup(
|
||||||
clientName: selectedBranch!['client_name'],
|
clientName: selectedBranch!['client_name'],
|
||||||
@ -66,6 +64,7 @@ class _NhanceTopBarState extends State<NhanceTopBar> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BranchPopup extends StatelessWidget {
|
class _BranchPopup extends StatelessWidget {
|
||||||
final String clientName;
|
final String clientName;
|
||||||
final String branchName;
|
final String branchName;
|
||||||
@ -85,7 +84,6 @@ class _BranchPopup extends StatelessWidget {
|
|||||||
tooltip: '',
|
tooltip: '',
|
||||||
offset: const Offset(0, 48),
|
offset: const Offset(0, 48),
|
||||||
onSelected: onSelected,
|
onSelected: onSelected,
|
||||||
|
|
||||||
itemBuilder: (context) {
|
itemBuilder: (context) {
|
||||||
return branches.map((branch) {
|
return branches.map((branch) {
|
||||||
return PopupMenuItem<Map<String, dynamic>>(
|
return PopupMenuItem<Map<String, dynamic>>(
|
||||||
@ -114,7 +112,6 @@ class _BranchPopup extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
},
|
},
|
||||||
|
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 40,
|
height: 40,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import '../models/platform_helper_mobile.dart'
|
|||||||
if (dart.library.html) '../models/platform_helper_other.dart';
|
if (dart.library.html) '../models/platform_helper_other.dart';
|
||||||
import 'branch/branch_selection_page.dart';
|
import 'branch/branch_selection_page.dart';
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
// import 'dart:html' as html;
|
// import 'dart:html' as html;
|
||||||
|
|
||||||
@ -101,13 +102,14 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
void verifyOTP(String otp) async {
|
void verifyOTP(String otp) async {
|
||||||
try {
|
try {
|
||||||
final Map<String, dynamic> payload = (widget.type == 'mobile')
|
final Map<String, dynamic> payload = (widget.type == 'mobile')
|
||||||
? {'otp': _otpController.text,'mobile_no': widget.value}
|
? {'otp': _otpController.text, 'mobile_no': widget.value}
|
||||||
: {'otp': _otpController.text, 'email': widget.value};
|
: {'otp': _otpController.text, 'email': widget.value};
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
Uri.parse(Environment.apiUrl + 'getVerifiedHrData'),
|
Uri.parse(Environment.apiUrl + 'getVerifiedHrData'),
|
||||||
body: json.encode(payload),
|
body: json.encode(payload),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -117,14 +119,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
Map<String, dynamic> data = json.decode(response.body);
|
||||||
print('Response data: $data');
|
logDebug('Response data: $data');
|
||||||
|
|
||||||
final String mainStatus = data['status'] ?? 'failed';
|
final String mainStatus = data['status'] ?? 'failed';
|
||||||
final Map<String, dynamic> postEnrollment1 =
|
final Map<String, dynamic> postEnrollment1 =
|
||||||
data['post_enrollment'] ?? {};
|
data['post_enrollment'] ?? {};
|
||||||
|
|
||||||
final String postStatus =
|
final String postStatus = postEnrollment1['status'] ?? 'failed';
|
||||||
postEnrollment1['status'] ?? 'failed';
|
|
||||||
|
|
||||||
/// ❌ BLOCK if BOTH failed
|
/// ❌ BLOCK if BOTH failed
|
||||||
if (mainStatus != 'success' && postStatus != 'success') {
|
if (mainStatus != 'success' && postStatus != 'success') {
|
||||||
@ -197,13 +198,13 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// print('data: $data');
|
// logDebug('data: $data');
|
||||||
// _token = data['data'];
|
// _token = data['data'];
|
||||||
// String status = data['status'];
|
// String status = data['status'];
|
||||||
//
|
//
|
||||||
// // Directly access the post_enrollment data
|
// // Directly access the post_enrollment data
|
||||||
// Map<String, dynamic> post = data['post_enrollment'];
|
// Map<String, dynamic> post = data['post_enrollment'];
|
||||||
// print('post: $post');
|
// logDebug('post: $post');
|
||||||
//
|
//
|
||||||
// _postToken = post['data'];
|
// _postToken = post['data'];
|
||||||
// String postStatus = post['status'];
|
// String postStatus = post['status'];
|
||||||
@ -224,7 +225,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
// });
|
// });
|
||||||
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
||||||
// // Show a Snackbar if the OTP is invalid
|
// // Show a Snackbar if the OTP is invalid
|
||||||
// print('Invalid OTP. Please try again');
|
// logDebug('Invalid OTP. Please try again');
|
||||||
// }
|
// }
|
||||||
} else if (response.statusCode == 401) {
|
} else if (response.statusCode == 401) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -239,7 +240,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
'hrLogin',
|
'hrLogin',
|
||||||
(route) => false,
|
(route) => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if (response.statusCode == 403) {
|
} else if (response.statusCode == 403) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -253,7 +253,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
'hrLogin',
|
'hrLogin',
|
||||||
(route) => false,
|
(route) => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if (response.statusCode == 451) {
|
} else if (response.statusCode == 451) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -278,10 +277,10 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
// Show a Snackbar if there's an error while verifying OTP
|
// 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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +294,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
|
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
||||||
print('postdecodedToken : $decodedToken');
|
logDebug('postdecodedToken : $decodedToken');
|
||||||
empClientBranchId = decodedToken['ref_id'];
|
empClientBranchId = decodedToken['ref_id'];
|
||||||
prefs.setString('empClientBranchId', empClientBranchId);
|
prefs.setString('empClientBranchId', empClientBranchId);
|
||||||
empCodeString = decodedToken['emp_code'].toString();
|
empCodeString = decodedToken['emp_code'].toString();
|
||||||
@ -314,7 +313,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
// prefs.setString('emp_status', emp_status);
|
// prefs.setString('emp_status', emp_status);
|
||||||
// getClientLogoAndDetails();
|
// getClientLogoAndDetails();
|
||||||
|
|
||||||
print('Successfully Login');
|
logDebug('Successfully Login');
|
||||||
|
|
||||||
// Redirect to another page
|
// Redirect to another page
|
||||||
}
|
}
|
||||||
@ -325,7 +324,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
|
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
print('postenrolldecodedToken : $decodedToken');
|
logDebug('postenrolldecodedToken : $decodedToken');
|
||||||
enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
||||||
prefs.setString(
|
prefs.setString(
|
||||||
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||||
@ -346,7 +345,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
getClientLogoAndDetails(empClientId, empClientBranchId,enrollmentClient_id,enrollmentEmpClientBranchId, post['data']);
|
getClientLogoAndDetails(empClientId, empClientBranchId, enrollmentClient_id,
|
||||||
|
enrollmentEmpClientBranchId, post['data']);
|
||||||
|
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
final _postToken = prefs.getString('_postToken');
|
final _postToken = prefs.getString('_postToken');
|
||||||
@ -367,7 +367,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
|
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
print('enrolldecodedToken : $decodedToken');
|
logDebug('enrolldecodedToken : $decodedToken');
|
||||||
enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
||||||
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||||
enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
||||||
@ -379,15 +379,16 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
enrollmentClient_id = decodedToken['client_id'];
|
enrollmentClient_id = decodedToken['client_id'];
|
||||||
prefs.setString('enrollmentClient_id', enrollmentClient_id);
|
prefs.setString('enrollmentClient_id', enrollmentClient_id);
|
||||||
enrollmentHrId = decodedToken['id'];
|
enrollmentHrId = decodedToken['id'];
|
||||||
print("enrollmentHrId- $enrollmentHrId");
|
logDebug("enrollmentHrId- $enrollmentHrId");
|
||||||
prefs.setString('enrollmentHrId', enrollmentHrId);
|
prefs.setString('enrollmentHrId', enrollmentHrId);
|
||||||
enrollmentAllowed_modules = decodedToken['allowed_modules'];
|
enrollmentAllowed_modules = decodedToken['allowed_modules'];
|
||||||
prefs.setString(
|
prefs.setString(
|
||||||
'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
|
'enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
|
||||||
// enrollmentEmp_status = decodedToken['emp_status'];
|
// enrollmentEmp_status = decodedToken['emp_status'];
|
||||||
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
// prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||||
getClientLogoAndDetails(empClientId,empClientBranchId,enrollmentClient_id, enrollmentEmpClientBranchId, data['data']);
|
getClientLogoAndDetails(empClientId, empClientBranchId, enrollmentClient_id,
|
||||||
print('Successfully Login');
|
enrollmentEmpClientBranchId, data['data']);
|
||||||
|
logDebug('Successfully Login');
|
||||||
|
|
||||||
// Redirect to another page
|
// Redirect to another page
|
||||||
final enrollToken = prefs.getString('enrollToken');
|
final enrollToken = prefs.getString('enrollToken');
|
||||||
@ -426,7 +427,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
Uri.parse(apiEndpoint),
|
Uri.parse(apiEndpoint),
|
||||||
body: json.encode(payload),
|
body: json.encode(payload),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -440,7 +442,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
context, 'Verification code sent to ${widget.value}');
|
context, 'Verification code sent to ${widget.value}');
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, message);
|
ToastHelper.showErrorToast(context, message);
|
||||||
print('Invalid mobile number');
|
logDebug('Invalid mobile number');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
@ -448,26 +450,28 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClientLogoAndDetails(empClientId,empClientBranchId,enrollmentClientId, enrollmentClientBranchId, token) async {
|
Future<void> getClientLogoAndDetails(empClientId, empClientBranchId,
|
||||||
|
enrollmentClientId, enrollmentClientBranchId, token) async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
var url = Uri.parse(Environment.apiUrl +
|
||||||
'getClientDetails?post_client_id=$empClientId&post_branch_id=$empClientBranchId&pre_client_id=$enrollmentClientId&pre_branch_id=$enrollmentClientBranchId');
|
'getClientDetails?post_client_id=$empClientId&post_branch_id=$empClientBranchId&pre_client_id=$enrollmentClientId&pre_branch_id=$enrollmentClientBranchId');
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $token', // Add token to the Authorization header
|
'Bearer $token', // Add token to the Authorization header
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
// print('response.statusCode == 200');
|
// logDebug('response.statusCode == 200');
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
Map<String, dynamic> data = json.decode(response.body);
|
||||||
// print(data);
|
// logDebug(data);
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
if (data.containsKey('data')) {
|
||||||
dynamic clientDetails = data['data'];
|
dynamic clientDetails = data['data'];
|
||||||
@ -476,27 +480,27 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
prefs.setString('clientName', clientDetails['client']['client_name']);
|
prefs.setString('clientName', clientDetails['client']['client_name']);
|
||||||
setState(() {
|
setState(() {
|
||||||
// dynamic clientDetails = data['data'];
|
// dynamic clientDetails = data['data'];
|
||||||
// print(clientDetails);
|
// logDebug(clientDetails);
|
||||||
clientName = clientDetails['client']['client_name'];
|
clientName = clientDetails['client']['client_name'];
|
||||||
print(clientName);
|
logDebug(clientName);
|
||||||
clientLogo = clientDetails['client']['client_logo'];
|
clientLogo = clientDetails['client']['client_logo'];
|
||||||
print(clientLogo);
|
logDebug(clientLogo);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,7 +547,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity, // ✅ fixed web width
|
width: double.infinity, // ✅ fixed web width
|
||||||
@ -591,13 +594,10 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Container(
|
Container(
|
||||||
margin: Responsive.isDesktop(context)
|
margin: Responsive.isDesktop(context)
|
||||||
? EdgeInsets.symmetric(
|
? EdgeInsets.symmetric(horizontal: 150)
|
||||||
horizontal: 150)
|
: EdgeInsets.symmetric(horizontal: 0),
|
||||||
: EdgeInsets.symmetric(
|
|
||||||
horizontal: 0),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Welcome to Nhance",
|
"Welcome to Nhance",
|
||||||
@ -612,10 +612,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Container(
|
Container(
|
||||||
margin: Responsive.isDesktop(context)
|
margin: Responsive.isDesktop(context)
|
||||||
? EdgeInsets.symmetric(
|
? EdgeInsets.symmetric(horizontal: 150)
|
||||||
horizontal: 150)
|
: EdgeInsets.symmetric(horizontal: 0),
|
||||||
: EdgeInsets.symmetric(
|
|
||||||
horizontal: 0),
|
|
||||||
child: RichText(
|
child: RichText(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
@ -627,21 +625,23 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
color: Color(0xFF000000)),
|
color: Color(0xFF000000)),
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: widget.type == 'mobile' ? 'mobile number ${widget.value}' : 'Email Id ${widget.value}',
|
text: widget.type == 'mobile'
|
||||||
|
? 'mobile number ${widget.value}'
|
||||||
|
: 'Email Id ${widget.value}',
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: widget.type == 'mobile' ? ' (Change Mobile)' : ' (Change Email)',
|
text: widget.type == 'mobile'
|
||||||
|
? ' (Change Mobile)'
|
||||||
|
: ' (Change Email)',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: Color(
|
color: Color(
|
||||||
0xFFE26728)), // Change color as desired
|
0xFFE26728)), // Change color as desired
|
||||||
recognizer:
|
recognizer: TapGestureRecognizer()
|
||||||
TapGestureRecognizer()
|
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
// Navigate to the page where the user can change the phone number
|
// Navigate to the page where the user can change the phone number
|
||||||
Navigator.pushNamed(
|
Navigator.pushNamed(
|
||||||
context,
|
context, 'hrLogin');
|
||||||
'hrLogin');
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -651,10 +651,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Container(
|
Container(
|
||||||
margin: Responsive.isDesktop(context)
|
margin: Responsive.isDesktop(context)
|
||||||
? EdgeInsets.symmetric(
|
? EdgeInsets.symmetric(horizontal: 150)
|
||||||
horizontal: 150)
|
: EdgeInsets.symmetric(horizontal: 0),
|
||||||
: EdgeInsets.symmetric(
|
|
||||||
horizontal: 0),
|
|
||||||
child: Pinput(
|
child: Pinput(
|
||||||
length: 6,
|
length: 6,
|
||||||
// defaultPinTheme: defaultPinTheme,
|
// defaultPinTheme: defaultPinTheme,
|
||||||
@ -667,10 +665,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Container(
|
Container(
|
||||||
margin: Responsive.isDesktop(context)
|
margin: Responsive.isDesktop(context)
|
||||||
? EdgeInsets.symmetric(
|
? EdgeInsets.symmetric(horizontal: 150)
|
||||||
horizontal: 150)
|
: EdgeInsets.symmetric(horizontal: 0),
|
||||||
: EdgeInsets.symmetric(
|
|
||||||
horizontal: 0),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment
|
mainAxisAlignment: MainAxisAlignment
|
||||||
.end, // Align text to the right
|
.end, // Align text to the right
|
||||||
@ -678,10 +674,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
_isTimerRunning
|
_isTimerRunning
|
||||||
? Text(
|
? Text(
|
||||||
"Resend OTP in $_secondsRemaining seconds",
|
"Resend OTP in $_secondsRemaining seconds",
|
||||||
style:
|
style: GoogleFonts.poppins(
|
||||||
GoogleFonts.poppins(
|
color: Colors.black),
|
||||||
color:
|
|
||||||
Colors.black),
|
|
||||||
)
|
)
|
||||||
: InkWell(
|
: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -689,10 +683,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Resend OTP",
|
"Resend OTP",
|
||||||
style:
|
style: GoogleFonts.poppins(
|
||||||
GoogleFonts.poppins(
|
color: Colors.blue),
|
||||||
color: Colors
|
|
||||||
.blue),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -701,29 +693,23 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Container(
|
Container(
|
||||||
margin: Responsive.isDesktop(context)
|
margin: Responsive.isDesktop(context)
|
||||||
? EdgeInsets.symmetric(
|
? EdgeInsets.symmetric(horizontal: 150)
|
||||||
horizontal: 150)
|
: EdgeInsets.symmetric(horizontal: 0),
|
||||||
: EdgeInsets.symmetric(
|
|
||||||
horizontal: 0),
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 45,
|
height: 45,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor: Color(0xFF00989E),
|
||||||
Color(0xFF00989E),
|
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius:
|
borderRadius: BorderRadius.circular(10),
|
||||||
BorderRadius.circular(10),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!
|
if (_formKey.currentState!.validate()) {
|
||||||
.validate()) {
|
|
||||||
_formKey.currentState!
|
_formKey.currentState!
|
||||||
.save(); // Save form fields before calling verifyOTP
|
.save(); // Save form fields before calling verifyOTP
|
||||||
verifyOTP(
|
verifyOTP(_otpController.text);
|
||||||
_otpController.text);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -737,13 +723,11 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
padding:
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
EdgeInsets.symmetric(vertical: 8),
|
|
||||||
child: RichText(
|
child: RichText(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text:
|
text: 'By continuing, you agree with our ',
|
||||||
'By continuing, you agree with our ',
|
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontSize: 9,
|
fontSize: 9,
|
||||||
@ -782,9 +766,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)));
|
||||||
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
|
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
import 'customAppBar/customFooter.dart';
|
import 'customAppBar/customFooter.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class empDetails extends StatefulWidget {
|
class empDetails extends StatefulWidget {
|
||||||
const empDetails({Key? key}) : super(key: key);
|
const empDetails({Key? key}) : super(key: key);
|
||||||
@ -131,10 +132,10 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
String? getHrToken = prefs.getString('hrtoken');
|
String? getHrToken = prefs.getString('hrtoken');
|
||||||
String? empID = prefs.getString('employee_id');
|
String? empID = prefs.getString('employee_id');
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(getHrToken!);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(getHrToken!);
|
||||||
print(decodedToken);
|
logDebug(decodedToken);
|
||||||
hrPrimaryId = decodedToken['id'];
|
hrPrimaryId = decodedToken['id'];
|
||||||
print('hrPrimaryId');
|
logDebug('hrPrimaryId');
|
||||||
print(hrPrimaryId);
|
logDebug(hrPrimaryId);
|
||||||
_hrLoadToken(empID);
|
_hrLoadToken(empID);
|
||||||
} else {
|
} else {
|
||||||
_loadToken();
|
_loadToken();
|
||||||
@ -142,7 +143,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _hrLoadToken(empID) async {
|
Future<void> _hrLoadToken(empID) async {
|
||||||
print('_hrLoadToken');
|
logDebug('_hrLoadToken');
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.setString('fromHrLoginMobileNo', mobileNumber);
|
prefs.setString('fromHrLoginMobileNo', mobileNumber);
|
||||||
|
|
||||||
@ -161,19 +162,20 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
'employee_id': empID
|
'employee_id': empID
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print('API Success');
|
logDebug('API Success');
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
Map<String, dynamic> data = json.decode(response.body);
|
||||||
print(data);
|
logDebug(data);
|
||||||
String status = data['status'];
|
String status = data['status'];
|
||||||
|
|
||||||
if (status == 'success') {
|
if (status == 'success') {
|
||||||
print(status);
|
logDebug(status);
|
||||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
setState(() {
|
setState(() {
|
||||||
prefs.setString('token', data['data']);
|
prefs.setString('token', data['data']);
|
||||||
@ -181,10 +183,10 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
|
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
print('decodedTokenssss $decodedToken');
|
logDebug('decodedTokenssss $decodedToken');
|
||||||
empClientBranchId = decodedToken['client_branch_id'];
|
empClientBranchId = decodedToken['client_branch_id'];
|
||||||
prefs.setString('empClientBranchId', empClientBranchId);
|
prefs.setString('empClientBranchId', empClientBranchId);
|
||||||
print(empClientBranchId);
|
logDebug(empClientBranchId);
|
||||||
empCodeString = decodedToken['emp_code'];
|
empCodeString = decodedToken['emp_code'];
|
||||||
prefs.setString('empCode', empCodeString);
|
prefs.setString('empCode', empCodeString);
|
||||||
empPrimaryId = decodedToken['id'];
|
empPrimaryId = decodedToken['id'];
|
||||||
@ -194,11 +196,11 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
client_id = decodedToken['client_id'];
|
client_id = decodedToken['client_id'];
|
||||||
prefs.setString('client_id', client_id);
|
prefs.setString('client_id', client_id);
|
||||||
|
|
||||||
print('Successfully Login');
|
logDebug('Successfully Login');
|
||||||
|
|
||||||
// Redirect to another page
|
// Redirect to another page
|
||||||
token = prefs.getString('token');
|
token = prefs.getString('token');
|
||||||
print('final $token');
|
logDebug('final $token');
|
||||||
if (token != null && token.isNotEmpty) {
|
if (token != null && token.isNotEmpty) {
|
||||||
// ToastHelper.showSuccessToast(context, 'Successfully Login');
|
// ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||||
await getTokenLoad(token);
|
await getTokenLoad(token);
|
||||||
@ -224,24 +226,24 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
||||||
// Show a Snackbar if the OTP is invalid
|
// Show a Snackbar if the OTP is invalid
|
||||||
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
||||||
print('Invalid OTP. Please try again');
|
logDebug('Invalid OTP. Please try again');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showErrorToast(context, 'Failed to verify OTP');
|
// ToastHelper.showErrorToast(context, 'Failed to verify OTP');
|
||||||
throw Exception('Failed to verify OTP');
|
throw Exception('Failed to verify OTP');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
// Show a Snackbar if there's an error while verifying OTP
|
// Show a Snackbar if there's an error while verifying OTP
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Failed to verify OTP. Please try again.');
|
// context, 'Failed to verify OTP. Please try again.');
|
||||||
print('Failed to verify OTP. Please try again.');
|
logDebug('Failed to verify OTP. Please try again.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadToken() async {
|
Future<void> _loadToken() async {
|
||||||
print('_loadToken');
|
logDebug('_loadToken');
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
final String? token = prefs.getString('token');
|
final String? token = prefs.getString('token');
|
||||||
if (token != null && token.isNotEmpty) {
|
if (token != null && token.isNotEmpty) {
|
||||||
@ -250,16 +252,16 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
});
|
});
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
print(decodedToken);
|
logDebug(decodedToken);
|
||||||
empClientBranchId = prefs.getString('empClientBranchId');
|
empClientBranchId = prefs.getString('empClientBranchId');
|
||||||
empCodeString = prefs.getString('empCode');
|
empCodeString = prefs.getString('empCode');
|
||||||
print(empCodeString); // Check if emp_code is correct
|
logDebug(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
gpaEmpName = prefs.getString('gpaEmpName');
|
gpaEmpName = prefs.getString('gpaEmpName');
|
||||||
client_id = prefs.getString('client_id');
|
client_id = prefs.getString('client_id');
|
||||||
print(client_id);
|
logDebug(client_id);
|
||||||
|
|
||||||
// print(empPrimaryId);
|
// logDebug(empPrimaryId);
|
||||||
// Call the API when the page enters
|
// Call the API when the page enters
|
||||||
// getSelfEmployeeProfile('');
|
// getSelfEmployeeProfile('');
|
||||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||||
@ -288,7 +290,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
final response = await apiService.getClientLogoAndDetailsToApi(
|
final response = await apiService.getClientLogoAndDetailsToApi(
|
||||||
client_id!, empCodeString!, empClientBranchId!);
|
client_id!, empCodeString!, empClientBranchId!);
|
||||||
print('check 1');
|
logDebug('check 1');
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
if (response.containsKey('data')) {
|
if (response.containsKey('data')) {
|
||||||
@ -298,27 +300,27 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
prefs.setString('clientName', clientDetails['client']['client_name']);
|
prefs.setString('clientName', clientDetails['client']['client_name']);
|
||||||
setState(() {
|
setState(() {
|
||||||
// dynamic clientDetails = data['data'];
|
// dynamic clientDetails = data['data'];
|
||||||
// print(clientDetails);
|
// logDebug(clientDetails);
|
||||||
clientName = clientDetails['client']['client_name'];
|
clientName = clientDetails['client']['client_name'];
|
||||||
print(clientName);
|
logDebug(clientName);
|
||||||
clientLogo = clientDetails['client']['client_logo'];
|
clientLogo = clientDetails['client']['client_logo'];
|
||||||
print(clientLogo);
|
logDebug(clientLogo);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +329,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
final response = await apiService.getTokenLoadAPI(token);
|
final response = await apiService.getTokenLoadAPI(token);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +347,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
if (response.containsKey('data')) {
|
if (response.containsKey('data')) {
|
||||||
setState(() {
|
setState(() {
|
||||||
dynamic selfDetails = response['data'];
|
dynamic selfDetails = response['data'];
|
||||||
print(selfDetails);
|
logDebug(selfDetails);
|
||||||
mobileNumber = selfDetails['relationship'];
|
mobileNumber = selfDetails['relationship'];
|
||||||
selfRelationship = selfDetails['relationship'];
|
selfRelationship = selfDetails['relationship'];
|
||||||
selfName = selfDetails['name'];
|
selfName = selfDetails['name'];
|
||||||
@ -359,7 +361,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
selfEmailPersonal = selfDetails['email_personal'];
|
selfEmailPersonal = selfDetails['email_personal'];
|
||||||
selfEmpCode = selfDetails['emp_code'];
|
selfEmpCode = selfDetails['emp_code'];
|
||||||
selfFamilyFloaterKey = selfDetails['family_floater_key'];
|
selfFamilyFloaterKey = selfDetails['family_floater_key'];
|
||||||
// print(clientDetails);
|
// logDebug(clientDetails);
|
||||||
selfEmpStatus = selfDetails['emp_status'];
|
selfEmpStatus = selfDetails['emp_status'];
|
||||||
selfUnit = selfDetails['unit'];
|
selfUnit = selfDetails['unit'];
|
||||||
});
|
});
|
||||||
@ -369,17 +371,17 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +418,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
gpaPolicies = response['data'];
|
gpaPolicies = response['data'];
|
||||||
print('gpaPolicies');
|
logDebug('gpaPolicies');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -424,11 +426,11 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
});
|
});
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,10 +452,10 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcPolicies = response['data'];
|
gmcPolicies = response['data'];
|
||||||
print('gmcPolicies');
|
logDebug('gmcPolicies');
|
||||||
});
|
});
|
||||||
// Assuming data is a List
|
// Assuming data is a List
|
||||||
print(gmcPolicies);
|
logDebug(gmcPolicies);
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcDataIsEmpty = 0;
|
gmcDataIsEmpty = 0;
|
||||||
@ -461,11 +463,11 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${response['status']}');
|
logDebug('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,15 +496,15 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Error fetching relationship list: $error');
|
// context, 'Error fetching relationship list: $error');
|
||||||
print('Error fetching relationship list: $error');
|
logDebug('Error fetching relationship list: $error');
|
||||||
// Handle error accordingly, e.g., show a snackbar with an error message
|
// Handle error accordingly, e.g., show a snackbar with an error message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _selectDate(BuildContext context, formType) async {
|
Future<void> _selectDate(BuildContext context, formType) async {
|
||||||
print(formType);
|
logDebug(formType);
|
||||||
var ageValidation = formType['age_validation'];
|
var ageValidation = formType['age_validation'];
|
||||||
print(ageValidation);
|
logDebug(ageValidation);
|
||||||
// Ensure ageValidation is a Map and contains the expected values
|
// Ensure ageValidation is a Map and contains the expected values
|
||||||
if (ageValidation is Map<String, dynamic>) {
|
if (ageValidation is Map<String, dynamic>) {
|
||||||
int min = ageValidation.containsKey('min')
|
int min = ageValidation.containsKey('min')
|
||||||
@ -512,17 +514,17 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
? int.tryParse(ageValidation['max'].toString()) ?? 100
|
? int.tryParse(ageValidation['max'].toString()) ?? 100
|
||||||
: 100;
|
: 100;
|
||||||
|
|
||||||
print('Min age: $min');
|
logDebug('Min age: $min');
|
||||||
print('Max age: $max');
|
logDebug('Max age: $max');
|
||||||
late DateTime minDate;
|
late DateTime minDate;
|
||||||
late DateTime maxDate;
|
late DateTime maxDate;
|
||||||
|
|
||||||
final DateTime now = DateTime.now();
|
final DateTime now = DateTime.now();
|
||||||
|
|
||||||
maxDate = DateTime(now.year - min, now.month, now.day);
|
maxDate = DateTime(now.year - min, now.month, now.day);
|
||||||
print(maxDate);
|
logDebug(maxDate);
|
||||||
minDate = DateTime(now.year - max, now.month, now.day);
|
minDate = DateTime(now.year - max, now.month, now.day);
|
||||||
print(minDate);
|
logDebug(minDate);
|
||||||
|
|
||||||
// if (formType['form_type'] == 'child') {
|
// if (formType['form_type'] == 'child') {
|
||||||
// // For 'child' form type, allow 0-25 age
|
// // For 'child' form type, allow 0-25 age
|
||||||
@ -576,12 +578,12 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('Invalid age validation data');
|
logDebug('Invalid age validation data');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteItem(Map<String, dynamic> deletedItem) async {
|
Future<void> deleteItem(Map<String, dynamic> deletedItem) async {
|
||||||
print(deletedItem);
|
logDebug(deletedItem);
|
||||||
try {
|
try {
|
||||||
var id = deletedItem['employee_id'];
|
var id = deletedItem['employee_id'];
|
||||||
final response = await apiService.deleteItemToApi(id);
|
final response = await apiService.deleteItemToApi(id);
|
||||||
@ -598,25 +600,25 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
getGmcEmpPolicyDetails(empPrimaryId);
|
getGmcEmpPolicyDetails(empPrimaryId);
|
||||||
fetchRelationshipList();
|
fetchRelationshipList();
|
||||||
ToastHelper.showSuccessToast(context, 'Item deleted successfully');
|
ToastHelper.showSuccessToast(context, 'Item deleted successfully');
|
||||||
print('Item deleted successfully');
|
logDebug('Item deleted successfully');
|
||||||
} else {
|
} else {
|
||||||
// Handle errors
|
// Handle errors
|
||||||
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
||||||
print('Failed to delete item. Status code: ${response['code']}');
|
logDebug('Failed to delete item. Status code: ${response['code']}');
|
||||||
print('Response body: ${response}');
|
logDebug('Response body: ${response}');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle network errors
|
// Handle network errors
|
||||||
print('Error deleting item: $error');
|
logDebug('Error deleting item: $error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveFamilyMemberDetails(Map<String, dynamic> formData,
|
void saveFamilyMemberDetails(Map<String, dynamic> formData,
|
||||||
Map<String, dynamic> floatedData, action, gmcSumInsured) async {
|
Map<String, dynamic> floatedData, action, gmcSumInsured) async {
|
||||||
// Construct the array of objects
|
// Construct the array of objects
|
||||||
print(formData);
|
logDebug(formData);
|
||||||
print('floatedData $floatedData');
|
logDebug('floatedData $floatedData');
|
||||||
print(action);
|
logDebug(action);
|
||||||
|
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
dynamic primaryId;
|
dynamic primaryId;
|
||||||
@ -665,11 +667,11 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
getGmcEmpPolicyDetails(empPrimaryId);
|
getGmcEmpPolicyDetails(empPrimaryId);
|
||||||
fetchRelationshipList();
|
fetchRelationshipList();
|
||||||
ToastHelper.showSuccessToast(context, 'Saved Successfully.');
|
ToastHelper.showSuccessToast(context, 'Saved Successfully.');
|
||||||
print('Form data sent successfully.');
|
logDebug('Form data sent successfully.');
|
||||||
} else {
|
} else {
|
||||||
// Request failed, handle error
|
// Request failed, handle error
|
||||||
ToastHelper.showErrorToast(context, 'Failed');
|
ToastHelper.showErrorToast(context, 'Failed');
|
||||||
print('Failed to send form data. Error: ${response}');
|
logDebug('Failed to send form data. Error: ${response}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,20 +695,20 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
final String? detailsString = prefs.getString('hrSelectArgumentsData');
|
final String? detailsString = prefs.getString('hrSelectArgumentsData');
|
||||||
if (detailsString != null) {
|
if (detailsString != null) {
|
||||||
final dynamic details = jsonDecode(detailsString);
|
final dynamic details = jsonDecode(detailsString);
|
||||||
print('Decoded details:');
|
logDebug('Decoded details:');
|
||||||
print(details);
|
logDebug(details);
|
||||||
|
|
||||||
// Ensure that details is a Map<String, dynamic> before passing it
|
// Ensure that details is a Map<String, dynamic> before passing it
|
||||||
if (details is Map<String, dynamic>) {
|
if (details is Map<String, dynamic>) {
|
||||||
Navigator.pushNamed(context, 'hrPolicyDetails', arguments: details);
|
Navigator.pushNamed(context, 'hrPolicyDetails', arguments: details);
|
||||||
} else {
|
} else {
|
||||||
print('Error: Decoded details is not a Map<String, dynamic>.');
|
logDebug('Error: Decoded details is not a Map<String, dynamic>.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('hrSelectArgumentsData is null.');
|
logDebug('hrSelectArgumentsData is null.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('hrtoken is null or empty.');
|
logDebug('hrtoken is null or empty.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,18 +720,18 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
if (arguments.containsKey('mobile')) {
|
if (arguments.containsKey('mobile')) {
|
||||||
mobileNumber = arguments["mobile"];
|
mobileNumber = arguments["mobile"];
|
||||||
// Call your tokenAPI or _loadToken function here
|
// Call your tokenAPI or _loadToken function here
|
||||||
print("_hrLoadToken");
|
logDebug("_hrLoadToken");
|
||||||
print(mobileNumber);
|
logDebug(mobileNumber);
|
||||||
// _hrLoadToken();
|
// _hrLoadToken();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print("Arguments are null or not in the expected format");
|
logDebug("Arguments are null or not in the expected format");
|
||||||
// _loadToken();
|
// _loadToken();
|
||||||
mobileNumber = '';
|
mobileNumber = '';
|
||||||
}
|
}
|
||||||
if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) {
|
if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) {
|
||||||
print('body if');
|
logDebug('body if');
|
||||||
print(gpaPolicies);
|
logDebug(gpaPolicies);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: CustomAppBar(),
|
appBar: CustomAppBar(),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
@ -1051,10 +1053,10 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void openForm(Map<String, dynamic> floaterData, action, gmcSumInsured) {
|
void openForm(Map<String, dynamic> floaterData, action, gmcSumInsured) {
|
||||||
print(action);
|
logDebug(action);
|
||||||
print(floaterData);
|
logDebug(floaterData);
|
||||||
print(relationshipOptions);
|
logDebug(relationshipOptions);
|
||||||
print('test');
|
logDebug('test');
|
||||||
// Check if the action is 'Edit'
|
// Check if the action is 'Edit'
|
||||||
dynamic popupName = floaterData['button_name'];
|
dynamic popupName = floaterData['button_name'];
|
||||||
|
|
||||||
@ -1071,32 +1073,32 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
_relationShipController.text = 'Spouse';
|
_relationShipController.text = 'Spouse';
|
||||||
}
|
}
|
||||||
|
|
||||||
print(selectedRelationships);
|
logDebug(selectedRelationships);
|
||||||
print(gmcMappedFamilyFloaters);
|
logDebug(gmcMappedFamilyFloaters);
|
||||||
if (action == 'Add') {
|
if (action == 'Add') {
|
||||||
if (floaterData['form_type'] == 'parent_in_law' ||
|
if (floaterData['form_type'] == 'parent_in_law' ||
|
||||||
floaterData['form_type'] == 'parent') {
|
floaterData['form_type'] == 'parent') {
|
||||||
print('Add');
|
logDebug('Add');
|
||||||
// Filter the addOnsDependentMappedFamilyFloatersDependent list to get only the objects where is_value_exist is true
|
// Filter the addOnsDependentMappedFamilyFloatersDependent list to get only the objects where is_value_exist is true
|
||||||
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
||||||
.where((element) => element['is_value_exist'] == true)
|
.where((element) => element['is_value_exist'] == true)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
print(getTrueObjects);
|
logDebug(getTrueObjects);
|
||||||
|
|
||||||
List<Map<String, dynamic>> getTrueDataObjects = getTrueObjects
|
List<Map<String, dynamic>> getTrueDataObjects = getTrueObjects
|
||||||
.map<Map<String, dynamic>>(
|
.map<Map<String, dynamic>>(
|
||||||
(element) => element['data'] as Map<String, dynamic>)
|
(element) => element['data'] as Map<String, dynamic>)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
print(getTrueDataObjects);
|
logDebug(getTrueDataObjects);
|
||||||
|
|
||||||
selectedRelationships.removeWhere((relationship) =>
|
selectedRelationships.removeWhere((relationship) =>
|
||||||
getTrueDataObjects.any((dataObject) =>
|
getTrueDataObjects.any((dataObject) =>
|
||||||
dataObject['relationship'] ==
|
dataObject['relationship'] ==
|
||||||
relationship['relationship_name']));
|
relationship['relationship_name']));
|
||||||
|
|
||||||
print(selectedRelationships);
|
logDebug(selectedRelationships);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Set values to all fields
|
// Set values to all fields
|
||||||
@ -1367,12 +1369,12 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
|
|
||||||
Future<void> _launchURL(String url) async {
|
Future<void> _launchURL(String url) async {
|
||||||
final Uri uri = Uri.parse(url); // Parse the URL properly
|
final Uri uri = Uri.parse(url); // Parse the URL properly
|
||||||
print('_launchURL $uri');
|
logDebug('_launchURL $uri');
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
print('If $uri');
|
logDebug('If $uri');
|
||||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} else {
|
} else {
|
||||||
print('else $uri');
|
logDebug('else $uri');
|
||||||
throw 'Could not launch $url';
|
throw 'Could not launch $url';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1738,8 +1740,8 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
List<Widget> cards = [];
|
List<Widget> cards = [];
|
||||||
|
|
||||||
for (var item in data) {
|
for (var item in data) {
|
||||||
print('item');
|
logDebug('item');
|
||||||
print(item);
|
logDebug(item);
|
||||||
|
|
||||||
String? gpaPolicyName = item['Policy_Name'];
|
String? gpaPolicyName = item['Policy_Name'];
|
||||||
String? gpaECardDownload = item['eCardDownload'];
|
String? gpaECardDownload = item['eCardDownload'];
|
||||||
@ -1991,8 +1993,8 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
List<Widget> cards = [];
|
List<Widget> cards = [];
|
||||||
|
|
||||||
for (var item in data) {
|
for (var item in data) {
|
||||||
print('item');
|
logDebug('item');
|
||||||
print(item);
|
logDebug(item);
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcPolicyName = item['Policy_Name'];
|
gmcPolicyName = item['Policy_Name'];
|
||||||
gmc_client_policy_id = item['ClientPolicyId'];
|
gmc_client_policy_id = item['ClientPolicyId'];
|
||||||
@ -2005,13 +2007,13 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
||||||
.where((element) => element['is_value_exist'] == true)
|
.where((element) => element['is_value_exist'] == true)
|
||||||
.toList();
|
.toList();
|
||||||
print('getTrueObjects');
|
logDebug('getTrueObjects');
|
||||||
print(getTrueObjects);
|
logDebug(getTrueObjects);
|
||||||
if (getTrueObjects.length > 0) {
|
if (getTrueObjects.length > 0) {
|
||||||
print('true');
|
logDebug('true');
|
||||||
gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"];
|
gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"];
|
||||||
} else {
|
} else {
|
||||||
print('false');
|
logDebug('false');
|
||||||
gmcSumInsured = item['Policy_Terms']['sum_insured'];
|
gmcSumInsured = item['Policy_Terms']['sum_insured'];
|
||||||
}
|
}
|
||||||
String intOpenForEnrollment = item['OpenForEnrollment'];
|
String intOpenForEnrollment = item['OpenForEnrollment'];
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import 'dart:convert';
|
|||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import 'customAppBar/customFooter.dart';
|
import 'customAppBar/customFooter.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class empReviewDetails extends StatefulWidget {
|
class empReviewDetails extends StatefulWidget {
|
||||||
const empReviewDetails({Key? key}) : super(key: key);
|
const empReviewDetails({Key? key}) : super(key: key);
|
||||||
@ -171,13 +172,13 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
selfEmpStatus = prefs.getString('selfEmpStatus');
|
selfEmpStatus = prefs.getString('selfEmpStatus');
|
||||||
empClientBranchId = prefs.getString('empClientBranchId');
|
empClientBranchId = prefs.getString('empClientBranchId');
|
||||||
empCodeString = prefs.getString('empCode');
|
empCodeString = prefs.getString('empCode');
|
||||||
print(empCodeString); // Check if emp_code is correct
|
logDebug(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
gpaEmpName = prefs.getString('gpaEmpName');
|
gpaEmpName = prefs.getString('gpaEmpName');
|
||||||
client_id = prefs.getString('client_id');
|
client_id = prefs.getString('client_id');
|
||||||
print(client_id);
|
logDebug(client_id);
|
||||||
|
|
||||||
// print(empPrimaryId);
|
// logDebug(empPrimaryId);
|
||||||
// Call the API when the page enters
|
// Call the API when the page enters
|
||||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||||
clientLogo = prefs.getString('clientLogo');
|
clientLogo = prefs.getString('clientLogo');
|
||||||
@ -205,8 +206,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (prefs.containsKey('siData')) {
|
if (prefs.containsKey('siData')) {
|
||||||
activeSiData = 1;
|
activeSiData = 1;
|
||||||
String? siDataJson = prefs.getString('siData');
|
String? siDataJson = prefs.getString('siData');
|
||||||
print('siDataJson');
|
logDebug('siDataJson');
|
||||||
print(siDataJson);
|
logDebug(siDataJson);
|
||||||
|
|
||||||
List<dynamic> siDataList = jsonDecode(siDataJson!);
|
List<dynamic> siDataList = jsonDecode(siDataJson!);
|
||||||
if (siDataList.isNotEmpty) {
|
if (siDataList.isNotEmpty) {
|
||||||
@ -221,8 +222,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (prefs.containsKey('siParentData')) {
|
if (prefs.containsKey('siParentData')) {
|
||||||
activeSiParentData = 1;
|
activeSiParentData = 1;
|
||||||
String? siParentDataJson = prefs.getString('siParentData');
|
String? siParentDataJson = prefs.getString('siParentData');
|
||||||
print('siParentDataJson');
|
logDebug('siParentDataJson');
|
||||||
print(siParentDataJson);
|
logDebug(siParentDataJson);
|
||||||
|
|
||||||
List<dynamic> siParentDataList = jsonDecode(siParentDataJson!);
|
List<dynamic> siParentDataList = jsonDecode(siParentDataJson!);
|
||||||
if (siParentDataList.isNotEmpty) {
|
if (siParentDataList.isNotEmpty) {
|
||||||
@ -238,8 +239,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (prefs.containsKey('dependentData')) {
|
if (prefs.containsKey('dependentData')) {
|
||||||
activeDependentData = 1;
|
activeDependentData = 1;
|
||||||
String? dependentDataJson = prefs.getString('dependentData');
|
String? dependentDataJson = prefs.getString('dependentData');
|
||||||
print('dependentDataJson');
|
logDebug('dependentDataJson');
|
||||||
print(dependentDataJson);
|
logDebug(dependentDataJson);
|
||||||
|
|
||||||
List<dynamic> dependentDataList = jsonDecode(dependentDataJson!);
|
List<dynamic> dependentDataList = jsonDecode(dependentDataJson!);
|
||||||
if (dependentDataList.isNotEmpty) {
|
if (dependentDataList.isNotEmpty) {
|
||||||
@ -269,7 +270,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
totalPayableAmt += addOnsDependentTotalAmt;
|
totalPayableAmt += addOnsDependentTotalAmt;
|
||||||
|
|
||||||
// Print or use the totalAmtSum value
|
// Print or use the totalAmtSum value
|
||||||
print('Sum of Total Amounts: $totalPayableAmt');
|
logDebug('Sum of Total Amounts: $totalPayableAmt');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClientLogoAndDetails() async {
|
Future<void> getClientLogoAndDetails() async {
|
||||||
@ -284,22 +285,22 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
if (response.containsKey('data')) {
|
if (response.containsKey('data')) {
|
||||||
dynamic clientDetails = response['data'];
|
dynamic clientDetails = response['data'];
|
||||||
print(clientDetails);
|
logDebug(clientDetails);
|
||||||
clientName = clientDetails['client']['client_name'];
|
clientName = clientDetails['client']['client_name'];
|
||||||
print(clientName);
|
logDebug(clientName);
|
||||||
clientLogo = clientDetails['client']['client_logo'];
|
clientLogo = clientDetails['client']['client_logo'];
|
||||||
print(clientLogo);
|
logDebug(clientLogo);
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
print('API request failed with status: ${response['status']}');
|
logDebug('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +328,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
gpaPolicies = response['data'];
|
gpaPolicies = response['data'];
|
||||||
print('gpaPolicies');
|
logDebug('gpaPolicies');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -335,11 +336,11 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
});
|
});
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,10 +367,10 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcPolicies = response['data'];
|
gmcPolicies = response['data'];
|
||||||
print('gmcPolicies');
|
logDebug('gmcPolicies');
|
||||||
});
|
});
|
||||||
// Assuming data is a List
|
// Assuming data is a List
|
||||||
print(gmcPolicies);
|
logDebug(gmcPolicies);
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcDataIsEmpty = 0;
|
gmcDataIsEmpty = 0;
|
||||||
@ -377,11 +378,11 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +398,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
if (response.containsKey('data')) {
|
if (response.containsKey('data')) {
|
||||||
dynamic topUpSiPolicies = response['data'];
|
dynamic topUpSiPolicies = response['data'];
|
||||||
print(topUpSiPolicies);
|
logDebug(topUpSiPolicies);
|
||||||
if (topUpSiPolicies.isNotEmpty) {
|
if (topUpSiPolicies.isNotEmpty) {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
topUpClientPolicyId =
|
topUpClientPolicyId =
|
||||||
@ -405,7 +406,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
|
|
||||||
topUpSumInsured = topUpSiPolicies['gmc_si_topup']
|
topUpSumInsured = topUpSiPolicies['gmc_si_topup']
|
||||||
['family_floaters_of_only_si_value'];
|
['family_floaters_of_only_si_value'];
|
||||||
print(topUpSumInsured);
|
logDebug(topUpSumInsured);
|
||||||
|
|
||||||
if (topUpSumInsured == 0) {
|
if (topUpSumInsured == 0) {
|
||||||
showHideTopUpCard = 0;
|
showHideTopUpCard = 0;
|
||||||
@ -420,8 +421,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
|
|
||||||
topUpMappedFamilyFloatersSiArray = topUpSiPolicies['gmc_si_topup']
|
topUpMappedFamilyFloatersSiArray = topUpSiPolicies['gmc_si_topup']
|
||||||
['family_floaters_of_only_si_array'];
|
['family_floaters_of_only_si_array'];
|
||||||
print('topUpMappedFamilyFloatersSiArray');
|
logDebug('topUpMappedFamilyFloatersSiArray');
|
||||||
print(topUpMappedFamilyFloatersSiArray);
|
logDebug(topUpMappedFamilyFloatersSiArray);
|
||||||
|
|
||||||
topUpTypeName = topUpSiPolicies['gmc_si_topup']['type'];
|
topUpTypeName = topUpSiPolicies['gmc_si_topup']['type'];
|
||||||
|
|
||||||
@ -437,23 +438,23 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'No data found in the response');
|
// context, 'No data found in the response');
|
||||||
print('No data found in the response');
|
logDebug('No data found in the response');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,8 +471,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (response.containsKey('data')) {
|
if (response.containsKey('data')) {
|
||||||
setState(() {
|
setState(() {
|
||||||
topUpSiParentPolicies = response['data'];
|
topUpSiParentPolicies = response['data'];
|
||||||
print('topUpSiParentPolicies');
|
logDebug('topUpSiParentPolicies');
|
||||||
print(topUpSiParentPolicies);
|
logDebug(topUpSiParentPolicies);
|
||||||
});
|
});
|
||||||
if (topUpSiParentPolicies.isNotEmpty) {
|
if (topUpSiParentPolicies.isNotEmpty) {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
@ -481,8 +482,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
|
|
||||||
topUpParentSlabRates =
|
topUpParentSlabRates =
|
||||||
await topUpSiParentPolicies['gmc_si_parent_topup']['SlabRates'];
|
await topUpSiParentPolicies['gmc_si_parent_topup']['SlabRates'];
|
||||||
print('topUpParentSlabRates');
|
logDebug('topUpParentSlabRates');
|
||||||
print(topUpParentSlabRates);
|
logDebug(topUpParentSlabRates);
|
||||||
|
|
||||||
topUpParentPolicyName =
|
topUpParentPolicyName =
|
||||||
await topUpSiParentPolicies['gmc_si_parent_topup']
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
||||||
@ -494,24 +495,24 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
topUpParentFamilyFloater =
|
topUpParentFamilyFloater =
|
||||||
await topUpSiParentPolicies['gmc_si_parent_topup']
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
||||||
['policy_terms']['family_floater'];
|
['policy_terms']['family_floater'];
|
||||||
print('topUpParentFamilyFloater');
|
logDebug('topUpParentFamilyFloater');
|
||||||
print(topUpParentFamilyFloater);
|
logDebug(topUpParentFamilyFloater);
|
||||||
|
|
||||||
topUpParentMappedFamilyFloatersSi =
|
topUpParentMappedFamilyFloatersSi =
|
||||||
await topUpSiParentPolicies['gmc_si_parent_topup']
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
||||||
['family_floaters_of_only_si_array'];
|
['family_floaters_of_only_si_array'];
|
||||||
print('topUpParentMappedFamilyFloatersSi');
|
logDebug('topUpParentMappedFamilyFloatersSi');
|
||||||
print(topUpParentMappedFamilyFloatersSi);
|
logDebug(topUpParentMappedFamilyFloatersSi);
|
||||||
|
|
||||||
print('topUpECardDownload');
|
logDebug('topUpECardDownload');
|
||||||
topUpParentECardDownload =
|
topUpParentECardDownload =
|
||||||
topUpSiParentPolicies['gmc_si_parent_topup']['eCardDownload'];
|
topUpSiParentPolicies['gmc_si_parent_topup']['eCardDownload'];
|
||||||
print(topUpParentECardDownload);
|
logDebug(topUpParentECardDownload);
|
||||||
String intOpenForEnrollment =
|
String intOpenForEnrollment =
|
||||||
topUpSiParentPolicies['gmc_si_parent_topup']
|
topUpSiParentPolicies['gmc_si_parent_topup']
|
||||||
['OpenForEnrollment'];
|
['OpenForEnrollment'];
|
||||||
topUpParentOpenForEnrollment = int.parse(intOpenForEnrollment);
|
topUpParentOpenForEnrollment = int.parse(intOpenForEnrollment);
|
||||||
print(topUpParentOpenForEnrollment);
|
logDebug(topUpParentOpenForEnrollment);
|
||||||
|
|
||||||
topUpParentTypeName =
|
topUpParentTypeName =
|
||||||
topUpSiParentPolicies['gmc_si_parent_topup']['type'];
|
topUpSiParentPolicies['gmc_si_parent_topup']['type'];
|
||||||
@ -537,23 +538,23 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'No data found in the response');
|
// context, 'No data found in the response');
|
||||||
print('No data found in the response');
|
logDebug('No data found in the response');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,19 +570,19 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
if (response.containsKey('data')) {
|
if (response.containsKey('data')) {
|
||||||
dynamic addOnsDependentPolicies = response['data'];
|
dynamic addOnsDependentPolicies = response['data'];
|
||||||
print('addOnsDependentPolicies');
|
logDebug('addOnsDependentPolicies');
|
||||||
print(addOnsDependentPolicies);
|
logDebug(addOnsDependentPolicies);
|
||||||
if (addOnsDependentPolicies.isNotEmpty) {
|
if (addOnsDependentPolicies.isNotEmpty) {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
addOnsDependentClientPolicyId =
|
addOnsDependentClientPolicyId =
|
||||||
addOnsDependentPolicies['gmc_dependent_addon']
|
addOnsDependentPolicies['gmc_dependent_addon']
|
||||||
['client_policy_id'];
|
['client_policy_id'];
|
||||||
print(addOnsDependentClientPolicyId);
|
logDebug(addOnsDependentClientPolicyId);
|
||||||
|
|
||||||
addOnsDependentSumInsured =
|
addOnsDependentSumInsured =
|
||||||
addOnsDependentPolicies['gmc_dependent_addon']
|
addOnsDependentPolicies['gmc_dependent_addon']
|
||||||
['family_floaters_of_dependent_and_si_value'];
|
['family_floaters_of_dependent_and_si_value'];
|
||||||
print(addOnsDependentSumInsured);
|
logDebug(addOnsDependentSumInsured);
|
||||||
|
|
||||||
if (addOnsDependentSumInsured == 0) {
|
if (addOnsDependentSumInsured == 0) {
|
||||||
showHideAddOnsCard = 0;
|
showHideAddOnsCard = 0;
|
||||||
@ -591,17 +592,17 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
|
|
||||||
addOnsDependentPolicyName =
|
addOnsDependentPolicyName =
|
||||||
addOnsDependentPolicies['gmc_dependent_addon']['policy_name'];
|
addOnsDependentPolicies['gmc_dependent_addon']['policy_name'];
|
||||||
print(addOnsDependentPolicyName);
|
logDebug(addOnsDependentPolicyName);
|
||||||
|
|
||||||
addOnsDependentPolicyType =
|
addOnsDependentPolicyType =
|
||||||
addOnsDependentPolicies['gmc_dependent_addon']['type'];
|
addOnsDependentPolicies['gmc_dependent_addon']['type'];
|
||||||
print(addOnsDependentPolicyType);
|
logDebug(addOnsDependentPolicyType);
|
||||||
|
|
||||||
addOnsDependentMappedFamilyFloatersArray =
|
addOnsDependentMappedFamilyFloatersArray =
|
||||||
await addOnsDependentPolicies['gmc_dependent_addon']
|
await addOnsDependentPolicies['gmc_dependent_addon']
|
||||||
['family_floaters_of_dependent_and_si_array'];
|
['family_floaters_of_dependent_and_si_array'];
|
||||||
print('addOnsDependentMappedFamilyFloatersArray');
|
logDebug('addOnsDependentMappedFamilyFloatersArray');
|
||||||
print(addOnsDependentMappedFamilyFloatersArray);
|
logDebug(addOnsDependentMappedFamilyFloatersArray);
|
||||||
|
|
||||||
addOnsFloaterTextHeading =
|
addOnsFloaterTextHeading =
|
||||||
addOnsDependentPolicies['gmc_dependent_addon']
|
addOnsDependentPolicies['gmc_dependent_addon']
|
||||||
@ -616,23 +617,23 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'No data found in the response');
|
// context, 'No data found in the response');
|
||||||
print('No data found in the response');
|
logDebug('No data found in the response');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +646,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
.where((element) => element['is_value_exist'] == true)
|
.where((element) => element['is_value_exist'] == true)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
print(getDependentTrueObjects);
|
logDebug(getDependentTrueObjects);
|
||||||
|
|
||||||
if (getDependentTrueObjects.isNotEmpty) {
|
if (getDependentTrueObjects.isNotEmpty) {
|
||||||
iAgreeForAddOn.add(int.parse(addOnsDependentClientPolicyId));
|
iAgreeForAddOn.add(int.parse(addOnsDependentClientPolicyId));
|
||||||
@ -657,7 +658,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
.where((element) => element['is_value_exist'] == true)
|
.where((element) => element['is_value_exist'] == true)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
print(getSiTrueObjects);
|
logDebug(getSiTrueObjects);
|
||||||
|
|
||||||
if (getSiTrueObjects.isNotEmpty) {
|
if (getSiTrueObjects.isNotEmpty) {
|
||||||
iAgreeForAddOn.add(int.parse(topUpClientPolicyId));
|
iAgreeForAddOn.add(int.parse(topUpClientPolicyId));
|
||||||
@ -669,22 +670,22 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
.where((element) => element['is_value_exist'] == true)
|
.where((element) => element['is_value_exist'] == true)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
print(getSiTrueObjects);
|
logDebug(getSiTrueObjects);
|
||||||
|
|
||||||
if (getSiTrueObjects.isNotEmpty) {
|
if (getSiTrueObjects.isNotEmpty) {
|
||||||
iAgreeForAddOn.add(int.parse(topUpParentClientPolicyId));
|
iAgreeForAddOn.add(int.parse(topUpParentClientPolicyId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print('gpaPolicies');
|
logDebug('gpaPolicies');
|
||||||
print(gpaPolicies);
|
logDebug(gpaPolicies);
|
||||||
print('gmcPolicies');
|
logDebug('gmcPolicies');
|
||||||
print(gmcPolicies);
|
logDebug(gmcPolicies);
|
||||||
|
|
||||||
if (gpaDataIsEmpty != 0) {
|
if (gpaDataIsEmpty != 0) {
|
||||||
print('gpaDataIsEmpty : $gpaDataIsEmpty');
|
logDebug('gpaDataIsEmpty : $gpaDataIsEmpty');
|
||||||
for (var item in gpaPolicies) {
|
for (var item in gpaPolicies) {
|
||||||
print('ClientPolicyId');
|
logDebug('ClientPolicyId');
|
||||||
// Extract ClientPolicyId value from each object
|
// Extract ClientPolicyId value from each object
|
||||||
String clientPolicyId = item['ClientPolicyId'];
|
String clientPolicyId = item['ClientPolicyId'];
|
||||||
// Convert to integer and add to iAgreeForAddOn list
|
// Convert to integer and add to iAgreeForAddOn list
|
||||||
@ -700,16 +701,16 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
iAgreeForAddOn.add(int.parse(clientPolicyId));
|
iAgreeForAddOn.add(int.parse(clientPolicyId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print('iAgreeForAddOn');
|
logDebug('iAgreeForAddOn');
|
||||||
iAgreeForAddOn = iAgreeForAddOn.toSet().toList();
|
iAgreeForAddOn = iAgreeForAddOn.toSet().toList();
|
||||||
print(iAgreeForAddOn); // Output: [90, 92, 88, 89]
|
logDebug(iAgreeForAddOn); // Output: [90, 92, 88, 89]
|
||||||
|
|
||||||
Map<String, dynamic> apiParams = {
|
Map<String, dynamic> apiParams = {
|
||||||
'emp_code': empCodeString,
|
'emp_code': empCodeString,
|
||||||
'client_policy_id': iAgreeForAddOn,
|
'client_policy_id': iAgreeForAddOn,
|
||||||
'client_id': client_id,
|
'client_id': client_id,
|
||||||
};
|
};
|
||||||
print(apiParams);
|
logDebug(apiParams);
|
||||||
|
|
||||||
// Convert the list of objects to JSON
|
// Convert the list of objects to JSON
|
||||||
String formDataJson = jsonEncode(apiParams);
|
String formDataJson = jsonEncode(apiParams);
|
||||||
@ -725,7 +726,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
topUpParentIsChecked = false;
|
topUpParentIsChecked = false;
|
||||||
addOnsDependentIsChecked = false;
|
addOnsDependentIsChecked = false;
|
||||||
});
|
});
|
||||||
print('response.statusCode == 200');
|
logDebug('response.statusCode == 200');
|
||||||
_showSuccessDialog();
|
_showSuccessDialog();
|
||||||
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||||
} else {
|
} else {
|
||||||
@ -735,14 +736,14 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
_showErrorDialog();
|
_showErrorDialog();
|
||||||
ToastHelper.showErrorToast(context, 'Failed to Save');
|
ToastHelper.showErrorToast(context, 'Failed to Save');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,12 +820,12 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
|
|
||||||
Future<void> _launchURL(String url) async {
|
Future<void> _launchURL(String url) async {
|
||||||
final Uri uri = Uri.parse(url); // Parse the URL properly
|
final Uri uri = Uri.parse(url); // Parse the URL properly
|
||||||
print('_launchURL $uri');
|
logDebug('_launchURL $uri');
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
print('If $uri');
|
logDebug('If $uri');
|
||||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} else {
|
} else {
|
||||||
print('else $uri');
|
logDebug('else $uri');
|
||||||
throw 'Could not launch $url';
|
throw 'Could not launch $url';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2570,8 +2571,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
List<Widget> cards = [];
|
List<Widget> cards = [];
|
||||||
|
|
||||||
for (var item in data) {
|
for (var item in data) {
|
||||||
print('item');
|
logDebug('item');
|
||||||
print(item);
|
logDebug(item);
|
||||||
|
|
||||||
String? gpaPolicyName = item['Policy_Name'];
|
String? gpaPolicyName = item['Policy_Name'];
|
||||||
String? gpaPolicyType = item['type'];
|
String? gpaPolicyType = item['type'];
|
||||||
@ -2770,24 +2771,24 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
||||||
.where((element) => element['is_value_exist'] == true)
|
.where((element) => element['is_value_exist'] == true)
|
||||||
.toList();
|
.toList();
|
||||||
print('getTrueObjects');
|
logDebug('getTrueObjects');
|
||||||
print(getTrueObjects);
|
logDebug(getTrueObjects);
|
||||||
if (getTrueObjects.length > 0) {
|
if (getTrueObjects.length > 0) {
|
||||||
print('true');
|
logDebug('true');
|
||||||
gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"];
|
gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"];
|
||||||
} else {
|
} else {
|
||||||
print('false');
|
logDebug('false');
|
||||||
gmcSumInsured = item['Policy_Terms']['sum_insured'];
|
gmcSumInsured = item['Policy_Terms']['sum_insured'];
|
||||||
}
|
}
|
||||||
gmcTypeName = item['type'];
|
gmcTypeName = item['type'];
|
||||||
});
|
});
|
||||||
print('forEach Card');
|
logDebug('forEach Card');
|
||||||
print(gmcMappedFamilyFloaters);
|
logDebug(gmcMappedFamilyFloaters);
|
||||||
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
||||||
.where((element) => element['is_value_exist'] == true)
|
.where((element) => element['is_value_exist'] == true)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
print(getTrueObjects);
|
logDebug(getTrueObjects);
|
||||||
|
|
||||||
Widget card = getTrueObjects.length > 0
|
Widget card = getTrueObjects.length > 0
|
||||||
? Card(
|
? Card(
|
||||||
|
|||||||
193
lib/home.dart
193
lib/home.dart
@ -13,6 +13,7 @@ import 'package:jwt_decode/jwt_decode.dart';
|
|||||||
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
||||||
|
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
// void main() {
|
// void main() {
|
||||||
// runApp(MaterialApp(
|
// runApp(MaterialApp(
|
||||||
@ -108,15 +109,15 @@ class _MyAppState extends State<MyApp> {
|
|||||||
});
|
});
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
print(decodedToken);
|
logDebug(decodedToken);
|
||||||
empCodeString =
|
empCodeString =
|
||||||
decodedToken['emp_code'].toString(); // Ensure it's a string
|
decodedToken['emp_code'].toString(); // Ensure it's a string
|
||||||
print(empCodeString); // Check if emp_code is correct
|
logDebug(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = decodedToken['id'].toString();
|
empPrimaryId = decodedToken['id'].toString();
|
||||||
gpaEmpName = decodedToken['name'].toString();
|
gpaEmpName = decodedToken['name'].toString();
|
||||||
client_id = decodedToken['client_id'].toString();
|
client_id = decodedToken['client_id'].toString();
|
||||||
print(client_id);
|
logDebug(client_id);
|
||||||
// print(empPrimaryId);
|
// logDebug(empPrimaryId);
|
||||||
// Call the API when the page enters
|
// Call the API when the page enters
|
||||||
getEmpDetails(empCodeString);
|
getEmpDetails(empCodeString);
|
||||||
fetchRelationshipList();
|
fetchRelationshipList();
|
||||||
@ -136,7 +137,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
'Bearer $_token', // Add token to the Authorization header
|
||||||
},
|
},
|
||||||
@ -153,7 +155,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
.where((obj) => obj['relationship'] != 'Self')
|
.where((obj) => obj['relationship'] != 'Self')
|
||||||
.toList();
|
.toList();
|
||||||
nonSelfObjectsArrayDetails = nonSelfObjects;
|
nonSelfObjectsArrayDetails = nonSelfObjects;
|
||||||
print(nonSelfObjectsArrayDetails);
|
logDebug(nonSelfObjectsArrayDetails);
|
||||||
List<FamilyMember> familyMembersFromDetails =
|
List<FamilyMember> familyMembersFromDetails =
|
||||||
nonSelfObjects.map((detail) {
|
nonSelfObjects.map((detail) {
|
||||||
return FamilyMember(
|
return FamilyMember(
|
||||||
@ -174,7 +176,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
|
|
||||||
personalDetails =
|
personalDetails =
|
||||||
selfObject; // Assuming the first item contains the desired details
|
selfObject; // Assuming the first item contains the desired details
|
||||||
print(personalDetails);
|
logDebug(personalDetails);
|
||||||
|
|
||||||
_empCodeController.text = personalDetails != null
|
_empCodeController.text = personalDetails != null
|
||||||
? personalDetails['emp_code'] ?? ''
|
? personalDetails['emp_code'] ?? ''
|
||||||
@ -191,18 +193,18 @@ class _MyAppState extends State<MyApp> {
|
|||||||
_mobileController.text =
|
_mobileController.text =
|
||||||
personalDetails != null ? personalDetails['mobile'] ?? '' : '';
|
personalDetails != null ? personalDetails['mobile'] ?? '' : '';
|
||||||
} else {
|
} else {
|
||||||
print('Empty or invalid data received');
|
logDebug('Empty or invalid data received');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('Invalid response format: missing "data" key');
|
logDebug('Invalid response format: missing "data" key');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +215,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
'Bearer $_token', // Add token to the Authorization header
|
||||||
},
|
},
|
||||||
@ -247,7 +250,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
|
|
||||||
if (gpaPolicies.isNotEmpty) {
|
if (gpaPolicies.isNotEmpty) {
|
||||||
// You can use gpaPolicies as needed
|
// You can use gpaPolicies as needed
|
||||||
print('GPA Policies found: $gpaPolicies');
|
logDebug('GPA Policies found: $gpaPolicies');
|
||||||
gpaPolicyName = await gpaPolicies[0]['Policy_Name'];
|
gpaPolicyName = await gpaPolicies[0]['Policy_Name'];
|
||||||
gpaGridMaster = await gpaPolicies[0]['GridMaster'];
|
gpaGridMaster = await gpaPolicies[0]['GridMaster'];
|
||||||
gpaSlabRates = await gpaPolicies[0]['SlabRates'];
|
gpaSlabRates = await gpaPolicies[0]['SlabRates'];
|
||||||
@ -259,18 +262,18 @@ class _MyAppState extends State<MyApp> {
|
|||||||
gpaSelectedSI =
|
gpaSelectedSI =
|
||||||
gpaMappedFamilyFloaters['basic_cover_si'].toString();
|
gpaMappedFamilyFloaters['basic_cover_si'].toString();
|
||||||
|
|
||||||
print(gpasumInsured);
|
logDebug(gpasumInsured);
|
||||||
//find the premium amount that match sumInsured amount from policyTerm
|
//find the premium amount that match sumInsured amount from policyTerm
|
||||||
Map<String, dynamic>? findGpasumInsuredObject =
|
Map<String, dynamic>? findGpasumInsuredObject =
|
||||||
gpaSlabRates.firstWhere(
|
gpaSlabRates.firstWhere(
|
||||||
(rate) => rate['si'] == gpasumInsured.toString(),
|
(rate) => rate['si'] == gpasumInsured.toString(),
|
||||||
orElse: () => null,
|
orElse: () => null,
|
||||||
);
|
);
|
||||||
print('test');
|
logDebug('test');
|
||||||
if (findGpasumInsuredObject != null) {
|
if (findGpasumInsuredObject != null) {
|
||||||
gpasumInsuredPermium =
|
gpasumInsuredPermium =
|
||||||
findGpasumInsuredObject['premium'].toString();
|
findGpasumInsuredObject['premium'].toString();
|
||||||
// print(test);
|
// logDebug(test);
|
||||||
} else {
|
} else {
|
||||||
gpasumInsuredPermium = 0;
|
gpasumInsuredPermium = 0;
|
||||||
}
|
}
|
||||||
@ -289,23 +292,23 @@ class _MyAppState extends State<MyApp> {
|
|||||||
gpaAssignSelectedSI = 0;
|
gpaAssignSelectedSI = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
print(gpaSelectedSlabRateObject);
|
logDebug(gpaSelectedSlabRateObject);
|
||||||
if (gpaSelectedSlabRateObject != null) {
|
if (gpaSelectedSlabRateObject != null) {
|
||||||
gpaPermiumValue = gpaSelectedSlabRateObject['premium'].toString();
|
gpaPermiumValue = gpaSelectedSlabRateObject['premium'].toString();
|
||||||
} else {
|
} else {
|
||||||
gpaPermiumValue = 0;
|
gpaPermiumValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
print(gpaAssignSelectedSI);
|
logDebug(gpaAssignSelectedSI);
|
||||||
|
|
||||||
String stringValue =
|
String stringValue =
|
||||||
gpaSelectedSI.toString(); // Extract the string from the list
|
gpaSelectedSI.toString(); // Extract the string from the list
|
||||||
int intValue1 = int.parse(stringValue);
|
int intValue1 = int.parse(stringValue);
|
||||||
int? intValue = int.tryParse(gpasumInsured);
|
int? intValue = int.tryParse(gpasumInsured);
|
||||||
print('policy_trem_amound');
|
logDebug('policy_trem_amound');
|
||||||
print(intValue);
|
logDebug(intValue);
|
||||||
print("selected si");
|
logDebug("selected si");
|
||||||
print(intValue1);
|
logDebug(intValue1);
|
||||||
if (intValue != null && intValue1 != null) {
|
if (intValue != null && intValue1 != null) {
|
||||||
if (intValue < intValue1) {
|
if (intValue < intValue1) {
|
||||||
gpaAdditionalText = 1;
|
gpaAdditionalText = 1;
|
||||||
@ -314,7 +317,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
(rate) => rate['si'] == gpaAssignSelectedSI.toString(),
|
(rate) => rate['si'] == gpaAssignSelectedSI.toString(),
|
||||||
orElse: () => null,
|
orElse: () => null,
|
||||||
);
|
);
|
||||||
print(findObject);
|
logDebug(findObject);
|
||||||
|
|
||||||
// setState(() {
|
// setState(() {
|
||||||
gpaAPISIDetails = findObject;
|
gpaAPISIDetails = findObject;
|
||||||
@ -327,84 +330,84 @@ class _MyAppState extends State<MyApp> {
|
|||||||
} else {
|
} else {
|
||||||
gpaPermiumValueChanged = 0;
|
gpaPermiumValueChanged = 0;
|
||||||
}
|
}
|
||||||
print(gpaPermiumValueChanged);
|
logDebug(gpaPermiumValueChanged);
|
||||||
print(gpaPermiumValue);
|
logDebug(gpaPermiumValue);
|
||||||
|
|
||||||
// Convert string values to integers
|
// Convert string values to integers
|
||||||
int gpaSelectedPermium =
|
int gpaSelectedPermium =
|
||||||
int.tryParse(gpasumInsuredPermium) ?? 0;
|
int.tryParse(gpasumInsuredPermium) ?? 0;
|
||||||
int gpaChangedPermium =
|
int gpaChangedPermium =
|
||||||
int.tryParse(gpaPermiumValueChanged) ?? 0;
|
int.tryParse(gpaPermiumValueChanged) ?? 0;
|
||||||
print('gpasumInsuredPermium');
|
logDebug('gpasumInsuredPermium');
|
||||||
print(gpaSelectedPermium);
|
logDebug(gpaSelectedPermium);
|
||||||
print("gpaChangedPermium");
|
logDebug("gpaChangedPermium");
|
||||||
print(gpaChangedPermium);
|
logDebug(gpaChangedPermium);
|
||||||
// Calculate the result
|
// Calculate the result
|
||||||
int? result =
|
int? result =
|
||||||
gpaSelectedPermium != null && gpaChangedPermium != null
|
gpaSelectedPermium != null && gpaChangedPermium != null
|
||||||
? gpaChangedPermium - gpaSelectedPermium
|
? gpaChangedPermium - gpaSelectedPermium
|
||||||
: null;
|
: null;
|
||||||
print(result);
|
logDebug(result);
|
||||||
gpaAdditionalTextAmount = result;
|
gpaAdditionalTextAmount = result;
|
||||||
|
|
||||||
print(gpaAdditionalText);
|
logDebug(gpaAdditionalText);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
gpaAdditionalText = 0;
|
gpaAdditionalText = 0;
|
||||||
print(gpaAdditionalText);
|
logDebug(gpaAdditionalText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('GPA Policies not found');
|
logDebug('GPA Policies not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gmcPolicies.isNotEmpty) {
|
if (gmcPolicies.isNotEmpty) {
|
||||||
// You can use gmcPolicies as needed
|
// You can use gmcPolicies as needed
|
||||||
print('GMC Policies found: $gmcPolicies');
|
logDebug('GMC Policies found: $gmcPolicies');
|
||||||
gmcPolicyName = await gmcPolicies[0]['Policy_Name'];
|
gmcPolicyName = await gmcPolicies[0]['Policy_Name'];
|
||||||
gmcGridMaster = await gmcPolicies[0]['GridMaster'];
|
gmcGridMaster = await gmcPolicies[0]['GridMaster'];
|
||||||
gmcSlabRates = await gmcPolicies[0]['SlabRates'];
|
gmcSlabRates = await gmcPolicies[0]['SlabRates'];
|
||||||
// relationshipOptions =
|
// relationshipOptions =
|
||||||
// await await gmcPolicies[0]['Policy_Terms']['family_floaters'];
|
// await await gmcPolicies[0]['Policy_Terms']['family_floaters'];
|
||||||
// print(relationshipOptions);
|
// logDebug(relationshipOptions);
|
||||||
gmcfamily_floaters = await gmcPolicies[0]['mapped_family_floaters'];
|
gmcfamily_floaters = await gmcPolicies[0]['mapped_family_floaters'];
|
||||||
print(gmcfamily_floaters);
|
logDebug(gmcfamily_floaters);
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcFamily_floater_Status =
|
gmcFamily_floater_Status =
|
||||||
gmcPolicies[0]['Policy_Terms']['family_floater'];
|
gmcPolicies[0]['Policy_Terms']['family_floater'];
|
||||||
print(gmcFamily_floater_Status);
|
logDebug(gmcFamily_floater_Status);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
print('GMC Policies not found');
|
logDebug('GMC Policies not found');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
print('API request failed with status: ${data['status']}');
|
logDebug('API request failed with status: ${data['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkGpaSumInsured() {
|
checkGpaSumInsured() {
|
||||||
print(gpaAssignSelectedSI);
|
logDebug(gpaAssignSelectedSI);
|
||||||
// print(gpaPermiumValue);
|
// logDebug(gpaPermiumValue);
|
||||||
// print(gpaSelectedSlabRateObject);
|
// logDebug(gpaSelectedSlabRateObject);
|
||||||
String stringValue =
|
String stringValue =
|
||||||
gpaSelectedSI.toString(); // Extract the string from the list
|
gpaSelectedSI.toString(); // Extract the string from the list
|
||||||
int intValue1 = int.parse(stringValue);
|
int intValue1 = int.parse(stringValue);
|
||||||
int? intValue = int.tryParse(gpasumInsured);
|
int? intValue = int.tryParse(gpasumInsured);
|
||||||
print('policy_trem_amound');
|
logDebug('policy_trem_amound');
|
||||||
print(intValue);
|
logDebug(intValue);
|
||||||
print("selected si");
|
logDebug("selected si");
|
||||||
print(intValue1);
|
logDebug(intValue1);
|
||||||
if (intValue != null && intValue1 != null) {
|
if (intValue != null && intValue1 != null) {
|
||||||
if (intValue < intValue1) {
|
if (intValue < intValue1) {
|
||||||
gpaAdditionalText = 1;
|
gpaAdditionalText = 1;
|
||||||
@ -413,7 +416,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
(rate) => rate['si'] == gpaSelectedSI.toString(),
|
(rate) => rate['si'] == gpaSelectedSI.toString(),
|
||||||
orElse: () => null,
|
orElse: () => null,
|
||||||
);
|
);
|
||||||
print(findObject);
|
logDebug(findObject);
|
||||||
|
|
||||||
// setState(() {
|
// setState(() {
|
||||||
gpaAPISIDetails = findObject;
|
gpaAPISIDetails = findObject;
|
||||||
@ -425,29 +428,29 @@ class _MyAppState extends State<MyApp> {
|
|||||||
} else {
|
} else {
|
||||||
gpaPermiumValueChanged = 0;
|
gpaPermiumValueChanged = 0;
|
||||||
}
|
}
|
||||||
print(gpaPermiumValueChanged);
|
logDebug(gpaPermiumValueChanged);
|
||||||
print(gpaPermiumValue);
|
logDebug(gpaPermiumValue);
|
||||||
|
|
||||||
// Convert string values to integers
|
// Convert string values to integers
|
||||||
int gpaSelectedPermium = int.tryParse(gpasumInsuredPermium) ?? 0;
|
int gpaSelectedPermium = int.tryParse(gpasumInsuredPermium) ?? 0;
|
||||||
int gpaChangedPermium = int.tryParse(gpaPermiumValueChanged) ?? 0;
|
int gpaChangedPermium = int.tryParse(gpaPermiumValueChanged) ?? 0;
|
||||||
print('gpasumInsuredPermium');
|
logDebug('gpasumInsuredPermium');
|
||||||
print(gpaSelectedPermium);
|
logDebug(gpaSelectedPermium);
|
||||||
print("gpaChangedPermium");
|
logDebug("gpaChangedPermium");
|
||||||
print(gpaChangedPermium);
|
logDebug(gpaChangedPermium);
|
||||||
// Calculate the result
|
// Calculate the result
|
||||||
int? result = gpaSelectedPermium != null && gpaChangedPermium != null
|
int? result = gpaSelectedPermium != null && gpaChangedPermium != null
|
||||||
? gpaChangedPermium - gpaSelectedPermium
|
? gpaChangedPermium - gpaSelectedPermium
|
||||||
: null;
|
: null;
|
||||||
print(result);
|
logDebug(result);
|
||||||
gpaAdditionalTextAmount = result;
|
gpaAdditionalTextAmount = result;
|
||||||
|
|
||||||
print(gpaAdditionalText);
|
logDebug(gpaAdditionalText);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
gpaAdditionalText = 0;
|
gpaAdditionalText = 0;
|
||||||
print(gpaAdditionalText);
|
logDebug(gpaAdditionalText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -477,7 +480,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
url,
|
url,
|
||||||
body: jsonEncode(requestBody),
|
body: jsonEncode(requestBody),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
// Add authorization header if needed
|
// Add authorization header if needed
|
||||||
'Authorization': 'Bearer $_token',
|
'Authorization': 'Bearer $_token',
|
||||||
@ -491,11 +495,11 @@ class _MyAppState extends State<MyApp> {
|
|||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(context, 'Failed to update user details');
|
// ToastHelper.showErrorToast(context, 'Failed to update user details');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
// ToastHelper.showErrorToast(context, 'Exception occurred: $e');
|
// ToastHelper.showErrorToast(context, 'Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,7 +512,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
'Bearer $_token', // Add token to the Authorization header
|
||||||
},
|
},
|
||||||
@ -526,7 +531,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Error fetching relationship list: $error');
|
// context, 'Error fetching relationship list: $error');
|
||||||
print('Error fetching relationship list: $error');
|
logDebug('Error fetching relationship list: $error');
|
||||||
// Handle error accordingly, e.g., show a snackbar with an error message
|
// Handle error accordingly, e.g., show a snackbar with an error message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -538,20 +543,20 @@ class _MyAppState extends State<MyApp> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// void removeFamilyMember(int index) {
|
// void removeFamilyMember(int index) {
|
||||||
// print(index);
|
// logDebug(index);
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// familyMembers.removeAt(index);
|
// familyMembers.removeAt(index);
|
||||||
// });
|
// });
|
||||||
// print(familyMembers.toString());
|
// logDebug(familyMembers.toString());
|
||||||
// }
|
// }
|
||||||
void removeFamilyMember(int index) async {
|
void removeFamilyMember(int index) async {
|
||||||
print(index);
|
logDebug(index);
|
||||||
// print(nonSelfObjectsArrayDetails[index]);
|
// logDebug(nonSelfObjectsArrayDetails[index]);
|
||||||
// return;
|
// return;
|
||||||
try {
|
try {
|
||||||
if (index >= 0 && index < nonSelfObjectsArrayDetails.length) {
|
if (index >= 0 && index < nonSelfObjectsArrayDetails.length) {
|
||||||
var removeObject = nonSelfObjectsArrayDetails[index] ?? false;
|
var removeObject = nonSelfObjectsArrayDetails[index] ?? false;
|
||||||
print(removeObject);
|
logDebug(removeObject);
|
||||||
if (removeObject != false) {
|
if (removeObject != false) {
|
||||||
final id = nonSelfObjectsArrayDetails[index]['id'];
|
final id = nonSelfObjectsArrayDetails[index]['id'];
|
||||||
// If the family member has an ID, it means it's an existing record, so make an API call to delete it
|
// If the family member has an ID, it means it's an existing record, so make an API call to delete it
|
||||||
@ -560,7 +565,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header // Add your authorization token here
|
'Bearer $_token', // Add token to the Authorization header // Add your authorization token here
|
||||||
@ -573,10 +579,10 @@ class _MyAppState extends State<MyApp> {
|
|||||||
familyMembers.removeAt(index);
|
familyMembers.removeAt(index);
|
||||||
nonSelfObjectsArrayDetails.removeAt(index);
|
nonSelfObjectsArrayDetails.removeAt(index);
|
||||||
});
|
});
|
||||||
print('Family member removed successfully');
|
logDebug('Family member removed successfully');
|
||||||
} else {
|
} else {
|
||||||
// If API call fails, print error message
|
// If API call fails, print error message
|
||||||
print('Failed to remove family member: ${response.statusCode}');
|
logDebug('Failed to remove family member: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the family member doesn't have an ID, it's a new record, so simply remove it from the list locally
|
// If the family member doesn't have an ID, it's a new record, so simply remove it from the list locally
|
||||||
@ -591,20 +597,20 @@ class _MyAppState extends State<MyApp> {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle any errors that occur during the API call
|
// Handle any errors that occur during the API call
|
||||||
// print('Error removing family member: $error');
|
// logDebug('Error removing family member: $error');
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Error removing family member: $error');
|
// context, 'Error removing family member: $error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveFamilyMemberDetails() async {
|
void saveFamilyMemberDetails() async {
|
||||||
print(nonSelfObjectsArrayDetails);
|
logDebug(nonSelfObjectsArrayDetails);
|
||||||
try {
|
try {
|
||||||
// Convert familyMembers list to a list of JSON objects
|
// Convert familyMembers list to a list of JSON objects
|
||||||
// Convert familyMembers list to a list of JSON objects
|
// Convert familyMembers list to a list of JSON objects
|
||||||
final List<Map<String, dynamic>> membersData =
|
final List<Map<String, dynamic>> membersData =
|
||||||
familyMembers.map((member) {
|
familyMembers.map((member) {
|
||||||
print(member);
|
logDebug(member);
|
||||||
// Include additional fields from personalDetails
|
// Include additional fields from personalDetails
|
||||||
return {
|
return {
|
||||||
'relationship': member.relationship,
|
'relationship': member.relationship,
|
||||||
@ -614,7 +620,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
'client_id': personalDetails['client_id'],
|
'client_id': personalDetails['client_id'],
|
||||||
};
|
};
|
||||||
}).toList();
|
}).toList();
|
||||||
print(membersData);
|
logDebug(membersData);
|
||||||
|
|
||||||
List<Map<String, dynamic>> updatedNewData =
|
List<Map<String, dynamic>> updatedNewData =
|
||||||
List<Map<String, dynamic>>.generate(membersData.length, (index) {
|
List<Map<String, dynamic>>.generate(membersData.length, (index) {
|
||||||
@ -625,7 +631,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
}
|
}
|
||||||
return updatedEntry;
|
return updatedEntry;
|
||||||
});
|
});
|
||||||
print(updatedNewData);
|
logDebug(updatedNewData);
|
||||||
|
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
// Iterate through familyMembers list and send each member's data to the API
|
||||||
final url = Uri.parse(Environment.apiUrl + 'addEmployeeAndDependence');
|
final url = Uri.parse(Environment.apiUrl + 'addEmployeeAndDependence');
|
||||||
@ -633,7 +639,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
url,
|
url,
|
||||||
body: jsonEncode(updatedNewData),
|
body: jsonEncode(updatedNewData),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
'Bearer $_token', // Add token to the Authorization header
|
||||||
@ -660,7 +667,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
|
|
||||||
void sendGpaDataToAPI() async {
|
void sendGpaDataToAPI() async {
|
||||||
// Create a list to store the selected values for each floater
|
// Create a list to store the selected values for each floater
|
||||||
print(gpaAPISIDetails);
|
logDebug(gpaAPISIDetails);
|
||||||
String si = gpaSelectedSI ?? '';
|
String si = gpaSelectedSI ?? '';
|
||||||
// String premium = gpaAPISIDetails['premium'];
|
// String premium = gpaAPISIDetails['premium'];
|
||||||
String ClientPolicyId = gpaClintPolicyId;
|
String ClientPolicyId = gpaClintPolicyId;
|
||||||
@ -679,11 +686,11 @@ class _MyAppState extends State<MyApp> {
|
|||||||
|
|
||||||
gpaApiData = floaterData;
|
gpaApiData = floaterData;
|
||||||
|
|
||||||
print(gpaApiData);
|
logDebug(gpaApiData);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final jsonData = gpaApiData;
|
final jsonData = gpaApiData;
|
||||||
print(jsonData);
|
logDebug(jsonData);
|
||||||
|
|
||||||
// return;
|
// return;
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
// Iterate through familyMembers list and send each member's data to the API
|
||||||
@ -693,7 +700,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
url,
|
url,
|
||||||
body: jsonEncode(jsonData),
|
body: jsonEncode(jsonData),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
'Bearer $_token', // Add token to the Authorization header
|
||||||
@ -710,15 +718,15 @@ class _MyAppState extends State<MyApp> {
|
|||||||
});
|
});
|
||||||
floaterData = [];
|
floaterData = [];
|
||||||
// ToastHelper.showSuccessToast(context, "Saved successfully!");
|
// ToastHelper.showSuccessToast(context, "Saved successfully!");
|
||||||
print('Saved successfully!');
|
logDebug('Saved successfully!');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Failed to save member
|
// Failed to save member
|
||||||
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
||||||
print('Operation Failed!');
|
logDebug('Operation Failed!');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print('Error saving family members');
|
logDebug('Error saving family members');
|
||||||
// ToastHelper.showErrorToast(context, "Error saving family members");
|
// ToastHelper.showErrorToast(context, "Error saving family members");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -727,7 +735,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
// Create a list to store the selected values for each floater
|
// Create a list to store the selected values for each floater
|
||||||
List<Map<String, String>> selectedValues = [];
|
List<Map<String, String>> selectedValues = [];
|
||||||
// try {
|
// try {
|
||||||
print('fff');
|
logDebug('fff');
|
||||||
// Iterate through each floater and get its selected value
|
// Iterate through each floater and get its selected value
|
||||||
// Iterate through each floater and get its selected value
|
// Iterate through each floater and get its selected value
|
||||||
for (var floater in gmcfamily_floaters) {
|
for (var floater in gmcfamily_floaters) {
|
||||||
@ -750,7 +758,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final jsonData = selectedValues;
|
final jsonData = selectedValues;
|
||||||
print(jsonData);
|
logDebug(jsonData);
|
||||||
// return;
|
// return;
|
||||||
// Iterate through each object in apidata
|
// Iterate through each object in apidata
|
||||||
for (var data in jsonData) {
|
for (var data in jsonData) {
|
||||||
@ -766,8 +774,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("gwm");
|
logDebug("gwm");
|
||||||
print(jsonData);
|
logDebug(jsonData);
|
||||||
// return;
|
// return;
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
// Iterate through familyMembers list and send each member's data to the API
|
||||||
final url =
|
final url =
|
||||||
@ -776,7 +784,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
url,
|
url,
|
||||||
body: jsonEncode(jsonData),
|
body: jsonEncode(jsonData),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
'Bearer $_token', // Add token to the Authorization header
|
||||||
@ -791,15 +800,15 @@ class _MyAppState extends State<MyApp> {
|
|||||||
getEmpDetails(empCodeString);
|
getEmpDetails(empCodeString);
|
||||||
});
|
});
|
||||||
// ToastHelper.showSuccessToast(context, "Saved successfully!");
|
// ToastHelper.showSuccessToast(context, "Saved successfully!");
|
||||||
print('Saved successfully!');
|
logDebug('Saved successfully!');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('Operation Failed!');
|
logDebug('Operation Failed!');
|
||||||
// Failed to save member
|
// Failed to save member
|
||||||
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
||||||
}
|
}
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
print('Error saving family members');
|
logDebug('Error saving family members');
|
||||||
// ToastHelper.showErrorToast(context, "Error saving family members");
|
// ToastHelper.showErrorToast(context, "Error saving family members");
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import 'package:path_provider/path_provider.dart';
|
|||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class MyHrHome extends StatefulWidget {
|
class MyHrHome extends StatefulWidget {
|
||||||
const MyHrHome({Key? key}) : super(key: key);
|
const MyHrHome({Key? key}) : super(key: key);
|
||||||
@ -95,30 +96,31 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization': 'Bearer $_token',
|
'Authorization': 'Bearer $_token',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
Map<String, dynamic> data = json.decode(response.body);
|
||||||
if (data['status'] == 'success') {
|
if (data['status'] == 'success') {
|
||||||
print(data);
|
logDebug(data);
|
||||||
setState(() {
|
setState(() {
|
||||||
dataPolicy = List<Map<String, dynamic>>.from(data['data']);
|
dataPolicy = List<Map<String, dynamic>>.from(data['data']);
|
||||||
print(dataPolicy);
|
logDebug(dataPolicy);
|
||||||
// reversedDataPolicy = dataPolicy.reversed.toList();
|
// reversedDataPolicy = dataPolicy.reversed.toList();
|
||||||
// getPolicyNameDetails0 = dataPolicy[0]['policy_name'];
|
// getPolicyNameDetails0 = dataPolicy[0]['policy_name'];
|
||||||
// print(getPolicyNameDetails0);
|
// logDebug(getPolicyNameDetails0);
|
||||||
// getPolicyNameDetails1 = dataPolicy[1]['policy_name'];
|
// getPolicyNameDetails1 = dataPolicy[1]['policy_name'];
|
||||||
// print(getPolicyNameDetails1);
|
// logDebug(getPolicyNameDetails1);
|
||||||
// getPolicyNameDetails2 = dataPolicy[2]['policy_name'];
|
// getPolicyNameDetails2 = dataPolicy[2]['policy_name'];
|
||||||
// print(getPolicyNameDetails2);
|
// logDebug(getPolicyNameDetails2);
|
||||||
// getPolicyNo0 = dataPolicy[0]['client_policy_id'];
|
// getPolicyNo0 = dataPolicy[0]['client_policy_id'];
|
||||||
// print(getPolicyNameDetails1);
|
// logDebug(getPolicyNameDetails1);
|
||||||
// getPolicyNo1 = dataPolicy[1]['client_policy_id'];
|
// getPolicyNo1 = dataPolicy[1]['client_policy_id'];
|
||||||
// print(getPolicyNameDetails1);
|
// logDebug(getPolicyNameDetails1);
|
||||||
// getPolicyNo2 = dataPolicy[2]['client_policy_id'];
|
// getPolicyNo2 = dataPolicy[2]['client_policy_id'];
|
||||||
// print(getPolicyNameDetails2);
|
// logDebug(getPolicyNameDetails2);
|
||||||
});
|
});
|
||||||
// Code to execute periodically every 2 seconds
|
// Code to execute periodically every 2 seconds
|
||||||
dataPolicy.forEach((policy) {
|
dataPolicy.forEach((policy) {
|
||||||
@ -147,15 +149,15 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
} else {
|
} else {
|
||||||
ToastHelper.showWarningToast(
|
ToastHelper.showWarningToast(
|
||||||
context, 'API request failed with status: ${data['status']}');
|
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 {
|
} else {
|
||||||
ToastHelper.showWarningToast(
|
ToastHelper.showWarningToast(
|
||||||
context, 'Request failed with status: ${response.statusCode}');
|
context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -173,7 +175,8 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization': 'Bearer $_token',
|
'Authorization': 'Bearer $_token',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -185,21 +188,21 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
List<Map<String, dynamic>>.from(data['data']);
|
List<Map<String, dynamic>>.from(data['data']);
|
||||||
originalDataGpa = getEmpDependenceByClintIdGPA;
|
originalDataGpa = getEmpDependenceByClintIdGPA;
|
||||||
filteredDataGpa = List.from(originalDataGpa);
|
filteredDataGpa = List.from(originalDataGpa);
|
||||||
print('filteredDataGpa');
|
logDebug('filteredDataGpa');
|
||||||
print(filteredDataGpa);
|
logDebug(filteredDataGpa);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showWarningToast(
|
ToastHelper.showWarningToast(
|
||||||
context, 'API request failed with status: ${data['status']}');
|
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 {
|
} else {
|
||||||
ToastHelper.showWarningToast(
|
ToastHelper.showWarningToast(
|
||||||
context, 'Request failed with status: ${response.statusCode}');
|
context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -217,7 +220,8 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization': 'Bearer $_token',
|
'Authorization': 'Bearer $_token',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -233,15 +237,15 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'API request failed with status: ${data['status']}');
|
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 {
|
} else {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'Request failed with status: ${response.statusCode}');
|
context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -259,7 +263,8 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization': 'Bearer $_token',
|
'Authorization': 'Bearer $_token',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -275,15 +280,15 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'API request failed with status: ${data['status']}');
|
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 {
|
} else {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'Request failed with status: ${response.statusCode}');
|
context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -303,7 +308,8 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer $_token',
|
'Authorization': 'Bearer $_token',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -320,15 +326,15 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'API request failed with status: ${data['status']}');
|
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 {
|
} else {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'Request failed with status: ${response.statusCode}');
|
context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -443,7 +449,8 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization': 'Bearer $_token',
|
'Authorization': 'Bearer $_token',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -467,7 +474,7 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
|
|||||||
html.Url.revokeObjectUrl(url);
|
html.Url.revokeObjectUrl(url);
|
||||||
} else {
|
} else {
|
||||||
// Handle error
|
// Handle error
|
||||||
print('Failed to download Excel file: ${response.statusCode}');
|
logDebug('Failed to download Excel file: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1306,7 +1313,7 @@ class _DependenceDataSource0 extends DataTableSource {
|
|||||||
int get selectedRowCount => 0;
|
int get selectedRowCount => 0;
|
||||||
|
|
||||||
void _navigateToAnotherPage(row) {
|
void _navigateToAnotherPage(row) {
|
||||||
print(row['mobile']);
|
logDebug(row['mobile']);
|
||||||
// Navigation logic here
|
// Navigation logic here
|
||||||
Navigator.pushNamed(context, 'empDetails',
|
Navigator.pushNamed(context, 'empDetails',
|
||||||
arguments: {'mobile': row['mobile']});
|
arguments: {'mobile': row['mobile']});
|
||||||
@ -1369,7 +1376,7 @@ class _DependenceDataSource1 extends DataTableSource {
|
|||||||
int get selectedRowCount => 0;
|
int get selectedRowCount => 0;
|
||||||
|
|
||||||
void _navigateToAnotherPage(row) {
|
void _navigateToAnotherPage(row) {
|
||||||
print(row);
|
logDebug(row);
|
||||||
Navigator.pushNamed(context, 'empDetails',
|
Navigator.pushNamed(context, 'empDetails',
|
||||||
arguments: {'mobile': row['mobile']});
|
arguments: {'mobile': row['mobile']});
|
||||||
}
|
}
|
||||||
@ -1432,7 +1439,7 @@ class _DependenceDataSource2 extends DataTableSource {
|
|||||||
int get selectedRowCount => 0;
|
int get selectedRowCount => 0;
|
||||||
|
|
||||||
void _navigateToAnotherPage(row) {
|
void _navigateToAnotherPage(row) {
|
||||||
print(row);
|
logDebug(row);
|
||||||
Navigator.pushNamed(context, 'empDetails',
|
Navigator.pushNamed(context, 'empDetails',
|
||||||
arguments: {'mobile': row['mobile']});
|
arguments: {'mobile': row['mobile']});
|
||||||
}
|
}
|
||||||
@ -1495,7 +1502,7 @@ class _DependenceDataSource3 extends DataTableSource {
|
|||||||
int get selectedRowCount => 0;
|
int get selectedRowCount => 0;
|
||||||
|
|
||||||
void _navigateToAnotherPage(row) {
|
void _navigateToAnotherPage(row) {
|
||||||
print(row);
|
logDebug(row);
|
||||||
Navigator.pushNamed(context, 'empDetails',
|
Navigator.pushNamed(context, 'empDetails',
|
||||||
arguments: {'mobile': row['mobile']});
|
arguments: {'mobile': row['mobile']});
|
||||||
}
|
}
|
||||||
|
|||||||
143
lib/hrLogin.dart
143
lib/hrLogin.dart
@ -17,6 +17,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
|
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
import 'email_verify.dart';
|
import 'email_verify.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class MyHrLogin extends StatefulWidget {
|
class MyHrLogin extends StatefulWidget {
|
||||||
const MyHrLogin({Key? key});
|
const MyHrLogin({Key? key});
|
||||||
@ -45,24 +46,21 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
print('vndbbcbdskbvkjs1');
|
logDebug('vndbbcbdskbvkjs1');
|
||||||
// countryController.text = "+91";
|
// countryController.text = "+91";
|
||||||
super.initState();
|
super.initState();
|
||||||
clearLocalStorageWhenStarts('initState');
|
clearLocalStorageWhenStarts('initState');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
clearLocalStorageWhenStarts(fromData) async {
|
clearLocalStorageWhenStarts(fromData) async {
|
||||||
print(fromData);
|
logDebug(fromData);
|
||||||
print('Clearing secure storage on app start');
|
logDebug('Clearing secure storage on app start');
|
||||||
|
|
||||||
await tokenService.clearAll();
|
await tokenService.clearAll();
|
||||||
|
|
||||||
print('Secure Storage Cleared');
|
logDebug('Secure Storage Cleared');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void toggleField() {
|
void toggleField() {
|
||||||
setState(() {
|
setState(() {
|
||||||
isEmailFieldVisible = !isEmailFieldVisible;
|
isEmailFieldVisible = !isEmailFieldVisible;
|
||||||
@ -71,7 +69,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
|
|
||||||
Future<void> verifyMobileAndEmailNumber() async {
|
Future<void> verifyMobileAndEmailNumber() async {
|
||||||
await tokenService.clearAll();
|
await tokenService.clearAll();
|
||||||
print('verifyMobileAndEmailNumber :- Local Storage Clear');
|
logDebug('verifyMobileAndEmailNumber :- Local Storage Clear');
|
||||||
try {
|
try {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -87,13 +85,12 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isEmailFieldVisible = true;
|
isEmailFieldVisible = true;
|
||||||
});
|
});
|
||||||
print("User entered Email: $input");
|
logDebug("User entered Email: $input");
|
||||||
} else if (isMobile) {
|
} else if (isMobile) {
|
||||||
isEmailFieldVisible = false;
|
isEmailFieldVisible = false;
|
||||||
print("User entered Mobile: $input");
|
logDebug("User entered Mobile: $input");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Determine the API and the payload based on the visible field
|
// Determine the API and the payload based on the visible field
|
||||||
String apiEndpoint = isEmailFieldVisible
|
String apiEndpoint = isEmailFieldVisible
|
||||||
? Environment.apiUrl + 'verifyHrWithEmail'
|
? Environment.apiUrl + 'verifyHrWithEmail'
|
||||||
@ -108,7 +105,8 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
Uri.parse(apiEndpoint),
|
Uri.parse(apiEndpoint),
|
||||||
body: json.encode(payload),
|
body: json.encode(payload),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -119,33 +117,37 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
String message = data['data']['message'];
|
String message = data['data']['message'];
|
||||||
if (userVerification) {
|
if (userVerification) {
|
||||||
if (isEmailFieldVisible) {
|
if (isEmailFieldVisible) {
|
||||||
print('isEmailFieldVisible $isEmailFieldVisible');
|
logDebug('isEmailFieldVisible $isEmailFieldVisible');
|
||||||
await tokenService.writeValue(
|
await tokenService.writeValue(
|
||||||
'empEmail',
|
'empEmail',
|
||||||
emailMobileController.text,
|
emailMobileController.text,
|
||||||
);
|
);
|
||||||
|
|
||||||
// print('${emailMobileController.text}');
|
// logDebug('${emailMobileController.text}');
|
||||||
// final message = 'Verification code sent to ${emailMobileController.text}';
|
// final message = 'Verification code sent to ${emailMobileController.text}';
|
||||||
ToastHelper.showSuccessToast(context, 'Verification code sent to ${emailMobileController.text}');
|
ToastHelper.showSuccessToast(context,
|
||||||
|
'Verification code sent to ${emailMobileController.text}');
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => MyEmailVerify(
|
builder: (context) => MyEmailVerify(
|
||||||
type: 'email',
|
type: 'email',
|
||||||
value: emailMobileController.text.trim(), // Pass the phone number
|
value: emailMobileController.text
|
||||||
|
.trim(), // Pass the phone number
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// final message = 'Verification code sent to ${emailMobileController.text}';
|
// final message = 'Verification code sent to ${emailMobileController.text}';
|
||||||
ToastHelper.showSuccessToast(context, 'Verification code sent to ${emailMobileController.text}');
|
ToastHelper.showSuccessToast(context,
|
||||||
|
'Verification code sent to ${emailMobileController.text}');
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => MyEmailVerify(
|
builder: (context) => MyEmailVerify(
|
||||||
type: 'mobile',
|
type: 'mobile',
|
||||||
value: emailMobileController.text.trim(), // Pass the phone number
|
value: emailMobileController.text
|
||||||
|
.trim(), // Pass the phone number
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -157,7 +159,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
ToastHelper.showErrorToast(context, message);
|
ToastHelper.showErrorToast(context, message);
|
||||||
print('Invalid mobile number');
|
logDebug('Invalid mobile number');
|
||||||
}
|
}
|
||||||
} else if (response.statusCode == 429) {
|
} else if (response.statusCode == 429) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -181,14 +183,14 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> _verifyPhoneNumber() async {
|
// Future<void> _verifyPhoneNumber() async {
|
||||||
// var enteredMobileNumber = mobileController.text;
|
// var enteredMobileNumber = mobileController.text;
|
||||||
// var countryCode = countryController.text;
|
// var countryCode = countryController.text;
|
||||||
// print('${countryCode + enteredMobileNumber}');
|
// logDebug('${countryCode + enteredMobileNumber}');
|
||||||
// await _auth.verifyPhoneNumber(
|
// await _auth.verifyPhoneNumber(
|
||||||
// phoneNumber: '${countryCode + enteredMobileNumber}',
|
// phoneNumber: '${countryCode + enteredMobileNumber}',
|
||||||
// timeout: const Duration(seconds: 60),
|
// timeout: const Duration(seconds: 60),
|
||||||
@ -200,7 +202,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
// // });
|
// // });
|
||||||
// },
|
// },
|
||||||
// verificationFailed: (FirebaseAuthException e) {
|
// verificationFailed: (FirebaseAuthException e) {
|
||||||
// print('Verification Failed: ${e.code} - ${e.message}');
|
// logDebug('Verification Failed: ${e.code} - ${e.message}');
|
||||||
// String errorMessage;
|
// String errorMessage;
|
||||||
// if (e.code == 'invalid-app-credential') {
|
// if (e.code == 'invalid-app-credential') {
|
||||||
// errorMessage = 'Invalid Credential. Please try again.';
|
// errorMessage = 'Invalid Credential. Please try again.';
|
||||||
@ -275,7 +277,7 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
// },
|
// },
|
||||||
// verificationFailed: (FirebaseAuthException e) {
|
// verificationFailed: (FirebaseAuthException e) {
|
||||||
// if (e.code == 'invalid-phone-number') {
|
// 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 {
|
// codeSent: (String verificationId, int? resendToken) async {
|
||||||
@ -328,7 +330,6 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity, // ✅ fixed web width
|
width: double.infinity, // ✅ fixed web width
|
||||||
@ -375,11 +376,9 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
),
|
),
|
||||||
SizedBox(height: 25),
|
SizedBox(height: 25),
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.symmetric(
|
margin: EdgeInsets.symmetric(horizontal: 150),
|
||||||
horizontal: 150),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -396,9 +395,11 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
Container(
|
Container(
|
||||||
height: 55,
|
height: 55,
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 150) ,
|
margin:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 150),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(width: 1, color: Colors.grey),
|
border:
|
||||||
|
Border.all(width: 1, color: Colors.grey),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
@ -407,10 +408,12 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
hintText: "Email / Mobile Number ",
|
hintText: "Email / Mobile Number ",
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 10),
|
contentPadding:
|
||||||
|
EdgeInsets.symmetric(horizontal: 10),
|
||||||
),
|
),
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.trim().isEmpty) {
|
if (value == null ||
|
||||||
|
value.trim().isEmpty) {
|
||||||
return "Please enter email or mobile number";
|
return "Please enter email or mobile number";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,11 +424,15 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
return "No spaces allowed";
|
return "No spaces allowed";
|
||||||
}
|
}
|
||||||
|
|
||||||
final emailRegex = RegExp(r'^[^@]+@[^@]+\.[^@]+$');
|
final emailRegex =
|
||||||
final mobileRegex = RegExp(r'^[0-9]{10}$');
|
RegExp(r'^[^@]+@[^@]+\.[^@]+$');
|
||||||
|
final mobileRegex =
|
||||||
|
RegExp(r'^[0-9]{10}$');
|
||||||
|
|
||||||
bool isEmailFormat = emailRegex.hasMatch(input);
|
bool isEmailFormat =
|
||||||
bool isMobileFormat = mobileRegex.hasMatch(input);
|
emailRegex.hasMatch(input);
|
||||||
|
bool isMobileFormat =
|
||||||
|
mobileRegex.hasMatch(input);
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
// 🛑 MOBILE VALIDATION
|
// 🛑 MOBILE VALIDATION
|
||||||
@ -441,27 +448,33 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
// ---------------------------
|
// ---------------------------
|
||||||
|
|
||||||
// Reject anything that has '@' but is NOT a valid email format
|
// Reject anything that has '@' but is NOT a valid email format
|
||||||
if (input.contains('@') && !isEmailFormat) {
|
if (input.contains('@') &&
|
||||||
|
!isEmailFormat) {
|
||||||
return "Enter a valid email address";
|
return "Enter a valid email address";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reject email with extra digits at the end
|
// Reject email with extra digits at the end
|
||||||
if (input.contains('@') && RegExp(r'\d+$').hasMatch(input)) {
|
if (input.contains('@') &&
|
||||||
|
RegExp(r'\d+$').hasMatch(input)) {
|
||||||
return "Email cannot contain extra numbers";
|
return "Email cannot contain extra numbers";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reject email+mobile combination
|
// Reject email+mobile combination
|
||||||
if (input.contains('@') && RegExp(r'\d{10}$').hasMatch(input)) {
|
if (input.contains('@') &&
|
||||||
|
RegExp(r'\d{10}$').hasMatch(input)) {
|
||||||
return "Enter only email OR mobile number";
|
return "Enter only email OR mobile number";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
// 🛑 MIXED CONTENT (letters + digits but NOT email)
|
// 🛑 MIXED CONTENT (letters + digits but NOT email)
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
bool hasLetters = RegExp(r'[A-Za-z]').hasMatch(input);
|
bool hasLetters =
|
||||||
bool hasDigits = RegExp(r'[0-9]').hasMatch(input);
|
RegExp(r'[A-Za-z]').hasMatch(input);
|
||||||
|
bool hasDigits =
|
||||||
|
RegExp(r'[0-9]').hasMatch(input);
|
||||||
|
|
||||||
if ((hasLetters && hasDigits) && !input.contains('@')) {
|
if ((hasLetters && hasDigits) &&
|
||||||
|
!input.contains('@')) {
|
||||||
return "Enter only email OR 10-digit mobile number";
|
return "Enter only email OR 10-digit mobile number";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,27 +486,19 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}),
|
||||||
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.symmetric(
|
margin: EdgeInsets.symmetric(horizontal: 150),
|
||||||
horizontal: 150),
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 45,
|
height: 45,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton
|
style: ElevatedButton.styleFrom(
|
||||||
.styleFrom(
|
backgroundColor: Color(0xFF00989E),
|
||||||
backgroundColor:
|
shape: RoundedRectangleBorder(
|
||||||
Color(0xFF00989E),
|
borderRadius: BorderRadius.circular(10),
|
||||||
shape:
|
|
||||||
RoundedRectangleBorder(
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius
|
|
||||||
.circular(10),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: _isLoading
|
onPressed: _isLoading
|
||||||
@ -502,16 +507,14 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
child: _isLoading
|
child: _isLoading
|
||||||
? const CircularProgressIndicator(
|
? const CircularProgressIndicator(
|
||||||
valueColor:
|
valueColor:
|
||||||
AlwaysStoppedAnimation<
|
AlwaysStoppedAnimation<Color>(
|
||||||
Color>(
|
|
||||||
Color(0xFF00989E),
|
Color(0xFF00989E),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Text( "Login with Email / Mobile OTP",
|
: Text(
|
||||||
style: GoogleFonts
|
"Login with Email / Mobile OTP",
|
||||||
.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: const Color(
|
color: const Color(0xFFFFFFFF),
|
||||||
0xFFFFFFFF),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -521,7 +524,8 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
Container(
|
Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: RichText(
|
child: RichText(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
@ -544,7 +548,8 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
'https://nhanceindia.in/privacy-policy/');
|
'https://nhanceindia.in/privacy-policy/');
|
||||||
if (await canLaunchUrl(url)) {
|
if (await canLaunchUrl(url)) {
|
||||||
await launchUrl(url,
|
await launchUrl(url,
|
||||||
mode: LaunchMode.externalApplication);
|
mode: LaunchMode
|
||||||
|
.externalApplication);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -568,7 +573,8 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
'https://nhanceindia.in/privacy-policy/');
|
'https://nhanceindia.in/privacy-policy/');
|
||||||
if (await canLaunchUrl(url)) {
|
if (await canLaunchUrl(url)) {
|
||||||
await launchUrl(url,
|
await launchUrl(url,
|
||||||
mode: LaunchMode.externalApplication);
|
mode: LaunchMode
|
||||||
|
.externalApplication);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -627,9 +633,6 @@ class _MyPhoneState extends State<MyHrLogin> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)));
|
||||||
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,8 +85,8 @@
|
|||||||
// // checkTokenAvailability();
|
// // checkTokenAvailability();
|
||||||
// verificationId = widget.verificationId;
|
// verificationId = widget.verificationId;
|
||||||
// mobileNumber = widget.mobileNumber;
|
// mobileNumber = widget.mobileNumber;
|
||||||
// print('Received verificationId: $verificationId');
|
// logDebug('Received verificationId: $verificationId');
|
||||||
// print('Received mobileNumber: $mobileNumber');
|
// logDebug('Received mobileNumber: $mobileNumber');
|
||||||
// if (verificationId.isEmpty) {
|
// if (verificationId.isEmpty) {
|
||||||
// // Handle the case where verificationId is not provided
|
// // Handle the case where verificationId is not provided
|
||||||
// Navigator.pop(context);
|
// Navigator.pop(context);
|
||||||
@ -103,7 +103,7 @@
|
|||||||
//
|
//
|
||||||
// void logOutFirebase() async {
|
// void logOutFirebase() async {
|
||||||
// await _auth.signOut();
|
// await _auth.signOut();
|
||||||
// print('User signed out');
|
// logDebug('User signed out');
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @override
|
// @override
|
||||||
@ -143,7 +143,7 @@
|
|||||||
// });
|
// });
|
||||||
// Map<String, dynamic> data = json.decode(response.body);
|
// Map<String, dynamic> data = json.decode(response.body);
|
||||||
//
|
//
|
||||||
// print('Response data: $data');
|
// logDebug('Response data: $data');
|
||||||
//
|
//
|
||||||
// // Extract enrollment data
|
// // Extract enrollment data
|
||||||
// List<dynamic> preEnrollmentData = data['data'] ?? [];
|
// List<dynamic> preEnrollmentData = data['data'] ?? [];
|
||||||
@ -165,13 +165,13 @@
|
|||||||
// ),
|
// ),
|
||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
// // print('data: $data');
|
// // logDebug('data: $data');
|
||||||
// // _token = data['data'];
|
// // _token = data['data'];
|
||||||
// // String status = data['status'];
|
// // String status = data['status'];
|
||||||
// //
|
// //
|
||||||
// // // Directly access the post_enrollment data
|
// // // Directly access the post_enrollment data
|
||||||
// // Map<String, dynamic> post = data['post_enrollment'];
|
// // Map<String, dynamic> post = data['post_enrollment'];
|
||||||
// // print('post: $post');
|
// // logDebug('post: $post');
|
||||||
// //
|
// //
|
||||||
// // _postToken = post['data'];
|
// // _postToken = post['data'];
|
||||||
// // String postStatus = post['status'];
|
// // String postStatus = post['status'];
|
||||||
@ -192,7 +192,7 @@
|
|||||||
// // });
|
// // });
|
||||||
// // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
// // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
||||||
// // // Show a Snackbar if the OTP is invalid
|
// // // Show a Snackbar if the OTP is invalid
|
||||||
// // print('Invalid OTP. Please try again');
|
// // logDebug('Invalid OTP. Please try again');
|
||||||
// // }
|
// // }
|
||||||
// } else {
|
// } else {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
@ -205,10 +205,10 @@
|
|||||||
// setState(() {
|
// setState(() {
|
||||||
// _isLoading = false;
|
// _isLoading = false;
|
||||||
// });
|
// });
|
||||||
// print('Error: $e');
|
// logDebug('Error: $e');
|
||||||
// ToastHelper.showWarningToast(context, 'Something went wrong');
|
// ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
// // Show a Snackbar if there's an error while verifying OTP
|
// // 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.');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -222,7 +222,7 @@
|
|||||||
//
|
//
|
||||||
// // Decode the JWT token received from the API response
|
// // Decode the JWT token received from the API response
|
||||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(post['data']);
|
||||||
// print('postdecodedToken : $decodedToken');
|
// logDebug('postdecodedToken : $decodedToken');
|
||||||
// empClientBranchId = decodedToken['ref_id'];
|
// empClientBranchId = decodedToken['ref_id'];
|
||||||
// prefs.setString('empClientBranchId', empClientBranchId);
|
// prefs.setString('empClientBranchId', empClientBranchId);
|
||||||
// empCodeString = decodedToken['emp_code'].toString();
|
// empCodeString = decodedToken['emp_code'].toString();
|
||||||
@ -247,7 +247,7 @@
|
|||||||
//
|
//
|
||||||
// // Decode the JWT token received from the API response
|
// // Decode the JWT token received from the API response
|
||||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
// print('decodedToken : $decodedToken');
|
// logDebug('decodedToken : $decodedToken');
|
||||||
// enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
// enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
||||||
// prefs.setString(
|
// prefs.setString(
|
||||||
// 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
// 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||||
@ -288,7 +288,7 @@
|
|||||||
//
|
//
|
||||||
// // Decode the JWT token received from the API response
|
// // Decode the JWT token received from the API response
|
||||||
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
// Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
// print('enrolldecodedToken : $decodedToken');
|
// logDebug('enrolldecodedToken : $decodedToken');
|
||||||
// enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
// enrollmentEmpClientBranchId = decodedToken['ref_id'];
|
||||||
// prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
// prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||||
// enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
// enrollmentEmpCodeString = decodedToken['emp_code'].toString();
|
||||||
@ -308,7 +308,7 @@
|
|||||||
// // enrollmentEmp_status = decodedToken['emp_status'];
|
// // enrollmentEmp_status = decodedToken['emp_status'];
|
||||||
// // prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
// // prefs.setString('enrollmentEmp_status', enrollmentEmp_status);
|
||||||
//
|
//
|
||||||
// print('Successfully Login');
|
// logDebug('Successfully Login');
|
||||||
//
|
//
|
||||||
// // Redirect to another page
|
// // Redirect to another page
|
||||||
// final enrollToken = prefs.getString('enrollToken');
|
// final enrollToken = prefs.getString('enrollToken');
|
||||||
@ -399,7 +399,7 @@
|
|||||||
// // setState(() {
|
// // setState(() {
|
||||||
// // _isLoading = false;
|
// // _isLoading = false;
|
||||||
// // });
|
// // });
|
||||||
// print('Error: $e');
|
// logDebug('Error: $e');
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Failed to verify OTP. Please try again.');
|
// context, 'Failed to verify OTP. Please try again.');
|
||||||
// }
|
// }
|
||||||
|
|||||||
111
lib/logger.dart
Normal file
111
lib/logger.dart
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
import 'dart:developer' as developer;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:nhancepolicy/config/environment.dart';
|
||||||
|
|
||||||
|
String _formatMessage(
|
||||||
|
String message, {
|
||||||
|
String? className,
|
||||||
|
String? methodName,
|
||||||
|
}) {
|
||||||
|
final timestamp = DateTime.now().toIso8601String();
|
||||||
|
final contextParts = <String>[];
|
||||||
|
if (className != null && className.isNotEmpty) {
|
||||||
|
contextParts.add(className);
|
||||||
|
}
|
||||||
|
if (methodName != null && methodName.isNotEmpty) {
|
||||||
|
contextParts.add(methodName);
|
||||||
|
}
|
||||||
|
final context = contextParts.isEmpty ? '' : '[${contextParts.join('.')}] ';
|
||||||
|
return '[$timestamp] $context$message';
|
||||||
|
}
|
||||||
|
|
||||||
|
void _log(
|
||||||
|
String level,
|
||||||
|
String message, {
|
||||||
|
String tag = 'APP',
|
||||||
|
Object? error,
|
||||||
|
StackTrace? stackTrace,
|
||||||
|
String? className,
|
||||||
|
String? methodName,
|
||||||
|
}) {
|
||||||
|
final shouldLog = kDebugMode || Environment.flavor == Flavor.dev;
|
||||||
|
if (!shouldLog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final formatted =
|
||||||
|
_formatMessage(message, className: className, methodName: methodName);
|
||||||
|
final channel = '$tag:$level';
|
||||||
|
|
||||||
|
developer.log(
|
||||||
|
formatted,
|
||||||
|
name: channel,
|
||||||
|
error: error,
|
||||||
|
stackTrace: stackTrace,
|
||||||
|
);
|
||||||
|
debugPrint('[$channel] $formatted');
|
||||||
|
}
|
||||||
|
|
||||||
|
void logDebug(
|
||||||
|
Object? message, {
|
||||||
|
String tag = 'APP',
|
||||||
|
String? className,
|
||||||
|
String? methodName,
|
||||||
|
}) {
|
||||||
|
_log(
|
||||||
|
'DEBUG',
|
||||||
|
'${message ?? 'null'}',
|
||||||
|
tag: tag,
|
||||||
|
className: className,
|
||||||
|
methodName: methodName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void logInfo(
|
||||||
|
Object? message, {
|
||||||
|
String tag = 'APP',
|
||||||
|
String? className,
|
||||||
|
String? methodName,
|
||||||
|
}) {
|
||||||
|
_log(
|
||||||
|
'INFO',
|
||||||
|
'${message ?? 'null'}',
|
||||||
|
tag: tag,
|
||||||
|
className: className,
|
||||||
|
methodName: methodName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void logWarning(
|
||||||
|
Object? message, {
|
||||||
|
String tag = 'APP',
|
||||||
|
String? className,
|
||||||
|
String? methodName,
|
||||||
|
}) {
|
||||||
|
_log(
|
||||||
|
'WARN',
|
||||||
|
'${message ?? 'null'}',
|
||||||
|
tag: tag,
|
||||||
|
className: className,
|
||||||
|
methodName: methodName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void logError(
|
||||||
|
Object? message, {
|
||||||
|
String tag = 'APP',
|
||||||
|
Object? error,
|
||||||
|
StackTrace? stackTrace,
|
||||||
|
String? className,
|
||||||
|
String? methodName,
|
||||||
|
}) {
|
||||||
|
_log(
|
||||||
|
'ERROR',
|
||||||
|
'${message ?? 'null'}',
|
||||||
|
tag: tag,
|
||||||
|
error: error,
|
||||||
|
stackTrace: stackTrace,
|
||||||
|
className: className,
|
||||||
|
methodName: methodName,
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:nhancepolicy/addons.dart';
|
import 'package:nhancepolicy/addons.dart';
|
||||||
@ -28,10 +27,11 @@ import 'package:firebase_core/firebase_core.dart';
|
|||||||
import 'presentation/cdTransactionDetails.dart';
|
import 'presentation/cdTransactionDetails.dart';
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
import 'email_verify.dart';
|
import 'email_verify.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
Future<void> startApp() async {
|
Future<void> startApp() async {
|
||||||
// html.window.onBeforeUnload.listen((event) {
|
// html.window.onBeforeUnload.listen((event) {
|
||||||
// print('Local Storage cleared by window');
|
// logDebug('Local Storage cleared by window');
|
||||||
// html.window.localStorage.clear();
|
// html.window.localStorage.clear();
|
||||||
// });
|
// });
|
||||||
// Ask confirmation (browser may or may not show it again)
|
// Ask confirmation (browser may or may not show it again)
|
||||||
@ -218,7 +218,6 @@ final Map<String, WidgetBuilder> appRoutes = {
|
|||||||
'mailVerify': (context) => MyEmailVerify(
|
'mailVerify': (context) => MyEmailVerify(
|
||||||
type: '',
|
type: '',
|
||||||
value: '',
|
value: '',
|
||||||
|
|
||||||
),
|
),
|
||||||
'verify': (context) => MyVerify(
|
'verify': (context) => MyVerify(
|
||||||
verificationId: '',
|
verificationId: '',
|
||||||
@ -271,8 +270,7 @@ final Map<String, WidgetBuilder> appRoutes = {
|
|||||||
clientBranchId: '',
|
clientBranchId: '',
|
||||||
Token: '',
|
Token: '',
|
||||||
TokenType: '',
|
TokenType: '',
|
||||||
id: ''
|
id: ''),
|
||||||
),
|
|
||||||
'empDetails': (context) => empDetails(),
|
'empDetails': (context) => empDetails(),
|
||||||
'addOnsDetails': (context) => addOnsDetails(),
|
'addOnsDetails': (context) => addOnsDetails(),
|
||||||
'empReviewDetails': (context) => empReviewDetails(),
|
'empReviewDetails': (context) => empReviewDetails(),
|
||||||
@ -297,7 +295,7 @@ final Map<String, WidgetBuilder> appRoutes = {
|
|||||||
'policies': (context) => policies(),
|
'policies': (context) => policies(),
|
||||||
'CdPoliciesList': (context) => CdPoliciesList(),
|
'CdPoliciesList': (context) => CdPoliciesList(),
|
||||||
'ClaimsPolicies': (context) => ClaimsPolicies(
|
'ClaimsPolicies': (context) => ClaimsPolicies(
|
||||||
empCode:'',
|
empCode: '',
|
||||||
),
|
),
|
||||||
'cdTransactionDetails': (context) => cdTransactionDetails(
|
'cdTransactionDetails': (context) => cdTransactionDetails(
|
||||||
insurerName: '',
|
insurerName: '',
|
||||||
@ -330,8 +328,7 @@ class _AuthWrapperState extends State<AuthWrapper> {
|
|||||||
|
|
||||||
if (token == null || token.isEmpty) {
|
if (token == null || token.isEmpty) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(context, 'hrLogin', (route) => false);
|
||||||
context, 'hrLogin', (route) => false);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import 'package:http/http.dart' as http;
|
|||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
import 'customAppBar/customAppBar.dart';
|
import 'customAppBar/customAppBar.dart';
|
||||||
import 'customAppBar/toastHelper.dart';
|
import 'customAppBar/toastHelper.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class oldPolicy extends StatefulWidget {
|
class oldPolicy extends StatefulWidget {
|
||||||
const oldPolicy({Key? key}) : super(key: key);
|
const oldPolicy({Key? key}) : super(key: key);
|
||||||
@ -53,7 +54,7 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadToken() async {
|
Future<void> _loadToken() async {
|
||||||
print('_loadToken');
|
logDebug('_loadToken');
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
final String? token = prefs.getString('token');
|
final String? token = prefs.getString('token');
|
||||||
if (token != null && token.isNotEmpty) {
|
if (token != null && token.isNotEmpty) {
|
||||||
@ -62,14 +63,14 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
});
|
});
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
print(decodedToken);
|
logDebug(decodedToken);
|
||||||
empClientBranchId = prefs.getString('empClientBranchId');
|
empClientBranchId = prefs.getString('empClientBranchId');
|
||||||
empCodeString = prefs.getString('empCode');
|
empCodeString = prefs.getString('empCode');
|
||||||
print(empCodeString); // Check if emp_code is correct
|
logDebug(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
gpaEmpName = prefs.getString('gpaEmpName');
|
gpaEmpName = prefs.getString('gpaEmpName');
|
||||||
client_id = prefs.getString('client_id');
|
client_id = prefs.getString('client_id');
|
||||||
print(client_id);
|
logDebug(client_id);
|
||||||
getOldPolicyDetails();
|
getOldPolicyDetails();
|
||||||
} else {
|
} else {
|
||||||
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
||||||
@ -95,10 +96,10 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
if (data['status'] == 'success') {
|
if (data['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
oldPolicyList = data['data'];
|
oldPolicyList = data['data'];
|
||||||
print('gmcPolicies');
|
logDebug('gmcPolicies');
|
||||||
});
|
});
|
||||||
// Assuming data is a List
|
// Assuming data is a List
|
||||||
print(oldPolicyList);
|
logDebug(oldPolicyList);
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
oldPolicyDataIsEmpty = 0;
|
oldPolicyDataIsEmpty = 0;
|
||||||
@ -106,7 +107,7 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -115,11 +116,11 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,8 +186,8 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
List<Widget> generateGmcCards(List<dynamic> data) {
|
List<Widget> generateGmcCards(List<dynamic> data) {
|
||||||
List<Widget> cards = [];
|
List<Widget> cards = [];
|
||||||
|
|
||||||
print('data');
|
logDebug('data');
|
||||||
print(data);
|
logDebug(data);
|
||||||
|
|
||||||
for (var item in data) {
|
for (var item in data) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import 'package:flutter_animated_button/flutter_animated_button.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class MyPhone extends StatefulWidget {
|
class MyPhone extends StatefulWidget {
|
||||||
const MyPhone({Key? key});
|
const MyPhone({Key? key});
|
||||||
@ -62,7 +63,8 @@ class _MyPhoneState extends State<MyPhone> {
|
|||||||
Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'),
|
Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'),
|
||||||
body: json.encode({'mobile_number': enteredMobileNumber}),
|
body: json.encode({'mobile_number': enteredMobileNumber}),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -78,7 +80,7 @@ class _MyPhoneState extends State<MyPhone> {
|
|||||||
// arguments: enteredMobileNumber);
|
// arguments: enteredMobileNumber);
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, message);
|
ToastHelper.showErrorToast(context, message);
|
||||||
print('Invalid mobile number');
|
logDebug('Invalid mobile number');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
@ -87,14 +89,14 @@ class _MyPhoneState extends State<MyPhone> {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _verifyPhoneNumber() async {
|
Future<void> _verifyPhoneNumber() async {
|
||||||
var enteredMobileNumber = mobileController.text;
|
var enteredMobileNumber = mobileController.text;
|
||||||
var countryCode = countryController.text;
|
var countryCode = countryController.text;
|
||||||
print('${countryCode + enteredMobileNumber}');
|
logDebug('${countryCode + enteredMobileNumber}');
|
||||||
await _auth.verifyPhoneNumber(
|
await _auth.verifyPhoneNumber(
|
||||||
phoneNumber: '${countryCode + enteredMobileNumber}',
|
phoneNumber: '${countryCode + enteredMobileNumber}',
|
||||||
timeout: const Duration(seconds: 60),
|
timeout: const Duration(seconds: 60),
|
||||||
@ -108,7 +110,7 @@ class _MyPhoneState extends State<MyPhone> {
|
|||||||
verificationFailed: (FirebaseAuthException e) {
|
verificationFailed: (FirebaseAuthException e) {
|
||||||
ToastHelper.showSuccessToast(context, 'Verification Failed!');
|
ToastHelper.showSuccessToast(context, 'Verification Failed!');
|
||||||
if (e.code == 'invalid-phone-number') {
|
if (e.code == 'invalid-phone-number') {
|
||||||
print('The provided phone number is not valid.');
|
logDebug('The provided phone number is not valid.');
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -158,7 +160,7 @@ class _MyPhoneState extends State<MyPhone> {
|
|||||||
},
|
},
|
||||||
verificationFailed: (FirebaseAuthException e) {
|
verificationFailed: (FirebaseAuthException e) {
|
||||||
if (e.code == 'invalid-phone-number') {
|
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) {
|
codeSent: (String verificationId, int? resendToken) {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import 'package:file_picker/file_picker.dart';
|
|||||||
import '../service/multi_file_upload_widget.dart';
|
import '../service/multi_file_upload_widget.dart';
|
||||||
import '../service/token_storage_service.dart';
|
import '../service/token_storage_service.dart';
|
||||||
import 'package:pdf/widgets.dart' as pw;
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class RaiseClaimDialog extends StatefulWidget {
|
class RaiseClaimDialog extends StatefulWidget {
|
||||||
final BuildContext parentContext;
|
final BuildContext parentContext;
|
||||||
@ -215,13 +216,14 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClaimsPoliciesDetails() async {
|
Future<void> getClaimsPoliciesDetails() async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final response = await apiService.getClaimPoliciesToApi(_postPreToken!,empClientId);
|
final response =
|
||||||
|
await apiService.getClaimPoliciesToApi(_postPreToken!, empClientId);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -235,8 +237,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
claimTypeMap = Map<String, dynamic>.from(getClaimPoliciesApi['claim_type']);
|
claimTypeMap =
|
||||||
print('claimTypeMap $claimTypeMap');
|
Map<String, dynamic>.from(getClaimPoliciesApi['claim_type']);
|
||||||
|
logDebug('claimTypeMap $claimTypeMap');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -245,13 +248,13 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
// isLoading = false;
|
// isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
// _isLoading = false;
|
// _isLoading = false;
|
||||||
@ -261,11 +264,11 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
|
|
||||||
Future<void> getPostCashDepositDetails(
|
Future<void> getPostCashDepositDetails(
|
||||||
empClientBranchId, empClientId, empHrId, _postPreToken) async {
|
empClientBranchId, empClientId, empHrId, _postPreToken) async {
|
||||||
print('IN');
|
logDebug('IN');
|
||||||
print("clintBranchId -$empClientBranchId");
|
logDebug("clintBranchId -$empClientBranchId");
|
||||||
print("clintID -$empClientId");
|
logDebug("clintID -$empClientId");
|
||||||
print("hr_id -$empHrId");
|
logDebug("hr_id -$empHrId");
|
||||||
print("token -$_postPreToken");
|
logDebug("token -$_postPreToken");
|
||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
// setState(() {
|
// setState(() {
|
||||||
@ -280,30 +283,30 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
|
|
||||||
// final response = await apiService.getCashDepositDetailsToApi(
|
// final response = await apiService.getCashDepositDetailsToApi(
|
||||||
// clintID!, clintBranchId!, hr_id, token);
|
// clintID!, clintBranchId!, hr_id, token);
|
||||||
print('IN1');
|
logDebug('IN1');
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
setState(() {
|
setState(() {
|
||||||
print('response');
|
logDebug('response');
|
||||||
print(response['data']);
|
logDebug(response['data']);
|
||||||
getPostCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
getPostCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
||||||
print('getPostCardArrays');
|
logDebug('getPostCardArrays');
|
||||||
print(getPostCardArrays);
|
logDebug(getPostCardArrays);
|
||||||
|
|
||||||
activePoliciesList = getPostCardArrays;
|
activePoliciesList = getPostCardArrays;
|
||||||
});
|
});
|
||||||
|
|
||||||
print('IN2');
|
logDebug('IN2');
|
||||||
} else {
|
} else {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
print('API request failed with status');
|
logDebug('API request failed with status');
|
||||||
setState(() {
|
setState(() {
|
||||||
activePoliciesList = [];
|
activePoliciesList = [];
|
||||||
});
|
});
|
||||||
print('API request failed with status');
|
logDebug('API request failed with status');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +341,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loadClaimTypes() {
|
void loadClaimTypes() {
|
||||||
print('serviceId $serviceId');
|
logDebug('serviceId $serviceId');
|
||||||
if (serviceId == null) return;
|
if (serviceId == null) return;
|
||||||
|
|
||||||
String key = serviceId.toString();
|
String key = serviceId.toString();
|
||||||
@ -353,13 +356,12 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
};
|
};
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
print('claimTypeList $claimTypeList');
|
logDebug('claimTypeList $claimTypeList');
|
||||||
|
|
||||||
// // ✅ AUTO SELECT FIRST CLAIM TYPE
|
// // ✅ AUTO SELECT FIRST CLAIM TYPE
|
||||||
// if (claimTypeList.isNotEmpty) {
|
// if (claimTypeList.isNotEmpty) {
|
||||||
// claimTypeId = claimTypeList.first['id'];
|
// claimTypeId = claimTypeList.first['id'];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
claimTypeList = [];
|
claimTypeList = [];
|
||||||
claimTypeId = null;
|
claimTypeId = null;
|
||||||
@ -368,12 +370,12 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getCDPoliciesDetails() async {
|
Future<void> getCDPoliciesDetails() async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
|
|
||||||
final response = await apiService.getEmployeeAndDependenceToApi(
|
final response = await apiService.getEmployeeAndDependenceToApi(
|
||||||
empClientId,
|
empClientId,
|
||||||
@ -408,7 +410,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -422,7 +424,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
isServiceValid = serviceId != null;
|
isServiceValid = serviceId != null;
|
||||||
isPolicyValid = selectedClientPolicyId != null;
|
isPolicyValid = selectedClientPolicyId != null;
|
||||||
isMemberValid = selectedMemberId != null;
|
isMemberValid = selectedMemberId != null;
|
||||||
MultiFileUploadWidget.showValidation = serviceId != null && FileUploadService().files.isEmpty;
|
MultiFileUploadWidget.showValidation =
|
||||||
|
serviceId != null && FileUploadService().files.isEmpty;
|
||||||
// MultiFileUploadWidget.showValidation = FileUploadService().files.isEmpty;
|
// MultiFileUploadWidget.showValidation = FileUploadService().files.isEmpty;
|
||||||
// isClaimTypeValid = claimTypeId != null;
|
// isClaimTypeValid = claimTypeId != null;
|
||||||
// isSubjectValid = subjectController.text.trim().isNotEmpty;
|
// isSubjectValid = subjectController.text.trim().isNotEmpty;
|
||||||
@ -445,7 +448,6 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
// isHospitalPhoneNoValid = !isGmc || (RegExp(r'^\d{10}$').hasMatch(phone));
|
// isHospitalPhoneNoValid = !isGmc || (RegExp(r'^\d{10}$').hasMatch(phone));
|
||||||
isHospitalPhoneNoValid = !isGmc || phone.isNotEmpty;
|
isHospitalPhoneNoValid = !isGmc || phone.isNotEmpty;
|
||||||
|
|
||||||
|
|
||||||
isAdmitDateValid = !isGmc || admitDate != null;
|
isAdmitDateValid = !isGmc || admitDate != null;
|
||||||
isDischargeDateValid = !isGmc || dischargeDate != null;
|
isDischargeDateValid = !isGmc || dischargeDate != null;
|
||||||
isClaimTypeValid = !isGmc || claimTypeId != null;
|
isClaimTypeValid = !isGmc || claimTypeId != null;
|
||||||
@ -463,17 +465,17 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
// 🎯 GPA / GTLI / EDLI validation
|
// 🎯 GPA / GTLI / EDLI validation
|
||||||
// 🎯 GPA / GTLI / EDLI dynamic validation
|
// 🎯 GPA / GTLI / EDLI dynamic validation
|
||||||
// if (serviceId == 2) {
|
// if (serviceId == 2) {
|
||||||
// print('serviceId == 2');
|
// logDebug('serviceId == 2');
|
||||||
// isAccidentDateValid = accidentDate != null;
|
// isAccidentDateValid = accidentDate != null;
|
||||||
// isDeathDateValid = true;
|
// isDeathDateValid = true;
|
||||||
// }
|
// }
|
||||||
// else if (serviceId == 3 || serviceId == 4) {
|
// else if (serviceId == 3 || serviceId == 4) {
|
||||||
// print('serviceId == 3 || serviceId == 4');
|
// logDebug('serviceId == 3 || serviceId == 4');
|
||||||
// isDeathDateValid = deathDate != null;
|
// isDeathDateValid = deathDate != null;
|
||||||
// isAccidentDateValid = true;
|
// isAccidentDateValid = true;
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
// print('ELSE');
|
// logDebug('ELSE');
|
||||||
// isAccidentDateValid = true;
|
// isAccidentDateValid = true;
|
||||||
// isDeathDateValid = true;
|
// isDeathDateValid = true;
|
||||||
// }
|
// }
|
||||||
@ -482,20 +484,17 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
isAccidentDateValid = accidentDate != null;
|
isAccidentDateValid = accidentDate != null;
|
||||||
isDeathDateValid = true;
|
isDeathDateValid = true;
|
||||||
isIntimationDateValid = true;
|
isIntimationDateValid = true;
|
||||||
}
|
} else if (serviceId == 3) {
|
||||||
else if (serviceId == 3) {
|
|
||||||
// GTLI
|
// GTLI
|
||||||
isDeathDateValid = deathDate != null;
|
isDeathDateValid = deathDate != null;
|
||||||
isAccidentDateValid = true;
|
isAccidentDateValid = true;
|
||||||
isIntimationDateValid = true;
|
isIntimationDateValid = true;
|
||||||
}
|
} else if (serviceId == 4) {
|
||||||
else if (serviceId == 4) {
|
|
||||||
// EDLI
|
// EDLI
|
||||||
isDeathDateValid = deathDate != null;
|
isDeathDateValid = deathDate != null;
|
||||||
isAccidentDateValid = true;
|
isAccidentDateValid = true;
|
||||||
isIntimationDateValid = true;
|
isIntimationDateValid = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
isAccidentDateValid = true;
|
isAccidentDateValid = true;
|
||||||
isDeathDateValid = true;
|
isDeathDateValid = true;
|
||||||
isIntimationDateValid = true;
|
isIntimationDateValid = true;
|
||||||
@ -529,12 +528,12 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
isAccidentDateValid &&
|
isAccidentDateValid &&
|
||||||
isDeathDateValid &&
|
isDeathDateValid &&
|
||||||
isIntimationDateValid) {
|
isIntimationDateValid) {
|
||||||
|
|
||||||
// ✅ Phone validation AFTER all required fields pass
|
// ✅ Phone validation AFTER all required fields pass
|
||||||
// ✅ Exact 10 digit validation AFTER all required fields filled
|
// ✅ Exact 10 digit validation AFTER all required fields filled
|
||||||
if ((serviceId == 1 || serviceId == 72) &&
|
if ((serviceId == 1 || serviceId == 72) &&
|
||||||
hospitalPhoneNoController.text.trim().isNotEmpty &&
|
hospitalPhoneNoController.text.trim().isNotEmpty &&
|
||||||
!RegExp(r'^\d{10}$').hasMatch(hospitalPhoneNoController.text.trim())) {
|
!RegExp(r'^\d{10}$')
|
||||||
|
.hasMatch(hospitalPhoneNoController.text.trim())) {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context,
|
context,
|
||||||
'Hospital phone number must be exactly 10 digits',
|
'Hospital phone number must be exactly 10 digits',
|
||||||
@ -549,7 +548,6 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context,
|
context,
|
||||||
@ -563,7 +561,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('Check One');
|
logDebug('Check One');
|
||||||
Map<String, dynamic> fields = {
|
Map<String, dynamic> fields = {
|
||||||
'client_policy_id': selectedClientPolicyId,
|
'client_policy_id': selectedClientPolicyId,
|
||||||
// 'policy_type_id': selectedPolicyTypeId,
|
// 'policy_type_id': selectedPolicyTypeId,
|
||||||
@ -609,13 +607,11 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deathDate != null) {
|
if (deathDate != null) {
|
||||||
fields['date_of_death'] =
|
fields['date_of_death'] = DateFormat('yyyy-MM-dd').format(deathDate!);
|
||||||
DateFormat('yyyy-MM-dd').format(deathDate!);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (birthDate != null) {
|
if (birthDate != null) {
|
||||||
fields['dob'] =
|
fields['dob'] = DateFormat('yyyy-MM-dd').format(birthDate!);
|
||||||
DateFormat('yyyy-MM-dd').format(birthDate!);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intimationDate != null) {
|
if (intimationDate != null) {
|
||||||
@ -635,18 +631,18 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
||||||
final stringFields =
|
final stringFields =
|
||||||
fields.map((key, value) => MapEntry(key, value?.toString() ?? ''));
|
fields.map((key, value) => MapEntry(key, value?.toString() ?? ''));
|
||||||
print("📁 stringFields: ${stringFields}");
|
logDebug("📁 stringFields: ${stringFields}");
|
||||||
request.fields.addAll(stringFields);
|
request.fields.addAll(stringFields);
|
||||||
|
|
||||||
// get uploaded files
|
// get uploaded files
|
||||||
final uploadedFiles = FileUploadService().files;
|
final uploadedFiles = FileUploadService().files;
|
||||||
print("📁 Total uploaded files: ${uploadedFiles.length}");
|
logDebug("📁 Total uploaded files: ${uploadedFiles.length}");
|
||||||
print(
|
logDebug(
|
||||||
"📂 File list (original names): ${uploadedFiles.map((f) => f.file.name).toList()}");
|
"📂 File list (original names): ${uploadedFiles.map((f) => f.file.name).toList()}");
|
||||||
|
|
||||||
// Validate all labels present (optional but recommended)
|
// Validate all labels present (optional but recommended)
|
||||||
for (final uf in uploadedFiles) {
|
for (final uf in uploadedFiles) {
|
||||||
print(
|
logDebug(
|
||||||
"📝 Checking label for file: ${uf.file.name}, current label: '${uf.label}'");
|
"📝 Checking label for file: ${uf.file.name}, current label: '${uf.label}'");
|
||||||
if ((uf.label ?? '').trim().isEmpty) {
|
if ((uf.label ?? '').trim().isEmpty) {
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
@ -706,7 +702,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
// replace file name with .pdf extension
|
// replace file name with .pdf extension
|
||||||
final pdfFileName = pf.name.replaceAll(RegExp(r'\.\w+$'), '.pdf');
|
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(
|
request.files.add(http.MultipartFile.fromBytes(
|
||||||
'claim_docs[]',
|
'claim_docs[]',
|
||||||
fileBytes,
|
fileBytes,
|
||||||
@ -729,9 +725,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
request.fields['claim_doc_names'] = encodedNames;
|
request.fields['claim_doc_names'] = encodedNames;
|
||||||
|
|
||||||
// ✅ Debug print
|
// ✅ Debug print
|
||||||
print("Payload being sent:");
|
logDebug("Payload being sent:");
|
||||||
print("Files: ${uploadedFiles.map((f) => f.file.name).toList()}");
|
logDebug("Files: ${uploadedFiles.map((f) => f.file.name).toList()}");
|
||||||
print("Names (JSON): $encodedNames");
|
logDebug("Names (JSON): $encodedNames");
|
||||||
|
|
||||||
final response = await request.send();
|
final response = await request.send();
|
||||||
final responseBody = await response.stream.bytesToString();
|
final responseBody = await response.stream.bytesToString();
|
||||||
@ -752,7 +748,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
// context.go('/claims', extra: 2);
|
// context.go('/claims', extra: 2);
|
||||||
print('Form data submitted successfully');
|
logDebug('Form data submitted successfully');
|
||||||
fileService.clearAll();
|
fileService.clearAll();
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -765,7 +761,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Error submitting form data: $e');
|
logDebug('Error submitting form data: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() => isSubmitting = false); // 🔥 stop loader
|
setState(() => isSubmitting = false); // 🔥 stop loader
|
||||||
}
|
}
|
||||||
@ -927,8 +923,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width:
|
width: MediaQuery.of(context).size.width *
|
||||||
MediaQuery.of(context).size.width * 0.75, // Desktop popup width
|
0.75, // Desktop popup width
|
||||||
// height: MediaQuery.of(context).size.height * 0.85,
|
// height: MediaQuery.of(context).size.height * 0.85,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -984,7 +980,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
policyNumberId = null;
|
policyNumberId = null;
|
||||||
isServiceValid = true;
|
isServiceValid = true;
|
||||||
});
|
});
|
||||||
print('🔥 serviceId set to $serviceId');
|
logDebug(
|
||||||
|
'🔥 serviceId set to $serviceId');
|
||||||
filterPoliciesByService(value!);
|
filterPoliciesByService(value!);
|
||||||
loadClaimTypes();
|
loadClaimTypes();
|
||||||
},
|
},
|
||||||
@ -997,8 +994,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
buildDropdownField(
|
buildDropdownField(
|
||||||
'Select Policy',
|
'Select Policy',
|
||||||
(value) {
|
(value) {
|
||||||
final selectedPolicy = policyNumberList
|
final selectedPolicy =
|
||||||
.firstWhere((p) => p['id'] == value);
|
policyNumberList.firstWhere(
|
||||||
|
(p) => p['id'] == value);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
// ✅ THIS is what you send to API
|
// ✅ THIS is what you send to API
|
||||||
@ -1050,7 +1048,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
member; // ✅ FULL OBJECT
|
member; // ✅ FULL OBJECT
|
||||||
selectedMemberName = member['name'];
|
selectedMemberName = member['name'];
|
||||||
isMemberValid = true;
|
isMemberValid = true;
|
||||||
print(
|
logDebug(
|
||||||
'selectedMemberObject $selectedMemberObject');
|
'selectedMemberObject $selectedMemberObject');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -1062,11 +1060,11 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
_row([
|
_row([
|
||||||
buildTextField('Message', messageController),
|
|
||||||
|
|
||||||
if (serviceId == 1 || serviceId == 72) ...[
|
|
||||||
buildTextField(
|
buildTextField(
|
||||||
'Hospital Name', hospitalNameController,
|
'Message', messageController),
|
||||||
|
if (serviceId == 1 || serviceId == 72) ...[
|
||||||
|
buildTextField('Hospital Name',
|
||||||
|
hospitalNameController,
|
||||||
required: true,
|
required: true,
|
||||||
isValid: isHospitalNameValid),
|
isValid: isHospitalNameValid),
|
||||||
buildTextField('Hospital Address',
|
buildTextField('Hospital Address',
|
||||||
@ -1077,16 +1075,16 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
]),
|
]),
|
||||||
if (serviceId == 1 || serviceId == 72)
|
if (serviceId == 1 || serviceId == 72)
|
||||||
_row([
|
_row([
|
||||||
buildTextField(
|
buildTextField('Hospital City',
|
||||||
'Hospital City', hospitalCityController,
|
hospitalCityController,
|
||||||
required: true,
|
required: true,
|
||||||
isValid: isHospitalCityValid,
|
isValid: isHospitalCityValid,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.allow(
|
FilteringTextInputFormatter.allow(
|
||||||
RegExp(r"[a-zA-Z\s]")),
|
RegExp(r"[a-zA-Z\s]")),
|
||||||
]),
|
]),
|
||||||
buildTextField(
|
buildTextField('Hospital State',
|
||||||
'Hospital State', hospitalStateController,
|
hospitalStateController,
|
||||||
required: true,
|
required: true,
|
||||||
isValid: isHospitalStateValid,
|
isValid: isHospitalStateValid,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
@ -1097,7 +1095,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
hospitalPinCodeController,
|
hospitalPinCodeController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
FilteringTextInputFormatter
|
||||||
|
.digitsOnly,
|
||||||
LengthLimitingTextInputFormatter(6),
|
LengthLimitingTextInputFormatter(6),
|
||||||
],
|
],
|
||||||
required: true,
|
required: true,
|
||||||
@ -1105,18 +1104,23 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
]),
|
]),
|
||||||
if (serviceId == 1 || serviceId == 72)
|
if (serviceId == 1 || serviceId == 72)
|
||||||
_row([
|
_row([
|
||||||
buildTextField('Hospital Phone No',
|
buildTextField(
|
||||||
|
'Hospital Phone No',
|
||||||
hospitalPhoneNoController,
|
hospitalPhoneNoController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
FilteringTextInputFormatter
|
||||||
|
.digitsOnly,
|
||||||
LengthLimitingTextInputFormatter(10),
|
LengthLimitingTextInputFormatter(10),
|
||||||
],
|
],
|
||||||
required: true,
|
required: true,
|
||||||
isValid: !hasSubmitted ||
|
isValid: !hasSubmitted ||
|
||||||
serviceId == null ||
|
serviceId == null ||
|
||||||
(serviceId != 1 && serviceId != 72) ||
|
(serviceId != 1 &&
|
||||||
RegExp(r'^\d{10}$').hasMatch(hospitalPhoneNoController.text.trim()),
|
serviceId != 72) ||
|
||||||
|
RegExp(r'^\d{10}$').hasMatch(
|
||||||
|
hospitalPhoneNoController.text
|
||||||
|
.trim()),
|
||||||
),
|
),
|
||||||
buildDatePickerField(
|
buildDatePickerField(
|
||||||
label: 'Admit Date',
|
label: 'Admit Date',
|
||||||
@ -1140,11 +1144,12 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
setState(() => dischargeDate = d),
|
setState(() => dischargeDate = d),
|
||||||
required: true,
|
required: true,
|
||||||
isValid: isDischargeDateValid),
|
isValid: isDischargeDateValid),
|
||||||
buildTextField(
|
buildTextField('Claims Amount',
|
||||||
'Claims Amount', claimAmountController,
|
claimAmountController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.digitsOnly
|
FilteringTextInputFormatter
|
||||||
|
.digitsOnly
|
||||||
],
|
],
|
||||||
required: true,
|
required: true,
|
||||||
isValid: isClaimAmountValid),
|
isValid: isClaimAmountValid),
|
||||||
@ -1177,7 +1182,10 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
allowFuture: false,
|
allowFuture: false,
|
||||||
onDateSelected: (d) =>
|
onDateSelected: (d) =>
|
||||||
setState(() => deathDate = d),
|
setState(() => deathDate = d),
|
||||||
required: (serviceId == 3 || serviceId == 4) ? true : false, // 🔥 GTLI & EDLI
|
required:
|
||||||
|
(serviceId == 3 || serviceId == 4)
|
||||||
|
? true
|
||||||
|
: false, // 🔥 GTLI & EDLI
|
||||||
isValid: isDeathDateValid,
|
isValid: isDeathDateValid,
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
@ -1187,8 +1195,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
label: 'Date of Intimation',
|
label: 'Date of Intimation',
|
||||||
selectedDate: intimationDate,
|
selectedDate: intimationDate,
|
||||||
allowFuture: false,
|
allowFuture: false,
|
||||||
onDateSelected: (d) =>
|
onDateSelected: (d) => setState(
|
||||||
setState(() => intimationDate = d)),
|
() => intimationDate = d)),
|
||||||
buildTextField(
|
buildTextField(
|
||||||
'Sum Insured',
|
'Sum Insured',
|
||||||
sumInsuredController,
|
sumInsuredController,
|
||||||
@ -1208,20 +1216,24 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
width: 120,
|
width: 120,
|
||||||
height: 42,
|
height: 42,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: (isSubmitting || serviceId == null)
|
onPressed:
|
||||||
|
(isSubmitting || serviceId == null)
|
||||||
? null
|
? null
|
||||||
: sendFormDataToApi,
|
: sendFormDataToApi,
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFFE26728),
|
backgroundColor:
|
||||||
|
const Color(0xFFE26728),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius:
|
||||||
|
BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: isSubmitting
|
child: isSubmitting
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
height: 18,
|
height: 18,
|
||||||
width: 18,
|
width: 18,
|
||||||
child: CircularProgressIndicator(
|
child:
|
||||||
|
CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
@ -1230,7 +1242,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
'Send',
|
'Send',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.w600),
|
fontWeight:
|
||||||
|
FontWeight.w600),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import 'package:collection/collection.dart';
|
|||||||
import '../customAppBar/base_layout.dart';
|
import '../customAppBar/base_layout.dart';
|
||||||
import '../service/api_service.dart';
|
import '../service/api_service.dart';
|
||||||
import '../service/token_storage_service.dart';
|
import '../service/token_storage_service.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class CdPoliciesList extends StatefulWidget {
|
class CdPoliciesList extends StatefulWidget {
|
||||||
const CdPoliciesList({Key? key}) : super(key: key);
|
const CdPoliciesList({Key? key}) : super(key: key);
|
||||||
@ -26,7 +26,6 @@ class CdPoliciesList extends StatefulWidget {
|
|||||||
State<CdPoliciesList> createState() => _CdPoliciesListState();
|
State<CdPoliciesList> createState() => _CdPoliciesListState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _CdPoliciesListState extends State<CdPoliciesList> {
|
class _CdPoliciesListState extends State<CdPoliciesList> {
|
||||||
final tokenService = TokenStorageService();
|
final tokenService = TokenStorageService();
|
||||||
Uint8List? fileBytes;
|
Uint8List? fileBytes;
|
||||||
@ -59,7 +58,6 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
return filteredData.sublist(startIndex, endIndex);
|
return filteredData.sublist(startIndex, endIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -73,23 +71,24 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkIds() async {
|
Future<void> checkIds() async {
|
||||||
print('checkIds');
|
logDebug('checkIds');
|
||||||
_postPreToken = await tokenService.getCurrentToken();
|
_postPreToken = await tokenService.getCurrentToken();
|
||||||
empClientId = await tokenService.readValue('empClientId');
|
empClientId = await tokenService.readValue('empClientId');
|
||||||
// empClientBranchId = await tokenService.readValue('empClientBranchId');
|
// empClientBranchId = await tokenService.readValue('empClientBranchId');
|
||||||
empHrId = await tokenService.readValue('empHrId');
|
empHrId = await tokenService.readValue('empHrId');
|
||||||
print('$_postPreToken - $empClientId - $empHrId');
|
logDebug('$_postPreToken - $empClientId - $empHrId');
|
||||||
await getCDPoliciesDetails(empClientId, empHrId, _postPreToken);
|
await getCDPoliciesDetails(empClientId, empHrId, _postPreToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getCDPoliciesDetails(empClientId, empHrId, _postPreToken) async {
|
Future<void> getCDPoliciesDetails(empClientId, empHrId, _postPreToken) async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final response = await apiService.getCDPoliciesToApi(empClientId, empHrId, _postPreToken);
|
final response = await apiService.getCDPoliciesToApi(
|
||||||
|
empClientId, empHrId, _postPreToken);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -98,8 +97,8 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
getCDPolicies = List<Map<String, dynamic>>.from(response['data']);
|
getCDPolicies = List<Map<String, dynamic>>.from(response['data']);
|
||||||
originalData = getCDPolicies;
|
originalData = getCDPolicies;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -108,13 +107,13 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -123,7 +122,7 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void search(String query) {
|
void search(String query) {
|
||||||
print(query);
|
logDebug(query);
|
||||||
// Check if the query is empty
|
// Check if the query is empty
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
// If search query is empty, show all data
|
// If search query is empty, show all data
|
||||||
@ -152,7 +151,7 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
print(filteredData.length);
|
logDebug(filteredData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exportToCsv(List<Map<String, dynamic>> data) {
|
void exportToCsv(List<Map<String, dynamic>> data) {
|
||||||
@ -185,29 +184,29 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleExportAction() async {
|
Future<void> handleExportAction() async {
|
||||||
print('handleExportAction');
|
logDebug('handleExportAction');
|
||||||
_postPreToken = await tokenService.getCurrentToken();
|
_postPreToken = await tokenService.getCurrentToken();
|
||||||
final postId = await tokenService.readValue('empHrId');
|
final postId = await tokenService.readValue('empHrId');
|
||||||
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
||||||
var activity = "export_cddata";
|
var activity = "export_cddata";
|
||||||
|
|
||||||
print('postId - $postId');
|
logDebug('postId - $postId');
|
||||||
print('preId - $preId');
|
logDebug('preId - $preId');
|
||||||
print('activity - $activity');
|
logDebug('activity - $activity');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final response = await apiService.getPostLogHrActivity(
|
final response = await apiService.getPostLogHrActivity(
|
||||||
postId!, preId!, _postPreToken!, activity);
|
postId!, preId!, _postPreToken!, activity);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,8 +352,6 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Widget _buildCDGrid() {
|
Widget _buildCDGrid() {
|
||||||
if (filteredData.isEmpty) {
|
if (filteredData.isEmpty) {
|
||||||
return const Center(
|
return const Center(
|
||||||
@ -377,8 +374,8 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
return ResponsiveGridConfig(4, 3.8);
|
return ResponsiveGridConfig(4, 3.8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final config = _getGridConfig(context, true);
|
|
||||||
|
|
||||||
|
final config = _getGridConfig(context, true);
|
||||||
|
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
itemCount: filteredData.length,
|
itemCount: filteredData.length,
|
||||||
@ -425,7 +422,8 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
settings: const RouteSettings(name: 'cdTransactionDetails'),
|
settings: const RouteSettings(name: 'cdTransactionDetails'),
|
||||||
builder: (_) => cdTransactionDetails(
|
builder: (_) => cdTransactionDetails(
|
||||||
insurerName: filteredData[index]['insurer_name'],
|
insurerName: filteredData[index]['insurer_name'],
|
||||||
cdMasterAccountNo: filteredData[index]['cd_master_account_no'],
|
cdMasterAccountNo: filteredData[index]
|
||||||
|
['cd_master_account_no'],
|
||||||
insurerId: filteredData[index]['insurer_id'],
|
insurerId: filteredData[index]['insurer_id'],
|
||||||
cd_ac_pk: filteredData[index]['cd_ac_pk'],
|
cd_ac_pk: filteredData[index]['cd_ac_pk'],
|
||||||
empClientId: empClientId,
|
empClientId: empClientId,
|
||||||
@ -435,12 +433,9 @@ class _CdPoliciesListState extends State<CdPoliciesList> {
|
|||||||
},
|
},
|
||||||
child: _CDPolicyCard(data: filteredData[index]),
|
child: _CDPolicyCard(data: filteredData[index]),
|
||||||
);
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CDPolicyCard extends StatelessWidget {
|
class _CDPolicyCard extends StatelessWidget {
|
||||||
@ -480,8 +475,7 @@ class _CDPolicyCard extends StatelessWidget {
|
|||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF000000)
|
color: Color(0xFF000000)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -538,4 +532,3 @@ class _CDPolicyCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import '../config/environment.dart';
|
|||||||
import '../customAppBar/base_layout.dart';
|
import '../customAppBar/base_layout.dart';
|
||||||
import 'cdList.dart';
|
import 'cdList.dart';
|
||||||
import 'claims.dart';
|
import 'claims.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class cdTransactionDetails extends StatefulWidget {
|
class cdTransactionDetails extends StatefulWidget {
|
||||||
final String insurerName;
|
final String insurerName;
|
||||||
@ -26,8 +27,8 @@ class cdTransactionDetails extends StatefulWidget {
|
|||||||
final String cd_ac_pk;
|
final String cd_ac_pk;
|
||||||
final String empClientId;
|
final String empClientId;
|
||||||
// final String postToken;
|
// final String postToken;
|
||||||
const cdTransactionDetails(
|
const cdTransactionDetails({
|
||||||
{Key? key,
|
Key? key,
|
||||||
required this.insurerName,
|
required this.insurerName,
|
||||||
required this.cdMasterAccountNo,
|
required this.cdMasterAccountNo,
|
||||||
required this.insurerId,
|
required this.insurerId,
|
||||||
@ -41,14 +42,12 @@ class cdTransactionDetails extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||||
|
|
||||||
String? localInsurerId;
|
String? localInsurerId;
|
||||||
String? localCdAcPk;
|
String? localCdAcPk;
|
||||||
String? localEmpClientId;
|
String? localEmpClientId;
|
||||||
String? localInsurerName;
|
String? localInsurerName;
|
||||||
String? localCdMasterAccountNo;
|
String? localCdMasterAccountNo;
|
||||||
|
|
||||||
|
|
||||||
final tokenService = TokenStorageService();
|
final tokenService = TokenStorageService();
|
||||||
Uint8List? fileBytes;
|
Uint8List? fileBytes;
|
||||||
List<Map<String, dynamic>> getCDTransData = [];
|
List<Map<String, dynamic>> getCDTransData = [];
|
||||||
@ -60,9 +59,11 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
// List<dynamic> dataPolicy = [];
|
// List<dynamic> dataPolicy = [];
|
||||||
List<dynamic> reversedDataPolicy = [];
|
List<dynamic> reversedDataPolicy = [];
|
||||||
List<Map<String, dynamic>> originalData = []; // Original data source
|
List<Map<String, dynamic>> originalData = []; // Original data source
|
||||||
List<Map<String, dynamic>> originalEndorsementData = []; // Original data source
|
List<Map<String, dynamic>> originalEndorsementData =
|
||||||
|
[]; // Original data source
|
||||||
List<Map<String, dynamic>> filteredData = []; // Filtered data source
|
List<Map<String, dynamic>> filteredData = []; // Filtered data source
|
||||||
List<Map<String, dynamic>> filteredEndorsementData = []; // Filtered data source
|
List<Map<String, dynamic>> filteredEndorsementData =
|
||||||
|
[]; // Filtered data source
|
||||||
List<Map<String, dynamic>> getCDTransDataAmount = []; // Filtered data source
|
List<Map<String, dynamic>> getCDTransDataAmount = []; // Filtered data source
|
||||||
dynamic argumentsData;
|
dynamic argumentsData;
|
||||||
dynamic policyType;
|
dynamic policyType;
|
||||||
@ -94,7 +95,6 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
apiService = ApiService(context); // Initialize ApiService here
|
apiService = ApiService(context); // Initialize ApiService here
|
||||||
|
|
||||||
restoreTransactionData();
|
restoreTransactionData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -102,8 +102,6 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// downloadPolicyFiles?file_id=13
|
// downloadPolicyFiles?file_id=13
|
||||||
// getPolicyAndEndorsementFiles?cd_ac_pk=12
|
// getPolicyAndEndorsementFiles?cd_ac_pk=12
|
||||||
|
|
||||||
@ -128,9 +126,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
? widget.cdMasterAccountNo
|
? widget.cdMasterAccountNo
|
||||||
: await tokenService.readValue('hr_cd_master_account_no');
|
: await tokenService.readValue('hr_cd_master_account_no');
|
||||||
|
|
||||||
print('restore localInsurerId = $localInsurerId');
|
logDebug('restore localInsurerId = $localInsurerId');
|
||||||
print('restore localCdAcPk = $localCdAcPk');
|
logDebug('restore localCdAcPk = $localCdAcPk');
|
||||||
print('restore localEmpClientId = $localEmpClientId');
|
logDebug('restore localEmpClientId = $localEmpClientId');
|
||||||
|
|
||||||
if (localInsurerId != null &&
|
if (localInsurerId != null &&
|
||||||
localCdAcPk != null &&
|
localCdAcPk != null &&
|
||||||
@ -148,15 +146,15 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getCdTransactionDetails() async {
|
Future<void> getCdTransactionDetails() async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final _postPreToken = await tokenService.getCurrentToken();
|
final _postPreToken = await tokenService.getCurrentToken();
|
||||||
final response = await apiService.getCdTransactionData(localEmpClientId!,
|
final response = await apiService.getCdTransactionData(
|
||||||
localInsurerId!, localCdAcPk!, _postPreToken!);
|
localEmpClientId!, localInsurerId!, localCdAcPk!, _postPreToken!);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -176,8 +174,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
// currect_balance = formatAmount(response['data']['currect_balance']);
|
// currect_balance = formatAmount(response['data']['currect_balance']);
|
||||||
insurer_short_name = response['data']['insurer_short_name'];
|
insurer_short_name = response['data']['insurer_short_name'];
|
||||||
// insurer_short_name = formatAmount(response['data']['insurer_short_name']);
|
// insurer_short_name = formatAmount(response['data']['insurer_short_name']);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -186,13 +184,13 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -203,7 +201,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
Future<void> _openEndorsementFile(id, file_name) async {
|
Future<void> _openEndorsementFile(id, file_name) async {
|
||||||
// final http.Response response = await apiService.getHrFileDownloadToApi(id, widget.Token);
|
// final http.Response response = await apiService.getHrFileDownloadToApi(id, widget.Token);
|
||||||
final _postPreToken = await tokenService.getCurrentToken();
|
final _postPreToken = await tokenService.getCurrentToken();
|
||||||
print("**********-------*****");
|
logDebug("**********-------*****");
|
||||||
final apiurl = Environment.apiUrlPost;
|
final apiurl = Environment.apiUrlPost;
|
||||||
final String url = '$apiurl/downloadPolicyFiles?file_id=$id';
|
final String url = '$apiurl/downloadPolicyFiles?file_id=$id';
|
||||||
|
|
||||||
@ -220,7 +218,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
print("PDF Downloaded");
|
logDebug("PDF Downloaded");
|
||||||
|
|
||||||
// ✅ Create a blob from the response body bytes
|
// ✅ Create a blob from the response body bytes
|
||||||
final blob = html.Blob([response.bodyBytes]);
|
final blob = html.Blob([response.bodyBytes]);
|
||||||
@ -242,51 +240,56 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Failed to download');
|
ToastHelper.showErrorToast(context, 'Failed to download');
|
||||||
print("Download failed with status: ${response.statusCode}");
|
logDebug("Download failed with status: ${response.statusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> getCdEndorsementDetails(id) async {
|
Future<void> getCdEndorsementDetails(id) async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final _postPreToken = await tokenService.getCurrentToken();
|
final _postPreToken = await tokenService.getCurrentToken();
|
||||||
final response = await apiService.getCdEndorsementData(id, _postPreToken!);
|
final response =
|
||||||
|
await apiService.getCdEndorsementData(id, _postPreToken!);
|
||||||
if (response['status'] == true) {
|
if (response['status'] == true) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
getCDEndorsementData = List<Map<String, dynamic>>.from(response['data']);
|
getCDEndorsementData =
|
||||||
|
List<Map<String, dynamic>>.from(response['data']);
|
||||||
originalEndorsementData = getCDEndorsementData;
|
originalEndorsementData = getCDEndorsementData;
|
||||||
filteredEndorsementData = List.from(originalEndorsementData);
|
filteredEndorsementData = List.from(originalEndorsementData);
|
||||||
_showFileListPopup(filteredEndorsementData);
|
_showFileListPopup(filteredEndorsementData);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
getCDEndorsementData = List<Map<String, dynamic>>.from(response['data']);
|
getCDEndorsementData =
|
||||||
if (getCDEndorsementData == null || getCDEndorsementData.isEmpty || getCDEndorsementData == null || (getCDEndorsementData as List).isEmpty) {
|
List<Map<String, dynamic>>.from(response['data']);
|
||||||
|
if (getCDEndorsementData == null ||
|
||||||
|
getCDEndorsementData.isEmpty ||
|
||||||
|
getCDEndorsementData == null ||
|
||||||
|
(getCDEndorsementData as List).isEmpty) {
|
||||||
_showEmptyPopup(response['message']);
|
_showEmptyPopup(response['message']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -327,7 +330,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Navigator.pop(context); // close popup
|
// Navigator.pop(context); // close popup
|
||||||
_openEndorsementFile(file['id'],file['file_name']);
|
_openEndorsementFile(file['id'], file['file_name']);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -369,9 +372,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void search(String query) {
|
void search(String query) {
|
||||||
print(query);
|
logDebug(query);
|
||||||
// Check if the query is empty
|
// Check if the query is empty
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
// If search query is empty, show all data
|
// If search query is empty, show all data
|
||||||
@ -436,7 +438,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
print(filteredData.length);
|
logDebug(filteredData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exportToCsv(List<Map<String, dynamic>> data) {
|
void exportToCsv(List<Map<String, dynamic>> data) {
|
||||||
@ -497,31 +499,31 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleExportAction() async {
|
Future<void> handleExportAction() async {
|
||||||
print('handleExportAction');
|
logDebug('handleExportAction');
|
||||||
|
|
||||||
final postId = await tokenService.readValue('empHrId');
|
final postId = await tokenService.readValue('empHrId');
|
||||||
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
||||||
|
|
||||||
var activity = "export_cdsummary";
|
var activity = "export_cdsummary";
|
||||||
|
|
||||||
print('postId - $postId');
|
logDebug('postId - $postId');
|
||||||
print('preId - $preId');
|
logDebug('preId - $preId');
|
||||||
print('activity - $activity');
|
logDebug('activity - $activity');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final _postPreToken = await tokenService.getCurrentToken();
|
final _postPreToken = await tokenService.getCurrentToken();
|
||||||
final response = await apiService.getPostLogHrActivity(
|
final response = await apiService.getPostLogHrActivity(
|
||||||
postId!, preId!, _postPreToken!, activity);
|
postId!, preId!, _postPreToken!, activity);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,13 +553,13 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
|
|
||||||
Future<void> _launchURL(String url) async {
|
Future<void> _launchURL(String url) async {
|
||||||
final Uri uri = Uri.parse(url); // Parse the URL properly
|
final Uri uri = Uri.parse(url); // Parse the URL properly
|
||||||
print('_launchURL $uri');
|
logDebug('_launchURL $uri');
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
print('If $uri');
|
logDebug('If $uri');
|
||||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showWarningToast(context, 'File not generated');
|
ToastHelper.showWarningToast(context, 'File not generated');
|
||||||
print('else $uri');
|
logDebug('else $uri');
|
||||||
throw 'Could not launch $url';
|
throw 'Could not launch $url';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -591,7 +593,6 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
return amount.round().toString();
|
return amount.round().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BaseLayout(
|
return BaseLayout(
|
||||||
@ -607,7 +608,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
Widget _buildContent(BuildContext context) {
|
||||||
return isLoading ? Container(
|
return isLoading
|
||||||
|
? Container(
|
||||||
color: Colors.transparent, // Semi-transparent background
|
color: Colors.transparent, // Semi-transparent background
|
||||||
child: Center(
|
child: Center(
|
||||||
child: // Your GIF loader widget
|
child: // Your GIF loader widget
|
||||||
@ -616,7 +618,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
width: 60,
|
width: 60,
|
||||||
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
||||||
),
|
),
|
||||||
) : Container(
|
)
|
||||||
|
: Container(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -637,7 +640,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
settings: const RouteSettings(name: 'cdPoliciesList'),
|
settings:
|
||||||
|
const RouteSettings(name: 'cdPoliciesList'),
|
||||||
builder: (_) => CdPoliciesList(),
|
builder: (_) => CdPoliciesList(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -724,8 +728,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
Color(0xFF39D45B), Icons.arrow_upward),
|
Color(0xFF39D45B), Icons.arrow_upward),
|
||||||
_buildInfoCard('Consumed', '₹$total_consumed',
|
_buildInfoCard('Consumed', '₹$total_consumed',
|
||||||
Color(0xFFED1D24), Icons.arrow_downward),
|
Color(0xFFED1D24), Icons.arrow_downward),
|
||||||
_buildInfoCard('Refund', '₹$total_refund',
|
_buildInfoCard('Refund', '₹$total_refund', Color(0xFF39D45B),
|
||||||
Color(0xFF39D45B), Icons.arrow_upward),
|
Icons.arrow_upward),
|
||||||
_buildInfoCard('Current Balance', '₹$currect_balance',
|
_buildInfoCard('Current Balance', '₹$currect_balance',
|
||||||
Colors.black, null),
|
Colors.black, null),
|
||||||
],
|
],
|
||||||
@ -735,13 +739,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: _buildCDDataTable(context),
|
child: _buildCDDataTable(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
));
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Widget _buildInfoCard(
|
Widget _buildInfoCard(
|
||||||
String label, String value, Color iconColor, IconData? icon) {
|
String label, String value, Color iconColor, IconData? icon) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
@ -831,8 +831,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
final bool isAllowedSubType =
|
final bool isAllowedSubType =
|
||||||
item['sub_type'] == '3' || item['sub_type'] == '4';
|
item['sub_type'] == '3' || item['sub_type'] == '4';
|
||||||
|
|
||||||
final bool hasSplitUpFile =
|
final bool hasSplitUpFile = item['split_up_url'] != null &&
|
||||||
item['split_up_url'] != null &&
|
|
||||||
item['split_up_url'].toString().trim().isNotEmpty;
|
item['split_up_url'].toString().trim().isNotEmpty;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
@ -862,9 +861,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
_cell(item['sub_type_text'], 2),
|
_cell(item['sub_type_text'], 2),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
_cell(
|
_cell(
|
||||||
item['transaction_type'] == 'Credit'
|
item['transaction_type'] == 'Credit' ? item['amount'] : '-',
|
||||||
? item['amount']
|
|
||||||
: '-',
|
|
||||||
2,
|
2,
|
||||||
alignRight: true,
|
alignRight: true,
|
||||||
),
|
),
|
||||||
@ -877,9 +874,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
// ),
|
// ),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
_cell(
|
_cell(
|
||||||
item['transaction_type'] == 'Debit'
|
item['transaction_type'] == 'Debit' ? item['amount'] : '-',
|
||||||
? item['amount']
|
|
||||||
: '-',
|
|
||||||
2,
|
2,
|
||||||
alignRight: true,
|
alignRight: true,
|
||||||
),
|
),
|
||||||
@ -905,7 +900,6 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
/// --- PDF ICON SLOT ---
|
/// --- PDF ICON SLOT ---
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 36,
|
width: 36,
|
||||||
@ -987,7 +981,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
final totalItems = filteredData.length;
|
final totalItems = filteredData.length;
|
||||||
|
|
||||||
// Calculate entries range
|
// Calculate entries range
|
||||||
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
final int startEntry =
|
||||||
|
totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
||||||
int endEntry = _currentPage * _rowsPerPage;
|
int endEntry = _currentPage * _rowsPerPage;
|
||||||
if (endEntry > totalItems) endEntry = totalItems;
|
if (endEntry > totalItems) endEntry = totalItems;
|
||||||
|
|
||||||
@ -1026,7 +1021,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
|
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Standard Table Footer Layout
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween, // Standard Table Footer Layout
|
||||||
children: [
|
children: [
|
||||||
/// --- LEFT SIDE: ENTRY DETAILS ---
|
/// --- LEFT SIDE: ENTRY DETAILS ---
|
||||||
Text(
|
Text(
|
||||||
@ -1041,7 +1037,6 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
/// --- RIGHT SIDE: CONTROLS ---
|
/// --- RIGHT SIDE: CONTROLS ---
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
DropdownButton<int>(
|
DropdownButton<int>(
|
||||||
value: _rowsPerPage,
|
value: _rowsPerPage,
|
||||||
items: [5, 10, 15, 20, 50].map((int value) {
|
items: [5, 10, 15, 20, 50].map((int value) {
|
||||||
@ -1225,10 +1220,8 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _CDTableHeaderDelegate extends SliverPersistentHeaderDelegate {
|
class _CDTableHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||||
@override
|
@override
|
||||||
double get minExtent => 52;
|
double get minExtent => 52;
|
||||||
@ -1301,8 +1294,9 @@ class _HeaderCell extends StatelessWidget {
|
|||||||
flex: flex,
|
flex: flex,
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
textAlign:
|
textAlign: center
|
||||||
center ? TextAlign.center : (alignRight ? TextAlign.right : TextAlign.left),
|
? TextAlign.center
|
||||||
|
: (alignRight ? TextAlign.right : TextAlign.left),
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
@ -1313,7 +1307,6 @@ class _HeaderCell extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _ActionIconButton extends StatelessWidget {
|
class _ActionIconButton extends StatelessWidget {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
@ -1334,9 +1327,7 @@ class _ActionIconButton extends StatelessWidget {
|
|||||||
width: 36,
|
width: 36,
|
||||||
height: 36,
|
height: 36,
|
||||||
child: Material(
|
child: Material(
|
||||||
color: enabled
|
color: enabled ? const Color(0xFFDFF4F5) : Colors.transparent,
|
||||||
? const Color(0xFFDFF4F5)
|
|
||||||
: Colors.transparent,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
@ -1363,8 +1354,6 @@ class _ActionIconButton extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sample Data class representing each element in the array
|
// Sample Data class representing each element in the array
|
||||||
class Data {
|
class Data {
|
||||||
final dynamic value;
|
final dynamic value;
|
||||||
|
|||||||
@ -19,12 +19,12 @@ import '../customAppBar/base_layout.dart';
|
|||||||
import '../service/api_service.dart';
|
import '../service/api_service.dart';
|
||||||
import '../service/token_storage_service.dart';
|
import '../service/token_storage_service.dart';
|
||||||
import 'RaiseClaimForm.dart';
|
import 'RaiseClaimForm.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class ClaimsPolicies extends StatefulWidget {
|
class ClaimsPolicies extends StatefulWidget {
|
||||||
|
|
||||||
final String empCode;
|
final String empCode;
|
||||||
const ClaimsPolicies(
|
const ClaimsPolicies({
|
||||||
{Key? key,
|
Key? key,
|
||||||
required this.empCode,
|
required this.empCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -32,9 +32,15 @@ class ClaimsPolicies extends StatefulWidget {
|
|||||||
State<ClaimsPolicies> createState() => _ClaimsPolicieState();
|
State<ClaimsPolicies> createState() => _ClaimsPolicieState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
||||||
List<String> tabHeader = ['name', 'empCode', 'from', 'to', 'claimNum','policyNumber'];
|
List<String> tabHeader = [
|
||||||
|
'name',
|
||||||
|
'empCode',
|
||||||
|
'from',
|
||||||
|
'to',
|
||||||
|
'claimNum',
|
||||||
|
'policyNumber'
|
||||||
|
];
|
||||||
final tokenService = TokenStorageService();
|
final tokenService = TokenStorageService();
|
||||||
List<Map<String, dynamic>> filteredData = []; // Filtered data source
|
List<Map<String, dynamic>> filteredData = []; // Filtered data source
|
||||||
dynamic empClientId;
|
dynamic empClientId;
|
||||||
@ -91,7 +97,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, dynamic> claim_Detials() {
|
Map<String, dynamic> claim_Detials() {
|
||||||
final data = {
|
final data = {
|
||||||
"client_id": empClientId ?? '',
|
"client_id": empClientId ?? '',
|
||||||
@ -116,15 +121,14 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
controllers[field] = TextEditingController();
|
controllers[field] = TextEditingController();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if (_postPreToken != null && _postPreToken!.isNotEmpty) {
|
// if (_postPreToken != null && _postPreToken!.isNotEmpty) {
|
||||||
//
|
//
|
||||||
// claim_Detials();
|
// claim_Detials();
|
||||||
//
|
//
|
||||||
// print("Empcoed1- ${widget.empCodeHrPolicy}");
|
// logDebug("Empcoed1- ${widget.empCodeHrPolicy}");
|
||||||
// print("EmpisHrcode- ${empHrId}");
|
// logDebug("EmpisHrcode- ${empHrId}");
|
||||||
// if (widget.empCodeHrPolicy != '') {
|
// if (widget.empCodeHrPolicy != '') {
|
||||||
// print("Empcoedbool- ${widget.isHrcode}");
|
// logDebug("Empcoedbool- ${widget.isHrcode}");
|
||||||
// controllers['empCode']!.text = widget.empCodeHrPolicy;
|
// controllers['empCode']!.text = widget.empCodeHrPolicy;
|
||||||
// // if (widget.isHrcode == 0) {
|
// // if (widget.isHrcode == 0) {
|
||||||
// // controllers['empCode']?.clear();
|
// // controllers['empCode']?.clear();
|
||||||
@ -132,19 +136,18 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
// // controllers['empCode']!.text = widget.empCodeHrPolicy;
|
// // controllers['empCode']!.text = widget.empCodeHrPolicy;
|
||||||
// // }
|
// // }
|
||||||
//
|
//
|
||||||
// print("Empcoed- ${widget.empCodeHrPolicy}");
|
// logDebug("Empcoed- ${widget.empCodeHrPolicy}");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // if (widget.empCodeHrPolicy != '' && widget.isHrcode) {
|
// // if (widget.empCodeHrPolicy != '' && widget.isHrcode) {
|
||||||
// // print("Empcoedbool- ${widget.isHrcode}");
|
// // logDebug("Empcoedbool- ${widget.isHrcode}");
|
||||||
// // controllers['empCode']!.text = widget.empCodeHrPolicy;
|
// // controllers['empCode']!.text = widget.empCodeHrPolicy;
|
||||||
// // print("Empcoed- ${widget.empCodeHrPolicy}");
|
// // logDebug("Empcoed- ${widget.empCodeHrPolicy}");
|
||||||
// // }
|
// // }
|
||||||
//
|
//
|
||||||
// getClaimList();
|
// getClaimList();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// getApiData();
|
// getApiData();
|
||||||
_loadIds();
|
_loadIds();
|
||||||
}
|
}
|
||||||
@ -178,13 +181,14 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClaimsPoliciesDetails() async {
|
Future<void> getClaimsPoliciesDetails() async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final response = await apiService.getClaimPoliciesToApi(_postPreToken!,'');
|
final response =
|
||||||
|
await apiService.getClaimPoliciesToApi(_postPreToken!, '');
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -199,13 +203,13 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
// isLoading = false;
|
// isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
// _isLoading = false;
|
// _isLoading = false;
|
||||||
@ -214,7 +218,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClaimList() async {
|
Future<void> getClaimList() async {
|
||||||
print('getClaimList called');
|
logDebug('getClaimList called');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
@ -224,7 +228,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
empClientBranchId ??= await tokenService.readValue('empClientBranchId');
|
empClientBranchId ??= await tokenService.readValue('empClientBranchId');
|
||||||
|
|
||||||
final requestData = claim_Detials();
|
final requestData = claim_Detials();
|
||||||
print("Request Body: $requestData");
|
logDebug("Request Body: $requestData");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await apiService.getClaimPoliciesListDataToApi(
|
final response = await apiService.getClaimPoliciesListDataToApi(
|
||||||
@ -235,21 +239,21 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
getClaimPolicies = List<Map<String, dynamic>>.from(response['data']);
|
getClaimPolicies = List<Map<String, dynamic>>.from(response['data']);
|
||||||
print('API Data - $getClaimPolicies');
|
logDebug('API Data - $getClaimPolicies');
|
||||||
|
|
||||||
originalData = getClaimPolicies;
|
originalData = getClaimPolicies;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('originalData - $getClaimPolicies');
|
logDebug('originalData - $getClaimPolicies');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getClaimPolicies = [];
|
getClaimPolicies = [];
|
||||||
originalData = getClaimPolicies;
|
originalData = getClaimPolicies;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('originalData - $getClaimPolicies');
|
logDebug('originalData - $getClaimPolicies');
|
||||||
print('Request failed: ${response['code']}');
|
logDebug('Request failed: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -265,14 +269,14 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
.length;
|
.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> applyFilter() async {
|
Future<void> applyFilter() async {
|
||||||
print("Filtersss");
|
logDebug("Filtersss");
|
||||||
|
|
||||||
/// ✅ Resolve futures FIRST
|
/// ✅ Resolve futures FIRST
|
||||||
empClientId ??= await tokenService.readValue('empClientId');
|
empClientId ??= await tokenService.readValue('empClientId');
|
||||||
empClientBranchId ??= await tokenService.readValue('empClientBranchId');
|
empClientBranchId ??= await tokenService.readValue('empClientBranchId');
|
||||||
final data = claim_Detials();
|
final data = claim_Detials();
|
||||||
print("data -- $data");
|
logDebug("data -- $data");
|
||||||
getClaimList();
|
getClaimList();
|
||||||
setState(() {
|
setState(() {
|
||||||
appliedClaimStatus = selectedClaimStatus; // ✅ apply only after API call
|
appliedClaimStatus = selectedClaimStatus; // ✅ apply only after API call
|
||||||
@ -300,14 +304,25 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
empClientBranchId ??= await tokenService.readValue('empClientBranchId');
|
empClientBranchId ??= await tokenService.readValue('empClientBranchId');
|
||||||
|
|
||||||
final data = claim_Detials();
|
final data = claim_Detials();
|
||||||
print("restdata -- $data");
|
logDebug("restdata -- $data");
|
||||||
}
|
}
|
||||||
|
|
||||||
void exportToCsv(List<Map<String, dynamic>> data) {
|
void exportToCsv(List<Map<String, dynamic>> data) {
|
||||||
List<List<String>> rows = [];
|
List<List<String>> rows = [];
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
rows.add(['Emp Name', 'Emp Code','Insured Name', 'Policy Type','Client Policy No','Claim Number','Claim Type','Status','Claim Amount','Record Date']);
|
rows.add([
|
||||||
|
'Emp Name',
|
||||||
|
'Emp Code',
|
||||||
|
'Insured Name',
|
||||||
|
'Policy Type',
|
||||||
|
'Client Policy No',
|
||||||
|
'Claim Number',
|
||||||
|
'Claim Type',
|
||||||
|
'Status',
|
||||||
|
'Claim Amount',
|
||||||
|
'Record Date'
|
||||||
|
]);
|
||||||
|
|
||||||
// Data rows
|
// Data rows
|
||||||
for (var item in data) {
|
for (var item in data) {
|
||||||
@ -340,34 +355,34 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleExportAction() async {
|
Future<void> handleExportAction() async {
|
||||||
print('handleExportAction');
|
logDebug('handleExportAction');
|
||||||
_postPreToken = await tokenService.getCurrentToken();
|
_postPreToken = await tokenService.getCurrentToken();
|
||||||
final postId = await tokenService.readValue('empHrId');
|
final postId = await tokenService.readValue('empHrId');
|
||||||
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
||||||
var activity = "export_cddata";
|
var activity = "export_cddata";
|
||||||
|
|
||||||
print('postId - $postId');
|
logDebug('postId - $postId');
|
||||||
print('preId - $preId');
|
logDebug('preId - $preId');
|
||||||
print('activity - $activity');
|
logDebug('activity - $activity');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final response = await apiService.getPostLogHrActivity(
|
final response = await apiService.getPostLogHrActivity(
|
||||||
postId!, preId!, _postPreToken!, activity);
|
postId!, preId!, _postPreToken!, activity);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void search(String query) {
|
void search(String query) {
|
||||||
print(query);
|
logDebug(query);
|
||||||
// Check if the query is empty
|
// Check if the query is empty
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
// If search query is empty, show all data
|
// If search query is empty, show all data
|
||||||
@ -424,7 +439,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
print(filteredData.length);
|
logDebug(filteredData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _showLogoutDialog() async {
|
Future<bool> _showLogoutDialog() async {
|
||||||
@ -488,7 +503,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
/// 🔙 Back + Title (LEFT)
|
/// 🔙 Back + Title (LEFT)
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
if(widget.empCode.isNotEmpty)
|
if (widget.empCode.isNotEmpty)
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
Navigator.of(context).pop(),
|
Navigator.of(context).pop(),
|
||||||
@ -567,6 +582,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
|
|
||||||
/// ⬇️ Add Button
|
/// ⬇️ Add Button
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 100,
|
width: 100,
|
||||||
@ -643,8 +659,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Widget _buildInputFields(BuildContext context) {
|
Widget _buildInputFields(BuildContext context) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 70, // 🔥 controls total height like image
|
height: 70, // 🔥 controls total height like image
|
||||||
@ -674,7 +688,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
selectedClaimStatus = value;
|
selectedClaimStatus = value;
|
||||||
});
|
});
|
||||||
print('Selected Claim Status ID: $selectedClaimStatus');
|
logDebug('Selected Claim Status ID: $selectedClaimStatus');
|
||||||
},
|
},
|
||||||
claimStatusList,
|
claimStatusList,
|
||||||
'name',
|
'name',
|
||||||
@ -683,7 +697,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildClaimsDataTable(BuildContext context) {
|
Widget _buildClaimsDataTable(BuildContext context) {
|
||||||
if (filteredData.isEmpty) {
|
if (filteredData.isEmpty) {
|
||||||
return const Center(child: Text('No available data'));
|
return const Center(child: Text('No available data'));
|
||||||
@ -807,14 +820,14 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
cursor: SystemMouseCursors.click,
|
cursor: SystemMouseCursors.click,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// print('id ${item['id']}');
|
// logDebug('id ${item['id']}');
|
||||||
// print('emp_name ${item['emp_name']}');
|
// logDebug('emp_name ${item['emp_name']}');
|
||||||
// print('emp_code ${item['emp_code']}');
|
// logDebug('emp_code ${item['emp_code']}');
|
||||||
// print('policy_type ${item['policy_type']}');
|
// logDebug('policy_type ${item['policy_type']}');
|
||||||
// print('client_policy_no ${item['client_policy_no']}');
|
// logDebug('client_policy_no ${item['client_policy_no']}');
|
||||||
// print('claim_amount ${item['claim_amount']}');
|
// logDebug('claim_amount ${item['claim_amount']}');
|
||||||
// print('claim_no ${item['claim_no']}');
|
// logDebug('claim_no ${item['claim_no']}');
|
||||||
// print(widget.postToken);
|
// logDebug(widget.postToken);
|
||||||
// return;
|
// return;
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -829,7 +842,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
empCode: item['emp_code'] ?? '', // example
|
empCode: item['emp_code'] ?? '', // example
|
||||||
policyType: item['policy_type'] ?? '',
|
policyType: item['policy_type'] ?? '',
|
||||||
clientPolicyNo: item['client_policy_no'] ?? '',
|
clientPolicyNo: item['client_policy_no'] ?? '',
|
||||||
claimAmount: item['claim_amount']?.toString() ?? '',
|
claimAmount:
|
||||||
|
item['claim_amount']?.toString() ?? '',
|
||||||
claimNo: item['claim_no'] ?? '',
|
claimNo: item['claim_no'] ?? '',
|
||||||
postToken: _postPreToken ?? '',
|
postToken: _postPreToken ?? '',
|
||||||
),
|
),
|
||||||
@ -845,7 +859,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(10), // You can adjust this value
|
padding:
|
||||||
|
EdgeInsets.all(10), // You can adjust this value
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/claimHistory.png',
|
'assets/claimHistory.png',
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
@ -871,7 +886,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
if (statusMaster.isEmpty) return const SizedBox();
|
if (statusMaster.isEmpty) return const SizedBox();
|
||||||
|
|
||||||
final List<dynamic> displayStatuses = appliedClaimStatus != null
|
final List<dynamic> displayStatuses = appliedClaimStatus != null
|
||||||
? statusMaster.where((status) =>
|
? statusMaster
|
||||||
|
.where((status) =>
|
||||||
int.parse(status['id'].toString()) == appliedClaimStatus)
|
int.parse(status['id'].toString()) == appliedClaimStatus)
|
||||||
.toList()
|
.toList()
|
||||||
: statusMaster;
|
: statusMaster;
|
||||||
@ -890,8 +906,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
final color = getStatusColor(statusName);
|
final color = getStatusColor(statusName);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color,
|
color: color,
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
@ -910,7 +925,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static final _dataBold = GoogleFonts.poppins(
|
static final _dataBold = GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
@ -943,7 +957,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
Widget _buildPagination(BuildContext context) {
|
Widget _buildPagination(BuildContext context) {
|
||||||
// 1. Calculate the range of entries being shown
|
// 1. Calculate the range of entries being shown
|
||||||
final totalItems = filteredData.length;
|
final totalItems = filteredData.length;
|
||||||
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
final int startEntry =
|
||||||
|
totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
||||||
int endEntry = _currentPage * _rowsPerPage;
|
int endEntry = _currentPage * _rowsPerPage;
|
||||||
if (endEntry > totalItems) endEntry = totalItems;
|
if (endEntry > totalItems) endEntry = totalItems;
|
||||||
|
|
||||||
@ -974,7 +989,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
_currentPage + 1,
|
_currentPage + 1,
|
||||||
_currentPage + 2,
|
_currentPage + 2,
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> visiblePages = getVisiblePages();
|
List<int> visiblePages = getVisiblePages();
|
||||||
@ -983,7 +997,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
// Match this horizontal padding (16) to your Table Header padding for perfect alignment
|
// Match this horizontal padding (16) to your Table Header padding for perfect alignment
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Pushes text to left, buttons to right
|
mainAxisAlignment: MainAxisAlignment
|
||||||
|
.spaceBetween, // Pushes text to left, buttons to right
|
||||||
children: [
|
children: [
|
||||||
// --- LEFT SIDE: Showing Text ---
|
// --- LEFT SIDE: Showing Text ---
|
||||||
Text(
|
Text(
|
||||||
@ -1196,23 +1211,23 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
|
|
||||||
// Get id from type_name
|
// Get id from type_name
|
||||||
int? getIdByTypeName(String? typeName) {
|
int? getIdByTypeName(String? typeName) {
|
||||||
print("getIdByTypeName");
|
logDebug("getIdByTypeName");
|
||||||
print("getIdByTypeName - $typeName");
|
logDebug("getIdByTypeName - $typeName");
|
||||||
final match = ticketTypeList.firstWhere(
|
final match = ticketTypeList.firstWhere(
|
||||||
(e) => e['type_name'] == typeName,
|
(e) => e['type_name'] == typeName,
|
||||||
orElse: () => null,
|
orElse: () => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
print("match - $match");
|
logDebug("match - $match");
|
||||||
|
|
||||||
if (match != null && match is Map) {
|
if (match != null && match is Map) {
|
||||||
final map = match as Map;
|
final map = match as Map;
|
||||||
final id = map['ticket_type'];
|
final id = map['ticket_type'];
|
||||||
print("Returning ticket_type: $id");
|
logDebug("Returning ticket_type: $id");
|
||||||
return id is int ? id : int.tryParse(id.toString());
|
return id is int ? id : int.tryParse(id.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
print("no match or invalid map");
|
logDebug("no match or invalid map");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1248,9 +1263,9 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
selectedPolicyType = getIdByTypeName(value);
|
selectedPolicyType = getIdByTypeName(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
print(
|
logDebug(
|
||||||
"Selected selectedPolicyTypeName: $selectedPolicyTypeName");
|
"Selected selectedPolicyTypeName: $selectedPolicyTypeName");
|
||||||
print("Selected selectedPolicyType: $selectedPolicyType");
|
logDebug("Selected selectedPolicyType: $selectedPolicyType");
|
||||||
},
|
},
|
||||||
decoratorProps: DropDownDecoratorProps(
|
decoratorProps: DropDownDecoratorProps(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -1339,10 +1354,11 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
String formattedDate =
|
String formattedDate =
|
||||||
"${pickedDate.day.toString().padLeft(2, '0')}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.year}";
|
"${pickedDate.day.toString().padLeft(2, '0')}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.year}";
|
||||||
|
|
||||||
print("FomatedFromDAta - $formattedDate");
|
logDebug("FomatedFromDAta - $formattedDate");
|
||||||
setState(() {
|
setState(() {
|
||||||
controllers['from']?.text = formattedDate;
|
controllers['from']?.text = formattedDate;
|
||||||
controllers['to']?.clear(); // 🔥 prevent invalid To date
|
controllers['to']
|
||||||
|
?.clear(); // 🔥 prevent invalid To date
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1373,8 +1389,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
suffixIcon: const Icon(Icons.calendar_today, size: 16),
|
suffixIcon: const Icon(Icons.calendar_today, size: 16),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -1418,7 +1433,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
DateTime? pickedDate = await showDatePicker(
|
DateTime? pickedDate = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: fromDate ?? DateTime.now(),
|
initialDate: fromDate ?? DateTime.now(),
|
||||||
firstDate: fromDate ?? DateTime(2000), // ✅ cannot be before From date
|
firstDate: fromDate ??
|
||||||
|
DateTime(2000), // ✅ cannot be before From date
|
||||||
lastDate: DateTime.now(), // ✅ no future dates
|
lastDate: DateTime.now(), // ✅ no future dates
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1461,8 +1477,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
suffixIcon: const Icon(Icons.calendar_today, size: 16),
|
suffixIcon: const Icon(Icons.calendar_today, size: 16),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -1475,7 +1490,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
String displayField,
|
String displayField,
|
||||||
int? selectedValue,
|
int? selectedValue,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -1543,7 +1557,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
orElse: () => {},
|
orElse: () => {},
|
||||||
);
|
);
|
||||||
|
|
||||||
final text = matchedItem['name']?.toString().toLowerCase() ?? '';
|
final text =
|
||||||
|
matchedItem['name']?.toString().toLowerCase() ?? '';
|
||||||
return text.contains(searchValue.toLowerCase());
|
return text.contains(searchValue.toLowerCase());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -1583,9 +1598,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Widget _buildPolicyNumber(BuildContext context) {
|
Widget _buildPolicyNumber(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
width: MediaQuery.of(context).size.width * 0.15,
|
width: MediaQuery.of(context).size.width * 0.15,
|
||||||
@ -1642,8 +1654,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
contentPadding: EdgeInsets.fromLTRB(12, 20, 12, 10),
|
contentPadding: EdgeInsets.fromLTRB(12, 20, 12, 10),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -1670,14 +1681,12 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
_IconActionButton(
|
_IconActionButton(
|
||||||
icon: Icons.filter_alt_outlined,
|
icon: Icons.filter_alt_outlined,
|
||||||
onTap: applyFilter,
|
onTap: applyFilter,
|
||||||
tooltip:"Filter"
|
tooltip: "Filter"),
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
_IconActionButton(
|
_IconActionButton(
|
||||||
icon: Icons.refresh_outlined,
|
icon: Icons.refresh_outlined,
|
||||||
onTap: reset,
|
onTap: reset,
|
||||||
tooltip:"Reset"
|
tooltip: "Reset"),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1685,7 +1694,6 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ClaimsHeaderDelegate extends SliverPersistentHeaderDelegate {
|
class _ClaimsHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||||
@ -1763,6 +1771,7 @@ class _IconActionButton extends StatelessWidget {
|
|||||||
child: Icon(icon, color: Colors.white, size: 20),
|
child: Icon(icon, color: Colors.white, size: 20),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),);
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import 'package:file_picker/file_picker.dart';
|
|||||||
import 'package:pdf/widgets.dart' as pw;
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
import '../../../config/environment.dart';
|
import '../../../config/environment.dart';
|
||||||
import '../../../customAppBar/toastHelper.dart';
|
import '../../../customAppBar/toastHelper.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class ClaimHistoryPopup extends StatefulWidget {
|
class ClaimHistoryPopup extends StatefulWidget {
|
||||||
final String ticket_id;
|
final String ticket_id;
|
||||||
@ -77,13 +78,13 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
apiService = ApiService(context);
|
apiService = ApiService(context);
|
||||||
|
|
||||||
// debug prints kept
|
// debug prints kept
|
||||||
print("CLAIMHISTORY");
|
logDebug("CLAIMHISTORY");
|
||||||
print(widget.claimAmount);
|
logDebug(widget.claimAmount);
|
||||||
print(widget.claimNo);
|
logDebug(widget.claimNo);
|
||||||
print(widget.clientPolicyNo);
|
logDebug(widget.clientPolicyNo);
|
||||||
print(widget.empCode);
|
logDebug(widget.empCode);
|
||||||
print(widget.policyType);
|
logDebug(widget.policyType);
|
||||||
print(widget.ticket_id);
|
logDebug(widget.ticket_id);
|
||||||
getClaimsHistoryDetails();
|
getClaimsHistoryDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
setState(() => isSubmitting = true); // 🔥 start loader
|
setState(() => isSubmitting = true); // 🔥 start loader
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('enter');
|
logDebug('enter');
|
||||||
|
|
||||||
// STEP 1: Must select at least one document type
|
// STEP 1: Must select at least one document type
|
||||||
final selectedDocs = requiredDocsList
|
final selectedDocs = requiredDocsList
|
||||||
@ -235,9 +236,9 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
request.fields['claim_doc_names'] = jsonEncode(labels);
|
request.fields['claim_doc_names'] = jsonEncode(labels);
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
print(
|
logDebug(
|
||||||
"Files uploaded: ${fileService.files.map((e) => e.file.name).toList()}");
|
"Files uploaded: ${fileService.files.map((e) => e.file.name).toList()}");
|
||||||
print("Labels: $labels");
|
logDebug("Labels: $labels");
|
||||||
|
|
||||||
// STEP 7: Send the request
|
// STEP 7: Send the request
|
||||||
final response = await request.send();
|
final response = await request.send();
|
||||||
@ -299,8 +300,8 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
print(isActionFreeze);
|
logDebug(isActionFreeze);
|
||||||
print('requiredDocsList $requiredDocsList');
|
logDebug('requiredDocsList $requiredDocsList');
|
||||||
|
|
||||||
for (var d in requiredDocsList) {
|
for (var d in requiredDocsList) {
|
||||||
_assignedFiles[d['document_name']] = null;
|
_assignedFiles[d['document_name']] = null;
|
||||||
@ -308,11 +309,11 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +322,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
try {
|
try {
|
||||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Could not launch URL: $e');
|
logDebug('Could not launch URL: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,13 +478,17 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
isDesktop: false,
|
isDesktop: false,
|
||||||
key: ValueKey('mobile_ir'),
|
key: ValueKey('mobile_ir'),
|
||||||
)
|
)
|
||||||
: _buildMainLeftContent(key: ValueKey('main_left'),showIRDocs: showIRDocs),
|
: _buildMainLeftContent(
|
||||||
|
key: ValueKey('main_left'),
|
||||||
|
showIRDocs: showIRDocs),
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// LEFT: main content - scrollable
|
// LEFT: main content - scrollable
|
||||||
Expanded(child: _buildMainLeftContent(showIRDocs: showIRDocs)),
|
Expanded(
|
||||||
|
child:
|
||||||
|
_buildMainLeftContent(showIRDocs: showIRDocs)),
|
||||||
|
|
||||||
// RIGHT: IR panel - desktop inline (only visible on wide screens)
|
// RIGHT: IR panel - desktop inline (only visible on wide screens)
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
@ -510,7 +515,10 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
// -------------------------
|
// -------------------------
|
||||||
// Main left content extracted to keep code tidy
|
// Main left content extracted to keep code tidy
|
||||||
// -------------------------
|
// -------------------------
|
||||||
Widget _buildMainLeftContent({Key? key,required bool showIRDocs,}) {
|
Widget _buildMainLeftContent({
|
||||||
|
Key? key,
|
||||||
|
required bool showIRDocs,
|
||||||
|
}) {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
key: key,
|
key: key,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -738,9 +746,9 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemCount: claimFiles.length,
|
itemCount: claimFiles.length,
|
||||||
gridDelegate:
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
SliverGridDelegateWithFixedCrossAxisCount(
|
crossAxisCount:
|
||||||
crossAxisCount: showIRDocs ? 2 : 3, // ✅ desktop: 3 per row
|
showIRDocs ? 2 : 3, // ✅ desktop: 3 per row
|
||||||
crossAxisSpacing: 16,
|
crossAxisSpacing: 16,
|
||||||
mainAxisSpacing: 16,
|
mainAxisSpacing: 16,
|
||||||
childAspectRatio: 5.9, // controls height
|
childAspectRatio: 5.9, // controls height
|
||||||
@ -805,7 +813,8 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
|
|||||||
padding: const EdgeInsets.all(6),
|
padding: const EdgeInsets.all(6),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFE6E6E6),
|
color: const Color(0xFFE6E6E6),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius:
|
||||||
|
BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.download,
|
Icons.download,
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import 'dart:typed_data';
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import '../customAppBar/base_layout.dart';
|
import '../customAppBar/base_layout.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class excelErrorScreen extends StatefulWidget {
|
class excelErrorScreen extends StatefulWidget {
|
||||||
final String ClientId;
|
final String ClientId;
|
||||||
@ -80,7 +81,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
final ScrollController _verticalController = ScrollController();
|
final ScrollController _verticalController = ScrollController();
|
||||||
final ScrollController _horizontalController = ScrollController();
|
final ScrollController _horizontalController = ScrollController();
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -95,7 +95,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> getCDPoliciesDetails() async {
|
Future<void> getCDPoliciesDetails() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
@ -117,19 +116,16 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
if (response['message'] == "Error data feteched successfully") {
|
if (response['message'] == "Error data feteched successfully") {
|
||||||
// This runs if the message matches EXACTLY (including the typo 'feteched')
|
// This runs if the message matches EXACTLY (including the typo 'feteched')
|
||||||
ToastHelper.showErrorToast(context, response['message']);
|
ToastHelper.showErrorToast(context, response['message']);
|
||||||
}else {
|
} else {
|
||||||
ToastHelper.showSuccessToast(context, response['message']);
|
ToastHelper.showSuccessToast(context, response['message']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
isSuccess = false;
|
isSuccess = false;
|
||||||
excelValidationStaus = 1;
|
excelValidationStaus = 1;
|
||||||
|
|
||||||
excelHeader =
|
excelHeader = List<String>.from(response['data']['excel_header']);
|
||||||
List<String>.from(response['data']['excel_header']);
|
|
||||||
|
|
||||||
excelData = (response['data']['excel_data'] as List)
|
excelData = (response['data']['excel_data'] as List)
|
||||||
.map<List<Map<String, dynamic>>>(
|
.map<List<Map<String, dynamic>>>(
|
||||||
@ -148,15 +144,13 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
_showEmptyDataDialog(response['message']);
|
_showEmptyDataDialog(response['message']);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
_showEmptyDataDialog('Something went wrong. Please try again.');
|
_showEmptyDataDialog('Something went wrong. Please try again.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _showEmptyDataDialog(String message) {
|
void _showEmptyDataDialog(String message) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -185,7 +179,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void search(String query) {
|
void search(String query) {
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -246,9 +239,8 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
html.Url.revokeObjectUrl(url);
|
html.Url.revokeObjectUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Future<void> handleExportAction() async {
|
// Future<void> handleExportAction() async {
|
||||||
// print('handleExportAction');
|
// logDebug('handleExportAction');
|
||||||
//
|
//
|
||||||
// final postId = await tokenService.readValue('empHrId');
|
// final postId = await tokenService.readValue('empHrId');
|
||||||
// final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
// final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
||||||
@ -258,12 +250,12 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
// var activityPre = "export_preempdata";
|
// var activityPre = "export_preempdata";
|
||||||
// dynamic response;
|
// dynamic response;
|
||||||
//
|
//
|
||||||
// print('postId - $postId');
|
// logDebug('postId - $postId');
|
||||||
// print('preId - $preId');
|
// logDebug('preId - $preId');
|
||||||
// print('activity - $activity');
|
// logDebug('activity - $activity');
|
||||||
//
|
//
|
||||||
// try {
|
// try {
|
||||||
// print('10');
|
// logDebug('10');
|
||||||
//
|
//
|
||||||
// if (widget.TokenType == 'pre') {
|
// if (widget.TokenType == 'pre') {
|
||||||
// response = await apiService.getPreLogHrActivity(
|
// response = await apiService.getPreLogHrActivity(
|
||||||
@ -274,14 +266,14 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (response['status'] == 'success') {
|
// if (response['status'] == 'success') {
|
||||||
// print('Request success');
|
// logDebug('Request success');
|
||||||
// } else {
|
// } else {
|
||||||
// // ToastHelper.showWarningToast(
|
// // ToastHelper.showWarningToast(
|
||||||
// // context, 'Request failed with status: ${response.statusCode}');
|
// // context, 'Request failed with status: ${response.statusCode}');
|
||||||
// print('Request failed with status: ${response['code']}');
|
// logDebug('Request failed with status: ${response['code']}');
|
||||||
// }
|
// }
|
||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
// print('Exception occurred: $e');
|
// logDebug('Exception occurred: $e');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -295,7 +287,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
return DateFormat('dd-MM-yyyy hh:mm a').format(parsedDate);
|
return DateFormat('dd-MM-yyyy hh:mm a').format(parsedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BaseLayout(
|
return BaseLayout(
|
||||||
@ -420,7 +411,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
excelHeader: excelHeader,
|
excelHeader: excelHeader,
|
||||||
excelData: filteredExcelData, // or excelData
|
excelData: filteredExcelData, // or excelData
|
||||||
);
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFFE26728),
|
backgroundColor: const Color(0xFFE26728),
|
||||||
@ -446,7 +436,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: _buildCDDataTable(context),
|
child: _buildCDDataTable(context),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -499,8 +488,7 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: columnWidth,
|
width: columnWidth,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
header,
|
header,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
@ -535,7 +523,8 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: columnWidth,
|
width: columnWidth,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: hasError
|
child: hasError
|
||||||
? Row(
|
? Row(
|
||||||
children: [
|
children: [
|
||||||
@ -561,103 +550,151 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
builder: (_) {
|
builder: (_) {
|
||||||
final List errors = cell['error'] as List;
|
final List errors =
|
||||||
|
cell['error'] as List;
|
||||||
|
|
||||||
return Dialog(
|
return Dialog(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor:
|
||||||
|
Colors.transparent,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 420,
|
width: 420,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 28),
|
padding: const EdgeInsets
|
||||||
|
.symmetric(
|
||||||
|
horizontal: 24,
|
||||||
|
vertical: 28),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
20),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize:
|
||||||
|
MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
/// ERROR TITLE
|
/// ERROR TITLE
|
||||||
Text(
|
Text(
|
||||||
'Error!',
|
'Error!',
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts
|
||||||
|
.poppins(
|
||||||
fontSize: 32,
|
fontSize: 32,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight:
|
||||||
|
FontWeight.bold,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(
|
||||||
|
height: 16),
|
||||||
|
|
||||||
/// RED ICON
|
/// RED ICON
|
||||||
Container(
|
Container(
|
||||||
width: 64,
|
width: 64,
|
||||||
height: 64,
|
height: 64,
|
||||||
decoration: const BoxDecoration(
|
decoration:
|
||||||
color: Color(0xFFE0002A),
|
const BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
color: Color(
|
||||||
|
0xFFE0002A),
|
||||||
|
shape:
|
||||||
|
BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'!',
|
'!',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors
|
||||||
|
.white,
|
||||||
fontSize: 36,
|
fontSize: 36,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight:
|
||||||
|
FontWeight
|
||||||
|
.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(
|
||||||
|
height: 20),
|
||||||
|
|
||||||
/// ERROR HEADING (optional – first error)
|
/// ERROR HEADING (optional – first error)
|
||||||
Text(
|
Text(
|
||||||
errors.isNotEmpty ? errors.first.toString() : 'Validation Error',
|
errors.isNotEmpty
|
||||||
textAlign: TextAlign.center,
|
? errors.first
|
||||||
style: GoogleFonts.poppins(
|
.toString()
|
||||||
|
: 'Validation Error',
|
||||||
|
textAlign:
|
||||||
|
TextAlign.center,
|
||||||
|
style: GoogleFonts
|
||||||
|
.poppins(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight:
|
||||||
|
FontWeight.w600,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 12),
|
const SizedBox(
|
||||||
|
height: 12),
|
||||||
|
|
||||||
/// ERROR DETAILS
|
/// ERROR DETAILS
|
||||||
...errors.skip(1).map(
|
...errors.skip(1).map(
|
||||||
(e) => Padding(
|
(e) => Padding(
|
||||||
padding: const EdgeInsets.only(top: 6),
|
padding:
|
||||||
|
const EdgeInsets
|
||||||
|
.only(
|
||||||
|
top: 6),
|
||||||
child: Text(
|
child: Text(
|
||||||
e.toString(),
|
e.toString(),
|
||||||
textAlign: TextAlign.center,
|
textAlign:
|
||||||
style: GoogleFonts.poppins(
|
TextAlign
|
||||||
fontSize: 14,
|
.center,
|
||||||
color: const Color(0xFFE09B2D), // orange text
|
style: GoogleFonts
|
||||||
|
.poppins(
|
||||||
|
fontSize:
|
||||||
|
14,
|
||||||
|
color: const Color(
|
||||||
|
0xFFE09B2D), // orange text
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(
|
||||||
|
height: 20),
|
||||||
|
|
||||||
/// OK BUTTON
|
/// OK BUTTON
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 120,
|
width: 120,
|
||||||
height: 30,
|
height: 30,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () =>
|
||||||
style: ElevatedButton.styleFrom(
|
Navigator.pop(
|
||||||
backgroundColor: const Color(0xFFE0002A),
|
context),
|
||||||
shape: RoundedRectangleBorder(
|
style:
|
||||||
borderRadius: BorderRadius.circular(20),
|
ElevatedButton
|
||||||
|
.styleFrom(
|
||||||
|
backgroundColor:
|
||||||
|
const Color(
|
||||||
|
0xFFE0002A),
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius
|
||||||
|
.circular(
|
||||||
|
20),
|
||||||
),
|
),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'OK',
|
'OK',
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts
|
||||||
|
.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight:
|
||||||
color: Colors.white,
|
FontWeight
|
||||||
|
.w600,
|
||||||
|
color: Colors
|
||||||
|
.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -668,7 +705,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -700,10 +736,8 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildPagination(BuildContext context) {
|
Widget _buildPagination(BuildContext context) {
|
||||||
final totalPages =
|
final totalPages = (filteredExcelData.length / _rowsPerPage).ceil();
|
||||||
(filteredExcelData.length / _rowsPerPage).ceil();
|
|
||||||
|
|
||||||
if (totalPages <= 1) {
|
if (totalPages <= 1) {
|
||||||
return const SizedBox.shrink(); // 👈 hide if only one page
|
return const SizedBox.shrink(); // 👈 hide if only one page
|
||||||
@ -730,14 +764,11 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.chevron_left),
|
icon: const Icon(Icons.chevron_left),
|
||||||
onPressed: _currentPage > 1
|
onPressed:
|
||||||
? () => setState(() => _currentPage--)
|
_currentPage > 1 ? () => setState(() => _currentPage--) : null,
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
for (int i = 1; i <= totalPages; i++)
|
for (int i = 1; i <= totalPages; i++)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
@ -759,7 +790,6 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
child: Text(i.toString()),
|
child: Text(i.toString()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.chevron_right),
|
icon: const Icon(Icons.chevron_right),
|
||||||
onPressed: _currentPage < totalPages
|
onPressed: _currentPage < totalPages
|
||||||
@ -769,6 +799,4 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,8 @@ class hrDashboard extends StatefulWidget {
|
|||||||
State<hrDashboard> createState() => _hrDashboardState();
|
State<hrDashboard> createState() => _hrDashboardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStateMixin {
|
class _hrDashboardState extends State<hrDashboard>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
late ApiService apiService;
|
late ApiService apiService;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
String? selectedPolicyId;
|
String? selectedPolicyId;
|
||||||
@ -67,7 +68,9 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
|||||||
? List<int>.from(jsonDecode(postRaw))
|
? List<int>.from(jsonDecode(postRaw))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
if (!(postModules.contains(2) || postModules.contains(3) || postModules.contains(4))) {
|
if (!(postModules.contains(2) ||
|
||||||
|
postModules.contains(3) ||
|
||||||
|
postModules.contains(4))) {
|
||||||
setState(() => hasDashboardError = true);
|
setState(() => hasDashboardError = true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -76,10 +79,12 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
|||||||
empClientBranchId = await tokenService.readValue('empClientBranchId');
|
empClientBranchId = await tokenService.readValue('empClientBranchId');
|
||||||
empHrId = await tokenService.readValue('empHrId');
|
empHrId = await tokenService.readValue('empHrId');
|
||||||
|
|
||||||
await getPostCashDepositDetails(empClientBranchId, empClientId, empHrId, _postPreToken);
|
await getPostCashDepositDetails(
|
||||||
|
empClientBranchId, empClientId, empHrId, _postPreToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getPostCashDepositDetails(branchId, clientId, hrId, token) async {
|
Future<void> getPostCashDepositDetails(
|
||||||
|
branchId, clientId, hrId, token) async {
|
||||||
setState(() => isLoading = true);
|
setState(() => isLoading = true);
|
||||||
try {
|
try {
|
||||||
if (branchId == null || clientId == null) return;
|
if (branchId == null || clientId == null) return;
|
||||||
@ -89,7 +94,8 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
|||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
final list = List<Map<String, dynamic>>.from(response['data']);
|
final list = List<Map<String, dynamic>>.from(response['data']);
|
||||||
final List<Map<String, dynamic>> filteredList = list.where((item) {
|
final List<Map<String, dynamic>> filteredList = list.where((item) {
|
||||||
final int policyTypeId = int.tryParse(item['policy_type_id'].toString()) ?? 0;
|
final int policyTypeId =
|
||||||
|
int.tryParse(item['policy_type_id'].toString()) ?? 0;
|
||||||
return policyTypeId == 2 ||
|
return policyTypeId == 2 ||
|
||||||
policyTypeId == 3 ||
|
policyTypeId == 3 ||
|
||||||
policyTypeId == 4 ||
|
policyTypeId == 4 ||
|
||||||
@ -137,7 +143,6 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
|||||||
isTpaSelected = false;
|
isTpaSelected = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
_registerMetabaseIframe(
|
_registerMetabaseIframe(
|
||||||
token: response['data']['metabaseToken'],
|
token: response['data']['metabaseToken'],
|
||||||
url: response['data']['metabaseUrl'],
|
url: response['data']['metabaseUrl'],
|
||||||
@ -173,9 +178,9 @@ class _hrDashboardState extends State<hrDashboard> with SingleTickerProviderStat
|
|||||||
}, _postPreToken);
|
}, _postPreToken);
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
isTpaSelected = true;
|
isTpaSelected = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
_registerMetabaseIframe(
|
_registerMetabaseIframe(
|
||||||
token: response['data']['metabaseToken'],
|
token: response['data']['metabaseToken'],
|
||||||
@ -184,7 +189,6 @@ setState(() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
setState(() => _metabaseLoaded = true);
|
setState(() => _metabaseLoaded = true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, response['message']);
|
ToastHelper.showErrorToast(context, response['message']);
|
||||||
}
|
}
|
||||||
@ -206,8 +210,7 @@ setState(() {
|
|||||||
|
|
||||||
_dashboardViewType = viewType;
|
_dashboardViewType = viewType;
|
||||||
|
|
||||||
final embedUrl =
|
final embedUrl = "$url/embed/dashboard/$token"
|
||||||
"$url/embed/dashboard/$token"
|
|
||||||
"#theme=light&bordered=true&titled=true"
|
"#theme=light&bordered=true&titled=true"
|
||||||
"&v=${DateTime.now().millisecondsSinceEpoch}"; // 🔥 cache buster
|
"&v=${DateTime.now().millisecondsSinceEpoch}"; // 🔥 cache buster
|
||||||
|
|
||||||
@ -406,7 +409,7 @@ setState(() {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (!isTpaSelected)...[
|
if (!isTpaSelected) ...[
|
||||||
const Text(
|
const Text(
|
||||||
'Select Policy',
|
'Select Policy',
|
||||||
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
|
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
|
||||||
@ -418,17 +421,18 @@ setState(() {
|
|||||||
child: SearchAnchor(
|
child: SearchAnchor(
|
||||||
viewBackgroundColor: Colors.white,
|
viewBackgroundColor: Colors.white,
|
||||||
viewConstraints: const BoxConstraints(maxHeight: 220),
|
viewConstraints: const BoxConstraints(maxHeight: 220),
|
||||||
|
|
||||||
builder: (BuildContext context, SearchController controller) {
|
builder: (BuildContext context, SearchController controller) {
|
||||||
String displayText = "Select Policy";
|
String displayText = "Select Policy";
|
||||||
|
|
||||||
if (selectedPolicyId != null) {
|
if (selectedPolicyId != null) {
|
||||||
final policy = activePoliciesList.firstWhere(
|
final policy = activePoliciesList.firstWhere(
|
||||||
(p) => p['client_policy_id'].toString() == selectedPolicyId,
|
(p) =>
|
||||||
|
p['client_policy_id'].toString() == selectedPolicyId,
|
||||||
orElse: () => {},
|
orElse: () => {},
|
||||||
);
|
);
|
||||||
if (policy.isNotEmpty) {
|
if (policy.isNotEmpty) {
|
||||||
displayText = "${policy['type']} - ${policy['policy_no']}";
|
displayText =
|
||||||
|
"${policy['type']} - ${policy['policy_no']}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,7 +463,6 @@ setState(() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
suggestionsBuilder:
|
suggestionsBuilder:
|
||||||
(BuildContext context, SearchController controller) {
|
(BuildContext context, SearchController controller) {
|
||||||
final input = controller.text.toLowerCase();
|
final input = controller.text.toLowerCase();
|
||||||
@ -475,8 +478,7 @@ setState(() {
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(input))
|
.contains(input))
|
||||||
.map((policy) {
|
.map((policy) {
|
||||||
final label =
|
final label = "${policy['type']} - ${policy['policy_no']}";
|
||||||
"${policy['type']} - ${policy['policy_no']}";
|
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
@ -497,18 +499,13 @@ setState(() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
|
||||||
if (isTpaDashboardEnabled)
|
if (isTpaDashboardEnabled)
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: isTpaSelected
|
backgroundColor:
|
||||||
? Colors.teal
|
isTpaSelected ? Colors.teal : Colors.grey.shade300,
|
||||||
: Colors.grey.shade300,
|
foregroundColor: isTpaSelected ? Colors.white : Colors.black,
|
||||||
foregroundColor:
|
|
||||||
isTpaSelected ? Colors.white : Colors.black,
|
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (selectedPolicyId == null) return;
|
if (selectedPolicyId == null) return;
|
||||||
@ -522,9 +519,7 @@ setState(() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
isTpaSelected
|
isTpaSelected ? "Insights from Nhance" : "Insights from TPA ",
|
||||||
? "Insights from Nhance"
|
|
||||||
: "Insights from TPA ",
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -532,13 +527,13 @@ setState(() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildLoader() => Center(
|
Widget _buildLoader() => Center(
|
||||||
child: Image.asset('assets/nhance-loader.gif', height: 60, width: 60),
|
child: Image.asset('assets/nhance-loader.gif', height: 60, width: 60),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildEmptyState() => const Center(
|
Widget _buildEmptyState() => const Center(
|
||||||
child: Text('No dashboard data available', style: TextStyle(color: Colors.grey)),
|
child: Text('No dashboard data available',
|
||||||
|
style: TextStyle(color: Colors.grey)),
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<bool> _showLogoutDialog() async {
|
Future<bool> _showLogoutDialog() async {
|
||||||
@ -548,8 +543,12 @@ setState(() {
|
|||||||
title: const Text("Confirm Logout"),
|
title: const Text("Confirm Logout"),
|
||||||
content: const Text("Do you want to logout?"),
|
content: const Text("Do you want to logout?"),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: () => Navigator.pop(context, false), child: const Text("Cancel")),
|
TextButton(
|
||||||
TextButton(onPressed: () => Navigator.pop(context, true), child: const Text("Logout")),
|
onPressed: () => Navigator.pop(context, false),
|
||||||
|
child: const Text("Cancel")),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context, true),
|
||||||
|
child: const Text("Logout")),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
) ??
|
) ??
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import '../customAppBar/base_layout.dart';
|
|||||||
import '../customAppBar/customFooter.dart';
|
import '../customAppBar/customFooter.dart';
|
||||||
import '../service/secure_pop_scope.dart';
|
import '../service/secure_pop_scope.dart';
|
||||||
import 'hrDashboard.dart';
|
import 'hrDashboard.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class hrPolicyDetails extends StatefulWidget {
|
class hrPolicyDetails extends StatefulWidget {
|
||||||
final String ClientId;
|
final String ClientId;
|
||||||
@ -68,7 +69,6 @@ class hrPolicyDetails extends StatefulWidget {
|
|||||||
|
|
||||||
class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||||
with TickerProviderStateMixin {
|
with TickerProviderStateMixin {
|
||||||
|
|
||||||
String? localClientId;
|
String? localClientId;
|
||||||
String? localPolicyTypeId;
|
String? localPolicyTypeId;
|
||||||
String? localClientPolicyId;
|
String? localClientPolicyId;
|
||||||
@ -162,9 +162,9 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
// super.initState();
|
// super.initState();
|
||||||
// apiService = ApiService(context); // Initialize ApiService here
|
// apiService = ApiService(context); // Initialize ApiService here
|
||||||
//
|
//
|
||||||
// print("_PreEnrollmentState 1");
|
// logDebug("_PreEnrollmentState 1");
|
||||||
// getCDPoliciesDetails();
|
// getCDPoliciesDetails();
|
||||||
// print('allowed_modules');
|
// logDebug('allowed_modules');
|
||||||
// }
|
// }
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -224,11 +224,10 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
? widget.total_premium
|
? widget.total_premium
|
||||||
: await tokenService.readValue('hr_total_premium');
|
: await tokenService.readValue('hr_total_premium');
|
||||||
|
|
||||||
final savedBulk = await tokenService.readValue(
|
final savedBulk =
|
||||||
'hr_is_ecard_bulk_download_for_employee');
|
await tokenService.readValue('hr_is_ecard_bulk_download_for_employee');
|
||||||
|
|
||||||
localIsEcardBulkDownload =
|
localIsEcardBulkDownload = widget.is_ecard_bulk_download_for_employee != 0
|
||||||
widget.is_ecard_bulk_download_for_employee != 0
|
|
||||||
? widget.is_ecard_bulk_download_for_employee
|
? widget.is_ecard_bulk_download_for_employee
|
||||||
: int.tryParse(savedBulk ?? '0') ?? 0;
|
: int.tryParse(savedBulk ?? '0') ?? 0;
|
||||||
|
|
||||||
@ -268,17 +267,17 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
Future<void> getCDPoliciesDetails_06FEB() async {
|
Future<void> getCDPoliciesDetails_06FEB() async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
|
|
||||||
modulesString = await tokenService.readValue('empAllowed_modules');
|
modulesString = await tokenService.readValue('empAllowed_modules');
|
||||||
// modulesString = "[2,3]";
|
// modulesString = "[2,3]";
|
||||||
|
|
||||||
print("empmodulesString - $modulesString");
|
logDebug("empmodulesString - $modulesString");
|
||||||
|
|
||||||
if (modulesString != null && modulesString!.trim().isNotEmpty) {
|
if (modulesString != null && modulesString!.trim().isNotEmpty) {
|
||||||
final List<int>? moduleList = modulesString
|
final List<int>? moduleList = modulesString
|
||||||
@ -293,10 +292,16 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
}
|
}
|
||||||
|
|
||||||
final response = localTokenType == "post"
|
final response = localTokenType == "post"
|
||||||
? await apiService.getEmployeeAndDependenceToApi(localClientId ?? widget.ClientId,
|
? await apiService.getEmployeeAndDependenceToApi(
|
||||||
localClientPolicyId ?? widget.ClientPoliyId, localClientBranchId ?? widget.clientBranchId, localToken ?? widget.Token)
|
localClientId ?? widget.ClientId,
|
||||||
: await apiService.getEmployeeAndDependenceToApiPre(localClientId ?? widget.ClientId,
|
localClientPolicyId ?? widget.ClientPoliyId,
|
||||||
localClientPolicyId ?? widget.ClientPoliyId, localClientBranchId ?? widget.clientBranchId, localToken ?? widget.Token!);
|
localClientBranchId ?? widget.clientBranchId,
|
||||||
|
localToken ?? widget.Token)
|
||||||
|
: await apiService.getEmployeeAndDependenceToApiPre(
|
||||||
|
localClientId ?? widget.ClientId,
|
||||||
|
localClientPolicyId ?? widget.ClientPoliyId,
|
||||||
|
localClientBranchId ?? widget.clientBranchId,
|
||||||
|
localToken ?? widget.Token!);
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -306,8 +311,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
getCDPolicies = List<Map<String, dynamic>>.from(response['data']);
|
getCDPolicies = List<Map<String, dynamic>>.from(response['data']);
|
||||||
originalData = getCDPolicies;
|
originalData = getCDPolicies;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -316,13 +321,13 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
// print('Request failed with status: ${response['code']}');
|
// logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -331,15 +336,15 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getCDPoliciesDetails() async {
|
Future<void> getCDPoliciesDetails() async {
|
||||||
print('getCDPoliciesDetails started');
|
logDebug('getCDPoliciesDetails started');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('Fetching modules...');
|
logDebug('Fetching modules...');
|
||||||
modulesString = await tokenService.readValue('empAllowed_modules');
|
modulesString = await tokenService.readValue('empAllowed_modules');
|
||||||
print("empmodulesString - $modulesString");
|
logDebug("empmodulesString - $modulesString");
|
||||||
|
|
||||||
if (modulesString != null && modulesString!.trim().isNotEmpty) {
|
if (modulesString != null && modulesString!.trim().isNotEmpty) {
|
||||||
final List<int>? moduleList = modulesString
|
final List<int>? moduleList = modulesString
|
||||||
@ -353,17 +358,23 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
hasModule = moduleList?.contains(storeModuleId) ?? false;
|
hasModule = moduleList?.contains(storeModuleId) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
print('Calling API with TokenType: ${localTokenType}');
|
logDebug('Calling API with TokenType: ${localTokenType}');
|
||||||
print(
|
logDebug(
|
||||||
'ClientId: ${localClientId}, ClientPoliyId: ${localClientPolicyId}');
|
'ClientId: ${localClientId}, ClientPoliyId: ${localClientPolicyId}');
|
||||||
|
|
||||||
final response = localTokenType == "post"
|
final response = localTokenType == "post"
|
||||||
? await apiService.getEmployeeAndDependenceToApi(localClientId ?? widget.ClientId,
|
? await apiService.getEmployeeAndDependenceToApi(
|
||||||
localClientPolicyId ?? widget.ClientPoliyId, localClientBranchId ?? widget.clientBranchId, localToken ?? widget.Token)
|
localClientId ?? widget.ClientId,
|
||||||
: await apiService.getEmployeeAndDependenceToApiPre(localClientId ?? widget.ClientId,
|
localClientPolicyId ?? widget.ClientPoliyId,
|
||||||
localClientPolicyId ?? widget.ClientPoliyId, localClientBranchId ?? widget.clientBranchId, localToken ?? widget.Token!);
|
localClientBranchId ?? widget.clientBranchId,
|
||||||
|
localToken ?? widget.Token)
|
||||||
|
: await apiService.getEmployeeAndDependenceToApiPre(
|
||||||
|
localClientId ?? widget.ClientId,
|
||||||
|
localClientPolicyId ?? widget.ClientPoliyId,
|
||||||
|
localClientBranchId ?? widget.clientBranchId,
|
||||||
|
localToken ?? widget.Token!);
|
||||||
|
|
||||||
print('API Response: ${response.toString()}');
|
logDebug('API Response: ${response.toString()}');
|
||||||
|
|
||||||
if (response != null && response['status'] == 'success') {
|
if (response != null && response['status'] == 'success') {
|
||||||
final data = response['data'];
|
final data = response['data'];
|
||||||
@ -378,11 +389,10 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
} else {
|
} else {
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
final errorCode = response?['code'] ?? 'Unknown';
|
final errorCode = response?['code'] ?? 'Unknown';
|
||||||
// final errorMessage = response?['message'] ?? 'Request failed';
|
// final errorMessage = response?['message'] ?? 'Request failed';
|
||||||
// print('❌ Request failed - Code: $errorCode, Message: $errorMessage');
|
// logDebug('❌ Request failed - Code: $errorCode, Message: $errorMessage');
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -393,8 +403,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
print('❌ Exception occurred: $e');
|
logDebug('❌ Exception occurred: $e');
|
||||||
print('Stack trace: $stackTrace');
|
logDebug('Stack trace: $stackTrace');
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -415,29 +425,28 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
'client_policy_id': clientPolicyId,
|
'client_policy_id': clientPolicyId,
|
||||||
'policy_no': policyNo
|
'policy_no': policyNo
|
||||||
};
|
};
|
||||||
final response =
|
final response = await apiService.getEcardRequest(eCarDParams, localToken!);
|
||||||
await apiService.getEcardRequest(eCarDParams, localToken!);
|
logDebug('check 1');
|
||||||
print('check 1');
|
|
||||||
final ecardDownloadUrl = response['data']['eCardDownload'];
|
final ecardDownloadUrl = response['data']['eCardDownload'];
|
||||||
final message = response['data']['message'];
|
final message = response['data']['message'];
|
||||||
if (ecardDownloadUrl != null) {
|
if (ecardDownloadUrl != null) {
|
||||||
print('✅ Link: $ecardDownloadUrl');
|
logDebug('✅ Link: $ecardDownloadUrl');
|
||||||
await _launchURL(ecardDownloadUrl); // Only launch if status is success
|
await _launchURL(ecardDownloadUrl); // Only launch if status is success
|
||||||
// ToastHelper.showSuccessToast(context, message);
|
// ToastHelper.showSuccessToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
print('❌ Error: $message');
|
logDebug('❌ Error: $message');
|
||||||
ToastHelper.showErrorToast(context, message);
|
ToastHelper.showErrorToast(context, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _launchURL(String url) async {
|
Future<void> _launchURL(String url) async {
|
||||||
final Uri uri = Uri.parse(url); // Parse the URL properly
|
final Uri uri = Uri.parse(url); // Parse the URL properly
|
||||||
print('_launchURL $uri');
|
logDebug('_launchURL $uri');
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
print('If $uri');
|
logDebug('If $uri');
|
||||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
} else {
|
} else {
|
||||||
print('else $uri');
|
logDebug('else $uri');
|
||||||
throw 'Could not launch $url';
|
throw 'Could not launch $url';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,9 +461,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
filteredData = originalData.where((row) {
|
filteredData = originalData.where((row) {
|
||||||
|
final status = row['status']?.toString().toLowerCase().trim() ?? '';
|
||||||
final status =
|
|
||||||
row['status']?.toString().toLowerCase().trim() ?? '';
|
|
||||||
|
|
||||||
bool statusMatch;
|
bool statusMatch;
|
||||||
|
|
||||||
@ -466,35 +473,30 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
statusMatch = status.contains(lowerQuery);
|
statusMatch = status.contains(lowerQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
return row['name']
|
return row['name']?.toString().toLowerCase().contains(lowerQuery) ==
|
||||||
?.toString()
|
true ||
|
||||||
.toLowerCase()
|
row['uhid']?.toString().toLowerCase().contains(lowerQuery) ==
|
||||||
.contains(lowerQuery) == true ||
|
true ||
|
||||||
row['uhid']
|
|
||||||
?.toString()
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(lowerQuery) == true ||
|
|
||||||
row['relationship']
|
row['relationship']
|
||||||
?.toString()
|
?.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(lowerQuery) == true ||
|
.contains(lowerQuery) ==
|
||||||
|
true ||
|
||||||
row['formatted_dob']
|
row['formatted_dob']
|
||||||
?.toString()
|
?.toString()
|
||||||
.replaceAll("/", "-")
|
.replaceAll("/", "-")
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(lowerQuery) == true ||
|
.contains(lowerQuery) ==
|
||||||
row['gender']
|
true ||
|
||||||
?.toString()
|
row['gender']?.toString().toLowerCase().contains(lowerQuery) ==
|
||||||
.toLowerCase()
|
true ||
|
||||||
.contains(lowerQuery) == true ||
|
row['mobile']?.toString().toLowerCase().contains(lowerQuery) ==
|
||||||
row['mobile']
|
true ||
|
||||||
?.toString()
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(lowerQuery) == true ||
|
|
||||||
row['email_corporate']
|
row['email_corporate']
|
||||||
?.toString()
|
?.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(lowerQuery) == true ||
|
.contains(lowerQuery) ==
|
||||||
|
true ||
|
||||||
statusMatch;
|
statusMatch;
|
||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
@ -547,7 +549,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleExportAction() async {
|
Future<void> handleExportAction() async {
|
||||||
print('handleExportAction');
|
logDebug('handleExportAction');
|
||||||
|
|
||||||
final postId = await tokenService.readValue('empHrId');
|
final postId = await tokenService.readValue('empHrId');
|
||||||
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
||||||
@ -557,12 +559,12 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
var activityPre = "export_preempdata";
|
var activityPre = "export_preempdata";
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
print('postId - $postId');
|
logDebug('postId - $postId');
|
||||||
print('preId - $preId');
|
logDebug('preId - $preId');
|
||||||
print('activity - $activity');
|
logDebug('activity - $activity');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
|
|
||||||
if (localTokenType == 'pre') {
|
if (localTokenType == 'pre') {
|
||||||
response = await apiService.getPreLogHrActivity(
|
response = await apiService.getPreLogHrActivity(
|
||||||
@ -573,14 +575,14 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,19 +594,19 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
Future<void> getEcardBulkDownload() async {
|
Future<void> getEcardBulkDownload() async {
|
||||||
try {
|
try {
|
||||||
final emp_policy_ids = selectedEmployeeIds.toList();
|
final emp_policy_ids = selectedEmployeeIds.toList();
|
||||||
print('10 $emp_policy_ids');
|
logDebug('10 $emp_policy_ids');
|
||||||
empHrId = await tokenService.readValue('empHrId');
|
empHrId = await tokenService.readValue('empHrId');
|
||||||
final response = await apiService.getEcardBulkDownloadApi(
|
final response = await apiService.getEcardBulkDownloadApi(
|
||||||
'', empHrId, emp_policy_ids, localToken!);
|
'', empHrId, emp_policy_ids, localToken!);
|
||||||
if (response['status'] == true) {
|
if (response['status'] == true) {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
_showBulkDownloadSuccessPopup(response['message']);
|
_showBulkDownloadSuccessPopup(response['message']);
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, response['message']);
|
ToastHelper.showErrorToast(context, response['message']);
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,8 +768,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
if (localIsEcardBulkDownload ==
|
if (localIsEcardBulkDownload == 1) ...[
|
||||||
1) ...[
|
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 40,
|
width: 40,
|
||||||
@ -800,23 +801,44 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
height: 37,
|
height: 37,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
await tokenService.writeValue('upload_ClientId',
|
||||||
await tokenService.writeValue('upload_ClientId', widget.ClientId.toString());
|
widget.ClientId.toString());
|
||||||
await tokenService.writeValue('upload_policyTypeId', widget.policyTypeId.toString());
|
await tokenService.writeValue(
|
||||||
await tokenService.writeValue('upload_ClientPoliyId', widget.ClientPoliyId.toString());
|
'upload_policyTypeId',
|
||||||
await tokenService.writeValue('upload_clientBranchId', widget.clientBranchId.toString());
|
widget.policyTypeId.toString());
|
||||||
await tokenService.writeValue('upload_Token', widget.Token.toString());
|
await tokenService.writeValue(
|
||||||
await tokenService.writeValue('upload_TokenType', widget.TokenType.toString());
|
'upload_ClientPoliyId',
|
||||||
await tokenService.writeValue('upload_cardType', widget.cardType.toString());
|
widget.ClientPoliyId.toString());
|
||||||
await tokenService.writeValue('upload_cardPolicyNo', widget.cardPolicyNo.toString());
|
await tokenService.writeValue(
|
||||||
await tokenService.writeValue('upload_cardInsurer_name', widget.cardInsurer_name.toString());
|
'upload_clientBranchId',
|
||||||
await tokenService.writeValue('upload_cardPolicy_name', widget.cardPolicy_name.toString());
|
widget.clientBranchId.toString());
|
||||||
await tokenService.writeValue('upload_cardPolicy_ExpDate', widget.cardPolicy_ExpDate.toString());
|
await tokenService.writeValue(
|
||||||
await tokenService.writeValue('upload_total_premium', widget.total_premium.toString());
|
'upload_Token', widget.Token.toString());
|
||||||
|
await tokenService.writeValue('upload_TokenType',
|
||||||
|
widget.TokenType.toString());
|
||||||
|
await tokenService.writeValue('upload_cardType',
|
||||||
|
widget.cardType.toString());
|
||||||
|
await tokenService.writeValue(
|
||||||
|
'upload_cardPolicyNo',
|
||||||
|
widget.cardPolicyNo.toString());
|
||||||
|
await tokenService.writeValue(
|
||||||
|
'upload_cardInsurer_name',
|
||||||
|
widget.cardInsurer_name.toString());
|
||||||
|
await tokenService.writeValue(
|
||||||
|
'upload_cardPolicy_name',
|
||||||
|
widget.cardPolicy_name.toString());
|
||||||
|
await tokenService.writeValue(
|
||||||
|
'upload_cardPolicy_ExpDate',
|
||||||
|
widget.cardPolicy_ExpDate.toString());
|
||||||
|
await tokenService.writeValue(
|
||||||
|
'upload_total_premium',
|
||||||
|
widget.total_premium.toString());
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
settings: localTokenType != "post" ? RouteSettings(name: 'preFileUpload') : RouteSettings(name: 'postFileUpload'),
|
settings: localTokenType != "post"
|
||||||
|
? RouteSettings(name: 'preFileUpload')
|
||||||
|
: RouteSettings(name: 'postFileUpload'),
|
||||||
builder: (context) => localTokenType !=
|
builder: (context) => localTokenType !=
|
||||||
"post"
|
"post"
|
||||||
? preFileUpload(
|
? preFileUpload(
|
||||||
@ -988,10 +1010,10 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
)
|
)
|
||||||
: Column(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
_buildCDDataTable(context), // ← DO NOT wrap again in Expanded
|
_buildCDDataTable(
|
||||||
|
context), // ← DO NOT wrap again in Expanded
|
||||||
],
|
],
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 48),
|
const SizedBox(height: 48),
|
||||||
@ -1367,19 +1389,17 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
return const Center(child: Text('No data available'));
|
return const Center(child: Text('No data available'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Expanded( // ✅ VERY IMPORTANT
|
return Expanded(
|
||||||
|
// ✅ VERY IMPORTANT
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
|
|
||||||
/// 🔒 Sticky Header
|
/// 🔒 Sticky Header
|
||||||
SliverPersistentHeader(
|
SliverPersistentHeader(
|
||||||
pinned: true,
|
pinned: true,
|
||||||
delegate: _CDHeaderDelegate(
|
delegate: _CDHeaderDelegate(
|
||||||
showUHID: localPolicyTypeId != '6' &&
|
showUHID: localPolicyTypeId != '6' && localPolicyTypeId != '7',
|
||||||
localPolicyTypeId != '7',
|
|
||||||
showAction:
|
showAction:
|
||||||
localTokenType != "pre" &&
|
localTokenType != "pre" && (hasAnyEcardLink || hasModule),
|
||||||
(hasAnyEcardLink || hasModule),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -1414,7 +1434,6 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
/// NAME
|
/// NAME
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
@ -1428,8 +1447,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// UHID
|
/// UHID
|
||||||
if (localPolicyTypeId != '6' &&
|
if (localPolicyTypeId != '6' && localPolicyTypeId != '7')
|
||||||
localPolicyTypeId != '7')
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text(item['uhid'] ?? '-', style: _dataBold),
|
child: Text(item['uhid'] ?? '-', style: _dataBold),
|
||||||
@ -1442,8 +1460,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(item['formatted_dob']?.replaceAll("/", "-") ?? '-',
|
||||||
item['formatted_dob']?.replaceAll("/", "-") ?? '-',
|
|
||||||
style: _dataBold),
|
style: _dataBold),
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -1466,8 +1483,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: getStatusColor(item['status'] ?? ''),
|
color: getStatusColor(item['status'] ?? ''),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
@ -1482,8 +1498,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
|
|
||||||
/// ACTION
|
/// ACTION
|
||||||
|
|
||||||
if (localTokenType != "pre" &&
|
if (localTokenType != "pre" && (hasAnyEcardLink || hasModule))
|
||||||
(hasAnyEcardLink || hasModule))
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
@ -1503,7 +1518,6 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
/// --- eCard Button (Fixed Space) ---
|
/// --- eCard Button (Fixed Space) ---
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 40,
|
width: 40,
|
||||||
@ -1603,14 +1617,14 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
// if (localTokenType == "post" && hasModule) {
|
// if (localTokenType == "post" && hasModule) {
|
||||||
// print("paginatTtt - $_paginatedData");
|
// logDebug("paginatTtt - $_paginatedData");
|
||||||
//
|
//
|
||||||
// print("📥 Any e-card link present: $hasAnyEcardLink");
|
// logDebug("📥 Any e-card link present: $hasAnyEcardLink");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// print('widgetpolicyTypeId');
|
// logDebug('widgetpolicyTypeId');
|
||||||
// print(localPolicyTypeId);
|
// logDebug(localPolicyTypeId);
|
||||||
//
|
//
|
||||||
// if (filteredData.isEmpty) {
|
// if (filteredData.isEmpty) {
|
||||||
// return SizedBox(
|
// return SizedBox(
|
||||||
@ -2062,7 +2076,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
// // GestureDetector(
|
// // GestureDetector(
|
||||||
// // onTap: () {
|
// // onTap: () {
|
||||||
// // setState(() {
|
// // setState(() {
|
||||||
// // print(
|
// // logDebug(
|
||||||
// // "policytabdata - ${item['emp_code']!}");
|
// // "policytabdata - ${item['emp_code']!}");
|
||||||
// // Navigator.push(
|
// // Navigator.push(
|
||||||
// // context,
|
// // context,
|
||||||
@ -2189,7 +2203,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
Widget _buildPagination(BuildContext context) {
|
Widget _buildPagination(BuildContext context) {
|
||||||
// 1. Calculate the range of entries being shown
|
// 1. Calculate the range of entries being shown
|
||||||
final totalItems = filteredData.length;
|
final totalItems = filteredData.length;
|
||||||
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
final int startEntry =
|
||||||
|
totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
||||||
int endEntry = _currentPage * _rowsPerPage;
|
int endEntry = _currentPage * _rowsPerPage;
|
||||||
if (endEntry > totalItems) endEntry = totalItems;
|
if (endEntry > totalItems) endEntry = totalItems;
|
||||||
|
|
||||||
@ -2220,7 +2235,6 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
_currentPage + 1,
|
_currentPage + 1,
|
||||||
_currentPage + 2,
|
_currentPage + 2,
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> visiblePages = getVisiblePages();
|
List<int> visiblePages = getVisiblePages();
|
||||||
@ -2229,7 +2243,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
// Match this horizontal padding (16) to your Table Header padding for perfect alignment
|
// Match this horizontal padding (16) to your Table Header padding for perfect alignment
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Pushes text to left, buttons to right
|
mainAxisAlignment: MainAxisAlignment
|
||||||
|
.spaceBetween, // Pushes text to left, buttons to right
|
||||||
children: [
|
children: [
|
||||||
// --- LEFT SIDE: Showing Text ---
|
// --- LEFT SIDE: Showing Text ---
|
||||||
Text(
|
Text(
|
||||||
@ -2247,7 +2262,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
// Dropdown for rows per page
|
// Dropdown for rows per page
|
||||||
DropdownButton<int>(
|
DropdownButton<int>(
|
||||||
value: _rowsPerPage,
|
value: _rowsPerPage,
|
||||||
focusColor: Colors.transparent, // Fix: Removes the grey/blue highlight on change
|
focusColor: Colors
|
||||||
|
.transparent, // Fix: Removes the grey/blue highlight on change
|
||||||
items: [5, 10, 15, 20, 50].map((int value) {
|
items: [5, 10, 15, 20, 50].map((int value) {
|
||||||
return DropdownMenuItem<int>(
|
return DropdownMenuItem<int>(
|
||||||
value: value,
|
value: value,
|
||||||
@ -2357,7 +2373,6 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _CDHeaderDelegate extends SliverPersistentHeaderDelegate {
|
class _CDHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||||
final bool showUHID;
|
final bool showUHID;
|
||||||
final bool showAction;
|
final bool showAction;
|
||||||
@ -2396,8 +2411,7 @@ class _CDHeaderDelegate extends SliverPersistentHeaderDelegate {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _headerCell(String text, int flex,
|
Widget _headerCell(String text, int flex, {bool center = false}) {
|
||||||
{bool center = false}) {
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
flex: flex,
|
flex: flex,
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import '../customAppBar/base_layout.dart';
|
|||||||
import '../customAppBar/toastHelper.dart';
|
import '../customAppBar/toastHelper.dart';
|
||||||
import '../service/secure_pop_scope.dart';
|
import '../service/secure_pop_scope.dart';
|
||||||
import 'hrPolicyDetails.dart';
|
import 'hrPolicyDetails.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class policies extends StatefulWidget {
|
class policies extends StatefulWidget {
|
||||||
const policies({Key? key}) : super(key: key);
|
const policies({Key? key}) : super(key: key);
|
||||||
@ -30,7 +31,6 @@ class policies extends StatefulWidget {
|
|||||||
State<policies> createState() => _policiesState();
|
State<policies> createState() => _policiesState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _policiesState extends State<policies>
|
class _policiesState extends State<policies>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
late ApiService apiService;
|
late ApiService apiService;
|
||||||
@ -61,7 +61,6 @@ class _policiesState extends State<policies>
|
|||||||
List<int> postModules = [];
|
List<int> postModules = [];
|
||||||
List<int> enrollmentModules = [];
|
List<int> enrollmentModules = [];
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -93,14 +92,14 @@ class _policiesState extends State<policies>
|
|||||||
|
|
||||||
// Get the current token
|
// Get the current token
|
||||||
final token = await tokenService.getCurrentToken();
|
final token = await tokenService.getCurrentToken();
|
||||||
print('token - $token');
|
logDebug('token - $token');
|
||||||
|
|
||||||
print('token check in');
|
logDebug('token check in');
|
||||||
if ((token != null && token!.isNotEmpty)) {
|
if ((token != null && token!.isNotEmpty)) {
|
||||||
print('token check done');
|
logDebug('token check done');
|
||||||
_loadToken();
|
_loadToken();
|
||||||
} else {
|
} else {
|
||||||
print('token check reject');
|
logDebug('token check reject');
|
||||||
ToastHelper.showErrorToast(context, 'Session Out');
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
Navigator.pushReplacementNamed(context, 'hrLogin');
|
Navigator.pushReplacementNamed(context, 'hrLogin');
|
||||||
}
|
}
|
||||||
@ -119,11 +118,11 @@ class _policiesState extends State<policies>
|
|||||||
// ? List<int>.from(jsonDecode(postRaw))
|
// ? List<int>.from(jsonDecode(postRaw))
|
||||||
// : [];
|
// : [];
|
||||||
//
|
//
|
||||||
// print('enrollmentModules $enrollmentModules');
|
// logDebug('enrollmentModules $enrollmentModules');
|
||||||
// print('postModules $postModules');
|
// logDebug('postModules $postModules');
|
||||||
//
|
//
|
||||||
// _postPreToken = await tokenService.getCurrentToken();
|
// _postPreToken = await tokenService.getCurrentToken();
|
||||||
// print(_postPreToken);
|
// logDebug(_postPreToken);
|
||||||
//
|
//
|
||||||
// if (enrollmentModules.contains(1)) {
|
// if (enrollmentModules.contains(1)) {
|
||||||
// enrollmentClient_id = await tokenService.readValue('enrollmentClient_id');
|
// enrollmentClient_id = await tokenService.readValue('enrollmentClient_id');
|
||||||
@ -153,8 +152,7 @@ class _policiesState extends State<policies>
|
|||||||
try {
|
try {
|
||||||
final enrollmentRaw =
|
final enrollmentRaw =
|
||||||
await tokenService.readValue('enrollmentAllowed_modules');
|
await tokenService.readValue('enrollmentAllowed_modules');
|
||||||
final postRaw =
|
final postRaw = await tokenService.readValue('empAllowed_modules');
|
||||||
await tokenService.readValue('empAllowed_modules');
|
|
||||||
|
|
||||||
enrollmentModules = enrollmentRaw != null && enrollmentRaw.isNotEmpty
|
enrollmentModules = enrollmentRaw != null && enrollmentRaw.isNotEmpty
|
||||||
? List<int>.from(jsonDecode(enrollmentRaw))
|
? List<int>.from(jsonDecode(enrollmentRaw))
|
||||||
@ -174,8 +172,7 @@ class _policiesState extends State<policies>
|
|||||||
await tokenService.readValue('enrollmentClient_id');
|
await tokenService.readValue('enrollmentClient_id');
|
||||||
enrollmentEmpClientBranchId =
|
enrollmentEmpClientBranchId =
|
||||||
await tokenService.readValue('enrollmentEmpClientBranchId');
|
await tokenService.readValue('enrollmentEmpClientBranchId');
|
||||||
enrollmentHrId =
|
enrollmentHrId = await tokenService.readValue('enrollmentHrId');
|
||||||
await tokenService.readValue('enrollmentHrId');
|
|
||||||
|
|
||||||
apiCalls.add(
|
apiCalls.add(
|
||||||
getPreCashDepositDetails(
|
getPreCashDepositDetails(
|
||||||
@ -189,8 +186,7 @@ class _policiesState extends State<policies>
|
|||||||
|
|
||||||
if (postModules.contains(2)) {
|
if (postModules.contains(2)) {
|
||||||
empClientId = await tokenService.readValue('empClientId');
|
empClientId = await tokenService.readValue('empClientId');
|
||||||
empClientBranchId =
|
empClientBranchId = await tokenService.readValue('empClientBranchId');
|
||||||
await tokenService.readValue('empClientBranchId');
|
|
||||||
empHrId = await tokenService.readValue('empHrId');
|
empHrId = await tokenService.readValue('empHrId');
|
||||||
|
|
||||||
apiCalls.add(
|
apiCalls.add(
|
||||||
@ -206,7 +202,7 @@ class _policiesState extends State<policies>
|
|||||||
/// 🔥 WAIT FOR ALL APIs
|
/// 🔥 WAIT FOR ALL APIs
|
||||||
await Future.wait(apiCalls);
|
await Future.wait(apiCalls);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error in _loadToken: $e");
|
logDebug("Error in _loadToken: $e");
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -218,11 +214,11 @@ class _policiesState extends State<policies>
|
|||||||
|
|
||||||
Future<void> getPreCashDepositDetails(enrollmentEmpClientBranchId,
|
Future<void> getPreCashDepositDetails(enrollmentEmpClientBranchId,
|
||||||
enrollmentClient_id, enrollmentHrId, _postPreToken) async {
|
enrollmentClient_id, enrollmentHrId, _postPreToken) async {
|
||||||
print('IN');
|
logDebug('IN');
|
||||||
print("clintBranchId -$enrollmentEmpClientBranchId");
|
logDebug("clintBranchId -$enrollmentEmpClientBranchId");
|
||||||
print("clintID -$enrollmentClient_id");
|
logDebug("clintID -$enrollmentClient_id");
|
||||||
print("hr_id -$enrollmentHrId");
|
logDebug("hr_id -$enrollmentHrId");
|
||||||
print("token -$_postPreToken");
|
logDebug("token -$_postPreToken");
|
||||||
|
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// _isLoading = true;
|
// _isLoading = true;
|
||||||
@ -239,33 +235,33 @@ class _policiesState extends State<policies>
|
|||||||
|
|
||||||
// final response = await apiService.getCashDepositDetailsToApi(
|
// final response = await apiService.getCashDepositDetailsToApi(
|
||||||
// clintID!, clintBranchId!, hr_id, token);
|
// clintID!, clintBranchId!, hr_id, token);
|
||||||
print('IN1');
|
logDebug('IN1');
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
print('response');
|
logDebug('response');
|
||||||
print(response['data']);
|
logDebug(response['data']);
|
||||||
getPreCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
getPreCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
||||||
print('getPreCardArrays');
|
logDebug('getPreCardArrays');
|
||||||
print(getPreCardArrays);
|
logDebug(getPreCardArrays);
|
||||||
openForEnrollmentList = getPreCardArrays;
|
openForEnrollmentList = getPreCardArrays;
|
||||||
});
|
});
|
||||||
|
|
||||||
print('IN2');
|
logDebug('IN2');
|
||||||
} else {
|
} else {
|
||||||
print('API request failed with status');
|
logDebug('API request failed with status');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getPostCashDepositDetails(
|
Future<void> getPostCashDepositDetails(
|
||||||
empClientBranchId, empClientId, empHrId, _postPreToken) async {
|
empClientBranchId, empClientId, empHrId, _postPreToken) async {
|
||||||
print('IN');
|
logDebug('IN');
|
||||||
print("clintBranchId -$empClientBranchId");
|
logDebug("clintBranchId -$empClientBranchId");
|
||||||
print("clintID -$empClientId");
|
logDebug("clintID -$empClientId");
|
||||||
print("hr_id -$empHrId");
|
logDebug("hr_id -$empHrId");
|
||||||
print("token -$_postPreToken");
|
logDebug("token -$_postPreToken");
|
||||||
|
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// _isLoading = true;
|
// _isLoading = true;
|
||||||
@ -279,28 +275,28 @@ class _policiesState extends State<policies>
|
|||||||
|
|
||||||
// final response = await apiService.getCashDepositDetailsToApi(
|
// final response = await apiService.getCashDepositDetailsToApi(
|
||||||
// clintID!, clintBranchId!, hr_id, token);
|
// clintID!, clintBranchId!, hr_id, token);
|
||||||
print('IN1');
|
logDebug('IN1');
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
print('response');
|
logDebug('response');
|
||||||
print(response['data']);
|
logDebug(response['data']);
|
||||||
getPostCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
getPostCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
||||||
print('getPostCardArrays');
|
logDebug('getPostCardArrays');
|
||||||
print(getPostCardArrays);
|
logDebug(getPostCardArrays);
|
||||||
|
|
||||||
activePoliciesList = getPostCardArrays;
|
activePoliciesList = getPostCardArrays;
|
||||||
});
|
});
|
||||||
|
|
||||||
print('IN2');
|
logDebug('IN2');
|
||||||
} else {
|
} else {
|
||||||
print('API request failed with status');
|
logDebug('API request failed with status');
|
||||||
setState(() {
|
setState(() {
|
||||||
activePoliciesList = [];
|
activePoliciesList = [];
|
||||||
});
|
});
|
||||||
print('API request failed with status');
|
logDebug('API request failed with status');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,22 +322,21 @@ class _policiesState extends State<policies>
|
|||||||
false;
|
false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> getEcardBulkDownload(clientPolicyId) async {
|
Future<void> getEcardBulkDownload(clientPolicyId) async {
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
empHrId = await tokenService.readValue('empHrId');
|
empHrId = await tokenService.readValue('empHrId');
|
||||||
final response = await apiService.getEcardBulkDownloadApi(clientPolicyId,empHrId,'',_postPreToken!);
|
final response = await apiService.getEcardBulkDownloadApi(
|
||||||
|
clientPolicyId, empHrId, '', _postPreToken!);
|
||||||
if (response['status'] == true) {
|
if (response['status'] == true) {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
_showBulkDownloadSuccessPopup(response['message']);
|
_showBulkDownloadSuccessPopup(response['message']);
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, response['message']);
|
ToastHelper.showErrorToast(context, response['message']);
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,9 +377,10 @@ class _policiesState extends State<policies>
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Text('OK',style: GoogleFonts.poppins(
|
child: Text(
|
||||||
color: Colors.white
|
'OK',
|
||||||
),),
|
style: GoogleFonts.poppins(color: Colors.white),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -394,7 +390,6 @@ class _policiesState extends State<policies>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BaseLayout(
|
return BaseLayout(
|
||||||
@ -411,7 +406,8 @@ class _policiesState extends State<policies>
|
|||||||
required List<Map<String, dynamic>> openEnrollment,
|
required List<Map<String, dynamic>> openEnrollment,
|
||||||
required List<Map<String, dynamic>> activePolicies,
|
required List<Map<String, dynamic>> activePolicies,
|
||||||
}) {
|
}) {
|
||||||
return isLoading ? Container(
|
return isLoading
|
||||||
|
? Container(
|
||||||
color: Colors.transparent, // Semi-transparent background
|
color: Colors.transparent, // Semi-transparent background
|
||||||
child: Center(
|
child: Center(
|
||||||
child: // Your GIF loader widget
|
child: // Your GIF loader widget
|
||||||
@ -420,7 +416,8 @@ class _policiesState extends State<policies>
|
|||||||
width: 60,
|
width: 60,
|
||||||
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
||||||
),
|
),
|
||||||
) : Scaffold(
|
)
|
||||||
|
: Scaffold(
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
|
|
||||||
// padding: const EdgeInsets.all(20),
|
// padding: const EdgeInsets.all(20),
|
||||||
@ -456,7 +453,7 @@ class _policiesState extends State<policies>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if(enrollmentModules.contains(1))...[
|
if (enrollmentModules.contains(1)) ...[
|
||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Container(
|
Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@ -474,7 +471,8 @@ class _policiesState extends State<policies>
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Open for Enrollment',
|
'Open for Enrollment',
|
||||||
style: GoogleFonts.poppins(fontSize: 14, fontWeight: FontWeight.w600),
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 14, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
SizedBox(height: 14),
|
SizedBox(height: 14),
|
||||||
|
|
||||||
@ -485,14 +483,11 @@ class _policiesState extends State<policies>
|
|||||||
policies: openEnrollment,
|
policies: openEnrollment,
|
||||||
isEnrollment: true,
|
isEnrollment: true,
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)),
|
||||||
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
if(postModules.contains(2))...[
|
if (postModules.contains(2)) ...[
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
Container(
|
Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@ -513,7 +508,8 @@ class _policiesState extends State<policies>
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Active Policies',
|
'Active Policies',
|
||||||
style: GoogleFonts.poppins(fontSize: 14, fontWeight: FontWeight.w600),
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 14, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
_ActiveExpiredToggle(
|
_ActiveExpiredToggle(
|
||||||
selectedIndex: selectedIndex,
|
selectedIndex: selectedIndex,
|
||||||
@ -536,28 +532,29 @@ class _policiesState extends State<policies>
|
|||||||
|
|
||||||
/// ✅ SCROLLABLE GRID
|
/// ✅ SCROLLABLE GRID
|
||||||
activePolicies.isEmpty
|
activePolicies.isEmpty
|
||||||
? stausVal == 0 ? _EmptyBox('You don’t have any expired policies at the moment.') : _EmptyBox('No active policies found')
|
? stausVal == 0
|
||||||
|
? _EmptyBox(
|
||||||
|
'You don’t have any expired policies at the moment.')
|
||||||
|
: _EmptyBox('No active policies found')
|
||||||
: _PolicyGrid(
|
: _PolicyGrid(
|
||||||
policies: activePolicies,
|
policies: activePolicies,
|
||||||
isEnrollment: false,
|
isEnrollment: false,
|
||||||
onBulkDownload: getEcardBulkDownload,
|
onBulkDownload: getEcardBulkDownload,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
child: Text(
|
child: Text(
|
||||||
'* Premium may vary subject to claims',
|
'* Premium may vary subject to claims',
|
||||||
style: GoogleFonts.poppins(fontSize: 10, color: Colors.red),
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 10, color: Colors.red),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
@ -603,8 +600,6 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
// return ResponsiveGridConfig(4, isEnrollment ? 3.1 : 2.4);
|
// return ResponsiveGridConfig(4, isEnrollment ? 3.1 : 2.4);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (width >= 1400) {
|
if (width >= 1400) {
|
||||||
return const ResponsiveGridConfig(4, 2.6); // Big screen
|
return const ResponsiveGridConfig(4, 2.6); // Big screen
|
||||||
} else if (width >= 1000) {
|
} else if (width >= 1000) {
|
||||||
@ -616,7 +611,6 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -633,9 +627,7 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
cardHeight = 170;
|
cardHeight = 170;
|
||||||
}
|
}
|
||||||
|
|
||||||
final double totalHeight =
|
final double totalHeight = rowCount * cardHeight + ((rowCount - 1) * 16);
|
||||||
rowCount * cardHeight + ((rowCount - 1) * 16);
|
|
||||||
|
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: totalHeight,
|
height: totalHeight,
|
||||||
@ -674,10 +666,8 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
settings: const RouteSettings(name: 'hrPolicyDetails'),
|
settings: const RouteSettings(name: 'hrPolicyDetails'),
|
||||||
builder: (_) => hrPolicyDetails(
|
builder: (_) => hrPolicyDetails(
|
||||||
ClientId: clientId,
|
ClientId: clientId,
|
||||||
policyTypeId:
|
policyTypeId: data['policy_type_id'].toString(),
|
||||||
data['policy_type_id'].toString(),
|
ClientPoliyId: data['client_policy_id'].toString(),
|
||||||
ClientPoliyId:
|
|
||||||
data['client_policy_id'].toString(),
|
|
||||||
clientBranchId: branchId,
|
clientBranchId: branchId,
|
||||||
Token: token,
|
Token: token,
|
||||||
TokenType: "pre",
|
TokenType: "pre",
|
||||||
@ -685,8 +675,7 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
cardPolicyNo: data['policy_no'].toString(),
|
cardPolicyNo: data['policy_no'].toString(),
|
||||||
cardInsurer_name:
|
cardInsurer_name:
|
||||||
data['insurer_short_name'].toString(),
|
data['insurer_short_name'].toString(),
|
||||||
cardPolicy_name:
|
cardPolicy_name: data['policy_name'].toString(),
|
||||||
data['policy_name'].toString(),
|
|
||||||
cardPolicy_ExpDate:
|
cardPolicy_ExpDate:
|
||||||
data['policy_expiry_date'].toString(),
|
data['policy_expiry_date'].toString(),
|
||||||
total_premium: '',
|
total_premium: '',
|
||||||
@ -701,15 +690,17 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
onBulkDownload: onBulkDownload,
|
onBulkDownload: onBulkDownload,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final token = await tokenService.getCurrentToken();
|
final token = await tokenService.getCurrentToken();
|
||||||
final clientId = await tokenService.readValue('empClientId');
|
final clientId =
|
||||||
final branchId = await tokenService.readValue('empClientBranchId');
|
await tokenService.readValue('empClientId');
|
||||||
|
final branchId =
|
||||||
|
await tokenService.readValue('empClientBranchId');
|
||||||
|
|
||||||
print("token: $token");
|
logDebug("token: $token");
|
||||||
print("clientId: $clientId");
|
logDebug("clientId: $clientId");
|
||||||
print("branchId: $branchId");
|
logDebug("branchId: $branchId");
|
||||||
|
|
||||||
if (token == null || clientId == null || branchId == null) {
|
if (token == null || clientId == null || branchId == null) {
|
||||||
print("Missing required values");
|
logDebug("Missing required values");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,10 +710,8 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
settings: const RouteSettings(name: 'hrPolicyDetails'),
|
settings: const RouteSettings(name: 'hrPolicyDetails'),
|
||||||
builder: (_) => hrPolicyDetails(
|
builder: (_) => hrPolicyDetails(
|
||||||
ClientId: clientId,
|
ClientId: clientId,
|
||||||
policyTypeId:
|
policyTypeId: data['policy_type_id'].toString(),
|
||||||
data['policy_type_id'].toString(),
|
ClientPoliyId: data['client_policy_id'].toString(),
|
||||||
ClientPoliyId:
|
|
||||||
data['client_policy_id'].toString(),
|
|
||||||
clientBranchId: branchId,
|
clientBranchId: branchId,
|
||||||
Token: token,
|
Token: token,
|
||||||
TokenType: 'post',
|
TokenType: 'post',
|
||||||
@ -730,12 +719,10 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
cardPolicyNo: data['policy_no'].toString(),
|
cardPolicyNo: data['policy_no'].toString(),
|
||||||
cardInsurer_name:
|
cardInsurer_name:
|
||||||
data['insurer_short_name'].toString(),
|
data['insurer_short_name'].toString(),
|
||||||
cardPolicy_name:
|
cardPolicy_name: data['policy_name'].toString(),
|
||||||
data['policy_name'].toString(),
|
|
||||||
cardPolicy_ExpDate:
|
cardPolicy_ExpDate:
|
||||||
data['policy_expiry_date'].toString(),
|
data['policy_expiry_date'].toString(),
|
||||||
total_premium:
|
total_premium: data['total_premium'].toString(),
|
||||||
data['total_premium'].toString(),
|
|
||||||
is_ecard_bulk_download_for_employee:
|
is_ecard_bulk_download_for_employee:
|
||||||
data['is_ecard_bulk_download_for_employee'],
|
data['is_ecard_bulk_download_for_employee'],
|
||||||
),
|
),
|
||||||
@ -749,7 +736,6 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// class _PolicyGrid extends StatelessWidget {
|
// class _PolicyGrid extends StatelessWidget {
|
||||||
// final List<Map<String, dynamic>> policies;
|
// final List<Map<String, dynamic>> policies;
|
||||||
// final bool isEnrollment;
|
// final bool isEnrollment;
|
||||||
@ -832,8 +818,8 @@ class _PolicyGrid extends StatelessWidget {
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// print('$token , $empClientId, $empBranchId');
|
// logDebug('$token , $empClientId, $empBranchId');
|
||||||
// print(data);
|
// logDebug(data);
|
||||||
// // return;
|
// // return;
|
||||||
//
|
//
|
||||||
// Navigator.push(
|
// Navigator.push(
|
||||||
@ -969,7 +955,11 @@ class _ActivePolicyCardNew extends StatelessWidget {
|
|||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
final Function(String clientPolicyId)? onBulkDownload;
|
final Function(String clientPolicyId)? onBulkDownload;
|
||||||
|
|
||||||
const _ActivePolicyCardNew({required this.data, this.onTap,this.onBulkDownload,});
|
const _ActivePolicyCardNew({
|
||||||
|
required this.data,
|
||||||
|
this.onTap,
|
||||||
|
this.onBulkDownload,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -1008,7 +998,8 @@ class _ActivePolicyCardNew extends StatelessWidget {
|
|||||||
right: 10,
|
right: 10,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
print('ICON CLICKED ${data['client_policy_id']}');
|
logDebug(
|
||||||
|
'ICON CLICKED ${data['client_policy_id']}');
|
||||||
onBulkDownload?.call(
|
onBulkDownload?.call(
|
||||||
data['client_policy_id'].toString(),
|
data['client_policy_id'].toString(),
|
||||||
);
|
);
|
||||||
@ -1098,10 +1089,7 @@ class _ActivePolicyCardNew extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)));
|
||||||
)
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
import '../config/environment.dart';
|
import '../config/environment.dart';
|
||||||
import '../customAppBar/base_layout.dart';
|
import '../customAppBar/base_layout.dart';
|
||||||
import '../customAppBar/customFooter.dart';
|
import '../customAppBar/customFooter.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class postFileUpload extends StatefulWidget {
|
class postFileUpload extends StatefulWidget {
|
||||||
final String ClientId;
|
final String ClientId;
|
||||||
@ -61,7 +62,6 @@ class postFileUpload extends StatefulWidget {
|
|||||||
class _postFileUploadState extends State<postFileUpload> {
|
class _postFileUploadState extends State<postFileUpload> {
|
||||||
final tokenService = TokenStorageService();
|
final tokenService = TokenStorageService();
|
||||||
|
|
||||||
|
|
||||||
String localClientId = '';
|
String localClientId = '';
|
||||||
String localPolicyTypeId = '';
|
String localPolicyTypeId = '';
|
||||||
String localClientPolicyId = '';
|
String localClientPolicyId = '';
|
||||||
@ -75,8 +75,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
String localCardPolicyExpDate = '';
|
String localCardPolicyExpDate = '';
|
||||||
String localTotalPremium = '';
|
String localTotalPremium = '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Uint8List? fileBytes;
|
Uint8List? fileBytes;
|
||||||
Uint8List? fileBytes2;
|
Uint8List? fileBytes2;
|
||||||
late String _token;
|
late String _token;
|
||||||
@ -145,7 +143,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
getFileUploadMasterDetails();
|
getFileUploadMasterDetails();
|
||||||
getFileListDetails();
|
getFileListDetails();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -253,9 +250,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
// PlatformFile file = result.files.first;
|
// PlatformFile file = result.files.first;
|
||||||
// Uint8List fileBytes = file.bytes!;
|
// Uint8List fileBytes = file.bytes!;
|
||||||
// // Use the fileBytes as needed
|
// // Use the fileBytes as needed
|
||||||
// print('File name: ${file.name}');
|
// logDebug('File name: ${file.name}');
|
||||||
// print('File size: ${file.size}');
|
// logDebug('File size: ${file.size}');
|
||||||
// print('File bytes: $fileBytes');
|
// logDebug('File bytes: $fileBytes');
|
||||||
// _processExcelData(fileBytes);
|
// _processExcelData(fileBytes);
|
||||||
// } else {
|
// } else {
|
||||||
// // User canceled the picker
|
// // User canceled the picker
|
||||||
@ -263,31 +260,31 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
Future<void> getFileUploadMasterDetails() async {
|
Future<void> getFileUploadMasterDetails() async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
try {
|
try {
|
||||||
final response = await apiService.getFileUploadMastersToApi(localToken);
|
final response = await apiService.getFileUploadMastersToApi(localToken);
|
||||||
|
|
||||||
if (response['status'] == true) {
|
if (response['status'] == true) {
|
||||||
print('getFileUploadMasterList1');
|
logDebug('getFileUploadMasterList1');
|
||||||
setState(() {
|
setState(() {
|
||||||
final actions = Map<String, String>.from(response['data']['actions']);
|
final actions = Map<String, String>.from(response['data']['actions']);
|
||||||
setState(() {
|
setState(() {
|
||||||
getFileUploadMasterList = actions.entries
|
getFileUploadMasterList = actions.entries
|
||||||
.map((e) => {"key": e.key, "value": e.value})
|
.map((e) => {"key": e.key, "value": e.value})
|
||||||
.toList();
|
.toList();
|
||||||
print('getFileUploadMasterList: $getFileUploadMasterList');
|
logDebug('getFileUploadMasterList: $getFileUploadMasterList');
|
||||||
});
|
});
|
||||||
print('getFileUploadMasterList');
|
logDebug('getFileUploadMasterList');
|
||||||
print(getFileUploadMasterList);
|
logDebug(getFileUploadMasterList);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
// _isLoading = false;
|
// _isLoading = false;
|
||||||
@ -299,28 +296,28 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
empPrimaryId = await tokenService.readValue('empPrimaryId');
|
empPrimaryId = await tokenService.readValue('empPrimaryId');
|
||||||
empClientId = await tokenService.readValue('empClientId');
|
empClientId = await tokenService.readValue('empClientId');
|
||||||
|
|
||||||
print('9');
|
logDebug('9');
|
||||||
try {
|
try {
|
||||||
final response = await apiService.getFileListToApi(empPrimaryId,
|
final response = await apiService.getFileListToApi(empPrimaryId,
|
||||||
localCardPolicyNo, empClientId, localToken, localTokenType);
|
localCardPolicyNo, empClientId, localToken, localTokenType);
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('getThrFileList');
|
logDebug('getThrFileList');
|
||||||
setState(() {
|
setState(() {
|
||||||
getThrFileList = List<Map<String, dynamic>>.from(response['data']);
|
getThrFileList = List<Map<String, dynamic>>.from(response['data']);
|
||||||
originalData = getThrFileList;
|
originalData = getThrFileList;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
// _isLoading = false;
|
// _isLoading = false;
|
||||||
@ -330,9 +327,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
|
|
||||||
Future<void> getHrFileDownload(id, file_name) async {
|
Future<void> getHrFileDownload(id, file_name) async {
|
||||||
// final http.Response response = await apiService.getHrFileDownloadToApi(id, localToken);
|
// final http.Response response = await apiService.getHrFileDownloadToApi(id, localToken);
|
||||||
print("**********-------*****");
|
logDebug("**********-------*****");
|
||||||
final encryptClientId = localClientId;
|
final encryptClientId = localClientId;
|
||||||
print(encryptClientId);
|
logDebug(encryptClientId);
|
||||||
final apiurl = Environment.apiUrlPost;
|
final apiurl = Environment.apiUrlPost;
|
||||||
final String url =
|
final String url =
|
||||||
'$apiurl/hrFileDownload?id=$id&cliend_id=$encryptClientId';
|
'$apiurl/hrFileDownload?id=$id&cliend_id=$encryptClientId';
|
||||||
@ -351,7 +348,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
print("PDF Downloaded");
|
logDebug("PDF Downloaded");
|
||||||
|
|
||||||
// ✅ Create a blob from the response body bytes
|
// ✅ Create a blob from the response body bytes
|
||||||
final blob = html.Blob([response.bodyBytes]);
|
final blob = html.Blob([response.bodyBytes]);
|
||||||
@ -373,15 +370,15 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Failed to download');
|
ToastHelper.showErrorToast(context, 'Failed to download');
|
||||||
print("Download failed with status: ${response.statusCode}");
|
logDebug("Download failed with status: ${response.statusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> downloadPostSampleFile(String apiParam) async {
|
Future<void> downloadPostSampleFile(String apiParam) async {
|
||||||
print("fun Sam f - in");
|
logDebug("fun Sam f - in");
|
||||||
|
|
||||||
final post_file_name = apiParam + '_sample_file.xlsx';
|
final post_file_name = apiParam + '_sample_file.xlsx';
|
||||||
print("fun Sam f - name $post_file_name");
|
logDebug("fun Sam f - name $post_file_name");
|
||||||
final apiurl = Environment.apiUrlPost;
|
final apiurl = Environment.apiUrlPost;
|
||||||
final String url = '$apiurl/downloadSampleExcel/$apiParam';
|
final String url = '$apiurl/downloadSampleExcel/$apiParam';
|
||||||
final token = localToken;
|
final token = localToken;
|
||||||
@ -399,7 +396,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
print("fun sam f - ${response.statusCode}");
|
logDebug("fun sam f - ${response.statusCode}");
|
||||||
|
|
||||||
// ✅ Create a blob from the response body bytes
|
// ✅ Create a blob from the response body bytes
|
||||||
final blob = html.Blob([response.bodyBytes]);
|
final blob = html.Blob([response.bodyBytes]);
|
||||||
@ -417,19 +414,19 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
|
|
||||||
ToastHelper.showSuccessToast(context, 'File Downloaded Successfully');
|
ToastHelper.showSuccessToast(context, 'File Downloaded Successfully');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("fun sam f - fail");
|
logDebug("fun sam f - fail");
|
||||||
throw Exception('Error parsing response: $e');
|
throw Exception('Error parsing response: $e');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Failed to download');
|
ToastHelper.showErrorToast(context, 'Failed to download');
|
||||||
print("Download failed with status: ${response.statusCode}");
|
logDebug("Download failed with status: ${response.statusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _uploadFile() async {
|
void _uploadFile() async {
|
||||||
print('Test');
|
logDebug('Test');
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
print('kIsWeb');
|
logDebug('kIsWeb');
|
||||||
final input = html.FileUploadInputElement();
|
final input = html.FileUploadInputElement();
|
||||||
input.accept = '.xlsx,.xls';
|
input.accept = '.xlsx,.xls';
|
||||||
input.click();
|
input.click();
|
||||||
@ -467,8 +464,8 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
// Save fileBytes to local storage
|
// Save fileBytes to local storage
|
||||||
final jsonString = json.encode(fileBytes);
|
final jsonString = json.encode(fileBytes);
|
||||||
html.window.localStorage['fileBytes'] = jsonString;
|
html.window.localStorage['fileBytes'] = jsonString;
|
||||||
print('File Name: $fileName');
|
logDebug('File Name: $fileName');
|
||||||
print('File Bytes: $fileBytes');
|
logDebug('File Bytes: $fileBytes');
|
||||||
sendExcelFIleTOAPI(fileBytes, fileName);
|
sendExcelFIleTOAPI(fileBytes, fileName);
|
||||||
// Call the function to process Excel data here
|
// Call the function to process Excel data here
|
||||||
// _processExcelData(fileBytes, fileName);
|
// _processExcelData(fileBytes, fileName);
|
||||||
@ -477,7 +474,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Handle non-web platforms here (e.g., show an error message)
|
// Handle non-web platforms here (e.g., show an error message)
|
||||||
print('File upload is only supported on web platforms.');
|
logDebug('File upload is only supported on web platforms.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,17 +492,17 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
// // Invalid DOB format, skip this entry
|
// // Invalid DOB format, skip this entry
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
print(entry['Relation']);
|
logDebug(entry['Relation']);
|
||||||
if ((entry['Relation'].toString() == 'Son' ||
|
if ((entry['Relation'].toString() == 'Son' ||
|
||||||
entry['Relation'].toString() == 'Daughter')) {
|
entry['Relation'].toString() == 'Daughter')) {
|
||||||
if (DateTime.now().difference(dob).inDays > 25 * 365) {
|
if (DateTime.now().difference(dob).inDays > 25 * 365) {
|
||||||
print('child $dob');
|
logDebug('child $dob');
|
||||||
invalidCount++;
|
invalidCount++;
|
||||||
}
|
}
|
||||||
} else if ((entry['Relation'] != 'Son' &&
|
} else if ((entry['Relation'] != 'Son' &&
|
||||||
entry['Relation'] != 'Daughter')) {
|
entry['Relation'] != 'Daughter')) {
|
||||||
if (DateTime.now().difference(dob).inDays < 18 * 365) {
|
if (DateTime.now().difference(dob).inDays < 18 * 365) {
|
||||||
print('others $dob');
|
logDebug('others $dob');
|
||||||
invalidCount++;
|
invalidCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -515,8 +512,8 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _dragAndDropFile(html.File file) async {
|
void _dragAndDropFile(html.File file) async {
|
||||||
print('file');
|
logDebug('file');
|
||||||
print(file);
|
logDebug(file);
|
||||||
// Prepare form data
|
// Prepare form data
|
||||||
final formData = html.FormData();
|
final formData = html.FormData();
|
||||||
formData.appendBlob('file', file);
|
formData.appendBlob('file', file);
|
||||||
@ -529,7 +526,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Handle response as needed
|
// Handle response as needed
|
||||||
print(response.responseText);
|
logDebug(response.responseText);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> sendExcelFIleTOAPI(Uint8List fileBytes, fileName) async {
|
Future<void> sendExcelFIleTOAPI(Uint8List fileBytes, fileName) async {
|
||||||
@ -539,24 +536,24 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
// });
|
// });
|
||||||
print('submit');
|
logDebug('submit');
|
||||||
print(fileBytes);
|
logDebug(fileBytes);
|
||||||
if (fileBytes == null) {
|
if (fileBytes == null) {
|
||||||
ToastHelper.showErrorToast(context, 'Please upload file');
|
ToastHelper.showErrorToast(context, 'Please upload file');
|
||||||
print('return');
|
logDebug('return');
|
||||||
return; // No file selected
|
return; // No file selected
|
||||||
} else {
|
} else {
|
||||||
print('else');
|
logDebug('else');
|
||||||
// // Prepare form data
|
// // Prepare form data
|
||||||
// final formData = html.FormData();
|
// final formData = html.FormData();
|
||||||
// formData.appendBlob('file', html.Blob([fileBytes]), fileName);
|
// formData.appendBlob('file', html.Blob([fileBytes]), fileName);
|
||||||
|
|
||||||
// URL of the API where you want to send the file
|
// URL of the API where you want to send the file
|
||||||
final apiUrl = Environment.apiUrlPost + 'hrFileUpload';
|
final apiUrl = Environment.apiUrlPost + 'hrFileUpload';
|
||||||
print('else');
|
logDebug('else');
|
||||||
// Create a multipart request
|
// Create a multipart request
|
||||||
final request = http.MultipartRequest('POST', Uri.parse(apiUrl));
|
final request = http.MultipartRequest('POST', Uri.parse(apiUrl));
|
||||||
print('else');
|
logDebug('else');
|
||||||
// Attach the file to the request
|
// Attach the file to the request
|
||||||
// Set authorization token in headers
|
// Set authorization token in headers
|
||||||
request.headers['APP-SIGNATURE'] =
|
request.headers['APP-SIGNATURE'] =
|
||||||
@ -564,7 +561,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
request.headers['Authorization'] = 'Bearer $_token';
|
request.headers['Authorization'] = 'Bearer $_token';
|
||||||
// request.files.add(http.MultipartFile.fromBytes('file', fileBytes,
|
// request.files.add(http.MultipartFile.fromBytes('file', fileBytes,
|
||||||
// filename: fileName));
|
// filename: fileName));
|
||||||
print('Filename: $fileName');
|
logDebug('Filename: $fileName');
|
||||||
// request.files.add(http.MultipartFile.fromBytes(
|
// request.files.add(http.MultipartFile.fromBytes(
|
||||||
// 'file',
|
// 'file',
|
||||||
// fileBytes,
|
// fileBytes,
|
||||||
@ -575,7 +572,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
fileBytes,
|
fileBytes,
|
||||||
filename: fileName ?? 'default_filename.xlsx',
|
filename: fileName ?? 'default_filename.xlsx',
|
||||||
));
|
));
|
||||||
print('clintID: $clintID');
|
logDebug('clintID: $clintID');
|
||||||
|
|
||||||
request.fields['client_id'] = localClientId;
|
request.fields['client_id'] = localClientId;
|
||||||
request.fields['policy_no'] = localCardPolicyNo;
|
request.fields['policy_no'] = localCardPolicyNo;
|
||||||
@ -591,16 +588,16 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
// "status": "inception",
|
// "status": "inception",
|
||||||
// "created_by": 10
|
// "created_by": 10
|
||||||
|
|
||||||
print('request : $request');
|
logDebug('request : $request');
|
||||||
// Send the request
|
// Send the request
|
||||||
final response = await request.send();
|
final response = await request.send();
|
||||||
print('else');
|
logDebug('else');
|
||||||
// Read response stream as a string
|
// Read response stream as a string
|
||||||
final responseString = await response.stream.bytesToString();
|
final responseString = await response.stream.bytesToString();
|
||||||
print(responseString);
|
logDebug(responseString);
|
||||||
Map<String, dynamic> data = json.decode(responseString);
|
Map<String, dynamic> data = json.decode(responseString);
|
||||||
if (data['status'] == true) {
|
if (data['status'] == true) {
|
||||||
print('upload success');
|
logDebug('upload success');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
@ -632,7 +629,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void search(String query) {
|
void search(String query) {
|
||||||
print(query);
|
logDebug(query);
|
||||||
// Check if the query is empty
|
// Check if the query is empty
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
// If search query is empty, show all data
|
// If search query is empty, show all data
|
||||||
@ -661,7 +658,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
print(filteredData.length);
|
logDebug(filteredData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -696,24 +693,47 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final clientId = await tokenService.readValue('hr_ClientId') ?? '';
|
final clientId =
|
||||||
final policyTypeId = await tokenService.readValue('hr_policyTypeId') ?? '';
|
await tokenService.readValue('hr_ClientId') ?? '';
|
||||||
final clientPolicyId = await tokenService.readValue('hr_ClientPoliyId') ?? '';
|
final policyTypeId =
|
||||||
final clientBranchId = await tokenService.readValue('hr_clientBranchId') ?? '';
|
await tokenService.readValue('hr_policyTypeId') ??
|
||||||
final token = await tokenService.readValue('hr_Token') ?? '';
|
'';
|
||||||
final tokenType = await tokenService.readValue('hr_TokenType') ?? '';
|
final clientPolicyId =
|
||||||
final cardType = await tokenService.readValue('hr_cardType') ?? '';
|
await tokenService.readValue('hr_ClientPoliyId') ??
|
||||||
final policyNo = await tokenService.readValue('hr_cardPolicyNo') ?? '';
|
'';
|
||||||
final insurer = await tokenService.readValue('hr_cardInsurer_name') ?? '';
|
final clientBranchId =
|
||||||
final policyName = await tokenService.readValue('hr_cardPolicy_name') ?? '';
|
await tokenService.readValue('hr_clientBranchId') ??
|
||||||
final expDate = await tokenService.readValue('hr_cardPolicy_ExpDate') ?? '';
|
'';
|
||||||
final totalPremium = await tokenService.readValue('hr_total_premium') ?? '';
|
final token =
|
||||||
final bulkDownload = await tokenService.readValue('hr_is_ecard_bulk_download_for_employee') ?? '0';
|
await tokenService.readValue('hr_Token') ?? '';
|
||||||
|
final tokenType =
|
||||||
|
await tokenService.readValue('hr_TokenType') ?? '';
|
||||||
|
final cardType =
|
||||||
|
await tokenService.readValue('hr_cardType') ?? '';
|
||||||
|
final policyNo =
|
||||||
|
await tokenService.readValue('hr_cardPolicyNo') ??
|
||||||
|
'';
|
||||||
|
final insurer = await tokenService
|
||||||
|
.readValue('hr_cardInsurer_name') ??
|
||||||
|
'';
|
||||||
|
final policyName = await tokenService
|
||||||
|
.readValue('hr_cardPolicy_name') ??
|
||||||
|
'';
|
||||||
|
final expDate = await tokenService
|
||||||
|
.readValue('hr_cardPolicy_ExpDate') ??
|
||||||
|
'';
|
||||||
|
final totalPremium =
|
||||||
|
await tokenService.readValue('hr_total_premium') ??
|
||||||
|
'';
|
||||||
|
final bulkDownload = await tokenService.readValue(
|
||||||
|
'hr_is_ecard_bulk_download_for_employee') ??
|
||||||
|
'0';
|
||||||
|
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
settings: const RouteSettings(name: 'hrPolicyDetails'),
|
settings:
|
||||||
|
const RouteSettings(name: 'hrPolicyDetails'),
|
||||||
builder: (_) => hrPolicyDetails(
|
builder: (_) => hrPolicyDetails(
|
||||||
ClientId: clientId,
|
ClientId: clientId,
|
||||||
policyTypeId: policyTypeId,
|
policyTypeId: policyTypeId,
|
||||||
@ -727,7 +747,8 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
cardPolicy_name: policyName,
|
cardPolicy_name: policyName,
|
||||||
cardPolicy_ExpDate: expDate,
|
cardPolicy_ExpDate: expDate,
|
||||||
total_premium: totalPremium,
|
total_premium: totalPremium,
|
||||||
is_ecard_bulk_download_for_employee: int.tryParse(bulkDownload) ?? 0,
|
is_ecard_bulk_download_for_employee:
|
||||||
|
int.tryParse(bulkDownload) ?? 0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -745,8 +766,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
// mainAxisAlignment: MainAxisAlignment.start,
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"${localCardType} - ${localCardPolicyNo} " ??
|
"${localCardType} - ${localCardPolicyNo} " ?? '',
|
||||||
'',
|
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@ -1063,8 +1083,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
return _buildFileCard(item);
|
return _buildFileCard(item);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildFileCard(Map<String, dynamic> item) {
|
Widget _buildFileCard(Map<String, dynamic> item) {
|
||||||
@ -1159,7 +1177,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
if (item['file_error_status'] == '1')
|
if (item['file_error_status'] == '1')
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
print(item);
|
logDebug(item);
|
||||||
// return;
|
// return;
|
||||||
final String? token =
|
final String? token =
|
||||||
await tokenService.getCurrentToken();
|
await tokenService.getCurrentToken();
|
||||||
@ -1168,18 +1186,18 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
final String? empBranchId =
|
final String? empBranchId =
|
||||||
await tokenService.readValue('empClientBranchId');
|
await tokenService.readValue('empClientBranchId');
|
||||||
|
|
||||||
print(item);
|
logDebug(item);
|
||||||
print(empClientId);
|
logDebug(empClientId);
|
||||||
print(localPolicyTypeId);
|
logDebug(localPolicyTypeId);
|
||||||
print(empBranchId);
|
logDebug(empBranchId);
|
||||||
print(token);
|
logDebug(token);
|
||||||
print('post');
|
logDebug('post');
|
||||||
print(localCardType);
|
logDebug(localCardType);
|
||||||
print(localCardPolicyNo);
|
logDebug(localCardPolicyNo);
|
||||||
print(localCardInsurerName);
|
logDebug(localCardInsurerName);
|
||||||
print(localCardPolicyName);
|
logDebug(localCardPolicyName);
|
||||||
print(localCardPolicyExpDate);
|
logDebug(localCardPolicyExpDate);
|
||||||
print(item['id']);
|
logDebug(item['id']);
|
||||||
|
|
||||||
// ✅ SAFETY CHECK
|
// ✅ SAFETY CHECK
|
||||||
if (token == null ||
|
if (token == null ||
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import '../config/environment.dart';
|
|||||||
import '../customAppBar/base_layout.dart';
|
import '../customAppBar/base_layout.dart';
|
||||||
import 'excelVerification.dart';
|
import 'excelVerification.dart';
|
||||||
import 'hrPolicyDetails.dart';
|
import 'hrPolicyDetails.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class preFileUpload extends StatefulWidget {
|
class preFileUpload extends StatefulWidget {
|
||||||
final String ClientId;
|
final String ClientId;
|
||||||
@ -229,9 +230,9 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
// PlatformFile file = result.files.first;
|
// PlatformFile file = result.files.first;
|
||||||
// Uint8List fileBytes = file.bytes!;
|
// Uint8List fileBytes = file.bytes!;
|
||||||
// // Use the fileBytes as needed
|
// // Use the fileBytes as needed
|
||||||
// print('File name: ${file.name}');
|
// logDebug('File name: ${file.name}');
|
||||||
// print('File size: ${file.size}');
|
// logDebug('File size: ${file.size}');
|
||||||
// print('File bytes: $fileBytes');
|
// logDebug('File bytes: $fileBytes');
|
||||||
// _processExcelData(fileBytes);
|
// _processExcelData(fileBytes);
|
||||||
// } else {
|
// } else {
|
||||||
// // User canceled the picker
|
// // User canceled the picker
|
||||||
@ -239,9 +240,9 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
void _uploadFile(importPolicyName) async {
|
void _uploadFile(importPolicyName) async {
|
||||||
print('Test');
|
logDebug('Test');
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
print('kIsWeb');
|
logDebug('kIsWeb');
|
||||||
final input = html.FileUploadInputElement();
|
final input = html.FileUploadInputElement();
|
||||||
input.accept = '.xlsx,.xls';
|
input.accept = '.xlsx,.xls';
|
||||||
input.click();
|
input.click();
|
||||||
@ -274,8 +275,8 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
// Save fileBytes to local storage
|
// Save fileBytes to local storage
|
||||||
// final jsonString = json.encode(fileBytes);
|
// final jsonString = json.encode(fileBytes);
|
||||||
// html.window.localStorage['fileBytes'] = jsonString;
|
// html.window.localStorage['fileBytes'] = jsonString;
|
||||||
print('File Name: $fileName');
|
logDebug('File Name: $fileName');
|
||||||
print('File Bytes: $fileBytes');
|
logDebug('File Bytes: $fileBytes');
|
||||||
sendExcelFIleTOAPI(fileBytes, fileName);
|
sendExcelFIleTOAPI(fileBytes, fileName);
|
||||||
// Call the function to process Excel data here
|
// Call the function to process Excel data here
|
||||||
// _processExcelData(fileBytes, fileName);
|
// _processExcelData(fileBytes, fileName);
|
||||||
@ -284,7 +285,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Handle non-web platforms here (e.g., show an error message)
|
// Handle non-web platforms here (e.g., show an error message)
|
||||||
print('File upload is only supported on web platforms.');
|
logDebug('File upload is only supported on web platforms.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,20 +305,20 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
} else if (fileName.endsWith('.xls')) {
|
} else if (fileName.endsWith('.xls')) {
|
||||||
dataArray = decodeXLSData(fileBytes);
|
dataArray = decodeXLSData(fileBytes);
|
||||||
} else if (fileName.endsWith('.csv')) {
|
} else if (fileName.endsWith('.csv')) {
|
||||||
print('csv');
|
logDebug('csv');
|
||||||
dataArray = decodeCSVData(fileBytes);
|
dataArray = decodeCSVData(fileBytes);
|
||||||
} else {
|
} else {
|
||||||
throw UnsupportedError('Unsupported file format: $fileName');
|
throw UnsupportedError('Unsupported file format: $fileName');
|
||||||
}
|
}
|
||||||
|
|
||||||
print('_processExcelData');
|
logDebug('_processExcelData');
|
||||||
// Decode the Excel file and extract relevant data
|
// Decode the Excel file and extract relevant data
|
||||||
// Assuming dataArray is your array containing Excel data
|
// Assuming dataArray is your array containing Excel data
|
||||||
// List<List<Data>> dataArray = decodeExcelData(fileBytes);
|
// List<List<Data>> dataArray = decodeExcelData(fileBytes);
|
||||||
print(dataArray);
|
logDebug(dataArray);
|
||||||
// print(dataArray[0].toString());
|
// logDebug(dataArray[0].toString());
|
||||||
// Extract Name, Age, and City from the array
|
// Extract Name, Age, and City from the array
|
||||||
print(dataArray[0].length);
|
logDebug(dataArray[0].length);
|
||||||
|
|
||||||
if (dataArray[0].length == 11) {
|
if (dataArray[0].length == 11) {
|
||||||
for (int i = 0; i < dataArray.length; i++) {
|
for (int i = 0; i < dataArray.length; i++) {
|
||||||
@ -335,71 +336,71 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
"Grade": dataArray[i][10].value,
|
"Grade": dataArray[i][10].value,
|
||||||
};
|
};
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// print(dataMap);
|
// logDebug(dataMap);
|
||||||
validationArray.add(dataMap);
|
validationArray.add(dataMap);
|
||||||
} else {
|
} else {
|
||||||
// print(dataMap);
|
// logDebug(dataMap);
|
||||||
extractedData.add(dataMap);
|
extractedData.add(dataMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do something with extracted data (e.g., display in UI)
|
// Do something with extracted data (e.g., display in UI)
|
||||||
originalData = extractedData;
|
originalData = extractedData;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
print(validationArray);
|
logDebug(validationArray);
|
||||||
|
|
||||||
validationArray[0].forEach((key, value) {
|
validationArray[0].forEach((key, value) {
|
||||||
print(key);
|
logDebug(key);
|
||||||
print(value);
|
logDebug(value);
|
||||||
if (key.toString().trim().toLowerCase() !=
|
if (key.toString().trim().toLowerCase() !=
|
||||||
value.toString().trim().toLowerCase()) {
|
value.toString().trim().toLowerCase()) {
|
||||||
// If key and value are not equal, increment mismatch count
|
// If key and value are not equal, increment mismatch count
|
||||||
columnIndexMismatchCount++;
|
columnIndexMismatchCount++;
|
||||||
print('columnIndexMismatchCount: $value');
|
logDebug('columnIndexMismatchCount: $value');
|
||||||
}
|
}
|
||||||
if (value.toString() == 'null') {
|
if (value.toString() == 'null') {
|
||||||
// If value is null, increment missing count
|
// If value is null, increment missing count
|
||||||
columnMissingCount++;
|
columnMissingCount++;
|
||||||
print('Value: $value');
|
logDebug('Value: $value');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
print('columnIndexMismatchCount: $columnIndexMismatchCount');
|
logDebug('columnIndexMismatchCount: $columnIndexMismatchCount');
|
||||||
print('columnMissingCount: $columnMissingCount');
|
logDebug('columnMissingCount: $columnMissingCount');
|
||||||
|
|
||||||
nonExcelFilteredData = filteredData.where((item) {
|
nonExcelFilteredData = filteredData.where((item) {
|
||||||
final relation = item['Relation'];
|
final relation = item['Relation'];
|
||||||
return relation != null &&
|
return relation != null &&
|
||||||
relation.toString().trim().toLowerCase() != 'self';
|
relation.toString().trim().toLowerCase() != 'self';
|
||||||
}).toList();
|
}).toList();
|
||||||
print('nonExcelFilteredData');
|
logDebug('nonExcelFilteredData');
|
||||||
|
|
||||||
print(nonExcelFilteredData);
|
logDebug(nonExcelFilteredData);
|
||||||
print(nonExcelFilteredData.length);
|
logDebug(nonExcelFilteredData.length);
|
||||||
if (argumentsData['type'] == 'GPA') {
|
if (argumentsData['type'] == 'GPA') {
|
||||||
if (nonExcelFilteredData.length > 0) {
|
if (nonExcelFilteredData.length > 0) {
|
||||||
print('nonSelf');
|
logDebug('nonSelf');
|
||||||
invalidRelationships = nonExcelFilteredData.length;
|
invalidRelationships = nonExcelFilteredData.length;
|
||||||
} else {
|
} else {
|
||||||
print('Self');
|
logDebug('Self');
|
||||||
invalidRelationships = nonExcelFilteredData.length;
|
invalidRelationships = nonExcelFilteredData.length;
|
||||||
}
|
}
|
||||||
print('invalidRelationships: $invalidRelationships');
|
logDebug('invalidRelationships: $invalidRelationships');
|
||||||
} else {
|
} else {
|
||||||
invalidRelationships = 0;
|
invalidRelationships = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invalidDobCount = countInvalidDobs(filteredData);
|
int invalidDobCount = countInvalidDobs(filteredData);
|
||||||
|
|
||||||
print('Number of invalid DOBs: $invalidDobCount');
|
logDebug('Number of invalid DOBs: $invalidDobCount');
|
||||||
|
|
||||||
dobAgeCheckCount = invalidDobCount;
|
dobAgeCheckCount = invalidDobCount;
|
||||||
} else {
|
} else {
|
||||||
print('Some Column is Missing');
|
logDebug('Some Column is Missing');
|
||||||
var columnMissingCount = 11 - dataArray[0].length;
|
var columnMissingCount = 11 - dataArray[0].length;
|
||||||
missingColumnErrorMsg = columnMissingCount;
|
missingColumnErrorMsg = columnMissingCount;
|
||||||
print(missingColumnErrorMsg);
|
logDebug(missingColumnErrorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,12 +413,12 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
|
|
||||||
// Placeholder function for decoding Excel data
|
// Placeholder function for decoding Excel data
|
||||||
List<List<Data>> decodeExcelData(Uint8List fileBytes) {
|
List<List<Data>> decodeExcelData(Uint8List fileBytes) {
|
||||||
print('decodeExcelData');
|
logDebug('decodeExcelData');
|
||||||
|
|
||||||
// Create an Excel instance from the fileBytes
|
// Create an Excel instance from the fileBytes
|
||||||
final excel = Excel.decodeBytes(fileBytes);
|
final excel = Excel.decodeBytes(fileBytes);
|
||||||
print('decodeExcelData');
|
logDebug('decodeExcelData');
|
||||||
print(excel);
|
logDebug(excel);
|
||||||
|
|
||||||
// Assuming there's only one sheet in the Excel file
|
// Assuming there's only one sheet in the Excel file
|
||||||
final sheet = excel.tables.keys.first;
|
final sheet = excel.tables.keys.first;
|
||||||
@ -484,17 +485,17 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
// // Invalid DOB format, skip this entry
|
// // Invalid DOB format, skip this entry
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
print(entry['Relation']);
|
logDebug(entry['Relation']);
|
||||||
if ((entry['Relation'].toString() == 'Son' ||
|
if ((entry['Relation'].toString() == 'Son' ||
|
||||||
entry['Relation'].toString() == 'Daughter')) {
|
entry['Relation'].toString() == 'Daughter')) {
|
||||||
if (DateTime.now().difference(dob).inDays > 25 * 365) {
|
if (DateTime.now().difference(dob).inDays > 25 * 365) {
|
||||||
print('child $dob');
|
logDebug('child $dob');
|
||||||
invalidCount++;
|
invalidCount++;
|
||||||
}
|
}
|
||||||
} else if ((entry['Relation'] != 'Son' &&
|
} else if ((entry['Relation'] != 'Son' &&
|
||||||
entry['Relation'] != 'Daughter')) {
|
entry['Relation'] != 'Daughter')) {
|
||||||
if (DateTime.now().difference(dob).inDays < 18 * 365) {
|
if (DateTime.now().difference(dob).inDays < 18 * 365) {
|
||||||
print('others $dob');
|
logDebug('others $dob');
|
||||||
invalidCount++;
|
invalidCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,8 +505,8 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _dragAndDropFile(html.File file) async {
|
void _dragAndDropFile(html.File file) async {
|
||||||
print('file');
|
logDebug('file');
|
||||||
print(file);
|
logDebug(file);
|
||||||
// Prepare form data
|
// Prepare form data
|
||||||
final formData = html.FormData();
|
final formData = html.FormData();
|
||||||
formData.appendBlob('file', file);
|
formData.appendBlob('file', file);
|
||||||
@ -518,7 +519,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Handle response as needed
|
// Handle response as needed
|
||||||
print(response.responseText);
|
logDebug(response.responseText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _retrieveAndUploadFile() {
|
void _retrieveAndUploadFile() {
|
||||||
@ -544,23 +545,23 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
isLoading = true;
|
isLoading = true;
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
print('submit');
|
logDebug('submit');
|
||||||
print(fileBytes);
|
logDebug(fileBytes);
|
||||||
if (fileBytes == null) {
|
if (fileBytes == null) {
|
||||||
print('return');
|
logDebug('return');
|
||||||
return; // No file selected
|
return; // No file selected
|
||||||
} else {
|
} else {
|
||||||
print('else');
|
logDebug('else');
|
||||||
// // Prepare form data
|
// // Prepare form data
|
||||||
// final formData = html.FormData();
|
// final formData = html.FormData();
|
||||||
// formData.appendBlob('file', html.Blob([fileBytes]), fileName);
|
// formData.appendBlob('file', html.Blob([fileBytes]), fileName);
|
||||||
final enrollmentHrId = await tokenService.readValue('enrollmentHrId');
|
final enrollmentHrId = await tokenService.readValue('enrollmentHrId');
|
||||||
// URL of the API where you want to send the file
|
// URL of the API where you want to send the file
|
||||||
final apiUrl = Environment.apiUrl + 'employeeUpload';
|
final apiUrl = Environment.apiUrl + 'employeeUpload';
|
||||||
print('else');
|
logDebug('else');
|
||||||
// Create a multipart request
|
// Create a multipart request
|
||||||
final request = http.MultipartRequest('POST', Uri.parse(apiUrl));
|
final request = http.MultipartRequest('POST', Uri.parse(apiUrl));
|
||||||
print('else');
|
logDebug('else');
|
||||||
// Attach the file to the request
|
// Attach the file to the request
|
||||||
// Set authorization token in headers
|
// Set authorization token in headers
|
||||||
request.headers['APP-SIGNATURE'] =
|
request.headers['APP-SIGNATURE'] =
|
||||||
@ -568,7 +569,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
request.headers['Authorization'] = 'Bearer $_token';
|
request.headers['Authorization'] = 'Bearer $_token';
|
||||||
// request.files.add(http.MultipartFile.fromBytes('file', fileBytes,
|
// request.files.add(http.MultipartFile.fromBytes('file', fileBytes,
|
||||||
// filename: fileName));
|
// filename: fileName));
|
||||||
print('Filename: $fileName');
|
logDebug('Filename: $fileName');
|
||||||
request.files.add(http.MultipartFile.fromBytes(
|
request.files.add(http.MultipartFile.fromBytes(
|
||||||
'file',
|
'file',
|
||||||
fileBytes,
|
fileBytes,
|
||||||
@ -586,20 +587,20 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
// } else {
|
// } else {
|
||||||
// request.fields['policy_id'] = '3';
|
// request.fields['policy_id'] = '3';
|
||||||
// }
|
// }
|
||||||
print('request : $request');
|
logDebug('request : $request');
|
||||||
// Send the request
|
// Send the request
|
||||||
final response = await request.send();
|
final response = await request.send();
|
||||||
print('else');
|
logDebug('else');
|
||||||
// Read response stream as a string
|
// Read response stream as a string
|
||||||
final responseString = await response.stream.bytesToString();
|
final responseString = await response.stream.bytesToString();
|
||||||
print('else');
|
logDebug('else');
|
||||||
// Check the status code of the response
|
// Check the status code of the response
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
Map<String, dynamic> data = json.decode(responseString);
|
Map<String, dynamic> data = json.decode(responseString);
|
||||||
if (data['status'] == false) {
|
if (data['status'] == false) {
|
||||||
ToastHelper.showErrorToast(context, data['message']);
|
ToastHelper.showErrorToast(context, data['message']);
|
||||||
print('Table');
|
logDebug('Table');
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isSuccess = true;
|
isSuccess = true;
|
||||||
@ -621,7 +622,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
getFileListDetails();
|
getFileListDetails();
|
||||||
});
|
});
|
||||||
// ToastHelper.showErrorToast(context, data['message']);
|
// ToastHelper.showErrorToast(context, data['message']);
|
||||||
print('Table');
|
logDebug('Table');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -630,38 +631,38 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
// ToastHelper.showSuccessToast(
|
// ToastHelper.showSuccessToast(
|
||||||
// context, 'Failed to upload file: ${response.reasonPhrase}');
|
// context, 'Failed to upload file: ${response.reasonPhrase}');
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
print('Failed to upload file: ${response.reasonPhrase}');
|
logDebug('Failed to upload file: ${response.reasonPhrase}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleImportAction() async {
|
Future<void> handleImportAction() async {
|
||||||
print('handleImportAction');
|
logDebug('handleImportAction');
|
||||||
final postId = await tokenService.readValue('empHrId');
|
final postId = await tokenService.readValue('empHrId');
|
||||||
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
||||||
var activity = "import_enrollempdata";
|
var activity = "import_enrollempdata";
|
||||||
|
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
print('postId - $postId');
|
logDebug('postId - $postId');
|
||||||
print('preId - $preId');
|
logDebug('preId - $preId');
|
||||||
print('activity - $activity');
|
logDebug('activity - $activity');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
|
|
||||||
response = await apiService.getImportLogHrActivity(
|
response = await apiService.getImportLogHrActivity(
|
||||||
postId!, preId!, localToken, activity);
|
postId!, preId!, localToken, activity);
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,28 +672,28 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
final enrollmentClientId =
|
final enrollmentClientId =
|
||||||
await tokenService.readValue('enrollmentClient_id');
|
await tokenService.readValue('enrollmentClient_id');
|
||||||
|
|
||||||
print('9');
|
logDebug('9');
|
||||||
try {
|
try {
|
||||||
final response = await apiService.getFileListToApi(enrollmentPrimaryId,
|
final response = await apiService.getFileListToApi(enrollmentPrimaryId,
|
||||||
localCardPolicyNo, enrollmentClientId, localToken, localTokenType);
|
localCardPolicyNo, enrollmentClientId, localToken, localTokenType);
|
||||||
|
|
||||||
if (response['status'] == true) {
|
if (response['status'] == true) {
|
||||||
print('getThrFileList');
|
logDebug('getThrFileList');
|
||||||
setState(() {
|
setState(() {
|
||||||
getThrFileList = List<Map<String, dynamic>>.from(response['data']);
|
getThrFileList = List<Map<String, dynamic>>.from(response['data']);
|
||||||
originalData = getThrFileList;
|
originalData = getThrFileList;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
// _isLoading = false;
|
// _isLoading = false;
|
||||||
@ -724,23 +725,23 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
// Future<void> downloadSampleFile() async {
|
// Future<void> downloadSampleFile() async {
|
||||||
//
|
//
|
||||||
// final response = await apiService.getSampleFileDownload(localToken);
|
// final response = await apiService.getSampleFileDownload(localToken);
|
||||||
// print('check 1');
|
// logDebug('check 1');
|
||||||
// if (response['status'] == 'success') {
|
// if (response['status'] == 'success') {
|
||||||
// final url = response['data'];
|
// final url = response['data'];
|
||||||
// _launchURL(url);
|
// _launchURL(url);
|
||||||
// } else {
|
// } else {
|
||||||
// ToastHelper.showErrorToast(context, '⚠️ Unknown response format');
|
// ToastHelper.showErrorToast(context, '⚠️ Unknown response format');
|
||||||
// print('⚠️ Unknown response format');
|
// logDebug('⚠️ Unknown response format');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Future<void> _launchURL(String url) async {
|
// Future<void> _launchURL(String url) async {
|
||||||
// print('url $url');
|
// logDebug('url $url');
|
||||||
// try {
|
// try {
|
||||||
// final Uri uri = Uri.parse(url);
|
// final Uri uri = Uri.parse(url);
|
||||||
// await launchUrl(uri, mode: LaunchMode.externalApplication);
|
// await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
// print('Could not launch URL: $e');
|
// logDebug('Could not launch URL: $e');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -770,7 +771,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
print("PDF Downloaded");
|
logDebug("PDF Downloaded");
|
||||||
|
|
||||||
// ✅ Create a blob from the response body bytes
|
// ✅ Create a blob from the response body bytes
|
||||||
final blob = html.Blob([response.bodyBytes]);
|
final blob = html.Blob([response.bodyBytes]);
|
||||||
@ -789,7 +790,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
throw Exception('Error parsing response: $e');
|
throw Exception('Error parsing response: $e');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print("Download failed with status: ${response.statusCode}");
|
logDebug("Download failed with status: ${response.statusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,24 +828,47 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final clientId = await tokenService.readValue('hr_ClientId') ?? '';
|
final clientId =
|
||||||
final policyTypeId = await tokenService.readValue('hr_policyTypeId') ?? '';
|
await tokenService.readValue('hr_ClientId') ?? '';
|
||||||
final clientPolicyId = await tokenService.readValue('hr_ClientPoliyId') ?? '';
|
final policyTypeId =
|
||||||
final clientBranchId = await tokenService.readValue('hr_clientBranchId') ?? '';
|
await tokenService.readValue('hr_policyTypeId') ??
|
||||||
final token = await tokenService.readValue('hr_Token') ?? '';
|
'';
|
||||||
final tokenType = await tokenService.readValue('hr_TokenType') ?? '';
|
final clientPolicyId =
|
||||||
final cardType = await tokenService.readValue('hr_cardType') ?? '';
|
await tokenService.readValue('hr_ClientPoliyId') ??
|
||||||
final policyNo = await tokenService.readValue('hr_cardPolicyNo') ?? '';
|
'';
|
||||||
final insurer = await tokenService.readValue('hr_cardInsurer_name') ?? '';
|
final clientBranchId =
|
||||||
final policyName = await tokenService.readValue('hr_cardPolicy_name') ?? '';
|
await tokenService.readValue('hr_clientBranchId') ??
|
||||||
final expDate = await tokenService.readValue('hr_cardPolicy_ExpDate') ?? '';
|
'';
|
||||||
final totalPremium = await tokenService.readValue('hr_total_premium') ?? '';
|
final token =
|
||||||
final bulkDownload = await tokenService.readValue('hr_is_ecard_bulk_download_for_employee') ?? '0';
|
await tokenService.readValue('hr_Token') ?? '';
|
||||||
|
final tokenType =
|
||||||
|
await tokenService.readValue('hr_TokenType') ?? '';
|
||||||
|
final cardType =
|
||||||
|
await tokenService.readValue('hr_cardType') ?? '';
|
||||||
|
final policyNo =
|
||||||
|
await tokenService.readValue('hr_cardPolicyNo') ??
|
||||||
|
'';
|
||||||
|
final insurer = await tokenService
|
||||||
|
.readValue('hr_cardInsurer_name') ??
|
||||||
|
'';
|
||||||
|
final policyName = await tokenService
|
||||||
|
.readValue('hr_cardPolicy_name') ??
|
||||||
|
'';
|
||||||
|
final expDate = await tokenService
|
||||||
|
.readValue('hr_cardPolicy_ExpDate') ??
|
||||||
|
'';
|
||||||
|
final totalPremium =
|
||||||
|
await tokenService.readValue('hr_total_premium') ??
|
||||||
|
'';
|
||||||
|
final bulkDownload = await tokenService.readValue(
|
||||||
|
'hr_is_ecard_bulk_download_for_employee') ??
|
||||||
|
'0';
|
||||||
|
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
settings: const RouteSettings(name: 'hrPolicyDetails'),
|
settings:
|
||||||
|
const RouteSettings(name: 'hrPolicyDetails'),
|
||||||
builder: (_) => hrPolicyDetails(
|
builder: (_) => hrPolicyDetails(
|
||||||
ClientId: clientId,
|
ClientId: clientId,
|
||||||
policyTypeId: policyTypeId,
|
policyTypeId: policyTypeId,
|
||||||
@ -858,7 +882,8 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
cardPolicy_name: policyName,
|
cardPolicy_name: policyName,
|
||||||
cardPolicy_ExpDate: expDate,
|
cardPolicy_ExpDate: expDate,
|
||||||
total_premium: totalPremium,
|
total_premium: totalPremium,
|
||||||
is_ecard_bulk_download_for_employee: int.tryParse(bulkDownload) ?? 0,
|
is_ecard_bulk_download_for_employee:
|
||||||
|
int.tryParse(bulkDownload) ?? 0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -1400,7 +1425,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
message: 'Info', // Added tooltip name
|
message: 'Info', // Added tooltip name
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
print(item);
|
logDebug(item);
|
||||||
// return;
|
// return;
|
||||||
final String? token =
|
final String? token =
|
||||||
await tokenService.getCurrentToken();
|
await tokenService.getCurrentToken();
|
||||||
@ -1410,18 +1435,18 @@ class _excelVerifyState extends State<preFileUpload> {
|
|||||||
await tokenService
|
await tokenService
|
||||||
.readValue('enrollmentEmpClientBranchId');
|
.readValue('enrollmentEmpClientBranchId');
|
||||||
|
|
||||||
print(item);
|
logDebug(item);
|
||||||
print(enrollmentClient_id);
|
logDebug(enrollmentClient_id);
|
||||||
print(localPolicyTypeId);
|
logDebug(localPolicyTypeId);
|
||||||
print(enrollmentEmpClientBranchId);
|
logDebug(enrollmentEmpClientBranchId);
|
||||||
print(token);
|
logDebug(token);
|
||||||
print('post');
|
logDebug('post');
|
||||||
print(localCardType);
|
logDebug(localCardType);
|
||||||
print(localCardPolicyNo);
|
logDebug(localCardPolicyNo);
|
||||||
print(localCardInsurerName);
|
logDebug(localCardInsurerName);
|
||||||
print(localCardPolicyName);
|
logDebug(localCardPolicyName);
|
||||||
print(localCardPolicyExpDate);
|
logDebug(localCardPolicyExpDate);
|
||||||
print(item['id']);
|
logDebug(item['id']);
|
||||||
|
|
||||||
// ✅ SAFETY CHECK
|
// ✅ SAFETY CHECK
|
||||||
if (token == null ||
|
if (token == null ||
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class _ResponsiveGridConfig {
|
|||||||
_ResponsiveGridConfig _getGridConfig(
|
_ResponsiveGridConfig _getGridConfig(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
bool isEnrollment,
|
bool isEnrollment,
|
||||||
) {
|
) {
|
||||||
final width = MediaQuery.of(context).size.width;
|
final width = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
if (width < 600) {
|
if (width < 600) {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import '../config/environment.dart';
|
import '../config/environment.dart';
|
||||||
import '../customAppBar/toastHelper.dart';
|
import '../customAppBar/toastHelper.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class ApiService {
|
class ApiService {
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
@ -29,7 +30,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getClientLogoAndDetailsToApi(
|
Future<Map<String, dynamic>> getClientLogoAndDetailsToApi(
|
||||||
String clientId, String empCode, String branchID) async {
|
String clientId, String empCode, String branchID) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -50,7 +51,8 @@ class ApiService {
|
|||||||
String? empCode,
|
String? empCode,
|
||||||
String? status,
|
String? status,
|
||||||
String? branchID,
|
String? branchID,
|
||||||
String? mobileNo,String? emailId) async {
|
String? mobileNo,
|
||||||
|
String? emailId) async {
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -69,7 +71,7 @@ class ApiService {
|
|||||||
String empCode,
|
String empCode,
|
||||||
String branchID,
|
String branchID,
|
||||||
String client_policy_id) async {
|
String client_policy_id) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
_token = await token;
|
_token = await token;
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
@ -84,7 +86,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> fetchRelationshipListToApi() async {
|
Future<Map<String, dynamic>> fetchRelationshipListToApi() async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -103,7 +105,7 @@ class ApiService {
|
|||||||
String policy,
|
String policy,
|
||||||
String branchID,
|
String branchID,
|
||||||
login_by_hr) async {
|
login_by_hr) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -123,7 +125,7 @@ class ApiService {
|
|||||||
String policy,
|
String policy,
|
||||||
String branchID,
|
String branchID,
|
||||||
login_by_hr) async {
|
login_by_hr) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -138,7 +140,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getGmcSiTopUpToApi(
|
Future<Map<String, dynamic>> getGmcSiTopUpToApi(
|
||||||
String client_id, String emp_code, String policy, String branchID) async {
|
String client_id, String emp_code, String policy, String branchID) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -153,7 +155,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getGmcSiParentTopUpToApi(
|
Future<Map<String, dynamic>> getGmcSiParentTopUpToApi(
|
||||||
String client_id, String emp_code, String policy, String branchID) async {
|
String client_id, String emp_code, String policy, String branchID) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -168,7 +170,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getGmcDependentAddOnsToApi(
|
Future<Map<String, dynamic>> getGmcDependentAddOnsToApi(
|
||||||
String client_id, String emp_code, String policy, String branchID) async {
|
String client_id, String emp_code, String policy, String branchID) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -181,19 +183,18 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getExcelFileErrorsApi(id,type) async {
|
Future<Map<String, dynamic>> getExcelFileErrorsApi(id, type) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
final apiURL;
|
final apiURL;
|
||||||
if(type == 'post'){
|
if (type == 'post') {
|
||||||
apiURL = Environment.apiUrlPost;
|
apiURL = Environment.apiUrlPost;
|
||||||
} else {
|
} else {
|
||||||
apiURL = Environment.apiUrl;
|
apiURL = Environment.apiUrl;
|
||||||
}
|
}
|
||||||
final url = Uri.parse(
|
final url = Uri.parse('${apiURL}getExcelFileErrors/${id}/api');
|
||||||
'${apiURL}getExcelFileErrors/${id}/api');
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $_token' ?? '',
|
'Authorization': 'Bearer $_token' ?? '',
|
||||||
};
|
};
|
||||||
@ -203,7 +204,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> removeAddonsGmcDependentToAPI(
|
Future<Map<String, dynamic>> removeAddonsGmcDependentToAPI(
|
||||||
String empCodeString, String addOnsDependentClientPolicyId) async {
|
String empCodeString, String addOnsDependentClientPolicyId) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -218,7 +219,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> removeAddonsGmcSiToAPI(
|
Future<Map<String, dynamic>> removeAddonsGmcSiToAPI(
|
||||||
String empCodeString, String topUpClientPolicyId) async {
|
String empCodeString, String topUpClientPolicyId) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -233,7 +234,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> removeAddonsGmcParentSiToAPI(
|
Future<Map<String, dynamic>> removeAddonsGmcParentSiToAPI(
|
||||||
String empCodeString, String topUpParentClientPolicyId) async {
|
String empCodeString, String topUpParentClientPolicyId) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -247,7 +248,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> deleteItemToApi(id) async {
|
Future<Map<String, dynamic>> deleteItemToApi(id) async {
|
||||||
print(_token);
|
logDebug(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -261,7 +262,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> saveFamilyMemberDetailsToApi(
|
Future<Map<String, dynamic>> saveFamilyMemberDetailsToApi(
|
||||||
List<Map<String, dynamic>> formDataList) async {
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
print('saveFamilyMemberDetailsToApi API SERVICE');
|
logDebug('saveFamilyMemberDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -282,7 +283,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> saveAddOnsDetailsToApi(
|
Future<Map<String, dynamic>> saveAddOnsDetailsToApi(
|
||||||
List<Map<String, dynamic>> formDataList) async {
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
print('saveAddOnsDetailsToApi API SERVICE');
|
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -303,7 +304,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> sendAddonsGmcDependentToAPI(
|
Future<Map<String, dynamic>> sendAddonsGmcDependentToAPI(
|
||||||
List<Map<String, dynamic>> formDataList) async {
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
print('saveAddOnsDetailsToApi API SERVICE');
|
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -325,7 +326,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> sendAddonsGmcSiToAPI(
|
Future<Map<String, dynamic>> sendAddonsGmcSiToAPI(
|
||||||
List<Map<String, dynamic>> formDataList) async {
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
print('saveAddOnsDetailsToApi API SERVICE');
|
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -347,7 +348,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> sendAddonsGmcParentSiToAPI(
|
Future<Map<String, dynamic>> sendAddonsGmcParentSiToAPI(
|
||||||
List<Map<String, dynamic>> formDataList) async {
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
print('saveAddOnsDetailsToApi API SERVICE');
|
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -369,7 +370,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> sendAddOnToAPI(
|
Future<Map<String, dynamic>> sendAddOnToAPI(
|
||||||
Map<String, dynamic> formData) async {
|
Map<String, dynamic> formData) async {
|
||||||
print('sendAddOnToAPI API SERVICE');
|
logDebug('sendAddOnToAPI API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -389,7 +390,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> topUpSiCalculationToAPI(formDataList) async {
|
Future<Map<String, dynamic>> topUpSiCalculationToAPI(formDataList) async {
|
||||||
print('saveAddOnsDetailsToApi API SERVICE');
|
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -410,7 +411,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> topUpParentSiCalculationToAPI(
|
Future<Map<String, dynamic>> topUpParentSiCalculationToAPI(
|
||||||
formDataList) async {
|
formDataList) async {
|
||||||
print('saveAddOnsDetailsToApi API SERVICE');
|
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -431,7 +432,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> addOnsDependentCalculationToAPI(
|
Future<Map<String, dynamic>> addOnsDependentCalculationToAPI(
|
||||||
formDataList) async {
|
formDataList) async {
|
||||||
print('saveAddOnsDetailsToApi API SERVICE');
|
logDebug('saveAddOnsDetailsToApi API SERVICE');
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -454,8 +455,8 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getCashDepositDetailsToApi(
|
Future<Map<String, dynamic>> getCashDepositDetailsToApi(
|
||||||
String clintID, String empRefId, String hr_id, String token) async {
|
String clintID, String empRefId, String hr_id, String token) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
print("HRID- $hr_id");
|
logDebug("HRID- $hr_id");
|
||||||
|
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
@ -472,7 +473,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getActiveCashDepositDetailsToApi(String clintID,
|
Future<Map<String, dynamic>> getActiveCashDepositDetailsToApi(String clintID,
|
||||||
String empRefId, String hr_id, String token, int emp_status) async {
|
String empRefId, String hr_id, String token, int emp_status) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
|
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
@ -491,7 +492,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getCDPoliciesToApi(
|
Future<Map<String, dynamic>> getCDPoliciesToApi(
|
||||||
String clintID, String hr_id, String token) async {
|
String clintID, String hr_id, String token) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
final url = Uri.parse(
|
final url = Uri.parse(
|
||||||
'${Environment.apiUrlPost}cdSummaryData?client_id=$clintID&hr_id=$hr_id');
|
'${Environment.apiUrlPost}cdSummaryData?client_id=$clintID&hr_id=$hr_id');
|
||||||
|
|
||||||
@ -504,11 +505,11 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getImportLogHrActivity(
|
Future<Map<String, dynamic>> getImportLogHrActivity(
|
||||||
String? postId, String? preId, String token, String activity) async {
|
String? postId, String? preId, String token, String activity) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
|
|
||||||
print('postId1 - $postId');
|
logDebug('postId1 - $postId');
|
||||||
print('preId1 - $preId');
|
logDebug('preId1 - $preId');
|
||||||
print('activity1 - $activity');
|
logDebug('activity1 - $activity');
|
||||||
|
|
||||||
// final url = Uri.parse(
|
// final url = Uri.parse(
|
||||||
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
||||||
@ -517,7 +518,8 @@ class ApiService {
|
|||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer ${token ?? ''}',
|
'Authorization': 'Bearer ${token ?? ''}',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
final body = {
|
final body = {
|
||||||
@ -542,8 +544,8 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getEcardBulkDownloadApi(client_policy_id,empHrId,emp_policy_ids,String token) async {
|
Future<Map<String, dynamic>> getEcardBulkDownloadApi(
|
||||||
|
client_policy_id, empHrId, emp_policy_ids, String token) async {
|
||||||
// final url = Uri.parse(
|
// final url = Uri.parse(
|
||||||
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
||||||
|
|
||||||
@ -551,13 +553,14 @@ class ApiService {
|
|||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer ${token ?? ''}',
|
'Authorization': 'Bearer ${token ?? ''}',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
final body = {
|
final body = {
|
||||||
'client_policy_id': client_policy_id,
|
'client_policy_id': client_policy_id,
|
||||||
'hr_id': empHrId,
|
'hr_id': empHrId,
|
||||||
'emp_policy_ids':emp_policy_ids,
|
'emp_policy_ids': emp_policy_ids,
|
||||||
};
|
};
|
||||||
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
@ -577,11 +580,11 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getPostLogHrActivity(
|
Future<Map<String, dynamic>> getPostLogHrActivity(
|
||||||
String? postId, String? preId, String token, String activity) async {
|
String? postId, String? preId, String token, String activity) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
|
|
||||||
print('postId1 - $postId');
|
logDebug('postId1 - $postId');
|
||||||
print('preId1 - $preId');
|
logDebug('preId1 - $preId');
|
||||||
print('activity1 - $activity');
|
logDebug('activity1 - $activity');
|
||||||
|
|
||||||
// final url = Uri.parse(
|
// final url = Uri.parse(
|
||||||
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
||||||
@ -590,7 +593,8 @@ class ApiService {
|
|||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer ${token ?? ''}',
|
'Authorization': 'Bearer ${token ?? ''}',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
final body = {
|
final body = {
|
||||||
@ -617,17 +621,18 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getPreLogHrActivity(
|
Future<Map<String, dynamic>> getPreLogHrActivity(
|
||||||
String? postId, String? preId, String token, String activity) async {
|
String? postId, String? preId, String token, String activity) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
|
|
||||||
print('postId1 - $postId');
|
logDebug('postId1 - $postId');
|
||||||
print('preId1 - $preId');
|
logDebug('preId1 - $preId');
|
||||||
print('activity1 - $activity');
|
logDebug('activity1 - $activity');
|
||||||
|
|
||||||
final url = Uri.parse('${Environment.apiUrl}logHrActivity');
|
final url = Uri.parse('${Environment.apiUrl}logHrActivity');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer ${token ?? ''}',
|
'Authorization': 'Bearer ${token ?? ''}',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
final body = {
|
final body = {
|
||||||
@ -652,13 +657,13 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> postHrDashboard(params,token) async {
|
Future<Map<String, dynamic>> postHrDashboard(params, token) async {
|
||||||
|
|
||||||
final url = Uri.parse('${Environment.apiUrlPost}getHrDashboad');
|
final url = Uri.parse('${Environment.apiUrlPost}getHrDashboad');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer ${token ?? ''}',
|
'Authorization': 'Bearer ${token ?? ''}',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
final body = params;
|
final body = params;
|
||||||
@ -679,12 +684,12 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> postHrTpaDashboard(params, token) async {
|
Future<Map<String, dynamic>> postHrTpaDashboard(params, token) async {
|
||||||
|
|
||||||
final url = Uri.parse('${Environment.apiUrlPost}getHrTpaDashboard');
|
final url = Uri.parse('${Environment.apiUrlPost}getHrTpaDashboard');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer ${token ?? ''}',
|
'Authorization': 'Bearer ${token ?? ''}',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
@ -701,9 +706,11 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getClaimPoliciesToApi(String token,empClientId) async {
|
Future<Map<String, dynamic>> getClaimPoliciesToApi(
|
||||||
print("getgetClaimPoliciesToApii1");
|
String token, empClientId) async {
|
||||||
final url = Uri.parse('${Environment.apiUrlPost}claimsSearch?client_id=$empClientId');
|
logDebug("getgetClaimPoliciesToApii1");
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrlPost}claimsSearch?client_id=$empClientId');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $token' ?? '',
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
@ -712,7 +719,8 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getClaimPoliciesFileDownload(id,String token) async {
|
Future<Map<String, dynamic>> getClaimPoliciesFileDownload(
|
||||||
|
id, String token) async {
|
||||||
final url = Uri.parse('${Environment.apiUrlPost}hrFileDownload?id=$id');
|
final url = Uri.parse('${Environment.apiUrlPost}hrFileDownload?id=$id');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
@ -724,11 +732,12 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getClaimPoliciesListDataToApi(
|
Future<Map<String, dynamic>> getClaimPoliciesListDataToApi(
|
||||||
String token, Map<String, dynamic> body) async {
|
String token, Map<String, dynamic> body) async {
|
||||||
print("getgetClaimPoliciesToApii1");
|
logDebug("getgetClaimPoliciesToApii1");
|
||||||
final url = Uri.parse('${Environment.apiUrlPost}claimsSearch');
|
final url = Uri.parse('${Environment.apiUrlPost}claimsSearch');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'APP-SIGNATURE' :'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization': 'Bearer $token',
|
'Authorization': 'Bearer $token',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
};
|
};
|
||||||
@ -746,7 +755,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getEcardRequest(eCardParam,String token) async {
|
Future<Map<String, dynamic>> getEcardRequest(eCardParam, String token) async {
|
||||||
final url = Uri.parse('${Environment.apiUrlPost}ecardRequest');
|
final url = Uri.parse('${Environment.apiUrlPost}ecardRequest');
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $token' ?? '',
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
@ -754,13 +763,14 @@ class ApiService {
|
|||||||
};
|
};
|
||||||
final jsonBody = jsonEncode(eCardParam);
|
final jsonBody = jsonEncode(eCardParam);
|
||||||
// Send formDataJson as the body
|
// Send formDataJson as the body
|
||||||
final response = await _makePostRequestWithoutFormData(url,jsonBody, headers);
|
final response =
|
||||||
|
await _makePostRequestWithoutFormData(url, jsonBody, headers);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getCdTransactionData(
|
Future<Map<String, dynamic>> getCdTransactionData(
|
||||||
String clintID, String insurerId, String cd_ac_pk, String token) async {
|
String clintID, String insurerId, String cd_ac_pk, String token) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
final url = Uri.parse(
|
final url = Uri.parse(
|
||||||
'${Environment.apiUrlPost}cdTransactionData?client_id=$clintID&insurer_id=$insurerId&cd_ac_pk=$cd_ac_pk');
|
'${Environment.apiUrlPost}cdTransactionData?client_id=$clintID&insurer_id=$insurerId&cd_ac_pk=$cd_ac_pk');
|
||||||
|
|
||||||
@ -771,10 +781,11 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getOpenEndorsementFileData(id, String token) async {
|
Future<Map<String, dynamic>> getOpenEndorsementFileData(
|
||||||
print("getPolicyAndEndorsementFiles");
|
id, String token) async {
|
||||||
final url = Uri.parse(
|
logDebug("getPolicyAndEndorsementFiles");
|
||||||
'${Environment.apiUrlPost}downloadPolicyFiles?file_id=$id');
|
final url =
|
||||||
|
Uri.parse('${Environment.apiUrlPost}downloadPolicyFiles?file_id=$id');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $token' ?? '',
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
@ -784,7 +795,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getCdEndorsementData(id, String token) async {
|
Future<Map<String, dynamic>> getCdEndorsementData(id, String token) async {
|
||||||
print("getPolicyAndEndorsementFiles");
|
logDebug("getPolicyAndEndorsementFiles");
|
||||||
final url = Uri.parse(
|
final url = Uri.parse(
|
||||||
'${Environment.apiUrlPost}getPolicyAndEndorsementFiles?cd_ac_pk=$id');
|
'${Environment.apiUrlPost}getPolicyAndEndorsementFiles?cd_ac_pk=$id');
|
||||||
|
|
||||||
@ -797,7 +808,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getClaimsHistoryToApi(
|
Future<Map<String, dynamic>> getClaimsHistoryToApi(
|
||||||
String ticket_type_id, String token) async {
|
String ticket_type_id, String token) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
logDebug("getCashDepositDetailsToApi1");
|
||||||
final url = Uri.parse(
|
final url = Uri.parse(
|
||||||
'${Environment.apiUrlPost}claimView?ticket_id=$ticket_type_id');
|
'${Environment.apiUrlPost}claimView?ticket_id=$ticket_type_id');
|
||||||
|
|
||||||
@ -809,8 +820,8 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getSampleFileDownload(String token) async {
|
Future<Map<String, dynamic>> getSampleFileDownload(String token) async {
|
||||||
final url = Uri.parse(
|
final url =
|
||||||
'${Environment.apiUrl}downloadSampleExcel/enrollment');
|
Uri.parse('${Environment.apiUrl}downloadSampleExcel/enrollment');
|
||||||
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $token' ?? '',
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
@ -821,7 +832,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getEmployeeAndDependenceToApi(
|
Future<Map<String, dynamic>> getEmployeeAndDependenceToApi(
|
||||||
String clintID, getPolicyNo, String empRefId, String token) async {
|
String clintID, getPolicyNo, String empRefId, String token) async {
|
||||||
print(_hrtoken);
|
logDebug(_hrtoken);
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -835,12 +846,11 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getFileUploadMastersToApi(String token) async {
|
Future<Map<String, dynamic>> getFileUploadMastersToApi(String token) async {
|
||||||
print(_hrtoken);
|
logDebug(_hrtoken);
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
final url = Uri.parse(
|
final url = Uri.parse('${Environment.apiUrlPost}hrFileUploadMasters');
|
||||||
'${Environment.apiUrlPost}hrFileUploadMasters');
|
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $token' ?? '',
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
};
|
};
|
||||||
@ -848,13 +858,14 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getFileListToApi(empPrimaryId,cardPolicyNo,empClientId,String token,String type) async {
|
Future<Map<String, dynamic>> getFileListToApi(empPrimaryId, cardPolicyNo,
|
||||||
print(_hrtoken);
|
empClientId, String token, String type) async {
|
||||||
|
logDebug(_hrtoken);
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
final apiURL;
|
final apiURL;
|
||||||
if(type == 'post'){
|
if (type == 'post') {
|
||||||
apiURL = Environment.apiUrlPost;
|
apiURL = Environment.apiUrlPost;
|
||||||
} else {
|
} else {
|
||||||
apiURL = Environment.apiUrl;
|
apiURL = Environment.apiUrl;
|
||||||
@ -863,14 +874,15 @@ class ApiService {
|
|||||||
'${apiURL}hrFileList?created_by=$empPrimaryId&policy_no=$cardPolicyNo&client_id=$empClientId');
|
'${apiURL}hrFileList?created_by=$empPrimaryId&policy_no=$cardPolicyNo&client_id=$empClientId');
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer ${token ?? ''}',
|
'Authorization': 'Bearer ${token ?? ''}',
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
};
|
};
|
||||||
final response = await _makeGetRequest(url, headers);
|
final response = await _makeGetRequest(url, headers);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<Map<String, dynamic>> getHrFileDownloadToApi(id,String token) async {
|
// Future<Map<String, dynamic>> getHrFileDownloadToApi(id,String token) async {
|
||||||
// print(_hrtoken);
|
// logDebug(_hrtoken);
|
||||||
// if (token == null) {
|
// if (token == null) {
|
||||||
// await _initializeToken();
|
// await _initializeToken();
|
||||||
// }
|
// }
|
||||||
@ -885,7 +897,7 @@ class ApiService {
|
|||||||
|
|
||||||
Future<Map<String, dynamic>> getEmployeeAndDependenceToApiPre(
|
Future<Map<String, dynamic>> getEmployeeAndDependenceToApiPre(
|
||||||
String clintID, String getPolicyNo, String empRefId, String token) async {
|
String clintID, String getPolicyNo, String empRefId, String token) async {
|
||||||
print(_hrtoken);
|
logDebug(_hrtoken);
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
@ -981,11 +993,11 @@ class ApiService {
|
|||||||
// if (!isWeb) {
|
// if (!isWeb) {
|
||||||
await tokenService.clearAll();
|
await tokenService.clearAll();
|
||||||
|
|
||||||
print('Secure Storage Cleared');
|
logDebug('Secure Storage Cleared');
|
||||||
|
|
||||||
// }
|
// }
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
print('context.mounted');
|
logDebug('context.mounted');
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context,
|
context,
|
||||||
'hrLogin',
|
'hrLogin',
|
||||||
@ -994,25 +1006,26 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<Map<String, dynamic>> _makePostRequestWithoutFormData(
|
Future<Map<String, dynamic>> _makePostRequestWithoutFormData(
|
||||||
Uri url, String body, Map<String, String> headers) async {
|
Uri url, String body, Map<String, String> headers) async {
|
||||||
headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
headers['APP-SIGNATURE'] =
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
||||||
final response = await http.post(url, headers: headers, body: body);
|
final response = await http.post(url, headers: headers, body: body);
|
||||||
return _handleResponse(response);
|
return _handleResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> _makeGetRequest(
|
Future<Map<String, dynamic>> _makeGetRequest(
|
||||||
Uri url, Map<String, String> headers) async {
|
Uri url, Map<String, String> headers) async {
|
||||||
headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
headers['APP-SIGNATURE'] =
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
||||||
final response = await http.get(url, headers: headers);
|
final response = await http.get(url, headers: headers);
|
||||||
return _handleResponse(response);
|
return _handleResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> _makePostRequest(
|
Future<Map<String, dynamic>> _makePostRequest(
|
||||||
Uri url, String body, Map<String, String> headers) async {
|
Uri url, String body, Map<String, String> headers) async {
|
||||||
headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
headers['APP-SIGNATURE'] =
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
|
||||||
final response = await http.post(url, headers: headers, body: body);
|
final response = await http.post(url, headers: headers, body: body);
|
||||||
return _handleResponse(response);
|
return _handleResponse(response);
|
||||||
}
|
}
|
||||||
@ -1036,7 +1049,7 @@ class ApiService {
|
|||||||
await _clearLocalStorageAndRedirect();
|
await _clearLocalStorageAndRedirect();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}else if (response.statusCode == 451) {
|
} else if (response.statusCode == 451) {
|
||||||
final body = jsonDecode(response.body);
|
final body = jsonDecode(response.body);
|
||||||
final message = body['message'];
|
final message = body['message'];
|
||||||
ToastHelper.showWarningToast(context, message);
|
ToastHelper.showWarningToast(context, message);
|
||||||
@ -1062,5 +1075,4 @@ class ApiService {
|
|||||||
(route) => false,
|
(route) => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@
|
|||||||
// apiService = ApiService(context);
|
// apiService = ApiService(context);
|
||||||
// _loadData();
|
// _loadData();
|
||||||
//
|
//
|
||||||
// print("_PreEnrollmentState 1");
|
// logDebug("_PreEnrollmentState 1");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Future<void> _loadData() async {
|
// Future<void> _loadData() async {
|
||||||
@ -86,12 +86,12 @@
|
|||||||
//
|
//
|
||||||
// Future<void> getCashDepositDetails(
|
// Future<void> getCashDepositDetails(
|
||||||
// clintBranchId, clintID, hr_id, token) async {
|
// clintBranchId, clintID, hr_id, token) async {
|
||||||
// print("_PreEnrollmentState 2");
|
// logDebug("_PreEnrollmentState 2");
|
||||||
// print('IN');
|
// logDebug('IN');
|
||||||
// print("clintBranchId -$clintBranchId");
|
// logDebug("clintBranchId -$clintBranchId");
|
||||||
// print("clintID -$clintID");
|
// logDebug("clintID -$clintID");
|
||||||
// print("hr_id -$hr_id");
|
// logDebug("hr_id -$hr_id");
|
||||||
// print("token -$token");
|
// logDebug("token -$token");
|
||||||
//
|
//
|
||||||
// isLoading = true;
|
// isLoading = true;
|
||||||
// // setState(() {
|
// // setState(() {
|
||||||
@ -107,33 +107,33 @@
|
|||||||
//
|
//
|
||||||
// // final response = await apiService.getCashDepositDetailsToApi(
|
// // final response = await apiService.getCashDepositDetailsToApi(
|
||||||
// // clintID!, clintBranchId!, hr_id, token);
|
// // clintID!, clintBranchId!, hr_id, token);
|
||||||
// print('IN1');
|
// logDebug('IN1');
|
||||||
// if (response['status'] == 'success') {
|
// if (response['status'] == 'success') {
|
||||||
// isLoading = false;
|
// isLoading = false;
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// print('response');
|
// logDebug('response');
|
||||||
// print(response['data']);
|
// logDebug(response['data']);
|
||||||
//
|
//
|
||||||
// print("_PreEnrollmentState 3");
|
// logDebug("_PreEnrollmentState 3");
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
// getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// print('getCardArrays');
|
// logDebug('getCardArrays');
|
||||||
// print(getCardArrays);
|
// logDebug(getCardArrays);
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// print('IN2');
|
// logDebug('IN2');
|
||||||
// print("getCardArrays9 - $getCardArrays");
|
// logDebug("getCardArrays9 - $getCardArrays");
|
||||||
// } else {
|
// } else {
|
||||||
// isLoading = false;
|
// isLoading = false;
|
||||||
// print('API request failed with status');
|
// logDebug('API request failed with status');
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// getCardArrays = [];
|
// getCardArrays = [];
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
// print('Exception occurred: $e');
|
// logDebug('Exception occurred: $e');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -153,7 +153,7 @@
|
|||||||
// // Dynamic aspect ratio:
|
// // Dynamic aspect ratio:
|
||||||
// final aspectRatio = screenWidth / screenHeight;
|
// final aspectRatio = screenWidth / screenHeight;
|
||||||
//
|
//
|
||||||
// print("_PreEnrollmentState 4");
|
// logDebug("_PreEnrollmentState 4");
|
||||||
// // TODO: implement build
|
// // TODO: implement build
|
||||||
// return Container(
|
// return Container(
|
||||||
// // height: MediaQuery.of(context).size.height * 0.2,
|
// // height: MediaQuery.of(context).size.height * 0.2,
|
||||||
@ -260,18 +260,18 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Widget buildPolicyCard(Map<String, dynamic> policy) {
|
// Widget buildPolicyCard(Map<String, dynamic> policy) {
|
||||||
// print("buildPolicyCard - $policy");
|
// logDebug("buildPolicyCard - $policy");
|
||||||
// final mediaQuery = MediaQuery.of(context);
|
// final mediaQuery = MediaQuery.of(context);
|
||||||
// final devicePixelRatio = mediaQuery.devicePixelRatio;
|
// final devicePixelRatio = mediaQuery.devicePixelRatio;
|
||||||
// final logicalWidth = 230 / devicePixelRatio;
|
// final logicalWidth = 230 / devicePixelRatio;
|
||||||
// final logicalHeight = 115 / devicePixelRatio;
|
// final logicalHeight = 115 / devicePixelRatio;
|
||||||
//
|
//
|
||||||
// print("logicalWidth - $logicalWidth");
|
// logDebug("logicalWidth - $logicalWidth");
|
||||||
// print("logicalHeight - $logicalHeight");
|
// logDebug("logicalHeight - $logicalHeight");
|
||||||
// return InkWell(
|
// return InkWell(
|
||||||
// onTap: () {
|
// onTap: () {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// print("policytab - $policy");
|
// logDebug("policytab - $policy");
|
||||||
// Navigator.push(
|
// Navigator.push(
|
||||||
// context,
|
// context,
|
||||||
// MaterialPageRoute(
|
// MaterialPageRoute(
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import '../api_service.dart';
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
import '../token_storage_service.dart';
|
import '../token_storage_service.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class CdPolicies extends StatefulWidget {
|
class CdPolicies extends StatefulWidget {
|
||||||
final String empClientId;
|
final String empClientId;
|
||||||
@ -85,12 +86,12 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getCDPoliciesDetails() async {
|
Future<void> getCDPoliciesDetails() async {
|
||||||
print('9');
|
logDebug('9');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final response = await apiService.getCDPoliciesToApi(
|
final response = await apiService.getCDPoliciesToApi(
|
||||||
widget.empClientId, widget.empHrId, widget.postToken);
|
widget.empClientId, widget.empHrId, widget.postToken);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
@ -101,8 +102,8 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
getCDPolicies = List<Map<String, dynamic>>.from(response['data']);
|
getCDPolicies = List<Map<String, dynamic>>.from(response['data']);
|
||||||
originalData = getCDPolicies;
|
originalData = getCDPolicies;
|
||||||
filteredData = List.from(originalData);
|
filteredData = List.from(originalData);
|
||||||
print('filteredData');
|
logDebug('filteredData');
|
||||||
print(filteredData);
|
logDebug(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -111,13 +112,13 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@ -126,7 +127,7 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void search(String query) {
|
void search(String query) {
|
||||||
print(query);
|
logDebug(query);
|
||||||
// Check if the query is empty
|
// Check if the query is empty
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
// If search query is empty, show all data
|
// If search query is empty, show all data
|
||||||
@ -155,7 +156,7 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
print(filteredData.length);
|
logDebug(filteredData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exportToCsv(List<Map<String, dynamic>> data) {
|
void exportToCsv(List<Map<String, dynamic>> data) {
|
||||||
@ -188,29 +189,29 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleExportAction() async {
|
Future<void> handleExportAction() async {
|
||||||
print('handleExportAction');
|
logDebug('handleExportAction');
|
||||||
|
|
||||||
final postId = await tokenService.readValue('empHrId');
|
final postId = await tokenService.readValue('empHrId');
|
||||||
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
final preId = await tokenService.readValue('enrollmentEmpPrimaryId');
|
||||||
var activity = "export_cddata";
|
var activity = "export_cddata";
|
||||||
|
|
||||||
print('postId - $postId');
|
logDebug('postId - $postId');
|
||||||
print('preId - $preId');
|
logDebug('preId - $preId');
|
||||||
print('activity - $activity');
|
logDebug('activity - $activity');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print('10');
|
logDebug('10');
|
||||||
final response = await apiService.getPostLogHrActivity(
|
final response = await apiService.getPostLogHrActivity(
|
||||||
postId!, preId!, widget.postToken, activity);
|
postId!, preId!, widget.postToken, activity);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('Request success');
|
logDebug('Request success');
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
logDebug('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +556,8 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
Widget _buildPagination(BuildContext context) {
|
Widget _buildPagination(BuildContext context) {
|
||||||
// 1. Calculate the range of entries being shown
|
// 1. Calculate the range of entries being shown
|
||||||
final totalItems = filteredData.length;
|
final totalItems = filteredData.length;
|
||||||
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
final int startEntry =
|
||||||
|
totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
|
||||||
int endEntry = _currentPage * _rowsPerPage;
|
int endEntry = _currentPage * _rowsPerPage;
|
||||||
if (endEntry > totalItems) endEntry = totalItems;
|
if (endEntry > totalItems) endEntry = totalItems;
|
||||||
|
|
||||||
@ -586,7 +588,6 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
_currentPage + 1,
|
_currentPage + 1,
|
||||||
_currentPage + 2,
|
_currentPage + 2,
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> visiblePages = getVisiblePages();
|
List<int> visiblePages = getVisiblePages();
|
||||||
@ -595,7 +596,8 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
// Match this horizontal padding (16) to your Table Header padding for perfect alignment
|
// Match this horizontal padding (16) to your Table Header padding for perfect alignment
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Pushes text to left, buttons to right
|
mainAxisAlignment: MainAxisAlignment
|
||||||
|
.spaceBetween, // Pushes text to left, buttons to right
|
||||||
children: [
|
children: [
|
||||||
// --- LEFT SIDE: Showing Text ---
|
// --- LEFT SIDE: Showing Text ---
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@ -75,7 +75,7 @@
|
|||||||
// apiService = ApiService(context);
|
// apiService = ApiService(context);
|
||||||
// _loadData();
|
// _loadData();
|
||||||
//
|
//
|
||||||
// print("_PreEnrollmentState 1");
|
// logDebug("_PreEnrollmentState 1");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Future<void> _loadData() async {
|
// Future<void> _loadData() async {
|
||||||
@ -85,12 +85,12 @@
|
|||||||
//
|
//
|
||||||
// Future<void> getCashDepositDetails(
|
// Future<void> getCashDepositDetails(
|
||||||
// clintBranchId, clintID, hr_id, token) async {
|
// clintBranchId, clintID, hr_id, token) async {
|
||||||
// print("_PreEnrollmentState 2");
|
// logDebug("_PreEnrollmentState 2");
|
||||||
// print('IN');
|
// logDebug('IN');
|
||||||
// print("clintBranchId -$clintBranchId");
|
// logDebug("clintBranchId -$clintBranchId");
|
||||||
// print("clintID -$clintID");
|
// logDebug("clintID -$clintID");
|
||||||
// print("hr_id -$hr_id");
|
// logDebug("hr_id -$hr_id");
|
||||||
// print("token -$token");
|
// logDebug("token -$token");
|
||||||
//
|
//
|
||||||
// // isLoading = true;
|
// // isLoading = true;
|
||||||
// setState(() {
|
// setState(() {
|
||||||
@ -105,32 +105,32 @@
|
|||||||
//
|
//
|
||||||
// // final response = await apiService.getCashDepositDetailsToApi(
|
// // final response = await apiService.getCashDepositDetailsToApi(
|
||||||
// // clintID!, clintBranchId!, hr_id, token);
|
// // clintID!, clintBranchId!, hr_id, token);
|
||||||
// print('IN1');
|
// logDebug('IN1');
|
||||||
// if (response['status'] == 'success') {
|
// if (response['status'] == 'success') {
|
||||||
//
|
//
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// isLoading = false;
|
// isLoading = false;
|
||||||
// print('response');
|
// logDebug('response');
|
||||||
// print(response['data']);
|
// logDebug(response['data']);
|
||||||
//
|
//
|
||||||
// print("_PreEnrollmentState 3");
|
// logDebug("_PreEnrollmentState 3");
|
||||||
// // getCardArrays = [];
|
// // getCardArrays = [];
|
||||||
// getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
// getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
||||||
// print('getCardArrays');
|
// logDebug('getCardArrays');
|
||||||
// print(getCardArrays);
|
// logDebug(getCardArrays);
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// print('IN2');
|
// logDebug('IN2');
|
||||||
// print("getCardArrays9 - $getCardArrays");
|
// logDebug("getCardArrays9 - $getCardArrays");
|
||||||
// } else {
|
// } else {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// isLoading = false;
|
// isLoading = false;
|
||||||
// });
|
// });
|
||||||
//
|
//
|
||||||
// print('API request failed with status');
|
// logDebug('API request failed with status');
|
||||||
// }
|
// }
|
||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
// print('Exception occurred: $e');
|
// logDebug('Exception occurred: $e');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -150,7 +150,7 @@
|
|||||||
// // Dynamic aspect ratio:
|
// // Dynamic aspect ratio:
|
||||||
// final aspectRatio = screenWidth / screenHeight;
|
// final aspectRatio = screenWidth / screenHeight;
|
||||||
//
|
//
|
||||||
// print("_PreEnrollmentState 4");
|
// logDebug("_PreEnrollmentState 4");
|
||||||
// // TODO: implement build
|
// // TODO: implement build
|
||||||
// return Container(
|
// return Container(
|
||||||
// // height: MediaQuery.of(context).size.height * 0.2,
|
// // height: MediaQuery.of(context).size.height * 0.2,
|
||||||
@ -237,12 +237,12 @@
|
|||||||
// final logicalWidth = 230 / devicePixelRatio;
|
// final logicalWidth = 230 / devicePixelRatio;
|
||||||
// final logicalHeight = 189 / devicePixelRatio;
|
// final logicalHeight = 189 / devicePixelRatio;
|
||||||
//
|
//
|
||||||
// print("logicalWidth - $logicalWidth");
|
// logDebug("logicalWidth - $logicalWidth");
|
||||||
// print("logicalHeight - $logicalHeight");
|
// logDebug("logicalHeight - $logicalHeight");
|
||||||
// return InkWell(
|
// return InkWell(
|
||||||
// onTap: () {
|
// onTap: () {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// print("policytab - $policy");
|
// logDebug("policytab - $policy");
|
||||||
// Navigator.push(
|
// Navigator.push(
|
||||||
// context,
|
// context,
|
||||||
// MaterialPageRoute(
|
// MaterialPageRoute(
|
||||||
|
|||||||
@ -19,7 +19,8 @@ class _MultiFileUploadWidgetState extends State<MultiFileUploadWidget> {
|
|||||||
String? errorMessage;
|
String? errorMessage;
|
||||||
|
|
||||||
void _pickFiles() async {
|
void _pickFiles() async {
|
||||||
final error = await fileService.pickFiles(maxFileSizeInMB: 10); // 5 MB limit
|
final error =
|
||||||
|
await fileService.pickFiles(maxFileSizeInMB: 10); // 5 MB limit
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -177,7 +178,6 @@ class _MultiFileUploadWidgetState extends State<MultiFileUploadWidget> {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
],
|
],
|
||||||
|
|
||||||
if (MultiFileUploadWidget.showValidation &&
|
if (MultiFileUploadWidget.showValidation &&
|
||||||
fileService.files.isEmpty &&
|
fileService.files.isEmpty &&
|
||||||
errorMessage == null) ...[
|
errorMessage == null) ...[
|
||||||
@ -187,7 +187,6 @@ class _MultiFileUploadWidgetState extends State<MultiFileUploadWidget> {
|
|||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
if (errorMessage != null) ...[
|
if (errorMessage != null) ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
@ -195,7 +194,6 @@ class _MultiFileUploadWidgetState extends State<MultiFileUploadWidget> {
|
|||||||
style: const TextStyle(color: Colors.red, fontSize: 12),
|
style: const TextStyle(color: Colors.red, fontSize: 12),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
...fileService.files.asMap().entries.map((entry) {
|
...fileService.files.asMap().entries.map((entry) {
|
||||||
final index = entry.key;
|
final index = entry.key;
|
||||||
@ -207,7 +205,8 @@ class _MultiFileUploadWidgetState extends State<MultiFileUploadWidget> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
title: Text(uploaded.file.name, style: const TextStyle(fontSize: 14)),
|
title: Text(uploaded.file.name,
|
||||||
|
style: const TextStyle(fontSize: 14)),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: const Icon(Icons.close, color: Colors.red),
|
icon: const Icon(Icons.close, color: Colors.red),
|
||||||
tooltip: 'Remove', // Built-in property
|
tooltip: 'Remove', // Built-in property
|
||||||
@ -215,7 +214,8 @@ class _MultiFileUploadWidgetState extends State<MultiFileUploadWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0, bottom: 8.0, right: 8.0),
|
padding:
|
||||||
|
const EdgeInsets.only(left: 8.0, bottom: 8.0, right: 8.0),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: uploaded.controller,
|
controller: uploaded.controller,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
|
|||||||
@ -38,7 +38,6 @@ class SvgService {
|
|||||||
</svg>
|
</svg>
|
||||||
''';
|
''';
|
||||||
|
|
||||||
|
|
||||||
static String getSvg(String svgName) {
|
static String getSvg(String svgName) {
|
||||||
switch (svgName) {
|
switch (svgName) {
|
||||||
case 'dashboard':
|
case 'dashboard':
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class TokenStorageService {
|
class TokenStorageService {
|
||||||
static final TokenStorageService _instance =
|
static final TokenStorageService _instance = TokenStorageService._internal();
|
||||||
TokenStorageService._internal();
|
|
||||||
factory TokenStorageService() => _instance;
|
factory TokenStorageService() => _instance;
|
||||||
TokenStorageService._internal();
|
TokenStorageService._internal();
|
||||||
|
|
||||||
// 🔐 Secure storage instance
|
// 🔐 Secure storage instance
|
||||||
static const FlutterSecureStorage _secureStorage =
|
static const FlutterSecureStorage _secureStorage = FlutterSecureStorage();
|
||||||
FlutterSecureStorage();
|
|
||||||
|
|
||||||
// Storage keys
|
// Storage keys
|
||||||
static const String _preEnrollmentKey = 'pre_enrollment_data';
|
static const String _preEnrollmentKey = 'pre_enrollment_data';
|
||||||
@ -37,14 +36,12 @@ class TokenStorageService {
|
|||||||
_postEnrollmentData = json.decode(postData);
|
_postEnrollmentData = json.decode(postData);
|
||||||
}
|
}
|
||||||
|
|
||||||
final branchData =
|
final branchData = await _secureStorage.read(key: _selectedBranchKey);
|
||||||
await _secureStorage.read(key: _selectedBranchKey);
|
|
||||||
if (branchData != null) {
|
if (branchData != null) {
|
||||||
_selectedBranch = json.decode(branchData);
|
_selectedBranch = json.decode(branchData);
|
||||||
}
|
}
|
||||||
|
|
||||||
final tokenData =
|
final tokenData = await _secureStorage.read(key: _decodedTokenKey);
|
||||||
await _secureStorage.read(key: _decodedTokenKey);
|
|
||||||
if (tokenData != null) {
|
if (tokenData != null) {
|
||||||
_decodedToken = json.decode(tokenData);
|
_decodedToken = json.decode(tokenData);
|
||||||
}
|
}
|
||||||
@ -71,8 +68,7 @@ class TokenStorageService {
|
|||||||
|
|
||||||
// Helper: check valid token
|
// Helper: check valid token
|
||||||
bool hasValidToken(dynamic token) {
|
bool hasValidToken(dynamic token) {
|
||||||
return token != null &&
|
return token != null && token.toString().trim().isNotEmpty;
|
||||||
token.toString().trim().isNotEmpty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add pre-enrollment data
|
// Add pre-enrollment data
|
||||||
@ -83,7 +79,8 @@ class TokenStorageService {
|
|||||||
// ❌ SKIP if token is empty or null
|
// ❌ SKIP if token is empty or null
|
||||||
if (!hasValidToken(token)) continue;
|
if (!hasValidToken(token)) continue;
|
||||||
|
|
||||||
String uniqueId = '${item['id']}_${item['client_id']}_${item['client_branch_id']}';
|
String uniqueId =
|
||||||
|
'${item['id']}_${item['client_id']}_${item['client_branch_id']}';
|
||||||
|
|
||||||
if (seenIds.contains(uniqueId)) continue;
|
if (seenIds.contains(uniqueId)) continue;
|
||||||
if (token.isNotEmpty && seenTokens.contains(token)) continue;
|
if (token.isNotEmpty && seenTokens.contains(token)) continue;
|
||||||
@ -103,7 +100,8 @@ class TokenStorageService {
|
|||||||
// ❌ SKIP if token is empty or null
|
// ❌ SKIP if token is empty or null
|
||||||
if (!hasValidToken(token)) continue;
|
if (!hasValidToken(token)) continue;
|
||||||
|
|
||||||
String uniqueId = '${item['id']}_${item['client_id']}_${item['client_branch_id']}';
|
String uniqueId =
|
||||||
|
'${item['id']}_${item['client_id']}_${item['client_branch_id']}';
|
||||||
|
|
||||||
if (seenIds.contains(uniqueId)) continue;
|
if (seenIds.contains(uniqueId)) continue;
|
||||||
if (token.isNotEmpty && seenTokens.contains(token)) continue;
|
if (token.isNotEmpty && seenTokens.contains(token)) continue;
|
||||||
@ -119,8 +117,7 @@ class TokenStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 🌿 Save selected branch + decode JWT
|
// 🌿 Save selected branch + decode JWT
|
||||||
Future<void> saveSelectedBranch(
|
Future<void> saveSelectedBranch(Map<String, dynamic> branch) async {
|
||||||
Map<String, dynamic> branch) async {
|
|
||||||
_selectedBranch = branch;
|
_selectedBranch = branch;
|
||||||
|
|
||||||
String token = branch['token']?.toString() ?? '';
|
String token = branch['token']?.toString() ?? '';
|
||||||
@ -131,8 +128,7 @@ class TokenStorageService {
|
|||||||
|
|
||||||
if (_decodedToken != null) {
|
if (_decodedToken != null) {
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
key: _decodedTokenKey,
|
key: _decodedTokenKey, value: json.encode(_decodedToken));
|
||||||
value: json.encode(_decodedToken));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
@ -152,7 +148,7 @@ class TokenStorageService {
|
|||||||
|
|
||||||
return json.decode(decoded);
|
return json.decode(decoded);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('JWT decode error: $e');
|
logDebug('JWT decode error: $e');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,16 +188,13 @@ class TokenStorageService {
|
|||||||
value: decodedToken['post_branch_id']?.toString());
|
value: decodedToken['post_branch_id']?.toString());
|
||||||
|
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
key: 'empPrimaryId',
|
key: 'empPrimaryId', value: decodedToken['post_hr_id']?.toString());
|
||||||
value: decodedToken['post_hr_id']?.toString());
|
|
||||||
|
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
key: 'empClientId',
|
key: 'empClientId', value: decodedToken['post_client_id']?.toString());
|
||||||
value: decodedToken['post_client_id']?.toString());
|
|
||||||
|
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
key: 'empHrId',
|
key: 'empHrId', value: decodedToken['post_hr_id']?.toString());
|
||||||
value: decodedToken['post_hr_id']?.toString());
|
|
||||||
|
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
key: 'empAllowed_modules',
|
key: 'empAllowed_modules',
|
||||||
@ -222,8 +215,7 @@ class TokenStorageService {
|
|||||||
value: decodedToken['pre_client_id']?.toString());
|
value: decodedToken['pre_client_id']?.toString());
|
||||||
|
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
key: 'enrollmentHrId',
|
key: 'enrollmentHrId', value: decodedToken['pre_hr_id']?.toString());
|
||||||
value: decodedToken['pre_hr_id']?.toString());
|
|
||||||
|
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
key: 'enrollmentAllowed_modules',
|
key: 'enrollmentAllowed_modules',
|
||||||
@ -291,5 +283,4 @@ class TokenStorageService {
|
|||||||
// 4️⃣ Update in-memory cache
|
// 4️⃣ Update in-memory cache
|
||||||
_selectedBranch = newBranch;
|
_selectedBranch = newBranch;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import 'package:jwt_decode/jwt_decode.dart';
|
|||||||
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
||||||
|
|
||||||
import 'config/environment.dart';
|
import 'config/environment.dart';
|
||||||
|
import 'package:nhancepolicy/logger.dart';
|
||||||
|
|
||||||
class MyVerify extends StatefulWidget {
|
class MyVerify extends StatefulWidget {
|
||||||
final String verificationId;
|
final String verificationId;
|
||||||
@ -59,8 +60,8 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
// Start the timer when the widget is initialized
|
// Start the timer when the widget is initialized
|
||||||
verificationId = widget.verificationId;
|
verificationId = widget.verificationId;
|
||||||
mobileNumber = widget.mobileNumber;
|
mobileNumber = widget.mobileNumber;
|
||||||
print('Received verificationId: $verificationId');
|
logDebug('Received verificationId: $verificationId');
|
||||||
print('Received mobileNumber: $mobileNumber');
|
logDebug('Received mobileNumber: $mobileNumber');
|
||||||
if (verificationId.isEmpty) {
|
if (verificationId.isEmpty) {
|
||||||
// Handle the case where verificationId is not provided
|
// Handle the case where verificationId is not provided
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@ -100,7 +101,7 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> resendOTP(String mobileNumber) async {
|
Future<void> resendOTP(String mobileNumber) async {
|
||||||
print(mobileNumber);
|
logDebug(mobileNumber);
|
||||||
// Update the UI as needed
|
// Update the UI as needed
|
||||||
setState(() {
|
setState(() {
|
||||||
_secondsRemaining = 30;
|
_secondsRemaining = 30;
|
||||||
@ -112,7 +113,8 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'),
|
Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'),
|
||||||
body: json.encode({'mobile_number': mobileNumber}),
|
body: json.encode({'mobile_number': mobileNumber}),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -127,7 +129,7 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle API call errors
|
// Handle API call errors
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'Failed to resend OTP. Please try again.');
|
context, 'Failed to resend OTP. Please try again.');
|
||||||
}
|
}
|
||||||
@ -144,24 +146,25 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
'otp_verification': otpVerifyStatus
|
'otp_verification': otpVerifyStatus
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
Map<String, dynamic> data = json.decode(response.body);
|
||||||
print(data);
|
logDebug(data);
|
||||||
_token = data['data'];
|
_token = data['data'];
|
||||||
String status = data['status'];
|
String status = data['status'];
|
||||||
print(status);
|
logDebug(status);
|
||||||
if (status == 'success') {
|
if (status == 'success') {
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.setString('token', data['data']);
|
prefs.setString('token', data['data']);
|
||||||
|
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
print(decodedToken);
|
logDebug(decodedToken);
|
||||||
empClientBranchId = decodedToken['client_branch_id'];
|
empClientBranchId = decodedToken['client_branch_id'];
|
||||||
prefs.setString('empClientBranchId', empClientBranchId);
|
prefs.setString('empClientBranchId', empClientBranchId);
|
||||||
empCodeString = decodedToken['emp_code'].toString();
|
empCodeString = decodedToken['emp_code'].toString();
|
||||||
@ -175,7 +178,7 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
|
|
||||||
getClientLogoAndDetails();
|
getClientLogoAndDetails();
|
||||||
|
|
||||||
print('Successfully Login');
|
logDebug('Successfully Login');
|
||||||
|
|
||||||
// Redirect to another page
|
// Redirect to another page
|
||||||
final token = prefs.getString('token');
|
final token = prefs.getString('token');
|
||||||
@ -193,19 +196,19 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
||||||
// Show a Snackbar if the OTP is invalid
|
// Show a Snackbar if the OTP is invalid
|
||||||
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
|
||||||
print('Invalid OTP. Please try again');
|
logDebug('Invalid OTP. Please try again');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
throw Exception('Failed to verify OTP');
|
throw Exception('Failed to verify OTP');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
// Show a Snackbar if there's an error while verifying OTP
|
// Show a Snackbar if there's an error while verifying OTP
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Failed to verify OTP. Please try again.');
|
// context, 'Failed to verify OTP. Please try again.');
|
||||||
print('Failed to verify OTP. Please try again.');
|
logDebug('Failed to verify OTP. Please try again.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +241,7 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
print('Error: $e');
|
logDebug('Error: $e');
|
||||||
ToastHelper.showErrorToast(
|
ToastHelper.showErrorToast(
|
||||||
context, 'Failed to verify OTP. Please try again.');
|
context, 'Failed to verify OTP. Please try again.');
|
||||||
}
|
}
|
||||||
@ -260,15 +263,16 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
'APP-SIGNATURE':
|
||||||
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
'Bearer $_token', // Add token to the Authorization header
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
// print('response.statusCode == 200');
|
// logDebug('response.statusCode == 200');
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
Map<String, dynamic> data = json.decode(response.body);
|
||||||
// print(data);
|
// logDebug(data);
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
if (data.containsKey('data')) {
|
||||||
dynamic clientDetails = data['data'];
|
dynamic clientDetails = data['data'];
|
||||||
@ -277,27 +281,27 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
prefs.setString('clientName', clientDetails['client']['client_name']);
|
prefs.setString('clientName', clientDetails['client']['client_name']);
|
||||||
setState(() {
|
setState(() {
|
||||||
// dynamic clientDetails = data['data'];
|
// dynamic clientDetails = data['data'];
|
||||||
// print(clientDetails);
|
// logDebug(clientDetails);
|
||||||
clientName = clientDetails['client']['client_name'];
|
clientName = clientDetails['client']['client_name'];
|
||||||
print(clientName);
|
logDebug(clientName);
|
||||||
clientLogo = clientDetails['client']['client_logo'];
|
clientLogo = clientDetails['client']['client_logo'];
|
||||||
print(clientLogo);
|
logDebug(clientLogo);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// 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 {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
logDebug('Request failed with status: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
print('Exception occurred: $e');
|
logDebug('Exception occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user