FIX: resolvendo a logica de validação do localization_service
This commit is contained in:
parent
43ff7cf5c8
commit
a63a9d3f30
|
@ -22,8 +22,9 @@ class LocalizationService {
|
||||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||||
|
|
||||||
var response = await callback.call();
|
var response = await callback.call();
|
||||||
|
final bool isError = response.jsonBody['error'];
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (isError) {
|
||||||
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||||
final bool isEmpty = locals.isEmpty;
|
final bool isEmpty = locals.isEmpty;
|
||||||
final bool isActive = locals
|
final bool isActive = locals
|
||||||
|
@ -41,10 +42,10 @@ class LocalizationService {
|
||||||
StorageUtil().context?.go('/homePage');
|
StorageUtil().context?.go('/homePage');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final bool isInvalid = response.jsonBody['error_msg'] == 'Esse dispositivo nao pertence a esse usuario';
|
final String content = response.jsonBody['error_msg'];
|
||||||
if(isInvalid) StorageUtil().isLogged = false;
|
if(isError) StorageUtil().isLogged = false;
|
||||||
if(isInvalid) context.go('/welcomePage');
|
if(isError) context.go('/welcomePage');
|
||||||
return DialogUtil.error(context, response.jsonBody['error_msg']);
|
return DialogUtil.error(context, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,19 +61,22 @@ class LocalizationService {
|
||||||
final ApiCallResponse response = await callback.call();
|
final ApiCallResponse response = await callback.call();
|
||||||
|
|
||||||
|
|
||||||
final bool isError = response.jsonBody['error'] == true;
|
final bool isError = response.jsonBody['error'];
|
||||||
final bool isInvalid = response.jsonBody['error_msg'] == 'Esse dispositivo nao pertence a esse usuario';
|
final String content = response.jsonBody['error_msg'];
|
||||||
|
|
||||||
|
if(isError) StorageUtil().isLogged = false;
|
||||||
|
if(isError) context.go('/welcomePage');
|
||||||
|
if(isError) DialogUtil.error(context, response.jsonBody['error_msg']);
|
||||||
|
if(isError) return false;
|
||||||
|
|
||||||
|
|
||||||
if(isInvalid) StorageUtil().isLogged = false;
|
|
||||||
if(isInvalid) context.go('/welcomePage');
|
|
||||||
final List<dynamic> locals = response.jsonBody['locais'].toList() ?? [];
|
final List<dynamic> locals = response.jsonBody['locais'].toList() ?? [];
|
||||||
for (var local in locals) {
|
for (var local in locals) {
|
||||||
final String status = local['CLU_STATUS'];
|
final String status = local['CLU_STATUS'];
|
||||||
log('() => CLU_STATUS: $status');
|
log('() => CLU_STATUS: $status');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isError) DialogUtil.error(context, response.jsonBody['error_msg']);
|
|
||||||
if(isError) return false;
|
|
||||||
|
|
||||||
final bool isActive = locals.where((local) => local['CLU_STATUS'] == 'A').toList().isNotEmpty;
|
final bool isActive = locals.where((local) => local['CLU_STATUS'] == 'A').toList().isNotEmpty;
|
||||||
final bool isInactived = locals.where((local) => local['CLI_ID'] != StorageUtil().cliUUID && local['CLU_STATUS'] == 'A').toList().isNotEmpty;
|
final bool isInactived = locals.where((local) => local['CLI_ID'] != StorageUtil().cliUUID && local['CLU_STATUS'] == 'A').toList().isNotEmpty;
|
||||||
|
|
Loading…
Reference in New Issue