api status code added
This commit is contained in:
parent
511a671c06
commit
c7d8b9504e
@ -116,12 +116,43 @@ class _changesPasswordState extends State<changesPassword> {
|
|||||||
ToastHelper.showErrorToast(context, message!);
|
ToastHelper.showErrorToast(context, message!);
|
||||||
print('Invalid mobile number');
|
print('Invalid mobile number');
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
throw Exception('Failed to load data');
|
||||||
throw Exception('Failed to verify mobile number');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -268,13 +268,18 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
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;
|
||||||
|
|
||||||
|
if (data['post_enrollment'] != null &&
|
||||||
|
data['post_enrollment'] is Map<String, dynamic>) {
|
||||||
|
post = data['post_enrollment'];
|
||||||
|
}
|
||||||
|
|
||||||
print('post: $post');
|
print('post: $post');
|
||||||
|
|
||||||
_postToken = postToken;
|
_postToken = postToken;
|
||||||
String postStatus = post['status'];
|
|
||||||
|
|
||||||
if (postStatus == 'success') {
|
if (post != null && post['status'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isOtpVerified = true; // ✅ LOCK
|
_isOtpVerified = true; // ✅ LOCK
|
||||||
});
|
});
|
||||||
@ -291,11 +296,43 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
// Show a Snackbar if the OTP is invalid
|
// Show a Snackbar if the OTP is invalid
|
||||||
print('OTP verification failed. Please try again.');
|
print('OTP verification failed. Please try again.');
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
setState(() {
|
||||||
prefs.clear();
|
_isLoading = false;
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
});
|
||||||
throw Exception('Failed to verify OTP');
|
throw Exception('Failed to load data');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
@ -882,42 +919,6 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!Responsive.isMobile(context) &&
|
|
||||||
!Responsive.isTablet(context))
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
context.go('/hrLogin');
|
|
||||||
// Navigator.pushNamed(
|
|
||||||
// context, 'hrLogin');
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment
|
|
||||||
.end, // Align to the end (right)
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'HR Login',
|
|
||||||
style: GoogleFonts.poppins(
|
|
||||||
color: Color(
|
|
||||||
0xFF000000), // Text color
|
|
||||||
// Add other text styles as needed
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 5),
|
|
||||||
Icon(
|
|
||||||
Icons
|
|
||||||
.east, // Icon for customer login
|
|
||||||
color: Colors
|
|
||||||
.black, // Adjust color as needed
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -948,38 +949,40 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
|
|||||||
MainAxisAlignment.center,
|
MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (!Responsive.isMobile(context) &&
|
if (!Responsive.isMobile(context) &&
|
||||||
!Responsive.isTablet(context))
|
!Responsive.isTablet(context))...[
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 10,
|
flex: 10,
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Responsive
|
alignment: Responsive
|
||||||
.isDesktop(context)
|
.isDesktop(context)
|
||||||
? Alignment.center
|
? Alignment.center
|
||||||
: Alignment
|
: Alignment
|
||||||
.bottomCenter, // Align to the start
|
.bottomCenter, // Align to the start
|
||||||
child: _size.width <= 1100
|
child: _size.width <= 1100
|
||||||
? Image.asset(
|
? Image.asset(
|
||||||
'assets/nhance_app_logo.png',
|
'assets/nhance_app_logo.png',
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
)
|
)
|
||||||
: _size.width > 1100
|
: _size.width > 1100
|
||||||
? Image.asset(
|
? Image.asset(
|
||||||
'assets/nhance_app_logo.png',
|
'assets/nhance_app_logo.png',
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
)
|
)
|
||||||
: Image.asset(
|
: Image.asset(
|
||||||
'assets/nhance_app_logo.png',
|
'assets/nhance_app_logo.png',
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
|
],
|
||||||
|
|
||||||
// SizedBox(
|
// SizedBox(
|
||||||
// height: Responsive.isDesktop(context)
|
// height: Responsive.isDesktop(context)
|
||||||
// ? _size.height * 0.1
|
// ? _size.height * 0.1
|
||||||
|
|||||||
@ -503,13 +503,18 @@ class ApiService {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return jsonDecode(response.body);
|
return jsonDecode(response.body);
|
||||||
} else if (response.statusCode == 401) {
|
} else if (response.statusCode == 401) {
|
||||||
if (!_isSessionOutToastShown) {
|
await _clearLocalStorageAndRedirect();
|
||||||
_isSessionOutToastShown = true;
|
return {};
|
||||||
await _clearLocalStorageAndRedirect();
|
} else if (response.statusCode == 403) {
|
||||||
}
|
await _clearLocalStorageAndRedirect();
|
||||||
|
return {};
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
return {};
|
return {};
|
||||||
} else if (response.statusCode == 429) {
|
} else if (response.statusCode == 429) {
|
||||||
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);
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@ -172,9 +172,35 @@ class _loginState extends State<login> {
|
|||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.clear();
|
prefs.clear();
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
setState(() {
|
||||||
throw Exception('Failed to verify pin number');
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
throw Exception('Failed to load data');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
@ -1072,43 +1098,6 @@ class _loginState extends State<login> {
|
|||||||
height: 100,
|
height: 100,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
if (!Responsive.isMobile(context) &&
|
|
||||||
!Responsive.isTablet(context))
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
// Add your navigation logic here
|
|
||||||
// For example, you can use Navigator.push to navigate to another page
|
|
||||||
Navigator.pushNamed(
|
|
||||||
context, 'hrLogin');
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment
|
|
||||||
.end, // Align to the end (right)
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'HR Login',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Color(
|
|
||||||
0xFF000000), // Text color
|
|
||||||
// Add other text styles as needed
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 5),
|
|
||||||
Icon(
|
|
||||||
Icons
|
|
||||||
.east, // Icon for customer login
|
|
||||||
color: Colors
|
|
||||||
.black, // Adjust color as needed
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1262,8 +1262,8 @@ class _claimsState extends State<claims> {
|
|||||||
message:
|
message:
|
||||||
claimsSubject, // Full text shown on hover
|
claimsSubject, // Full text shown on hover
|
||||||
child: Text(
|
child: Text(
|
||||||
claimsSubject.length > 30
|
claimsSubject.length > 20
|
||||||
? '${claimsSubject.substring(0, 30)}...'
|
? '${claimsSubject.substring(0, 20)}...'
|
||||||
: claimsSubject,
|
: claimsSubject,
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initializeToken() async {
|
Future<void> _initializeToken() async {
|
||||||
_postToken = await TokenService.getPostToken();
|
_postToken = await TokenService.getPostToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getActiveAndInactivePolicyDetails(
|
Future<Map<String, dynamic>> getActiveAndInactivePolicyDetails(
|
||||||
@ -25,7 +25,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 {
|
||||||
print(_postToken);
|
print(_postToken);
|
||||||
if (_postToken == null) {
|
if (_postToken == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
@ -61,7 +62,8 @@ class ApiService {
|
|||||||
if (_postToken == null) {
|
if (_postToken == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
final url = Uri.parse('${Environment.apiUrl}getAdvertisementImage?client_id=$clientID');
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getAdvertisementImage?client_id=$clientID');
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $_postToken' ?? '',
|
'Authorization': 'Bearer $_postToken' ?? '',
|
||||||
};
|
};
|
||||||
@ -110,7 +112,8 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getTrackClaimsList(String empPrimaryId,mobileNo,emailID) async {
|
Future<Map<String, dynamic>> getTrackClaimsList(
|
||||||
|
String empPrimaryId, mobileNo, emailID) async {
|
||||||
print(_postToken);
|
print(_postToken);
|
||||||
if (_postToken == null) {
|
if (_postToken == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
@ -158,12 +161,14 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getWellnessLink(empPrimaryId,client_policy_id) async {
|
Future<Map<String, dynamic>> getWellnessLink(
|
||||||
|
empPrimaryId, client_policy_id) async {
|
||||||
print(_postToken);
|
print(_postToken);
|
||||||
if (_postToken == null) {
|
if (_postToken == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
final url = Uri.parse('${Environment.apiUrl}getWellnessURL?emp_id=$empPrimaryId');
|
final url =
|
||||||
|
Uri.parse('${Environment.apiUrl}getWellnessURL?emp_id=$empPrimaryId');
|
||||||
// final url = Uri.parse('${Environment.apiUrl}getWellnessURL?emp_id=$empPrimaryId&client_policy_id=$client_policy_id');
|
// final url = Uri.parse('${Environment.apiUrl}getWellnessURL?emp_id=$empPrimaryId&client_policy_id=$client_policy_id');
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $_postToken' ?? '',
|
'Authorization': 'Bearer $_postToken' ?? '',
|
||||||
@ -184,7 +189,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +206,8 @@ class ApiService {
|
|||||||
};
|
};
|
||||||
final jsonBody = jsonEncode(formData);
|
final jsonBody = jsonEncode(formData);
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +234,6 @@ class ApiService {
|
|||||||
return response['status'] == 'success';
|
return response['status'] == 'success';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<Map<String, dynamic>> fetchPolicyTypeAndInsurer() async {
|
Future<Map<String, dynamic>> fetchPolicyTypeAndInsurer() async {
|
||||||
print(_postToken);
|
print(_postToken);
|
||||||
if (_postToken == null) {
|
if (_postToken == null) {
|
||||||
@ -241,12 +247,14 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> fetchDepartmentList(String clientId, String empCode) async {
|
Future<Map<String, dynamic>> fetchDepartmentList(
|
||||||
|
String clientId, String empCode) async {
|
||||||
print(_postToken);
|
print(_postToken);
|
||||||
if (_postToken == null) {
|
if (_postToken == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
final url = Uri.parse('${Environment.apiUrl}get_ticket_type?client_id=$clientId&emp_code=$empCode');
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}get_ticket_type?client_id=$clientId&emp_code=$empCode');
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Bearer $_postToken' ?? '',
|
'Authorization': 'Bearer $_postToken' ?? '',
|
||||||
};
|
};
|
||||||
@ -378,7 +386,8 @@ class ApiService {
|
|||||||
Future<Map<String, dynamic>> _makeGetRequest(
|
Future<Map<String, dynamic>> _makeGetRequest(
|
||||||
Uri url, Map<String, String> headers) async {
|
Uri url, Map<String, String> headers) async {
|
||||||
// Add global APP_SIGNATURE header
|
// Add global APP_SIGNATURE header
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -386,7 +395,8 @@ class ApiService {
|
|||||||
Future<Map<String, dynamic>> _makePostRequest(
|
Future<Map<String, dynamic>> _makePostRequest(
|
||||||
Uri url, Map<String, String> body, Map<String, String> headers) async {
|
Uri url, Map<String, String> body, Map<String, String> headers) async {
|
||||||
// Add global APP_SIGNATURE header
|
// Add global APP_SIGNATURE header
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -394,20 +404,28 @@ 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 {
|
||||||
// Add global APP_SIGNATURE header
|
// Add global APP_SIGNATURE header
|
||||||
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>> _handleResponse(http.Response response) async {
|
Future<Map<String, dynamic>> _handleResponse(http.Response response) async {
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return jsonDecode(response.body);
|
return jsonDecode(response.body);
|
||||||
} else if (response.statusCode == 401) {
|
} else if (response.statusCode == 401) {
|
||||||
await _clearLocalStorageAndRedirect();
|
await _clearLocalStorageAndRedirect();
|
||||||
return {};
|
return {};
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
await _clearLocalStorageAndRedirect();
|
||||||
|
return {};
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
return {};
|
||||||
} else if (response.statusCode == 429) {
|
} else if (response.statusCode == 429) {
|
||||||
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);
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@ -207,10 +207,28 @@
|
|||||||
ToastHelper.showErrorToast(context, 'Invalid Pin Number');
|
ToastHelper.showErrorToast(context, 'Invalid Pin Number');
|
||||||
print('Invalid Pin Number');
|
print('Invalid Pin Number');
|
||||||
}
|
}
|
||||||
} else {
|
} else if (response.statusCode == 401) {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
context.go('/login');
|
context.go('/login');
|
||||||
throw Exception('Failed to verify pin number');
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load data');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
@ -425,9 +443,28 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
throw Exception('Failed to load data');
|
||||||
throw Exception('Failed to verify pin number');
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
@ -580,6 +617,7 @@
|
|||||||
child: Column(
|
child: Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import '../../config/environment.dart';
|
|||||||
import '../../customAppBar/responsive.dart';
|
import '../../customAppBar/responsive.dart';
|
||||||
import '../../customAppBar/toastHelper.dart';
|
import '../../customAppBar/toastHelper.dart';
|
||||||
import '../postEnrollment/service/svg_service.dart';
|
import '../postEnrollment/service/svg_service.dart';
|
||||||
|
import '../service/SessionManager.dart';
|
||||||
import 'authenticationService.dart';
|
import 'authenticationService.dart';
|
||||||
|
|
||||||
class changePin extends StatefulWidget {
|
class changePin extends StatefulWidget {
|
||||||
@ -107,11 +108,28 @@ class _changePinState extends State<changePin> {
|
|||||||
ToastHelper.showErrorToast(context, message);
|
ToastHelper.showErrorToast(context, message);
|
||||||
print('Invalid Pin Number');
|
print('Invalid Pin Number');
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
throw Exception('Failed to load data');
|
||||||
String message = data['data']['message'];
|
|
||||||
ToastHelper.showErrorToast(context, message);
|
|
||||||
throw Exception('Failed to verify mobile number');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -166,9 +166,28 @@ class _pinSettingPageState extends State<pinSettingPage> {
|
|||||||
ToastHelper.showErrorToast(context, message);
|
ToastHelper.showErrorToast(context, message);
|
||||||
print('Invalid Pin Number');
|
print('Invalid Pin Number');
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
throw Exception('Failed to load data');
|
||||||
throw Exception('Failed to verify mobile number');
|
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -319,6 +338,7 @@ class _pinSettingPageState extends State<pinSettingPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -110,12 +110,43 @@ class _setPasswordState extends State<setPassword> {
|
|||||||
ToastHelper.showErrorToast(context, message!);
|
ToastHelper.showErrorToast(context, message!);
|
||||||
print('Invalid mobile number');
|
print('Invalid mobile number');
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
await SessionManager().clear();
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go('/login');
|
||||||
|
|
||||||
|
} else if (response.statusCode == 451) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
|
} else if (response.statusCode == 429) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
final body = jsonDecode(response.body);
|
||||||
|
final message = body['message'];
|
||||||
|
ToastHelper.showWarningToast(context, message);
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
throw Exception('Failed to load data');
|
||||||
throw Exception('Failed to verify mobile number');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user