CHANGE_ : hr flow
This commit is contained in:
parent
962cbce784
commit
aca3d32f44
@ -14,7 +14,8 @@ class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
}
|
||||
|
||||
class _CustomAppBarState extends State<CustomAppBar> {
|
||||
bool showBackToHR = true;
|
||||
bool showBackToHR = false;
|
||||
// bool isLoading = true; // Add a loading state
|
||||
// bool hideInactiveStatus = true;
|
||||
|
||||
@override
|
||||
@ -27,10 +28,15 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final String? hrtoken = prefs.getString('hrtoken');
|
||||
final String? token = prefs.getString('token');
|
||||
// showBackToHR = prefs.getBool('showBackToHR')!;
|
||||
|
||||
setState(() {
|
||||
showBackToHR = (hrtoken != null && hrtoken.isNotEmpty) &&
|
||||
(token != null && token.isNotEmpty);
|
||||
showBackToHR = prefs.getBool('showBackToHR')!;
|
||||
// showBackToHR = (hrtoken != null && hrtoken.isNotEmpty) &&
|
||||
// (token != null && token.isNotEmpty);
|
||||
// print((hrtoken != null && hrtoken.isNotEmpty));
|
||||
// print((token != null && token.isNotEmpty));
|
||||
// print('showBackToHR $showBackToHR');
|
||||
|
||||
// hideInactiveStatus = token != null && token.isNotEmpty;
|
||||
});
|
||||
@ -41,6 +47,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
final String? hrtoken = prefs.getString('hrtoken');
|
||||
|
||||
if (hrtoken != null && hrtoken.isNotEmpty) {
|
||||
prefs.setBool('showBackToHR', false);
|
||||
prefs.remove('token');
|
||||
Navigator.pushNamed(context, 'hrDashboard');
|
||||
} else {
|
||||
@ -71,7 +78,12 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sw = MediaQuery.of(context).size.width;
|
||||
|
||||
// if (isLoading) {
|
||||
// // Show a loading indicator or a placeholder AppBar while waiting
|
||||
// return AppBar(
|
||||
// title: Text('Loading...'),
|
||||
// );
|
||||
// }
|
||||
return Scaffold(
|
||||
backgroundColor: Color(0xFFFFFCE5), // Set background color for AppBar
|
||||
appBar: PreferredSize(
|
||||
|
||||
@ -125,18 +125,19 @@ class _empDetailsState extends State<empDetails> {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.containsKey('hrtoken')) {
|
||||
String? getHrToken = prefs.getString('hrtoken');
|
||||
String? empID = prefs.getString('employee_id');
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(getHrToken!);
|
||||
print(decodedToken);
|
||||
hrPrimaryId = decodedToken['id'];
|
||||
print('hrPrimaryId');
|
||||
print(hrPrimaryId);
|
||||
_hrLoadToken();
|
||||
_hrLoadToken(empID);
|
||||
} else {
|
||||
_loadToken();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _hrLoadToken() async {
|
||||
Future<void> _hrLoadToken(empID) async {
|
||||
print('_hrLoadToken');
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString('fromHrLoginMobileNo', mobileNumber);
|
||||
@ -148,8 +149,9 @@ class _empDetailsState extends State<empDetails> {
|
||||
Uri.parse(Environment.apiUrl + 'getVerifiedUserData'),
|
||||
body: json.encode({
|
||||
'mobile_number': mobileNumber,
|
||||
'otp': 0,
|
||||
'login_by_hr': login_by_hr
|
||||
'otp_verification': 0,
|
||||
'login_by_hr': login_by_hr,
|
||||
'employee_id': empID
|
||||
}),
|
||||
headers: {
|
||||
HttpHeaders.contentTypeHeader: 'application/json',
|
||||
@ -165,11 +167,13 @@ class _empDetailsState extends State<empDetails> {
|
||||
if (status == 'success') {
|
||||
print(status);
|
||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString('token', data['data']);
|
||||
setState(() {
|
||||
prefs.setString('token', data['data']);
|
||||
});
|
||||
|
||||
// Decode the JWT token received from the API response
|
||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||
print(decodedToken);
|
||||
print('decodedTokenssss $decodedToken');
|
||||
empClientBranchId = decodedToken['client_branch_id'];
|
||||
prefs.setString('empClientBranchId', empClientBranchId);
|
||||
print(empClientBranchId);
|
||||
@ -186,9 +190,10 @@ class _empDetailsState extends State<empDetails> {
|
||||
|
||||
// Redirect to another page
|
||||
final token = prefs.getString('token');
|
||||
print('final $token');
|
||||
if (token != null && token.isNotEmpty) {
|
||||
// ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||
getSelfEmployeeProfile();
|
||||
await getSelfEmployeeProfile(token);
|
||||
if (prefs.containsKey('clientLogo') &&
|
||||
prefs.containsKey('clientName')) {
|
||||
clientLogo = prefs.getString('clientLogo');
|
||||
@ -196,8 +201,8 @@ class _empDetailsState extends State<empDetails> {
|
||||
} else {
|
||||
getClientLogoAndDetails();
|
||||
}
|
||||
getGpaEmpPolicyDetails(empPrimaryId);
|
||||
getGmcEmpPolicyDetails(empPrimaryId);
|
||||
await getGpaEmpPolicyDetails(empPrimaryId);
|
||||
await getGmcEmpPolicyDetails(empPrimaryId);
|
||||
fetchRelationshipList();
|
||||
// Navigator.pushReplacementNamed(context, 'empDetails',
|
||||
// arguments: {'mobile': ''});
|
||||
@ -248,7 +253,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
|
||||
// print(empPrimaryId);
|
||||
// Call the API when the page enters
|
||||
getSelfEmployeeProfile();
|
||||
getSelfEmployeeProfile('');
|
||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||
clientLogo = prefs.getString('clientLogo');
|
||||
clientName = prefs.getString('clientName');
|
||||
@ -309,7 +314,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getSelfEmployeeProfile() async {
|
||||
Future<void> getSelfEmployeeProfile(token) async {
|
||||
try {
|
||||
if (client_id == null ||
|
||||
empCodeString == null ||
|
||||
@ -317,7 +322,7 @@ class _empDetailsState extends State<empDetails> {
|
||||
return;
|
||||
}
|
||||
final response = await apiService.getSelfEmployeeProfileToApi(
|
||||
client_id!, empCodeString!, empClientBranchId!);
|
||||
token, client_id!, empCodeString!, empClientBranchId!);
|
||||
|
||||
if (response['status'] == 'success') {
|
||||
if (response.containsKey('data')) {
|
||||
|
||||
@ -745,8 +745,18 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
color: Color(0xFFE26728),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.popAndPushNamed(context, 'empDetails');
|
||||
onPressed: () async {
|
||||
final SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
final String? fromHrLoginMobileNo =
|
||||
prefs.getString('fromHrLoginMobileNo');
|
||||
if (fromHrLoginMobileNo != null &&
|
||||
fromHrLoginMobileNo.isNotEmpty) {
|
||||
Navigator.pushNamed(context, 'empDetails',
|
||||
arguments: {'mobile': fromHrLoginMobileNo});
|
||||
} else {
|
||||
Navigator.popAndPushNamed(context, 'empDetails');
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -106,7 +106,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
String int_inception_type = argumentsData['inception_type'];
|
||||
inceptionType = int.parse(int_inception_type);
|
||||
getEmployeeAndDependence(clientId, clientPolicyId);
|
||||
} else if (argumentsData['type'] == 'SI TopUp') {
|
||||
} else if (argumentsData['type'] == 'GMC - Parents') {
|
||||
_isLoading = true;
|
||||
clientPolicyId = argumentsData['client_policy_id'];
|
||||
clientId = argumentsData['client_id'];
|
||||
@ -115,7 +115,16 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
String int_inception_type = argumentsData['inception_type'];
|
||||
inceptionType = int.parse(int_inception_type);
|
||||
getEmployeeAndDependence(clientId, clientPolicyId);
|
||||
} else if (argumentsData['type'] == 'Dependent AddOn') {
|
||||
} else if (argumentsData['type'] == 'GMC - Topup') {
|
||||
_isLoading = true;
|
||||
clientPolicyId = argumentsData['client_policy_id'];
|
||||
clientId = argumentsData['client_id'];
|
||||
policyType = argumentsData['type'];
|
||||
policyName = argumentsData['policy_name'];
|
||||
String int_inception_type = argumentsData['inception_type'];
|
||||
inceptionType = int.parse(int_inception_type);
|
||||
getEmployeeAndDependence(clientId, clientPolicyId);
|
||||
} else if (argumentsData['type'] == 'GMC - Topup(Parents)') {
|
||||
_isLoading = true;
|
||||
clientPolicyId = argumentsData['client_policy_id'];
|
||||
clientId = argumentsData['client_id'];
|
||||
@ -818,8 +827,11 @@ class _DependenceDataSource0 extends DataTableSource {
|
||||
@override
|
||||
int get selectedRowCount => 0;
|
||||
|
||||
void _navigateToAnotherPage(row) {
|
||||
void _navigateToAnotherPage(row) async {
|
||||
print(row['mobile']);
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
prefs.setBool('showBackToHR', true);
|
||||
prefs.setString('employee_id', row['employee_id']);
|
||||
// Navigation logic here
|
||||
Navigator.pushNamed(context, 'empDetails',
|
||||
arguments: {'mobile': row['mobile']});
|
||||
|
||||
@ -39,8 +39,9 @@ class ApiService {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getSelfEmployeeProfileToApi(
|
||||
String clientId, String empCode, String branchID) async {
|
||||
token, String clientId, String empCode, String branchID) async {
|
||||
print(_token);
|
||||
_token = await token;
|
||||
if (_token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user