region and access_management ui

This commit is contained in:
mohammad
2024-08-12 15:23:45 +03:00
parent cb0ebcca37
commit 3f1fdf4f93
3 changed files with 287 additions and 249 deletions

View File

@ -45,33 +45,38 @@ class AuthenticationAPI {
"regionUuid": regionUuid
},
showServerMessage: true,
options: Options(),
expectedResponseModel: (json) {
Map<String, dynamic> parsedJson = jsonDecode(json);
int cooldown = parsedJson['data']['cooldown'];
debugPrint('Cooldown: $cooldown seconds');
return cooldown;
return 30;
}
);
return response;
return 30;
} on DioError catch (e) {
if (e.response != null) {
if (e.response!.statusCode == 400) {
// Handle 400 Bad Request
final errorData = e.response!.data;
String errorMessage = errorData['message'] ?? 'Unknown error';
int cooldown = errorData['data']['cooldown'] ?? 0;
return cooldown;
String errorMessage = errorData['message'];
debugPrint('Unexpected Error: $errorMessage');
if(errorMessage=='User not found'){
return 1;
}else{
int cooldown = errorData['data']['cooldown'] ?? 1;
return cooldown;
}
} else {
debugPrint('Error: ${e.response!.statusCode} - ${e.response!.statusMessage}');
return 1;
}
} else {
debugPrint('Error: ${e.message}');
return 1;
}
return null;
return 1;
} catch (e) {
debugPrint('Unexpected Error: $e');
return null;
return 1;
}
}
@ -79,7 +84,7 @@ class AuthenticationAPI {
{required String email, required String otpCode}) async {
final response = await HTTPService().post(
path: ApiEndpoints.verifyOtp,
body: {"email": email, "type": "VERIFICATION", "otpCode": otpCode},
body: {"email": email, "type": "PASSWORD", "otpCode": otpCode},
showServerMessage: true,
expectedResponseModel: (json) {
if (json['message'] == 'Otp Verified Successfully') {