fix handleError localization service
This commit is contained in:
parent
746e02ee5f
commit
fd7402547e
|
@ -82,6 +82,7 @@ class AuthenticationService {
|
||||||
DialogUtil.errorDefault(context);
|
DialogUtil.errorDefault(context);
|
||||||
} else {
|
} else {
|
||||||
DialogUtil.error(context, response.jsonBody['error_msg'].toString());
|
DialogUtil.error(context, response.jsonBody['error_msg'].toString());
|
||||||
|
DialogUtil.error(context, response.jsonBody['error_msg'].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,4 +222,4 @@ class AuthenticationService {
|
||||||
SnackBarUtil.showSnackBar(context, content, isError: true);
|
SnackBarUtil.showSnackBar(context, content, isError: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -198,17 +198,35 @@ class LocalizationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _handleError(BuildContext context, String errorMsg) {
|
static void _handleError(BuildContext context, String errorMsg) async {
|
||||||
AuthenticationService.signOut(context);
|
final String devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? '';
|
||||||
DialogUtil.error(context, errorMsg);
|
final String userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? '';
|
||||||
|
final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty;
|
||||||
|
final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario');
|
||||||
|
log('() => isLinked: $errorMsg');
|
||||||
|
if (isAuthenticated && isDevLinked) await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context));
|
||||||
|
if (isAuthenticated && !isDevLinked) {
|
||||||
|
errorMsg = FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Não foi possível vincular o dispositivo, tente novamente',
|
||||||
|
enText: 'Unable to link device, try again',
|
||||||
|
);
|
||||||
|
await DialogUtil.warning(context, errorMsg);
|
||||||
|
}
|
||||||
|
if (!isAuthenticated) {
|
||||||
|
errorMsg = FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Erro ao obter credenciais de autenticação',
|
||||||
|
enText: 'Error getting authentication credentials',
|
||||||
|
);
|
||||||
|
await DialogUtil.error(context, errorMsg);
|
||||||
|
// await DialogUtil.error(context, errorMsg).whenComplete(() async => await AuthenticationService.signOut(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
|
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
|
||||||
log('() => isUnavailable');
|
log('() => isUnavailable');
|
||||||
try {
|
try {
|
||||||
await StorageHelper().set(SQLiteStorageKey.clientUUID.value, locals[0]['CLI_ID'], Storage.SQLiteStorage);
|
await StorageHelper().set(SQLiteStorageKey.clientUUID.value, locals[0]['CLI_ID'], Storage.SQLiteStorage);
|
||||||
await StorageHelper()
|
await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID'], Storage.SQLiteStorage);
|
||||||
.set(SQLiteStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID'], Storage.SQLiteStorage);
|
|
||||||
await StorageHelper().set(SQLiteStorageKey.clientName.value, locals[0]['CLI_NOME'], Storage.SQLiteStorage);
|
await StorageHelper().set(SQLiteStorageKey.clientName.value, locals[0]['CLI_NOME'], Storage.SQLiteStorage);
|
||||||
var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A');
|
var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A');
|
||||||
if (response.jsonBody['error'] == true) {
|
if (response.jsonBody['error'] == true) {
|
||||||
|
@ -286,9 +304,10 @@ class LocalizationService {
|
||||||
SQLiteStorageKey.petAmount.value,
|
SQLiteStorageKey.petAmount.value,
|
||||||
jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty
|
jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty
|
||||||
? '0'
|
? '0'
|
||||||
: jsonBody['petAmountRegister'].toString(),
|
: jsonBody['petAmountRegister'].toString(),
|
||||||
Storage.SQLiteStorage);
|
Storage.SQLiteStorage
|
||||||
|
);
|
||||||
await StorageHelper()
|
await StorageHelper()
|
||||||
.set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage);
|
.set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue