|
|
|
|
@ -1,7 +1,11 @@
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/validator/validator.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
@ -24,6 +28,8 @@ import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
import 'package:test_sa/new_views/swipe_module/dialoge/single_btn_dialog.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/dialogs/dialog.dart';
|
|
|
|
|
|
|
|
|
|
class SignUpScreen extends StatefulWidget {
|
|
|
|
|
static const String routeName = "/signup_screen";
|
|
|
|
|
@ -401,16 +407,16 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
|
|
|
|
|
|
|
|
|
if (employee != null) {
|
|
|
|
|
// Check if the error message indicates duplicate account
|
|
|
|
|
if (_signUpProvider.errorMessage != null && _signUpProvider.errorMessage!.toLowerCase().contains('already')) {
|
|
|
|
|
// Show duplicate account popup
|
|
|
|
|
_showDuplicateAccountDialog();
|
|
|
|
|
setState(() {
|
|
|
|
|
_employeeFetched = false;
|
|
|
|
|
_employeeERPData = null;
|
|
|
|
|
_employeeIdController.clear();
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// if (_signUpProvider.errorMessage != null && _signUpProvider.errorMessage!.toLowerCase().contains('already')) {
|
|
|
|
|
// // Show duplicate account popup
|
|
|
|
|
// _showDuplicateAccountDialog();
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _employeeFetched = false;
|
|
|
|
|
// _employeeERPData = null;
|
|
|
|
|
// _employeeIdController.clear();
|
|
|
|
|
// });
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
_employeeFetched = true;
|
|
|
|
|
@ -422,29 +428,29 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
|
|
|
|
_departmentController.text = '';
|
|
|
|
|
_siteController.text = employee.branchCode ?? '';
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Check if it's a duplicate account error
|
|
|
|
|
if (_signUpProvider.errorMessage != null &&
|
|
|
|
|
(_signUpProvider.errorMessage!.toLowerCase().contains('already') ||
|
|
|
|
|
_signUpProvider.errorMessage!.toLowerCase().contains('exists') ||
|
|
|
|
|
_signUpProvider.errorMessage!.toLowerCase().contains('account'))) {
|
|
|
|
|
_showDuplicateAccountDialog();
|
|
|
|
|
setState(() {
|
|
|
|
|
_employeeFetched = false;
|
|
|
|
|
_employeeERPData = null;
|
|
|
|
|
_employeeIdController.clear();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
_employeeFetched = false;
|
|
|
|
|
_employeeERPData = null;
|
|
|
|
|
// _employeeIdController.clear();
|
|
|
|
|
});
|
|
|
|
|
if (_signUpProvider.errorMessage != null) {
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
msg: _signUpProvider.errorMessage!,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Check if it's a duplicate account error
|
|
|
|
|
// if (_signUpProvider.errorMessage != null &&
|
|
|
|
|
// (_signUpProvider.errorMessage!.toLowerCase().contains('already') ||
|
|
|
|
|
// _signUpProvider.errorMessage!.toLowerCase().contains('exists') ||
|
|
|
|
|
// _signUpProvider.errorMessage!.toLowerCase().contains('account'))) {
|
|
|
|
|
// _showDuplicateAccountDialog();
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _employeeFetched = false;
|
|
|
|
|
// _employeeERPData = null;
|
|
|
|
|
// _employeeIdController.clear();
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _employeeFetched = false;
|
|
|
|
|
// _employeeERPData = null;
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -638,69 +644,70 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (_signUpProvider.errorMessage != null) {
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
msg: _signUpProvider.errorMessage!,
|
|
|
|
|
);
|
|
|
|
|
context.showSingleBtnDialog(_signUpProvider.errorMessage!);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _showSuccessDialog() {
|
|
|
|
|
final successMessage = _signUpProvider.successMessage ?? 'Your signup request has been submitted successfully';
|
|
|
|
|
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) => Dialog(
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
shape: const RoundedRectangleBorder(),
|
|
|
|
|
insetPadding: const EdgeInsets.only(left: 21, right: 21),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
"Success",
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontSize: 24,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
color: Colors.black87,
|
|
|
|
|
height: 35 / 24,
|
|
|
|
|
letterSpacing: -0.96,
|
|
|
|
|
),
|
|
|
|
|
).paddingOnly(top: 16),
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
icon: const Icon(Icons.close),
|
|
|
|
|
color: Colors.black87,
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context); // Close dialog
|
|
|
|
|
Navigator.pop(context); // Go back to login
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
successMessage.bodyText(context),
|
|
|
|
|
28.height,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: "OK",
|
|
|
|
|
onPressed: () {
|
|
|
|
|
final successMessage = _signUpProvider.successMessage ?? 'Your signup request has been submitted';
|
|
|
|
|
context.showSingleBtnDialog(successMessage, title: 'Success', onTap: () {
|
|
|
|
|
Navigator.pop(context); // Close dialog
|
|
|
|
|
Navigator.pop(context); // Go back to login
|
|
|
|
|
},
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
});
|
|
|
|
|
// showDialog(
|
|
|
|
|
// context: context,
|
|
|
|
|
// builder: (context) => Dialog(
|
|
|
|
|
// backgroundColor: Colors.white,
|
|
|
|
|
// shape: const RoundedRectangleBorder(),
|
|
|
|
|
// insetPadding: const EdgeInsets.only(left: 21, right: 21),
|
|
|
|
|
// child: Padding(
|
|
|
|
|
// padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
|
|
|
|
|
// child: Column(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// children: [
|
|
|
|
|
// Row(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// Expanded(
|
|
|
|
|
// child: Text(
|
|
|
|
|
// "Success",
|
|
|
|
|
// style: const TextStyle(
|
|
|
|
|
// fontSize: 24,
|
|
|
|
|
// fontWeight: FontWeight.w600,
|
|
|
|
|
// color: Colors.black87,
|
|
|
|
|
// height: 35 / 24,
|
|
|
|
|
// letterSpacing: -0.96,
|
|
|
|
|
// ),
|
|
|
|
|
// ).paddingOnly(top: 16),
|
|
|
|
|
// ),
|
|
|
|
|
// IconButton(
|
|
|
|
|
// padding: EdgeInsets.zero,
|
|
|
|
|
// icon: const Icon(Icons.close),
|
|
|
|
|
// color: Colors.black87,
|
|
|
|
|
// constraints: const BoxConstraints(),
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// Navigator.pop(context); // Close dialog
|
|
|
|
|
// Navigator.pop(context); // Go back to login
|
|
|
|
|
// },
|
|
|
|
|
// )
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// successMessage.bodyText(context),
|
|
|
|
|
// 28.height,
|
|
|
|
|
// AppFilledButton(
|
|
|
|
|
// label: "OK",
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// Navigator.pop(context); // Close dialog
|
|
|
|
|
// Navigator.pop(context); // Go back to login
|
|
|
|
|
// },
|
|
|
|
|
// textColor: Colors.white,
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|