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',
},
params: {
'email': email,
'email': email.toLowerCase(),
'password': password,
'uuid': devUUID,
'token': token,
@ -623,13 +623,13 @@ class LoginCall {
class RegisterCall {
Future<ApiCallResponse> call({
final String? name,
final String? email,
final String? password,
final String? token,
final String? uuid,
final String? tipo,
final String? descricao,
required final String name,
required final String email,
required final String password,
required final String token,
required final String uuid,
required final String tipo,
required final String descricao,
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
@ -642,7 +642,7 @@ class RegisterCall {
},
params: {
'name': name,
'email': email,
'email': email.toLowerCase(),
'password': password,
'token': token,
'uuid': uuid,
@ -724,10 +724,10 @@ class GetLocalsCall {
class PostScheduleVisitorCall {
Future<ApiCallResponse> call({
final String? documento,
final String? nome,
final String? tipo,
final String? foto,
required final String documento,
required final String nome,
required final String tipo,
required final String foto,
}) async {
final String baseUrl = PhpGroup.getBaseUrl();

View File

@ -41,9 +41,8 @@ class _LocalProfileComponentWidgetState
_model.setOnUpdate(onUpdate: () => setState(() {}));
_model.setStateCallback = () => safeSetState(() {});
WidgetsBinding.instance.addPostFrameCallback((_) async {
await processLocals();
});
WidgetsBinding.instance
.addPostFrameCallback((_) async => await processLocals());
}
@override
@ -97,29 +96,32 @@ class _LocalProfileComponentWidgetState
final ApiCallResponse response = await callback.call();
final List<dynamic> locals = response.jsonBody['locais']
.where((local) => local['CLU_STATUS'])
.toList() ??
[];
final List<dynamic> locals = response.jsonBody['locais'].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 isBlocked = locals[0]['CLU_STATUS'] == 'B';
final bool isEnable = isUnique && isActive;
final bool isDisabled = isUnique && isBlocked;
final bool isSelected =
StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty;
StorageUtil().cliUUID.isEmpty && StorageUtil().cliName.isEmpty;
if (!mounted) return;
if (isDisabled) {
context.go('/welcomePage');
if (mounted) context.go('/welcomePage');
} else if (isEnable) {
await showModalSelectLocal();
} else if (!isSelected) {
} else if (isSelected) {
await showModalSelectLocal();
} else {
await processData();
}
} 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')
.toList()
.isNotEmpty;
final bool isEnable = !isEmpty && isActive;
if (!isEmpty && isActive) {
if (isEnable) {
StorageUtil().haveLocal = true;
StorageUtil().isLogged = true;
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';
class SharedPreferencesStorageHelper implements Storage {
static final SharedPreferencesStorageHelper _instance = SharedPreferencesStorageHelper._internal();
static final SharedPreferencesStorageHelper _instance =
SharedPreferencesStorageHelper._internal();
SharedPreferences? _prefs;
SharedPreferences? get prefs => _prefs;
set prefs(SharedPreferences? value) => _prefs = value;
@ -18,45 +19,50 @@ class SharedPreferencesStorageHelper implements Storage {
bool _isFirstRun = true;
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');
await setFunc(key, value);
CacheUtil.instance.set(key, 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');
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');
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');
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');
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');
await _setAndCache(key, value, cacheSetter, _prefs!.setStringList);
}
@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) {
await _prefs?.setBool(key, value);
} else if (value is String) {
@ -94,6 +100,5 @@ class SharedPreferencesStorageHelper implements Storage {
log('Purging shared preferences');
await _prefs?.clear();
CacheUtil.instance.clear();
}
}