|
|
|
@ -30,7 +30,6 @@ import '../../../widgets/status/service_request/service_request_defect_types_mun
|
|
|
|
import '../../../widgets/status/service_request/service_request_priority_mune.dart';
|
|
|
|
import '../../../widgets/status/service_request/service_request_priority_mune.dart';
|
|
|
|
import '../../../widgets/titles/app_sub_title.dart';
|
|
|
|
import '../../../widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CreateRequestPage extends StatefulWidget {
|
|
|
|
class CreateRequestPage extends StatefulWidget {
|
|
|
|
static final String id = "/create-request";
|
|
|
|
static final String id = "/create-request";
|
|
|
|
|
|
|
|
|
|
|
|
@ -46,7 +45,7 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
ServiceRequest _serviceRequest = ServiceRequest();
|
|
|
|
ServiceRequest _serviceRequest = ServiceRequest();
|
|
|
|
List<File> _deviceImages = [];
|
|
|
|
List<File> _deviceImages = [];
|
|
|
|
bool _isLoading = false;
|
|
|
|
bool _isLoading = false;
|
|
|
|
late Device _device;
|
|
|
|
Device? _device;
|
|
|
|
late Subtitle _subtitle;
|
|
|
|
late Subtitle _subtitle;
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
@ -101,7 +100,12 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Text(
|
|
|
|
child: Text(
|
|
|
|
_subtitle.newServiceRequest,
|
|
|
|
_subtitle.newServiceRequest,
|
|
|
|
style: Theme.of(context).textTheme.headline5?.copyWith(color: AColors.cyan, fontWeight: FontWeight.w600),
|
|
|
|
style: Theme.of(context)
|
|
|
|
|
|
|
|
.textTheme
|
|
|
|
|
|
|
|
.headline5
|
|
|
|
|
|
|
|
?.copyWith(
|
|
|
|
|
|
|
|
color: AColors.cyan,
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w600),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -113,7 +117,9 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
? SizedBox.shrink()
|
|
|
|
? SizedBox.shrink()
|
|
|
|
: ATextFormField(
|
|
|
|
: ATextFormField(
|
|
|
|
enable: false,
|
|
|
|
enable: false,
|
|
|
|
initialValue: _userProvider.user?.hospital?.name ?? _subtitle.noHospitalFound,
|
|
|
|
initialValue:
|
|
|
|
|
|
|
|
_userProvider.user?.hospital?.name ??
|
|
|
|
|
|
|
|
_subtitle.noHospitalFound,
|
|
|
|
hintText: _subtitle.hospital,
|
|
|
|
hintText: _subtitle.hospital,
|
|
|
|
prefixIconData: FontAwesomeIcons.hospital,
|
|
|
|
prefixIconData: FontAwesomeIcons.hospital,
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
@ -123,7 +129,9 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
? SizedBox.shrink()
|
|
|
|
? SizedBox.shrink()
|
|
|
|
: ATextFormField(
|
|
|
|
: ATextFormField(
|
|
|
|
enable: false,
|
|
|
|
enable: false,
|
|
|
|
initialValue: _userProvider.user?.department?.name ?? _subtitle.noUniteFound,
|
|
|
|
initialValue:
|
|
|
|
|
|
|
|
_userProvider.user?.department?.name ??
|
|
|
|
|
|
|
|
_subtitle.noUniteFound,
|
|
|
|
hintText: _subtitle.unite,
|
|
|
|
hintText: _subtitle.unite,
|
|
|
|
prefixIconData: FontAwesomeIcons.hospitalUser,
|
|
|
|
prefixIconData: FontAwesomeIcons.hospitalUser,
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
@ -136,21 +144,29 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8,),
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 8,
|
|
|
|
|
|
|
|
),
|
|
|
|
const ASubTitle("Priority"),
|
|
|
|
const ASubTitle("Priority"),
|
|
|
|
const SizedBox(height: 4,),
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 4,
|
|
|
|
|
|
|
|
),
|
|
|
|
ServiceRequestPriorityMenu(
|
|
|
|
ServiceRequestPriorityMenu(
|
|
|
|
initialValue: _serviceRequest.priority,
|
|
|
|
initialValue: _serviceRequest.priority,
|
|
|
|
onSelect: (status){
|
|
|
|
onSelect: (status) {
|
|
|
|
_serviceRequest.priority = status;
|
|
|
|
_serviceRequest.priority = status;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8,),
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 8,
|
|
|
|
|
|
|
|
),
|
|
|
|
const ASubTitle("Defect Type"),
|
|
|
|
const ASubTitle("Defect Type"),
|
|
|
|
const SizedBox(height: 4,),
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 4,
|
|
|
|
|
|
|
|
),
|
|
|
|
ServiceRequestDefectTypesMenu(
|
|
|
|
ServiceRequestDefectTypesMenu(
|
|
|
|
initialValue: _serviceRequest.defectType,
|
|
|
|
initialValue: _serviceRequest.defectType,
|
|
|
|
onSelect: (status){
|
|
|
|
onSelect: (status) {
|
|
|
|
_serviceRequest.defectType = status;
|
|
|
|
_serviceRequest.defectType = status;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -169,7 +185,9 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
prefixIconData: FontAwesomeIcons.triangleExclamation,
|
|
|
|
prefixIconData: FontAwesomeIcons.triangleExclamation,
|
|
|
|
style: Theme.of(context).textTheme.headline6,
|
|
|
|
style: Theme.of(context).textTheme.headline6,
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
validator: (value) => Validator.hasValue(value!) ? '' : _subtitle.maintenanceIssueRequired,
|
|
|
|
validator: (value) => Validator.hasValue(value!)
|
|
|
|
|
|
|
|
? ''
|
|
|
|
|
|
|
|
: _subtitle.maintenanceIssueRequired,
|
|
|
|
onSaved: (value) {
|
|
|
|
onSaved: (value) {
|
|
|
|
_serviceRequest.maintenanceIssue = value;
|
|
|
|
_serviceRequest.maintenanceIssue = value;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -186,19 +204,24 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
child: AButton(
|
|
|
|
child: AButton(
|
|
|
|
text: _subtitle.submit,
|
|
|
|
text: _subtitle.submit,
|
|
|
|
onPressed: () async {
|
|
|
|
onPressed: () async {
|
|
|
|
if (!(_formKey.currentState?.validate()??false)) return;
|
|
|
|
if (!(_formKey.currentState?.validate() ?? false))
|
|
|
|
|
|
|
|
return;
|
|
|
|
_formKey.currentState?.save();
|
|
|
|
_formKey.currentState?.save();
|
|
|
|
_serviceRequest.deviceId = _device?.id ?? "";
|
|
|
|
_serviceRequest.deviceId = _device?.id ?? "";
|
|
|
|
_isLoading = true;
|
|
|
|
_isLoading = true;
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
_serviceRequest.devicePhotos = _deviceImages.map((e) => base64Encode(e.readAsBytesSync())).toList();
|
|
|
|
_serviceRequest.devicePhotos = _deviceImages
|
|
|
|
|
|
|
|
.map((e) => base64Encode(e.readAsBytesSync()))
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
if (_serviceRequest.audio != null) {
|
|
|
|
if (_serviceRequest.audio != null) {
|
|
|
|
final file = File(_serviceRequest.audio!);
|
|
|
|
final file = File(_serviceRequest.audio!);
|
|
|
|
_serviceRequest.audio = base64Encode(file.readAsBytesSync());
|
|
|
|
_serviceRequest.audio =
|
|
|
|
|
|
|
|
base64Encode(file.readAsBytesSync());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int status = await _serviceRequestsProvider.createRequest(
|
|
|
|
int status =
|
|
|
|
|
|
|
|
await _serviceRequestsProvider.createRequest(
|
|
|
|
user: _userProvider.user!,
|
|
|
|
user: _userProvider.user!,
|
|
|
|
host: _settingProvider.host??"",
|
|
|
|
host: _settingProvider.host ?? "",
|
|
|
|
serviceRequest: _serviceRequest,
|
|
|
|
serviceRequest: _serviceRequest,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
_isLoading = false;
|
|
|
|
_isLoading = false;
|
|
|
|
@ -209,7 +232,9 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
|
|
|
|
String errorMessage =
|
|
|
|
|
|
|
|
HttpStatusManger.getStatusMessage(
|
|
|
|
|
|
|
|
status: status, subtitle: _subtitle);
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
|
|
content: Text(errorMessage),
|
|
|
|
content: Text(errorMessage),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|