In Update gas refill : add expected Date field and enable the engineer to updated.

main_design2.0
zaid_daoud 3 years ago
parent 4b23db582a
commit 3e79091d7e

@ -104,7 +104,6 @@ class GasRefillProvider extends ChangeNotifier {
@required User user,
@required GasRefillModel model,
}) async {
print("ss");
Map<String, dynamic> body = {
"uid": user.id.toString(),
"token": user.token ?? "",
@ -121,7 +120,6 @@ class GasRefillProvider extends ChangeNotifier {
"GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}",
"status": model.status.toMap(),
};
print("ss1");
body["gazRefillDetails"] = model.details
.map((model) => {
"gasType": model.type.toMap(),
@ -134,7 +132,6 @@ class GasRefillProvider extends ChangeNotifier {
Response response;
try {
response = await ApiManager.instance.post(URLs.requestGasRefill, body: body);
print("ss2");
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
if (items != null) {
@ -159,8 +156,8 @@ class GasRefillProvider extends ChangeNotifier {
"id": newModel.id,
"gazRefillNo": newModel.title ?? "",
"status": newModel.status.toMap(),
"expectedDate": oldModel.expectedDate?.toIso8601String(),
"expectedTime": oldModel.expectedDate?.toIso8601String(),
"expectedDate": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate?.toIso8601String(),
"startDate": startDate?.toIso8601String(),
"startTime": startDate?.toIso8601String(),
"endDate": endDate?.toIso8601String(),

@ -153,8 +153,8 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
}
if (_firstTime) {
if (widget.gasRefillModel != null) {
_formModel = widget.gasRefillModel;
_formModel.status = const Lookup(value: 0);
_gasRefillProvider.expectedDateTime = _formModel.expectedDate;
}
HospitalsProvider().getHospitalsListByVal(searchVal: _userProvider.user?.clientName).then((value) {
_gasRefillProvider.hospital = value?.firstWhere((element) => element.name == _userProvider.user?.clientName, orElse: () => null);
@ -275,7 +275,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
},
),
const SizedBox(height: 8),
if (_userProvider.user?.type == UsersTypes.normal_user)
if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null)
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@ -289,6 +289,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
to: DateTime.now().add(const Duration(days: 365)),
onDateTimePicker: (date) {
_gasRefillProvider.expectedDateTime = date;
_formModel.expectedDate = _gasRefillProvider.expectedDateTime;
setState(() {});
},
),

Loading…
Cancel
Save