WIP
This commit is contained in:
parent
479b76dc26
commit
014cdcac93
|
@ -71,28 +71,37 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
||||||
|
|
||||||
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||||
|
|
||||||
if (locals.isNotEmpty) {
|
final bool isEmpty = locals.isEmpty;
|
||||||
|
final bool isUnique = locals.length == 1;
|
||||||
|
final bool isActive = locals[0]['CLU_STATUS'] == 'A';
|
||||||
|
final bool isBlocked = locals[0]['CLU_STATUS'] == 'B';
|
||||||
|
final bool isEnabled = isUnique && isActive;
|
||||||
|
final bool isDisabled = isUnique && isBlocked;
|
||||||
|
|
||||||
|
if (!isEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_localsWrap.addAll(locals);
|
_localsWrap.addAll(locals);
|
||||||
_hasData = true;
|
_hasData = true;
|
||||||
_loading = false;
|
_loading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verifica se há apenas um local e se o status é 'A'
|
if (isDisabled) {
|
||||||
if (locals.length == 1 && locals[0]['CLU_STATUS'] == 'A') {
|
context.go('/receptionPage');
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
if (isEnabled) {
|
||||||
final local = locals[0];
|
final local = locals[0];
|
||||||
StorageUtil().cliName = local['CLI_NOME'];
|
StorageUtil().cliName = local['CLI_NOME'];
|
||||||
StorageUtil().cliUUID = local['CLI_ID'];
|
StorageUtil().cliUUID = local['CLI_ID'];
|
||||||
StorageUtil().ownerUUID = local['CLU_OWNER_ID'];
|
StorageUtil().ownerUUID = local['CLU_OWNER_ID'];
|
||||||
|
|
||||||
context.pop();
|
context.pop();
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
_showNoMoreDataSnackBar(context);
|
_showNoMoreDataSnackBar(context);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_hasData = false;
|
_hasData = false;
|
||||||
_loading = false;
|
_loading = false;
|
||||||
|
@ -182,12 +191,13 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
||||||
String message = FFLocalizations.of(context).getVariableText(
|
String message = FFLocalizations.of(context).getVariableText(
|
||||||
ptText:
|
ptText:
|
||||||
'Local Bloqueado para Acesso, Entre em Contato com Administração',
|
'Local Bloqueado para Acesso, Entre em Contato com Administração',
|
||||||
enText: 'Location Blocked for Access, Contact Administration');
|
enText: 'Location Blocked for Access, Contact Administration',
|
||||||
|
);
|
||||||
|
|
||||||
if (local['CLU_BLK_MESSAGE'] != null &&
|
// if (local['CLU_BLK_MESSAGE'] != null &&
|
||||||
local['CLU_BLK_MESSAGE'] != '') {
|
// local['CLU_BLK_MESSAGE'] != '') {
|
||||||
message = local['CLU_BLK_MESSAGE'];
|
// message = local['CLU_BLK_MESSAGE'];
|
||||||
}
|
// }
|
||||||
|
|
||||||
DialogUtil.warning(context, message);
|
DialogUtil.warning(context, message);
|
||||||
_localsWrap = [];
|
_localsWrap = [];
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
|
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
|
||||||
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
import 'package:hub/shared/utils/storage_util.dart';
|
import 'package:hub/shared/utils/storage_util.dart';
|
||||||
|
|
||||||
|
@ -40,9 +41,9 @@ class _LocalProfileComponentWidgetState
|
||||||
_model.setOnUpdate(onUpdate: () => setState(() {}));
|
_model.setOnUpdate(onUpdate: () => setState(() {}));
|
||||||
_model.setStateCallback = () => safeSetState(() {});
|
_model.setStateCallback = () => safeSetState(() {});
|
||||||
|
|
||||||
() async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
await processLocals();
|
await processLocals();
|
||||||
}();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -59,7 +60,6 @@ class _LocalProfileComponentWidgetState
|
||||||
var response = await callback.call();
|
var response = await callback.call();
|
||||||
|
|
||||||
final error = response.jsonBody['error'];
|
final error = response.jsonBody['error'];
|
||||||
// final errorMsg = response.jsonBody['error_msg'];
|
|
||||||
|
|
||||||
if (error == false) {
|
if (error == false) {
|
||||||
final bool whatsapp = response.jsonBody['whatsapp'] ?? false;
|
final bool whatsapp = response.jsonBody['whatsapp'] ?? false;
|
||||||
|
@ -95,16 +95,25 @@ class _LocalProfileComponentWidgetState
|
||||||
try {
|
try {
|
||||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||||
|
|
||||||
final cliUUID = StorageUtil().cliUUID;
|
final ApiCallResponse response = await callback.call();
|
||||||
final cliName = StorageUtil().cliName;
|
|
||||||
var response = await callback.call();
|
|
||||||
|
|
||||||
List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
final List<dynamic> locals = response.jsonBody['locais']
|
||||||
|
.where((local) => local['CLU_STATUS'])
|
||||||
|
.toList() ??
|
||||||
|
[];
|
||||||
|
|
||||||
final activeLocals =
|
final bool isEnable = locals.any((local) => local['CLU_STATUS'] == 'A');
|
||||||
locals.where((local) => local['CLU_STATUS'] == 'A').toList();
|
final bool isUnique = locals.length == 1;
|
||||||
|
final bool isBlocked = locals[0]['CLU_STATUS'] == 'B';
|
||||||
|
final bool isDisabled = isUnique && isBlocked;
|
||||||
|
final bool isSelected =
|
||||||
|
StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty;
|
||||||
|
|
||||||
if (activeLocals.isEmpty || cliUUID.isEmpty || cliName.isEmpty) {
|
if (isDisabled) {
|
||||||
|
context.go('/welcomePage');
|
||||||
|
} else if (isEnable) {
|
||||||
|
await showModalSelectLocal();
|
||||||
|
} else if (!isSelected) {
|
||||||
await showModalSelectLocal();
|
await showModalSelectLocal();
|
||||||
} else {
|
} else {
|
||||||
await processData();
|
await processData();
|
||||||
|
|
|
@ -54,9 +54,14 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget>
|
||||||
var response = await callback.call();
|
var response = await callback.call();
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||||
|
final bool isEmpty = locals.isEmpty;
|
||||||
|
final bool isActive = locals
|
||||||
|
.where((local) => local['CLU_STATUS'] == 'A')
|
||||||
|
.toList()
|
||||||
|
.isNotEmpty;
|
||||||
|
|
||||||
if (locals.isNotEmpty) {
|
if (!isEmpty && isActive) {
|
||||||
StorageUtil().haveLocal = true;
|
StorageUtil().haveLocal = true;
|
||||||
StorageUtil().isLogged = true;
|
StorageUtil().isLogged = true;
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
await WidgetsBinding.instance.endOfFrame;
|
||||||
|
|
Loading…
Reference in New Issue