diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index a587fb7f..0dec4fe9 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -70,7 +70,7 @@ class URLs { static get getServiceReportLastCalls => "$_baseUrl/WorkOrder/GetLookupCallLastSituationBasedOnCase"; // get static get getAssetTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=500"; // get static get getPartNumber => "$_baseUrl/PartCatalog/GetPartAutoComplete"; // get - static get getServiceReportPriority => "$_baseUrl/Lookups/GetLookup?lookupEnum=602"; // get + static get getServiceReportPriority => "$_baseUrl/Lookups/GetLookup?lookupEnum=4"; // get static get getServiceReportDefectTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=601"; // get static get getCallRequestForWorkOrder => "$_baseUrl/CallRequest/GetCallRequestForWorkOrder"; // get diff --git a/lib/controllers/providers/api/gas_refill_provider.dart b/lib/controllers/providers/api/gas_refill_provider.dart index fc657ce5..445be633 100644 --- a/lib/controllers/providers/api/gas_refill_provider.dart +++ b/lib/controllers/providers/api/gas_refill_provider.dart @@ -185,24 +185,23 @@ class GasRefillProvider extends ChangeNotifier { }) .toList(); log(body.toString()); - return -1; - // Response response; - // try { - // response = await ApiManager.instance.put(URLs.updateGasRefill, body: body); - // // response = await post( - // // Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"), - // // body: body, - // // ); - // - // stateCode = response.statusCode; - // if (response.statusCode >= 200 && response.statusCode < 300) { - // oldModel.fromGasRefillModel(newModel); - // notifyListeners(); - // } - // return response.statusCode; - // } catch (error) { - // return -1; - // } + Response response; + try { + response = await ApiManager.instance.put(URLs.updateGasRefill, body: body); + // response = await post( + // Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"), + // body: body, + // ); + + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + oldModel.fromGasRefillModel(newModel); + notifyListeners(); + } + return response.statusCode; + } catch (error) { + return -1; + } } Hospital hospital; diff --git a/lib/views/pages/user/gas_refill/gas_refill_details.dart b/lib/views/pages/user/gas_refill/gas_refill_details.dart index bc6f49a0..7a4cd554 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_details.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_details.dart @@ -25,9 +25,9 @@ import '../../../../models/enums/user_types.dart'; import '../../../app_style/colors.dart'; class GasRefillDetails extends StatefulWidget { - final GasRefillModel model; + GasRefillModel model; - const GasRefillDetails({Key key, this.model}) : super(key: key); + GasRefillDetails({Key key, this.model}) : super(key: key); @override State createState() => _GasRefillDetailsState(); @@ -102,7 +102,9 @@ class _GasRefillDetailsState extends State { padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), child: Row( children: [ - const ABackButton(), + ABackButton(onPressed: (){ + Navigator.of(context).pop(_model); + },), Expanded( child: Center( child: Text( @@ -123,14 +125,17 @@ class _GasRefillDetailsState extends State { _model.fromGasRefillModel(widget.model); print(widget.model.startDate); // setState(() {}); - Navigator.push( + Navigator.push( context, MaterialPageRoute( builder: (context) => RequestGasRefill( gasRefillModel: widget.model, ), ), - ); + ).then((value) { + _model.status= value; + }); + setState(() {}); }, ), const SizedBox( diff --git a/lib/views/pages/user/gas_refill/request_gas_refill.dart b/lib/views/pages/user/gas_refill/request_gas_refill.dart index 43a324aa..83fb8f47 100644 --- a/lib/views/pages/user/gas_refill/request_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/request_gas_refill.dart @@ -106,7 +106,8 @@ class _RequestGasRefillState extends State { Fluttertoast.showToast( msg: _subtitle.requestCompleteSuccessfully, ); - Navigator.of(context).pop(); + Navigator.of(context).pop(_formModel.status); + setState(() { }); } else { String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle); ScaffoldMessenger.of(context).showSnackBar(SnackBar( @@ -151,7 +152,7 @@ class _RequestGasRefillState extends State { _settingProvider = Provider.of(context); if (_gasRefillProvider == null) { _gasRefillProvider = Provider.of(context, listen: false); - _gasRefillProvider.reset(); + //_gasRefillProvider.reset(); } if (_firstTime) { if (widget.gasRefillModel != null) { diff --git a/lib/views/pages/user/requests/create_request.dart b/lib/views/pages/user/requests/create_request.dart index 4aaf65bc..ebc23e44 100644 --- a/lib/views/pages/user/requests/create_request.dart +++ b/lib/views/pages/user/requests/create_request.dart @@ -189,7 +189,7 @@ class CreateRequestPageState extends State { height: 4, ), ServiceRequestPriorityMenu( - initialValue: _serviceRequest.priority, + initialValue: widget.serviceRequest.priority, onSelect: (status) { _serviceRequest.priority = status; }, @@ -341,13 +341,13 @@ class CreateRequestPageState extends State { child: AButton( text: widget.serviceRequest == null ? _subtitle.submit : _subtitle.update, onPressed: () async { - if (!_formKey.currentState.validate()) return; + //if (!_formKey.currentState.validate()) return; if (_device?.id == null) { Fluttertoast.showToast(msg: _subtitle.pickDevice); return; } if (_serviceRequest.firstAction?.name == "Need a visit" && _dateTime == null) { - Fluttertoast.showToast(msg: _subtitle.noDateFound); + Fluttertoast.showToast(msg: "first action is required"); return; } if (widget.serviceRequest != null && (_serviceRequest?.engineerId == null || (_serviceRequest?.engineerId?.isEmpty ?? false))) { diff --git a/lib/views/widgets/gas_refill/gas_refill_list.dart b/lib/views/widgets/gas_refill/gas_refill_list.dart index b6f58e83..f805e67c 100644 --- a/lib/views/widgets/gas_refill/gas_refill_list.dart +++ b/lib/views/widgets/gas_refill/gas_refill_list.dart @@ -7,37 +7,45 @@ import 'package:test_sa/views/widgets/gas_refill/gas_refill_item.dart'; import 'package:test_sa/views/widgets/loaders/lazy_loading.dart'; import 'package:test_sa/views/widgets/loaders/no_item_found.dart'; -class GasRefillList extends StatelessWidget { +class GasRefillList extends StatefulWidget { final List items; final bool nextPage; final Future Function() onLazyLoad; const GasRefillList({Key key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); + @override + State createState() => _GasRefillListState(); +} + +class _GasRefillListState extends State { @override Widget build(BuildContext context) { - if (items.length == 0) { + if (widget.items.length == 0) { Subtitle subtitle = AppLocalization.of(context).subtitle; return NoItemFound( message: subtitle.noServiceRequestFound, ); } return LazyLoading( - nextPage: nextPage, - onLazyLoad: onLazyLoad, + nextPage: widget.nextPage, + onLazyLoad: widget.onLazyLoad, child: ListView.builder( //physics: const BouncingScrollPhysics(), - itemCount: items.length, + itemCount: widget.items.length, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), itemBuilder: (context, itemIndex) { return GasRefillItem( index: itemIndex, - item: items[itemIndex], + item: widget.items[itemIndex], onPressed: (model) { Navigator.of(context).push(MaterialPageRoute( builder: (_) => GasRefillDetails( model: model, - ))); + ))).then((value) { + model=value; + setState(() {}); + }); }, ); }),