Merge remote-tracking branch 'origin/main_design2.0' into main_design2.0

main_design2.0
Sikander Saleem 2 years ago
commit c8e3f2df48

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

@ -35,5 +35,8 @@
"onlyNumbers": "Only Numbers Allowed", "onlyNumbers": "Only Numbers Allowed",
"youHaveToSelect" : "You have to select", "youHaveToSelect" : "You have to select",
"building" : "Building", "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 = { Map<String, dynamic> body = {
"uid": user.id.toString(), "uid": user.id.toString(),
"token": user.token ?? "", "token": user.token ?? "",
"site": hospital?.toMap(), "site": model.site?.toJson(),
"building": {"id": building?.id, "name": building?.name, "value": building?.value}, "building": model.building != null ? {"id": model.building?.id, "name": model.building?.name, "value": model.building?.value} : null,
"floor": {"id": floor?.id, "name": floor?.name, "value": floor?.value}, "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) "expectedDate": expectedDateTime?.toIso8601String(),
if (expectedDateTime != null) "expectedTime": expectedDateTime?.toIso8601String(), if (expectedDateTime != null) "expectedTime": expectedDateTime?.toIso8601String(),
if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(), if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(),
if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(), if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(),
if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(), if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(),
if (timer?.endAt != null) "endTime": 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}", "GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}",
"status": model.status?.toMap(), "status": model.status?.toMap(),
}; };

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

Loading…
Cancel
Save