fix: bug do vitassay
This commit is contained in:
parent
edd776a5ec
commit
dce7d11a3e
|
@ -840,7 +840,7 @@ class PostScheduleVisitCall {
|
|||
'unica': unica,
|
||||
'idMotivo': idMotivo,
|
||||
'idNAC': idNAC,
|
||||
'obs': obs,
|
||||
'Obs': obs,
|
||||
'DevDesc': devDesc,
|
||||
},
|
||||
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:hub/shared/utils/dialog_util.dart';
|
|||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:hub/shared/utils/storage_util.dart';
|
||||
|
||||
import '../../../shared/services/authentication/authentication_service.dart';
|
||||
import '/backend/api_requests/api_calls.dart';
|
||||
import '/flutter_flow/flutter_flow_theme.dart';
|
||||
|
||||
|
@ -61,6 +62,14 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
|||
try {
|
||||
setState(() => _loading = true);
|
||||
var response = await PhpGroup.getLocalsCall.call();
|
||||
final bool isError = response.jsonBody['error'];
|
||||
|
||||
|
||||
if (isError) {
|
||||
final String errorMsg = response.jsonBody['error_msg'];
|
||||
_handleError(context, errorMsg);
|
||||
return response;
|
||||
}
|
||||
|
||||
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||
|
||||
|
@ -73,11 +82,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
|||
final bool isEnabled = isUnique && isActive;
|
||||
final bool isDisabled = isUnique && isBlocked;
|
||||
|
||||
final bool isError = response.jsonBody['error'] == true;
|
||||
final bool isInvalid = response.jsonBody['error_msg'] == 'Esse dispositivo nao pertence a esse usuario';
|
||||
if(isError) DialogUtil.error(context, response.jsonBody['error_msg']);
|
||||
if(isInvalid) StorageUtil().isLogged = false;
|
||||
if(isInvalid) context.go('/welcomePage');
|
||||
|
||||
|
||||
|
||||
if (!isEmpty) {
|
||||
|
@ -119,6 +124,12 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
|||
return null;
|
||||
}
|
||||
|
||||
static void _handleError(BuildContext context, String errorMsg) {
|
||||
AuthenticationService.signOut(context);
|
||||
DialogUtil.error(context, errorMsg);
|
||||
LogUtil.requestAPIFailed('getLocals.php', '{devUUID: ${StorageUtil().devUUID}, cliUUID: ${StorageUtil().userUUID}}', 'Get Locals', errorMsg, StackTrace.current);
|
||||
}
|
||||
|
||||
Future<dynamic> _fetchResponseLink(String status, String cliID) async {
|
||||
try {
|
||||
StorageUtil().cliUUID = cliID;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -423,9 +425,8 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
await widget.getVisitors?.call(
|
||||
_model.visitors,
|
||||
);
|
||||
await widget.getDocs?.call(
|
||||
_model.docs,
|
||||
);
|
||||
log('() => docs: ${_model.docs}');
|
||||
await widget.getDocs?.call(_model.docs);
|
||||
context.pop();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import 'package:hub/flutter_flow/internationalization.dart';
|
|||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart';
|
||||
import 'package:hub/shared/helpers/shared_preferences_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/device_util.dart';
|
||||
import 'package:hub/shared/utils/storage_util.dart';
|
||||
import 'package:responsive_framework/responsive_framework.dart';
|
||||
|
||||
|
@ -265,6 +266,8 @@ class _AppState extends State<App> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
log('DeviceUtil: ${DeviceUtil.getDeviceOSVersion()}');
|
||||
|
||||
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
|
||||
_appStateNotifier = AppStateNotifier.instance;
|
||||
_router = createRouter(_appStateNotifier);
|
||||
|
|
|
@ -229,27 +229,5 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
|
|||
);
|
||||
}
|
||||
|
||||
void logout(BuildContext context) async {
|
||||
showAlertDialog(
|
||||
context,
|
||||
'Logout',
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Are you sure you want to logout?',
|
||||
ptText: 'Tem certeza',
|
||||
), () async {
|
||||
StorageUtil.purge();
|
||||
// setState(() {});
|
||||
|
||||
context.go(
|
||||
'/welcomePage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1501,7 +1501,7 @@ Widget scheduleVisit(BuildContext context, ScheduleCompleteVisitPageModel model,
|
|||
.convertDateFormat(model.textController1.text),
|
||||
dtFim: model
|
||||
.convertDateFormat(model.textController2.text),
|
||||
unica: model.switchValue == true ? 'Sim' : 'Não',
|
||||
unica: model.switchValue == true ? 'S' : 'N',
|
||||
idMotivo: extractIdToStr(model.dropDownValue1!),
|
||||
idNAC: extractIdToStr(model.dropDownValue2!),
|
||||
obs: model.textController3.text,
|
||||
|
@ -1614,7 +1614,7 @@ Widget scheduleVisit(BuildContext context, ScheduleCompleteVisitPageModel model,
|
|||
.toString()) ??
|
||||
'',
|
||||
'Single Visit':
|
||||
model.switchValue == true ? 'Sim' : 'Não',
|
||||
model.switchValue == true ? 'S' : 'N',
|
||||
if (model.textController3.text.isNotEmpty)
|
||||
'Observation': model.textController3.text,
|
||||
},
|
||||
|
|
|
@ -128,17 +128,15 @@ class AuthenticationService {
|
|||
|
||||
static Future<void> signOut(BuildContext context) async {
|
||||
await PhpGroup.unregisterDevice.call();
|
||||
final Map<String, dynamic> extra = <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
};
|
||||
await StorageUtil.purge();
|
||||
context.go(
|
||||
'/welcomePage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
context.go( '/welcomePage', extra: extra);
|
||||
}
|
||||
|
||||
static Future<void> forgotPassword(BuildContext context, String email) async {
|
||||
|
@ -189,6 +187,13 @@ class AuthenticationService {
|
|||
String content;
|
||||
try {
|
||||
await PhpGroup.deleteAccount.call().then((value) {
|
||||
final Map<String, dynamic> extra = <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
};
|
||||
if (value.jsonBody['error'] == false) {
|
||||
content = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Account deleted successfully',
|
||||
|
@ -196,16 +201,7 @@ class AuthenticationService {
|
|||
);
|
||||
StorageUtil.purge();
|
||||
context.pop();
|
||||
context.go(
|
||||
'/welcomePage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
context.go('/welcomePage', extra: extra);
|
||||
}
|
||||
}).catchError((err) {
|
||||
context.pop();
|
||||
|
|
|
@ -10,6 +10,7 @@ import '../../../components/organism_components/bottom_arrow_linked_locals_compo
|
|||
import '../../../flutter_flow/flutter_flow_util.dart';
|
||||
import '../../utils/log_util.dart';
|
||||
import '../../utils/snackbar_util.dart';
|
||||
import '../authentication/authentication_service.dart';
|
||||
|
||||
class LocalizationService {
|
||||
|
||||
|
@ -70,7 +71,7 @@ class LocalizationService {
|
|||
final bool isAvailable = _isAvailable();
|
||||
|
||||
if (isDisabled) {
|
||||
context.go('/welcomePage');
|
||||
AuthenticationService.signOut(context);
|
||||
return true;
|
||||
} else if (isUnavailable) {
|
||||
return await _handleUnavailable(context, locals);
|
||||
|
@ -185,9 +186,9 @@ class LocalizationService {
|
|||
}
|
||||
|
||||
static void _handleError(BuildContext context, String errorMsg) {
|
||||
StorageUtil().isLogged = false;
|
||||
context.go('/welcomePage');
|
||||
AuthenticationService.signOut(context);
|
||||
DialogUtil.error(context, errorMsg);
|
||||
LogUtil.requestAPIFailed('getLocals.php', '{devUUID: ${StorageUtil().devUUID}, cliUUID: ${StorageUtil().userUUID}}', 'Get Locals', errorMsg, StackTrace.current);
|
||||
}
|
||||
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
|
||||
log('() => isUnavailable');
|
||||
|
|
|
@ -29,4 +29,17 @@ class DeviceUtil {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<String?> getDeviceOSVersion() async {
|
||||
var deviceInfo = DeviceInfoPlugin();
|
||||
if (Platform.isIOS) {
|
||||
var iosDeviceInfo = await deviceInfo.iosInfo;
|
||||
return iosDeviceInfo.systemVersion; // unique ID on iOS. e.g. 14.5
|
||||
} else if (Platform.isAndroid) {
|
||||
var androidDeviceInfo = await deviceInfo.androidInfo;
|
||||
return androidDeviceInfo.version.release; // unique ID on Android. e.g . 11
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,9 +109,9 @@ class StorageUtil {
|
|||
|
||||
static Future<void> purge() async {
|
||||
try {
|
||||
// await SecureStorageHelper().purge();
|
||||
// await SharedPreferencesStorageHelper().purge();
|
||||
await SecureStorageHelper().purge();
|
||||
await SQLiteStorageHelper().purge();
|
||||
// await SharedPreferencesStorageHelper().purge();
|
||||
} catch (e) {
|
||||
log('Error purging data: $e');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue