Request Gas refill screen Done

main_design2.0
zaid_daoud 2 years ago
parent df4a9a4887
commit 4bffab9c9b

@ -35,5 +35,8 @@
"onlyNumbers": "يسمح بإدخال الأرقام فقط",
"youHaveToSelect" : "يجب عليك إختيار",
"building" : "المبنى",
"floor" : "الطابق"
"floor" : "الطابق",
"youHaveToAddRequests" : "يجب إضافة طلبات",
"createdSuccessfully" : "إكتمل الطلب بنجاح",
"failedToCompleteRequest" : "فشل إتمام الطلب"
}

@ -35,5 +35,8 @@
"onlyNumbers": "Only Numbers Allowed",
"youHaveToSelect" : "You have to select",
"building" : "Building",
"floor" : "Floor"
"floor" : "Floor",
"youHaveToAddRequests" : "You have to add requests",
"createdSuccessfully" : "Created successfully",
"failedToCompleteRequest" : "Failed to complete request"
}

@ -96,16 +96,16 @@ class GasRefillProvider extends ChangeNotifier {
Map<String, dynamic> body = {
"uid": user.id.toString(),
"token": user.token ?? "",
"site": hospital?.toMap(),
"building": {"id": building?.id, "name": building?.name, "value": building?.value},
"floor": {"id": floor?.id, "name": floor?.name, "value": floor?.value},
"site": model.site?.toJson(),
"building": model.building != null ? {"id": model.building?.id, "name": model.building?.name, "value": model.building?.value} : null,
"floor": model.floor != null ? {"id": model.floor?.id, "name": model.floor?.name, "value": model.floor?.value} : null,
//if (expectedDateTime != null) "expectedDate": expectedDateTime?.toIso8601String(),
if (expectedDateTime != null) "expectedTime": expectedDateTime?.toIso8601String(),
if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(),
if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(),
if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(),
if (timer?.endAt != null) "endTime": timer.endAt.toIso8601String(),
"department": {"id": department?.id, "departmentName": department?.name, "departmentCode": "", "ntCode": ""},
"department": model.department?.toJson(),
"GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}",
"status": model.status?.toMap(),
};

@ -37,4 +37,6 @@ enum TranslationKeys {
building,
floor,
createdSuccessfully,
failedToCompleteRequest,
youHaveToAddRequests,
}

@ -25,6 +25,7 @@ import 'package:test_sa/providers/loading_list_notifier.dart';
import '../../controllers/providers/api/gas_refill_provider.dart';
import '../../controllers/validator/validator.dart';
import '../common_widgets/app_lazy_loading.dart';
import '../common_widgets/default_app_bar.dart';
class NewGasRefillRequestPage extends StatefulWidget {
@ -208,8 +209,10 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
],
),
const Divider().defaultStyle(context),
("${context.translate(TranslationKeys.department)}: ${_gasModel.department?.departmentCode}").bodyText(context),
("${context.translate(TranslationKeys.site)}: ${_gasModel.department?.departmentName}").bodyText(context),
("${context.translate(TranslationKeys.site)}: ${_gasModel.site?.custName}").bodyText(context),
("${context.translate(TranslationKeys.building)}: ${_gasModel.building?.name}").bodyText(context),
("${context.translate(TranslationKeys.floor)}: ${_gasModel.floor?.name}").bodyText(context),
("${context.translate(TranslationKeys.department)}: ${_gasModel.department?.departmentName}").bodyText(context),
],
).paddingAll(16),
);
@ -242,14 +245,22 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
}
Future<void> _submit() async {
if (_gasModel.gazRefillDetails?.isEmpty ?? true) {
Fluttertoast.showToast(msg: context.translate(TranslationKeys.youHaveToAddRequests));
return;
}
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
final status = await Provider.of<GasRefillProvider>(context, listen: false).createModel(
user: Provider.of<UserProvider>(context, listen: false).user,
model: _gasModel,
);
Navigator.pop(context);
if (status >= 200 && status < 300) {
Fluttertoast.showToast(msg: context.translate(TranslationKeys.createdSuccessfully));
Navigator.of(context).pop();
setState(() {});
} else {
Fluttertoast.showToast(msg: context.translate(TranslationKeys.failedToCompleteRequest));
}
}
}

Loading…
Cancel
Save