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 '/backend/api_requests/api_calls.dart';
|
||||||
import '/components/molecular_components/throw_exception/throw_exception_widget.dart';
|
import '/components/molecular_components/throw_exception/throw_exception_widget.dart';
|
||||||
import '/flutter_flow/flutter_flow_icon_button.dart';
|
import '/flutter_flow/flutter_flow_icon_button.dart';
|
||||||
|
@ -49,6 +54,18 @@ class _ScheduleProvisionalVisitPageWidgetState
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isFormValid() {
|
||||||
|
if (_model.personNameTextController.text == '' || _model.personNameTextController.text.length > 80) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_model.dateTimeTextController.text == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
context.watch<FFAppState>();
|
context.watch<FFAppState>();
|
||||||
|
@ -72,7 +89,7 @@ class _ScheduleProvisionalVisitPageWidgetState
|
||||||
size: 30.0,
|
size: 30.0,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// context.pop();
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
|
@ -102,7 +119,7 @@ class _ScheduleProvisionalVisitPageWidgetState
|
||||||
children: [
|
children: [
|
||||||
Form(
|
Form(
|
||||||
key: _model.formKey,
|
key: _model.formKey,
|
||||||
autovalidateMode: AutovalidateMode.always,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
@ -464,6 +481,7 @@ class _ScheduleProvisionalVisitPageWidgetState
|
||||||
const Duration(milliseconds: 500),
|
const Duration(milliseconds: 500),
|
||||||
() => setState(() {}),
|
() => setState(() {}),
|
||||||
),
|
),
|
||||||
|
readOnly: true,
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
@ -943,71 +961,51 @@ class _ScheduleProvisionalVisitPageWidgetState
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
FFButtonWidget(
|
FFButtonWidget(
|
||||||
onPressed: ((_model.personNameTextController.text ==
|
onPressed: !_isFormValid() ? null : () async {
|
||||||
'') ||
|
|
||||||
(_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,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (PhpGroup.postProvVisitSchedulingCall
|
try {
|
||||||
.error(
|
_model.provVisitSchedule = await PhpGroup.postProvVisitSchedulingCall.call(
|
||||||
(_model.provVisitSchedule?.jsonBody ??
|
devUUID: FFAppState().devUUID,
|
||||||
''),
|
userUUID: FFAppState().userUUID,
|
||||||
) ==
|
cliID: FFAppState().cliUUID,
|
||||||
false) {
|
atividade: 'putAgendamentoProv',
|
||||||
setState(() {
|
data: _model.dateTimeTextController.text,
|
||||||
_model.dateTimeTextController?.clear();
|
motivo: _model.notesTextController.text,
|
||||||
_model.personNameTextController
|
nome: _model.personNameTextController.text,
|
||||||
?.clear();
|
proID: FFAppState().ownerUUID,
|
||||||
_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(() {}));
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {});
|
if (PhpGroup.postProvVisitSchedulingCall.error((_model.provVisitSchedule?.jsonBody ?? '')) == false) {
|
||||||
},
|
DialogUtil.success(
|
||||||
text: FFLocalizations.of(context).getText(
|
context,
|
||||||
'bv5fg9sv' /* Enviar */,
|
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(
|
options: FFButtonOptions(
|
||||||
width: 150.0,
|
width: 150.0,
|
||||||
height: 50.0,
|
height: 50.0,
|
||||||
|
|
Loading…
Reference in New Issue