fix fluxo de seleção de locais, showRoom

This commit is contained in:
J. A. Messias 2024-11-12 14:21:55 -03:00
parent ee7b4ebc19
commit 0f2c5c2fd4
15 changed files with 75 additions and 74 deletions

View File

@ -14,8 +14,8 @@ void main() {
group('Initialization', () {
group('Navigation', () {
setUpAll(() async => await initializeApp()
.then((_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
setUpAll(() async => await initializeApp().then(
(_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
testWidgets('Test Welcome', (WidgetTester tester) async {
widget = tester;
await _testWelcome();
@ -26,16 +26,16 @@ void main() {
});
group('Authentication', () {
group('Sign in', () {
setUpAll(() async => await initializeApp()
.then((_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
setUpAll(() async => await initializeApp().then(
(_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
testWidgets('Test Sign In', (WidgetTester tester) async {
widget = tester;
await _testSignIn();
});
});
group('Sign up', () {
setUpAll(() async => await initializeApp()
.then((_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
setUpAll(() async => await initializeApp().then(
(_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
testWidgets('Test Sign Up', (WidgetTester tester) async {
widget = tester;
await _testSignUp();

View File

@ -73,19 +73,19 @@ Future<void> onMessageReceived(Map<String, dynamic> payload, String? extra, Stri
task: 'L',
response: '',
id: payload['idVisitante'].toString(),
).then((value) {
).then((value) async {
if (value) {
context.pop();
context.pop();
} else {
context.pop();
context.pop();
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
}
}).catchError((e) {
}).catchError((e) async {
context.pop();
context.pop();
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
});
},
);
@ -112,19 +112,19 @@ Future<void> onMessageReceived(Map<String, dynamic> payload, String? extra, Stri
response: '',
id: payload['idVisitante'].toString(),
)
.then((value) {
.then((value) async {
if (value) {
context.pop();
context.pop();
} else {
context.pop();
context.pop();
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
}
}).catchError((e) {
}).catchError((e) async {
context.pop();
context.pop();
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
});
});
},

View File

@ -77,7 +77,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
if (isError) {
final String errorMsg = widget.response?.jsonBody['error_msg'];
_handleError(context, errorMsg);
await _handleError(context, errorMsg);
return widget.response;
}
@ -131,8 +131,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
return null;
}
static void _handleError(BuildContext context, String errorMsg) {
DialogUtil.error(context, errorMsg);
static Future<void> _handleError(BuildContext context, String errorMsg) async {
await DialogUtil.error(context, errorMsg);
}
Future<dynamic> _fetchResponseLink(String status, String cliID) async {
@ -151,7 +151,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
return response.jsonBody;
}
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vínculo', e, s);
return {
'error': true,
@ -212,30 +212,32 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
// message = local['CLU_BLK_MESSAGE'];
// }
DialogUtil.warning(context, message);
await DialogUtil.warning(context, message);
_localsWrap = [];
_localsFuture = _fetchLocals();
} else {
String localName = local['CLI_NOME'];
showAlertDialog(
context,
FFLocalizations.of(context).getVariableText(ptText: 'Ativar Vínculo', enText: 'Activate Link'),
FFLocalizations.of(context).getVariableText(
ptText: 'Deseja aceitar o vínculo a $localName?',
enText: 'Do you wish to accept the link to $localName?'), () async {
var response = await _fetchResponseLink('A', local['CLI_ID']);
context.pop();
context,
FFLocalizations.of(context).getVariableText(ptText: 'Ativar Vínculo', enText: 'Activate Link'),
FFLocalizations.of(context).getVariableText(
ptText: 'Deseja aceitar o vínculo a $localName?',
enText: 'Do you wish to accept the link to $localName?'),
() async {
var response = await _fetchResponseLink('A', local['CLI_ID']);
context.pop();
if (response['error'] == true) {
DialogUtil.error(context, response['error_msg']);
} else {
DialogUtil.success(context, response['error_msg']);
setState(() {
_localsWrap = [];
_localsFuture = _fetchLocals();
});
}
});
if (response['error'] == true) {
await DialogUtil.error(context, response['error_msg']);
} else {
await DialogUtil.success(context, response['error_msg']);
setState(() {
_localsWrap = [];
_localsFuture = _fetchLocals();
});
}
},
);
}
},
);

View File

@ -98,8 +98,7 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
highlightColor: Colors.transparent,
onTap: () async {
await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
await LocalizationService.processLocals(context)
.then((value) => value == true ? onUpdate() : null);
await LocalizationService.processLocals(context).whenComplete(() => onUpdate());
},
child: ClipRRect(
borderRadius: BorderRadius.circular(200.0),

View File

@ -604,7 +604,7 @@ class _ScheduleProvisionalVisitPageWidgetState extends State<ScheduleProvisional
if (PhpGroup.postProvVisitSchedulingCall
.error((model.provVisitSchedule?.jsonBody ?? '')) ==
false) {
DialogUtil.success(
await DialogUtil.success(
context,
FFLocalizations.of(context).getVariableText(
ptText: "Agendamento Provisório Realizado com Sucesso!",
@ -619,14 +619,14 @@ class _ScheduleProvisionalVisitPageWidgetState extends State<ScheduleProvisional
var message = PhpGroup.postProvVisitSchedulingCall
.msg((model.provVisitSchedule?.jsonBody ?? ''));
if (message != null) {
DialogUtil.error(context, message);
await DialogUtil.error(context, message);
} else {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
}
}
setState(() {});
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed(
"processRequest.php", "", "Cadastrar Visita Provisória", e, s);
}

View File

@ -733,7 +733,7 @@ class _RegisiterVistorTemplateComponentWidgetState extends State<RegisiterVistor
}
});
} else {
return DialogUtil.error(
return await DialogUtil.error(
context,
PhpGroup.postScheduleVisitorCall.errorMsg(_model.scheduleVisitor?.jsonBody) == null
? FFLocalizations.of(context).getVariableText(

View File

@ -195,13 +195,13 @@ Future<List<SelectedFile>?> selectMediaWithSourceBottomSheetandFaceDetection({
if (faces.isEmpty) {
final String message = FFLocalizations.of(context)
.getVariableText(ptText: "Nenhuma face detectada na imagem", enText: "No face detected in the image");
DialogUtil.error(context, message);
await DialogUtil.error(context, message);
return null;
}
if (faces.length > 1) {
final String message = FFLocalizations.of(context).getVariableText(
ptText: "Mais de uma face detectada na imagem", enText: "More than one face detected in the image");
DialogUtil.error(context, message);
await DialogUtil.error(context, message);
return null;
}
}

View File

@ -209,7 +209,7 @@ class _AccessHistoryState extends State<AccessHistoryScreen> {
});
return null;
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('processRequest', "", "Busca Acesso", e, s);
setState(() {
_hasData = false;

View File

@ -333,7 +333,7 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
return null;
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Solicitações", e, s);
setState(() {
_hasData = false;

View File

@ -119,7 +119,7 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
});
return null;
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Mensagems", e, s);
setState(() {
_hasData = false;

View File

@ -122,7 +122,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
return null;
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('processRequest', "", "Busca Encomendas", e, s);
setState(() {
_hasData = false;

View File

@ -79,7 +79,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
return null;
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Pets", e, s);
setState(() {
_hasData = false;
@ -256,8 +256,8 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
_petsWrap = [];
_petsFuture = _fetch().then((value) => value!.jsonBody['pets'] ?? []);
});
}).catchError((e, s) {
DialogUtil.errorDefault(context);
}).catchError((e, s) async {
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Pets", e, s);
safeSetState(() {
_hasData = false;

View File

@ -94,7 +94,7 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> with TickerProv
return null;
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Visitas", e, s);
setState(() {
_hasData = false;
@ -273,8 +273,8 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> with TickerProv
_visitWrap = [];
_visitFuture = _fetchVisits();
});
}).catchError((e, s) {
DialogUtil.errorDefault(context);
}).catchError((e, s) async {
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Visitas", e, s);
safeSetState(() {
_hasData = false;

View File

@ -18,7 +18,7 @@ class AuthenticationService {
final response = await callback.call();
if (response.jsonBody['error']) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
return;
}
List<dynamic> locals = response.jsonBody['locais'] ?? [];
@ -78,16 +78,16 @@ class AuthenticationService {
await login(context);
} else {
if (response.jsonBody['error'] == null) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
} else {
DialogUtil.error(context, response.jsonBody['error_msg'].toString());
DialogUtil.error(context, response.jsonBody['error_msg'].toString());
await DialogUtil.error(context, response.jsonBody['error_msg'].toString());
await DialogUtil.error(context, response.jsonBody['error_msg'].toString());
}
}
}
return;
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('login.php', emailAdress.toString(), "Login", e, s);
}
}
@ -115,14 +115,14 @@ class AuthenticationService {
);
if (response.jsonBody['error'] == false) return true;
DialogUtil.error(context, response.jsonBody['error_msg']);
await DialogUtil.error(context, response.jsonBody['error_msg']);
return false;
} else {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
return false;
}
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('registro.php', email.toString(), "Register", e, s);
return false;
}
@ -152,12 +152,12 @@ class AuthenticationService {
response = await callback.call(email: email);
if (response.jsonBody['error'] == false) {
DialogUtil.success(context, message);
await DialogUtil.success(context, message);
} else {
DialogUtil.error(context, response.jsonBody['error_msg']);
await DialogUtil.error(context, response.jsonBody['error_msg']);
}
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('forgotPassword.php', email, "Forgot Password", e, s);
}
}
@ -172,13 +172,13 @@ class AuthenticationService {
enText: "Password changed successfully!",
ptText: "Senha alterada com sucesso!",
);
DialogUtil.success(context, message).then((_) => context.pop);
await DialogUtil.success(context, message).then((_) => context.pop);
} else {
final String message = response.jsonBody['error_msg'];
DialogUtil.error(context, message);
await DialogUtil.error(context, message);
}
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('changePassword.php', email, "Change Password", e, s);
}
}

View File

@ -34,7 +34,7 @@ class LocalizationService {
enText: 'Verify your connection',
ptText: 'Verifique sua conexão',
);
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
return;
}
@ -72,7 +72,7 @@ class LocalizationService {
enText: 'Verify your connection',
ptText: 'Verifique sua conexão',
);
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
return false;
}
@ -123,7 +123,7 @@ class LocalizationService {
enText: 'Error getting locals, verify your connection',
ptText: 'Erro ao obter locais, verifique sua conexão',
);
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
return false;
}
}
@ -160,7 +160,7 @@ class LocalizationService {
enText: 'Error getting data, verify your connection',
ptText: 'Erro ao obter dados, verifique sua conexão',
);
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
return false;
}
}
@ -270,7 +270,7 @@ class LocalizationService {
}
if (response.jsonBody['error'] == false) return await processData(context).then((value) => value);
} catch (e, s) {
DialogUtil.errorDefault(context);
await DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vínculo', e, s);
return false;
}