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