WIP
This commit is contained in:
parent
518e4140c4
commit
08e072e183
|
@ -37,6 +37,7 @@ class RegisiterVistorTemplateComponentModel
|
||||||
|
|
||||||
Future<bool?> getVisitanteByDocument(
|
Future<bool?> getVisitanteByDocument(
|
||||||
String document, BuildContext context) async {
|
String document, BuildContext context) async {
|
||||||
|
|
||||||
final response = await PhpGroup.getVisitorByDocCall.call(
|
final response = await PhpGroup.getVisitorByDocCall.call(
|
||||||
devUUID: FFAppState().devUUID,
|
devUUID: FFAppState().devUUID,
|
||||||
userUUID: FFAppState().userUUID,
|
userUUID: FFAppState().userUUID,
|
||||||
|
@ -44,6 +45,7 @@ class RegisiterVistorTemplateComponentModel
|
||||||
atividade: 'getVisitante',
|
atividade: 'getVisitante',
|
||||||
documento: document,
|
documento: document,
|
||||||
);
|
);
|
||||||
|
|
||||||
log('${response.jsonBody}');
|
log('${response.jsonBody}');
|
||||||
if (response.jsonBody['visitante']['VTE_ID'] != '0' &&
|
if (response.jsonBody['visitante']['VTE_ID'] != '0' &&
|
||||||
response.jsonBody['error'] != 'false') {
|
response.jsonBody['error'] != 'false') {
|
||||||
|
|
|
@ -38,6 +38,8 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
|
|
||||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
|
bool _isVisitorRegistered = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -71,6 +73,32 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isFormValid(BuildContext context) {
|
||||||
|
|
||||||
|
if (_model.uploadedLocalFile.bytes?.isEmpty ?? true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_model.textController1.text.isEmpty || _model.textController1.text == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_model.dropDownValue == null || _model.dropDownValue!.isEmpty || _model.dropDownValue == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_model.textController2.text.isEmpty || _model.textController2.text == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
log("Visitante Já Cadastrado $_isVisitorRegistered");
|
||||||
|
if (_isVisitorRegistered) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
BehaviorSubject<bool> visitorAlreadyRegistered = BehaviorSubject<bool>();
|
BehaviorSubject<bool> visitorAlreadyRegistered = BehaviorSubject<bool>();
|
||||||
|
@ -216,9 +244,11 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
} else if (snapshot.hasError ||
|
} else if (snapshot.hasError ||
|
||||||
snapshot.data == null ||
|
snapshot.data == null ||
|
||||||
snapshot.data == '') {
|
snapshot.data == '') {
|
||||||
|
_isVisitorRegistered = false;
|
||||||
visitorAlreadyRegistered.add(true);
|
visitorAlreadyRegistered.add(true);
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
} else {
|
} else {
|
||||||
|
_isVisitorRegistered = true;
|
||||||
visitorAlreadyRegistered.add(false);
|
visitorAlreadyRegistered.add(false);
|
||||||
return _model.textController2.text.isEmpty
|
return _model.textController2.text.isEmpty
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
|
@ -775,12 +805,7 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsetsDirectional.fromSTEB(0.0, 65.0, 0.0, 0.0),
|
const EdgeInsetsDirectional.fromSTEB(0.0, 65.0, 0.0, 0.0),
|
||||||
child: FFButtonWidget(
|
child: FFButtonWidget(
|
||||||
onPressed: (((_model.uploadedLocalFile.bytes?.isNotEmpty ??
|
onPressed: _isFormValid(context)
|
||||||
false)) &&
|
|
||||||
(_model.textController1.text != '') &&
|
|
||||||
(_model.dropDownValue != null &&
|
|
||||||
_model.dropDownValue != '') &&
|
|
||||||
(_model.textController2.text != ''))
|
|
||||||
? () async {
|
? () async {
|
||||||
log(visitorAlreadyRegistered.value.toString());
|
log(visitorAlreadyRegistered.value.toString());
|
||||||
if (visitorAlreadyRegistered.value == true) {
|
if (visitorAlreadyRegistered.value == true) {
|
||||||
|
|
Loading…
Reference in New Issue