api status code added

This commit is contained in:
Surendiran 2026-03-16 14:32:47 +05:30
parent 511a671c06
commit c7d8b9504e
11 changed files with 1027 additions and 791 deletions

View File

@ -116,12 +116,43 @@ class _changesPasswordState extends State<changesPassword> {
ToastHelper.showErrorToast(context, message!);
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 {
setState(() {
_isLoading = false;
});
ToastHelper.showErrorToast(context, 'Something went wrong');
throw Exception('Failed to verify mobile number');
throw Exception('Failed to load data');
}
}
} catch (e) {

View File

@ -268,13 +268,18 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
String status = data['status'];
// 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');
_postToken = postToken;
String postStatus = post['status'];
if (postStatus == 'success') {
if (post != null && post['status'] == 'success') {
setState(() {
_isOtpVerified = true; // LOCK
});
@ -291,11 +296,43 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
// Show a Snackbar if the OTP is invalid
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 {
final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.clear();
ToastHelper.showWarningToast(context, 'Something went wrong');
throw Exception('Failed to verify OTP');
setState(() {
_isLoading = false;
});
throw Exception('Failed to load data');
}
} catch (e) {
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,7 +949,7 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
MainAxisAlignment.center,
children: [
if (!Responsive.isMobile(context) &&
!Responsive.isTablet(context))
!Responsive.isTablet(context))...[
Row(
children: [
Expanded(
@ -980,6 +981,8 @@ class _MyEmailVerifyState extends State<MyEmailVerify> {
],
),
SizedBox(height: 10),
],
// SizedBox(
// height: Responsive.isDesktop(context)
// ? _size.height * 0.1

View File

@ -503,10 +503,15 @@ class ApiService {
if (response.statusCode == 200) {
return jsonDecode(response.body);
} else if (response.statusCode == 401) {
if (!_isSessionOutToastShown) {
_isSessionOutToastShown = true;
await _clearLocalStorageAndRedirect();
}
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) {
final body = jsonDecode(response.body);

View File

@ -172,9 +172,35 @@ class _loginState extends State<login> {
final SharedPreferences prefs = await SharedPreferences.getInstance();
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 {
ToastHelper.showErrorToast(context, 'Something went wrong');
throw Exception('Failed to verify pin number');
setState(() {
_isLoading = false;
});
throw Exception('Failed to load data');
}
} catch (e) {
// ToastHelper.showErrorToast(context, 'Something went wrong');
@ -1072,43 +1098,6 @@ class _loginState extends State<login> {
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
),
],
),
),
),
),
],
),
],

View File

@ -1262,8 +1262,8 @@ class _claimsState extends State<claims> {
message:
claimsSubject, // Full text shown on hover
child: Text(
claimsSubject.length > 30
? '${claimsSubject.substring(0, 30)}...'
claimsSubject.length > 20
? '${claimsSubject.substring(0, 20)}...'
: claimsSubject,
textAlign: TextAlign.left,
style: GoogleFonts.poppins(

View File

@ -80,6 +80,11 @@ class _planclaimsformState extends State<planclaimsform> {
final fileService = FileUploadService();
bool isSubmitting = false;
Map<String, dynamic> claimTypeMap = {};
List<Map<String, dynamic>> claimTypeList = [];
int? claimTypeId;
bool isClaimTypeValid = true;
// Declare subjectController and bodyController as instance variables
late TextEditingController subjectController;
@ -206,6 +211,7 @@ class _planclaimsformState extends State<planclaimsform> {
print('fromClaimsPage $fromClaimsPage');
}
if (fromClaimsPage == 0) {
setState(() {
claimSubject = claimsDetails['claim_subject'];
print('claimSubject $claimSubject');
claimsDepartmentId = claimsDetails['ticket_type_id'];
@ -216,6 +222,9 @@ class _planclaimsformState extends State<planclaimsform> {
print('claimsDepartmentId $claimsDepartmentId');
claimsPolicyNo = claimsDetails['policy_no'];
client_policy_id = claimsDetails['client_policy_id'];
print('Current Client ID : ${client_policy_id}');
});
// employeePolicyList = claimsDetails['EmployeePolicy'];
// print('employeePolicyList : $employeePolicyList');
List<dynamic> empList = claimsDetails['EmployeePolicy'];
@ -367,11 +376,23 @@ class _planclaimsformState extends State<planclaimsform> {
// 'private': department['private'],
};
}).toList();
claimTypeMap = Map<String, dynamic>.from(response['claim_type']);
isLoading = false;
});
// AUTO SELECT SERVICE = 1 (GMC)
if (fromClaimsPage == 1 && departmentList.isNotEmpty) {
serviceId = 1;
loadClaimTypes(serviceId);
}
if (fromClaimsPage == 0) {
setInitialServiceId(departmentList);
loadClaimTypes(claimsDepartmentId);
}
// if (fromClaimsPage == 0) {
// setInitialServiceId(departmentList);
// }
} else {
throw Exception('Failed to fetch department list');
}
@ -380,6 +401,35 @@ class _planclaimsformState extends State<planclaimsform> {
}
}
void loadClaimTypes(int? serviceId) {
if (serviceId == null) return;
String key = serviceId.toString();
if (claimTypeMap.containsKey(key)) {
Map<String, dynamic> types =
Map<String, dynamic>.from(claimTypeMap[key]);
claimTypeList = types.entries.map((entry) {
return {
'id': int.parse(entry.key),
'name': entry.value,
};
}).toList();
// // AUTO SELECT FIRST CLAIM TYPE
// if (claimTypeList.isNotEmpty) {
// claimTypeId = claimTypeList.first['id'];
// }
setState(() {});
} else {
claimTypeList = [];
claimTypeId = null;
setState(() {});
}
}
void fetchPoliciesBasedOnService(int? serviceId) {
if (policyList.isEmpty) {
print('Policy list is empty. Ensure data is fetched before filtering.');
@ -388,7 +438,7 @@ class _planclaimsformState extends State<planclaimsform> {
setState(() {
policyNumberId = null;
policyTypeCondition = null;
client_policy_id = null;
// client_policy_id = null;
});
print('1111 serviceId : $serviceId');
if (serviceId == 1 || serviceId == 2 || serviceId == 3 || serviceId == 4 || serviceId == 72) {
@ -445,7 +495,7 @@ class _planclaimsformState extends State<planclaimsform> {
});
policyTypeCondition = filteredPolicies[0]['ticket_type_id'];
client_policy_id = filteredPolicies[0]['client_policy_id'];
// client_policy_id = filteredPolicies[0]['client_policy_id'];
print('Output : $policyTypeCondition'); // Output: GMC
});
} else {
@ -496,7 +546,7 @@ class _planclaimsformState extends State<planclaimsform> {
print('Filtered matching policy_no: $filteredPoliciesList');
client_policy_id = filteredPoliciesList[0]['client_policy_id'];
// client_policy_id = filteredPoliciesList[0]['client_policy_id'];
subjectController.text = filteredPoliciesList[0]['claim_subject'];
@ -554,6 +604,7 @@ class _planclaimsformState extends State<planclaimsform> {
isHospitalPincodeValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || hospitalPinCodeController.text.trim().isNotEmpty;
isHospitalPhoneNoValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || hospitalPhoneNoController.text.trim().isNotEmpty;
// isAdmitDischargeValid = policyTypeCondition != 1 || (admitDate != null && dischargeDate != null);
isClaimTypeValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || claimTypeId != null;
isAdmitDateValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || admitDate != null;
isDischargeDateValid = (policyTypeCondition != 1 && policyTypeCondition != 72) || dischargeDate != null;
isClaimAmountValid = serviceId != 1 || claimAmountController.text.trim().isNotEmpty;
@ -562,6 +613,7 @@ class _planclaimsformState extends State<planclaimsform> {
});
if (isServiceValid &&
isClaimTypeValid &&
isPolicyValid &&
isMemberValid &&
isSubjectValid &&
@ -627,6 +679,7 @@ class _planclaimsformState extends State<planclaimsform> {
if (policyTypeCondition == 1 || policyTypeCondition == 72) {
String formattedAdmitDate = DateFormat('yyyy-MM-dd').format(admitDate!);
String formattedDischargeDate = DateFormat('yyyy-MM-dd').format(dischargeDate!);
fields['claim_type'] = claimTypeId;
fields['hospital_name'] = hospitalNameController.text;
fields['hospital_address'] = hospitalAddressController.text;
fields['hospital_city'] = hospitalCityController.text;
@ -662,6 +715,7 @@ class _planclaimsformState extends State<planclaimsform> {
request.headers['Authorization'] = 'Bearer $_token';
request.headers['APP-SIGNATURE'] = 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y';
final stringFields = fields.map((key, value) => MapEntry(key, value?.toString() ?? ''));
print("📁 stringFields: ${stringFields}");
request.fields.addAll(stringFields);
// get uploaded files
@ -1034,10 +1088,12 @@ class _planclaimsformState extends State<planclaimsform> {
orElse: () => {'name': ''},
)['name'];
policyNumberId = null;
loadClaimTypes(serviceId); // LOAD CLAIM TYPES
isServiceValid = true;
if (fromClaimsPage == 1) {
fetchPoliciesBasedOnService(serviceId);
}
isServiceValid = true;
});
},
fromClaimsPage == 0,
@ -1109,6 +1165,33 @@ class _planclaimsformState extends State<planclaimsform> {
],
),
SizedBox(height: 15),
if (policyTypeCondition == 1 || policyTypeCondition == 72)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildDropdownField(
'Select Claim Type',
(value) {
setState(() {
claimTypeId = value;
isClaimTypeValid = true;
});
},
false,
claimTypeList,
'name',
claimTypeId,
),
if (!isClaimTypeValid)
Text(
'Please select a claim type',
style: TextStyle(color: Colors.red),
),
],
),
// // if (fromClaimsPage == 1)
// buildDropdownField(
// 'Select Policy',
@ -1169,7 +1252,7 @@ class _planclaimsformState extends State<planclaimsform> {
Text('Please select a member', style: TextStyle(color: Colors.red)),
],
),
SizedBox(height: 15),
SizedBox(height: 15),
// buildDropdownField(
// 'Member Name',
// (value) {

View File

@ -25,7 +25,8 @@ class ApiService {
String? empCode,
String? status,
String? branchID,
String? mobileNo,String? emailId) async {
String? mobileNo,
String? emailId) async {
print(_postToken);
if (_postToken == null) {
await _initializeToken();
@ -61,7 +62,8 @@ class ApiService {
if (_postToken == null) {
await _initializeToken();
}
final url = Uri.parse('${Environment.apiUrl}getAdvertisementImage?client_id=$clientID');
final url = Uri.parse(
'${Environment.apiUrl}getAdvertisementImage?client_id=$clientID');
final headers = {
'Authorization': 'Bearer $_postToken' ?? '',
};
@ -110,7 +112,8 @@ class ApiService {
return response;
}
Future<Map<String, dynamic>> getTrackClaimsList(String empPrimaryId,mobileNo,emailID) async {
Future<Map<String, dynamic>> getTrackClaimsList(
String empPrimaryId, mobileNo, emailID) async {
print(_postToken);
if (_postToken == null) {
await _initializeToken();
@ -158,12 +161,14 @@ class ApiService {
return response;
}
Future<Map<String, dynamic>> getWellnessLink(empPrimaryId,client_policy_id) async {
Future<Map<String, dynamic>> getWellnessLink(
empPrimaryId, client_policy_id) async {
print(_postToken);
if (_postToken == null) {
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 headers = {
'Authorization': 'Bearer $_postToken' ?? '',
@ -184,7 +189,8 @@ class ApiService {
};
final jsonBody = jsonEncode(eCardParam);
// Send formDataJson as the body
final response = await _makePostRequestWithoutFormData(url,jsonBody, headers);
final response =
await _makePostRequestWithoutFormData(url, jsonBody, headers);
return response;
}
@ -200,7 +206,8 @@ class ApiService {
};
final jsonBody = jsonEncode(formData);
// Send formDataJson as the body
final response = await _makePostRequestWithoutFormData(url,jsonBody, headers);
final response =
await _makePostRequestWithoutFormData(url, jsonBody, headers);
return response;
}
@ -227,7 +234,6 @@ class ApiService {
return response['status'] == 'success';
}
Future<Map<String, dynamic>> fetchPolicyTypeAndInsurer() async {
print(_postToken);
if (_postToken == null) {
@ -241,12 +247,14 @@ class ApiService {
return response;
}
Future<Map<String, dynamic>> fetchDepartmentList(String clientId, String empCode) async {
Future<Map<String, dynamic>> fetchDepartmentList(
String clientId, String empCode) async {
print(_postToken);
if (_postToken == null) {
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 = {
'Authorization': 'Bearer $_postToken' ?? '',
};
@ -378,7 +386,8 @@ class ApiService {
Future<Map<String, dynamic>> _makeGetRequest(
Uri url, Map<String, String> headers) async {
// 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);
return _handleResponse(response);
}
@ -386,7 +395,8 @@ class ApiService {
Future<Map<String, dynamic>> _makePostRequest(
Uri url, Map<String, String> body, Map<String, String> headers) async {
// 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);
return _handleResponse(response);
}
@ -394,18 +404,26 @@ class ApiService {
Future<Map<String, dynamic>> _makePostRequestWithoutFormData(
Uri url, String body, Map<String, String> headers) async {
// 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);
return _handleResponse(response);
}
Future<Map<String, dynamic>> _handleResponse(http.Response response) async {
if (response.statusCode == 200) {
return jsonDecode(response.body);
} else if (response.statusCode == 401) {
await _clearLocalStorageAndRedirect();
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) {
final body = jsonDecode(response.body);
final message = body['message'];

View File

@ -207,10 +207,28 @@
ToastHelper.showErrorToast(context, 'Invalid Pin Number');
print('Invalid Pin Number');
}
} else {
ToastHelper.showErrorToast(context, 'Something went wrong');
} else if (response.statusCode == 401) {
await SessionManager().clear();
ToastHelper.showErrorToast(context, 'Session Out');
if (!context.mounted) return;
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) {
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 {
ToastHelper.showErrorToast(context, 'Something went wrong');
throw Exception('Failed to verify pin number');
throw Exception('Failed to load data');
}
} catch (e) {
// ToastHelper.showErrorToast(context, 'Something went wrong');
@ -580,6 +617,7 @@
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [

View File

@ -12,6 +12,7 @@ import '../../config/environment.dart';
import '../../customAppBar/responsive.dart';
import '../../customAppBar/toastHelper.dart';
import '../postEnrollment/service/svg_service.dart';
import '../service/SessionManager.dart';
import 'authenticationService.dart';
class changePin extends StatefulWidget {
@ -107,11 +108,28 @@ class _changePinState extends State<changePin> {
ToastHelper.showErrorToast(context, message);
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 {
Map<String, dynamic> data = json.decode(response.body);
String message = data['data']['message'];
ToastHelper.showErrorToast(context, message);
throw Exception('Failed to verify mobile number');
throw Exception('Failed to load data');
}
}
} catch (e) {

View File

@ -166,9 +166,28 @@ class _pinSettingPageState extends State<pinSettingPage> {
ToastHelper.showErrorToast(context, message);
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 {
ToastHelper.showErrorToast(context, 'Something went wrong');
throw Exception('Failed to verify mobile number');
throw Exception('Failed to load data');
}
// }
} catch (e) {
@ -319,6 +338,7 @@ class _pinSettingPageState extends State<pinSettingPage> {
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [

View File

@ -110,12 +110,43 @@ class _setPasswordState extends State<setPassword> {
ToastHelper.showErrorToast(context, message!);
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 {
setState(() {
_isLoading = false;
});
ToastHelper.showErrorToast(context, 'Something went wrong');
throw Exception('Failed to verify mobile number');
throw Exception('Failed to load data');
}
}
} catch (e) {