|
|
|
|
@ -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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|