fix: Provisional Schedule
This commit is contained in:
parent
a379d7f352
commit
cfd7e0e4ae
|
@ -1,3 +1,8 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
|
||||
import '/backend/api_requests/api_calls.dart';
|
||||
import '/components/molecular_components/throw_exception/throw_exception_widget.dart';
|
||||
import '/flutter_flow/flutter_flow_icon_button.dart';
|
||||
|
@ -49,6 +54,18 @@ class _ScheduleProvisionalVisitPageWidgetState
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
bool _isFormValid() {
|
||||
if (_model.personNameTextController.text == '' || _model.personNameTextController.text.length > 80) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_model.dateTimeTextController.text == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
context.watch<FFAppState>();
|
||||
|
@ -72,7 +89,7 @@ class _ScheduleProvisionalVisitPageWidgetState
|
|||
size: 30.0,
|
||||
),
|
||||
onPressed: () async {
|
||||
// context.pop();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
|
@ -102,7 +119,7 @@ class _ScheduleProvisionalVisitPageWidgetState
|
|||
children: [
|
||||
Form(
|
||||
key: _model.formKey,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
|
@ -464,6 +481,7 @@ class _ScheduleProvisionalVisitPageWidgetState
|
|||
const Duration(milliseconds: 500),
|
||||
() => setState(() {}),
|
||||
),
|
||||
readOnly: true,
|
||||
autofocus: false,
|
||||
obscureText: false,
|
||||
decoration: InputDecoration(
|
||||
|
@ -943,71 +961,51 @@ class _ScheduleProvisionalVisitPageWidgetState
|
|||
),
|
||||
),
|
||||
FFButtonWidget(
|
||||
onPressed: ((_model.personNameTextController.text ==
|
||||
'') ||
|
||||
(_model.dateTimeTextController.text ==
|
||||
''))
|
||||
? null
|
||||
: () async {
|
||||
_model.provVisitSchedule = await PhpGroup
|
||||
.postProvVisitSchedulingCall
|
||||
.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'putAgendamentoProv',
|
||||
data: _model.dateTimeTextController.text,
|
||||
motivo: _model.notesTextController.text,
|
||||
nome:
|
||||
_model.personNameTextController.text,
|
||||
proID: FFAppState().ownerUUID,
|
||||
);
|
||||
onPressed: !_isFormValid() ? null : () async {
|
||||
|
||||
if (PhpGroup.postProvVisitSchedulingCall
|
||||
.error(
|
||||
(_model.provVisitSchedule?.jsonBody ??
|
||||
''),
|
||||
) ==
|
||||
false) {
|
||||
setState(() {
|
||||
_model.dateTimeTextController?.clear();
|
||||
_model.personNameTextController
|
||||
?.clear();
|
||||
_model.notesTextController?.clear();
|
||||
});
|
||||
} else {
|
||||
await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
enableDrag: false,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return GestureDetector(
|
||||
onTap: () => FocusScope.of(context)
|
||||
.unfocus(),
|
||||
child: Padding(
|
||||
padding: MediaQuery.viewInsetsOf(
|
||||
context),
|
||||
child: ThrowExceptionWidget(
|
||||
msg: PhpGroup
|
||||
.postProvVisitSchedulingCall
|
||||
.msg(
|
||||
(_model.provVisitSchedule
|
||||
?.jsonBody ??
|
||||
''),
|
||||
)!,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
).then((value) => safeSetState(() {}));
|
||||
}
|
||||
try {
|
||||
_model.provVisitSchedule = await PhpGroup.postProvVisitSchedulingCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'putAgendamentoProv',
|
||||
data: _model.dateTimeTextController.text,
|
||||
motivo: _model.notesTextController.text,
|
||||
nome: _model.personNameTextController.text,
|
||||
proID: FFAppState().ownerUUID,
|
||||
);
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
text: FFLocalizations.of(context).getText(
|
||||
'bv5fg9sv' /* Enviar */,
|
||||
),
|
||||
if (PhpGroup.postProvVisitSchedulingCall.error((_model.provVisitSchedule?.jsonBody ?? '')) == false) {
|
||||
DialogUtil.success(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: "Agendamento Provisório Realizado com Sucesso!",
|
||||
enText: "Provisional Scheduling Successfully Completed"
|
||||
)
|
||||
);
|
||||
setState(() {
|
||||
_model.dateTimeTextController?.clear();
|
||||
_model.personNameTextController?.clear();
|
||||
_model.notesTextController?.clear();
|
||||
});
|
||||
} else {
|
||||
var message = PhpGroup.postProvVisitSchedulingCall.msg((_model.provVisitSchedule?.jsonBody ?? ''));
|
||||
if (message != null) {
|
||||
DialogUtil.error(context, message);
|
||||
} else {
|
||||
DialogUtil.errorDefault(context);
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
} catch (e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
LogUtil.requestAPIFailed("processRequest.php", "", "Cadastrar Visita Provisória", e, s);
|
||||
}
|
||||
|
||||
},
|
||||
showLoadingIndicator: true,
|
||||
text: FFLocalizations.of(context).getText('bv5fg9sv' /* Enviar */),
|
||||
options: FFButtonOptions(
|
||||
width: 150.0,
|
||||
height: 50.0,
|
||||
|
|
Loading…
Reference in New Issue