Merge pull request #45 from FRE-Informatica/fd-848

FD-848 - Cadastro de novo usuário no APP com caracteres maiúsculos
This commit is contained in:
Jônatas Antunes Messias 2024-10-02 09:05:30 -03:00 committed by GitHub
commit 9cffa75e9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 40 deletions

View File

@ -603,7 +603,7 @@ class LoginCall {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
}, },
params: { params: {
'email': email, 'email': email.toLowerCase(),
'password': password, 'password': password,
'uuid': devUUID, 'uuid': devUUID,
'token': token, 'token': token,
@ -623,13 +623,13 @@ class LoginCall {
class RegisterCall { class RegisterCall {
Future<ApiCallResponse> call({ Future<ApiCallResponse> call({
final String? name, required final String name,
final String? email, required final String email,
final String? password, required final String password,
final String? token, required final String token,
final String? uuid, required final String uuid,
final String? tipo, required final String tipo,
final String? descricao, required final String descricao,
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
@ -642,7 +642,7 @@ class RegisterCall {
}, },
params: { params: {
'name': name, 'name': name,
'email': email, 'email': email.toLowerCase(),
'password': password, 'password': password,
'token': token, 'token': token,
'uuid': uuid, 'uuid': uuid,
@ -724,10 +724,10 @@ class GetLocalsCall {
class PostScheduleVisitorCall { class PostScheduleVisitorCall {
Future<ApiCallResponse> call({ Future<ApiCallResponse> call({
final String? documento, required final String documento,
final String? nome, required final String nome,
final String? tipo, required final String tipo,
final String? foto, required final String foto,
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();

View File

@ -41,9 +41,8 @@ class _LocalProfileComponentWidgetState
_model.setOnUpdate(onUpdate: () => setState(() {})); _model.setOnUpdate(onUpdate: () => setState(() {}));
_model.setStateCallback = () => safeSetState(() {}); _model.setStateCallback = () => safeSetState(() {});
WidgetsBinding.instance.addPostFrameCallback((_) async { WidgetsBinding.instance
await processLocals(); .addPostFrameCallback((_) async => await processLocals());
});
} }
@override @override
@ -97,29 +96,32 @@ class _LocalProfileComponentWidgetState
final ApiCallResponse response = await callback.call(); final ApiCallResponse response = await callback.call();
final List<dynamic> locals = response.jsonBody['locais'] final List<dynamic> locals = response.jsonBody['locais'].toList() ?? [];
.where((local) => local['CLU_STATUS'])
.toList() ??
[];
final bool isEnable = locals.any((local) => local['CLU_STATUS'] == 'A'); final bool isActive = response.jsonBody['locais']
.where((local) => local['CLU_STATUS'] == 'A')
.toList()
.isNotEmpty;
final bool isUnique = locals.length == 1; final bool isUnique = locals.length == 1;
final bool isBlocked = locals[0]['CLU_STATUS'] == 'B'; final bool isBlocked = locals[0]['CLU_STATUS'] == 'B';
final bool isEnable = isUnique && isActive;
final bool isDisabled = isUnique && isBlocked; final bool isDisabled = isUnique && isBlocked;
final bool isSelected = final bool isSelected =
StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty; StorageUtil().cliUUID.isEmpty && StorageUtil().cliName.isEmpty;
if (!mounted) return;
if (isDisabled) { if (isDisabled) {
context.go('/welcomePage'); if (mounted) context.go('/welcomePage');
} else if (isEnable) { } else if (isEnable) {
await showModalSelectLocal(); await showModalSelectLocal();
} else if (!isSelected) { } else if (isSelected) {
await showModalSelectLocal(); await showModalSelectLocal();
} else { } else {
await processData(); await processData();
} }
} catch (e) { } catch (e) {
await showModalSelectLocal(); if (mounted) await showModalSelectLocal();
} }
} }

View File

@ -60,8 +60,9 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget>
.where((local) => local['CLU_STATUS'] == 'A') .where((local) => local['CLU_STATUS'] == 'A')
.toList() .toList()
.isNotEmpty; .isNotEmpty;
final bool isEnable = !isEmpty && isActive;
if (!isEmpty && isActive) { if (isEnable) {
StorageUtil().haveLocal = true; StorageUtil().haveLocal = true;
StorageUtil().isLogged = true; StorageUtil().isLogged = true;
await WidgetsBinding.instance.endOfFrame; await WidgetsBinding.instance.endOfFrame;

View File

@ -5,7 +5,8 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:hub/shared/utils/cache_util.dart'; import 'package:hub/shared/utils/cache_util.dart';
class SharedPreferencesStorageHelper implements Storage { class SharedPreferencesStorageHelper implements Storage {
static final SharedPreferencesStorageHelper _instance = SharedPreferencesStorageHelper._internal(); static final SharedPreferencesStorageHelper _instance =
SharedPreferencesStorageHelper._internal();
SharedPreferences? _prefs; SharedPreferences? _prefs;
SharedPreferences? get prefs => _prefs; SharedPreferences? get prefs => _prefs;
set prefs(SharedPreferences? value) => _prefs = value; set prefs(SharedPreferences? value) => _prefs = value;
@ -18,45 +19,50 @@ class SharedPreferencesStorageHelper implements Storage {
bool _isFirstRun = true; bool _isFirstRun = true;
bool get isFirstRun => _isFirstRun; bool get isFirstRun => _isFirstRun;
set isFirstRun(bool value) => _setAndCacheBool('first_run', value, (v) => _isFirstRun = v); set isFirstRun(bool value) =>
_setAndCacheBool('milestone', value, (v) => _isFirstRun = v);
Future<void> _setAndCache<T>(String key, T value, Function(T) cacheSetter,
Future<void> Function(String, T) setFunc) async {
Future<void> _setAndCache<T>(String key, T value, Function(T) cacheSetter, Future<void> Function(String, T) setFunc) async {
log('setAndCache value for key: $key to $value'); log('setAndCache value for key: $key to $value');
await setFunc(key, value); await setFunc(key, value);
CacheUtil.instance.set(key, value); CacheUtil.instance.set(key, value);
cacheSetter(value); cacheSetter(value);
} }
Future<void> _setAndCacheString(String key, String value, Function(String) cacheSetter) async { Future<void> _setAndCacheString(
String key, String value, Function(String) cacheSetter) async {
log('setAndCacheString value for key: $key to $value'); log('setAndCacheString value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setString); await _setAndCache(key, value, cacheSetter, _prefs!.setString);
} }
Future<void> _setAndCacheBool(String key, bool value, Function(bool) cacheSetter) async { Future<void> _setAndCacheBool(
String key, bool value, Function(bool) cacheSetter) async {
log('setAndCacheBool value for key: $key to $value'); log('setAndCacheBool value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setBool); await _setAndCache(key, value, cacheSetter, _prefs!.setBool);
} }
Future<void> _setAndCacheInt(String key, int value, Function(int) cacheSetter) async { Future<void> _setAndCacheInt(
String key, int value, Function(int) cacheSetter) async {
log('setAndCacheInt value for key: $key to $value'); log('setAndCacheInt value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setInt); await _setAndCache(key, value, cacheSetter, _prefs!.setInt);
} }
Future<void> _setAndCacheDouble(String key, double value, Function(double) cacheSetter) async { Future<void> _setAndCacheDouble(
String key, double value, Function(double) cacheSetter) async {
log('setAndCacheDouble value for key: $key to $value'); log('setAndCacheDouble value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setDouble); await _setAndCache(key, value, cacheSetter, _prefs!.setDouble);
} }
Future<void> _setAndCacheStringList(String key, List<String> value, Function(List<String>) cacheSetter) async { Future<void> _setAndCacheStringList(String key, List<String> value,
Function(List<String>) cacheSetter) async {
log('setAndCacheStringList value for key: $key to $value'); log('setAndCacheStringList value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setStringList); await _setAndCache(key, value, cacheSetter, _prefs!.setStringList);
} }
@override @override
Future<void> set(String key, dynamic value, Function(dynamic) cacheSetter) async { Future<void> set(
String key, dynamic value, Function(dynamic) cacheSetter) async {
if (value is bool) { if (value is bool) {
await _prefs?.setBool(key, value); await _prefs?.setBool(key, value);
} else if (value is String) { } else if (value is String) {
@ -94,6 +100,5 @@ class SharedPreferencesStorageHelper implements Storage {
log('Purging shared preferences'); log('Purging shared preferences');
await _prefs?.clear(); await _prefs?.clear();
CacheUtil.instance.clear(); CacheUtil.instance.clear();
} }
} }