validations
This commit is contained in:
parent
2e85273b06
commit
2a77ebc7d1
File diff suppressed because it is too large
Load Diff
@ -267,6 +267,11 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
errorMessages["end_date"] =
|
errorMessages["end_date"] =
|
||||||
"End date cannot be earlier than start date";
|
"End date cannot be earlier than start date";
|
||||||
;
|
;
|
||||||
|
} else if (checkEndDate.isAtSameMomentAs(checkStartDate)) {
|
||||||
|
setState(() {
|
||||||
|
errorMessages["end_date"] =
|
||||||
|
"Start and end dates cannot be the same";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errorMessages["end_date"] = "Invalid date format";
|
errorMessages["end_date"] = "Invalid date format";
|
||||||
@ -320,6 +325,16 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
final cash = data["deposit_on_cash"];
|
final cash = data["deposit_on_cash"];
|
||||||
print("card - $card");
|
print("card - $card");
|
||||||
print("cash - $cash");
|
print("cash - $cash");
|
||||||
|
// Call validations first (they populate errorMessages)
|
||||||
|
_validateCardAmount(card);
|
||||||
|
_validateCashAmount(cash);
|
||||||
|
|
||||||
|
// Now check if any errors exist
|
||||||
|
if (errorMessages.isNotEmpty) {
|
||||||
|
print("Validation Failed: ${errorMessages}");
|
||||||
|
setState(() {}); // Refresh UI with error messages
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isValidForexData(data)) {
|
if (!isValidForexData(data)) {
|
||||||
// && errorMessages.isNotEmpty) {
|
// && errorMessages.isNotEmpty) {
|
||||||
@ -495,6 +510,7 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
|
|
||||||
// Check if all required fields have data
|
// Check if all required fields have data
|
||||||
bool _isForexDataDurationComplete() {
|
bool _isForexDataDurationComplete() {
|
||||||
|
print("Calculate 13ww Duration");
|
||||||
final data = getForexData;
|
final data = getForexData;
|
||||||
return (data["start_date"]?.isNotEmpty ?? false) &&
|
return (data["start_date"]?.isNotEmpty ?? false) &&
|
||||||
(data["end_date"]?.isNotEmpty ?? false);
|
(data["end_date"]?.isNotEmpty ?? false);
|
||||||
@ -503,7 +519,7 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
// Handle field changes
|
// Handle field changes
|
||||||
void _onFieldChanged() {
|
void _onFieldChanged() {
|
||||||
if (_isForexDataDurationComplete()) {
|
if (_isForexDataDurationComplete()) {
|
||||||
print("Calculate 1");
|
print("Calculate 1 Duration");
|
||||||
CalculateDuration();
|
CalculateDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +533,7 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CalculateDuration() {
|
void CalculateDuration() {
|
||||||
print("Calculate 2");
|
print("Calculate 2 Duration");
|
||||||
final data = getForexData;
|
final data = getForexData;
|
||||||
final startDateString = data["start_date"];
|
final startDateString = data["start_date"];
|
||||||
final endDateString = data["end_date"];
|
final endDateString = data["end_date"];
|
||||||
@ -539,7 +555,7 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
|
|
||||||
// Calculate difference
|
// Calculate difference
|
||||||
final durationInDays =
|
final durationInDays =
|
||||||
endDate.difference(startDate).inDays + 1; // +1 to include both days
|
endDate.difference(startDate).inDays; // +1 to include both days
|
||||||
|
|
||||||
// You can now use durationInDays however you want:
|
// You can now use durationInDays however you want:
|
||||||
print("Duration: $durationInDays days");
|
print("Duration: $durationInDays days");
|
||||||
@ -976,18 +992,36 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
textControllers["_forexEndDate"]!.text,
|
textControllers["_forexEndDate"]!.text,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (startDate != null &&
|
if (startDate != null && endDate != null) {
|
||||||
endDate != null &&
|
if (endDate.isBefore(startDate)) {
|
||||||
endDate.isBefore(startDate)) {
|
setState(() {
|
||||||
setState(() {
|
errorMessages["end_date"] =
|
||||||
errorMessages["end_date"] =
|
"End date cannot be earlier than start date";
|
||||||
"End date cannot be earlier than start date";
|
});
|
||||||
});
|
} else if (endDate.isAtSameMomentAs(startDate)) {
|
||||||
} else {
|
setState(() {
|
||||||
setState(() {
|
errorMessages["end_date"] =
|
||||||
errorMessages.remove("end_date");
|
"Start and end dates cannot be the same";
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
errorMessages.remove("end_date");
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (startDate != null &&
|
||||||
|
// endDate != null &&
|
||||||
|
// endDate.isBefore(startDate)) {
|
||||||
|
// setState(() {
|
||||||
|
// errorMessages["end_date"] =
|
||||||
|
// "End date cannot be earlier than start date";
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// setState(() {
|
||||||
|
// errorMessages.remove("end_date");
|
||||||
|
// });
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: AbsorbPointer(
|
child: AbsorbPointer(
|
||||||
@ -1062,6 +1096,11 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
errorMessages["end_date"] =
|
errorMessages["end_date"] =
|
||||||
"End date cannot be earlier than start date";
|
"End date cannot be earlier than start date";
|
||||||
});
|
});
|
||||||
|
} else if (endDate!.isAtSameMomentAs(startDate!)) {
|
||||||
|
setState(() {
|
||||||
|
errorMessages["end_date"] =
|
||||||
|
"Start and end dates cannot be the same";
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
errorMessages.remove("end_date");
|
errorMessages.remove("end_date");
|
||||||
@ -1098,7 +1137,8 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
errorMessages["end_date"]!,
|
errorMessages["end_date"]!,
|
||||||
style: const TextStyle(color: Colors.red, fontSize: 12),
|
style: const TextStyle(color: Colors.red, fontSize: 12),
|
||||||
maxLines: 2, // Allow it to wrap onto two lines
|
maxLines: 2, // Allow it to wrap onto two lines
|
||||||
overflow: TextOverflow.ellipsis, // Add ellipsis if it still overflows
|
overflow:
|
||||||
|
TextOverflow.ellipsis, // Add ellipsis if it still overflows
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@ -42,9 +42,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
final ApiService apiService = ApiService();
|
final ApiService apiService = ApiService();
|
||||||
|
|
||||||
final GlobalKey<PersonalDetailsState> personalDetailsKey =
|
final GlobalKey<PersonalDetailsState> personalDetailsKey =
|
||||||
GlobalKey<PersonalDetailsState>();
|
GlobalKey<PersonalDetailsState>();
|
||||||
final GlobalKey<TravellerDetailsState> travellerDetailsKey =
|
final GlobalKey<TravellerDetailsState> travellerDetailsKey =
|
||||||
GlobalKey<TravellerDetailsState>();
|
GlobalKey<TravellerDetailsState>();
|
||||||
|
|
||||||
// late List<Map<String, dynamic>?> travelDetailsData;
|
// late List<Map<String, dynamic>?> travelDetailsData;
|
||||||
Map<String, dynamic>? travelDetailsData;
|
Map<String, dynamic>? travelDetailsData;
|
||||||
@ -64,6 +64,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
final Map<String, TextEditingController> controllers = {};
|
final Map<String, TextEditingController> controllers = {};
|
||||||
bool isViewMode = false;
|
bool isViewMode = false;
|
||||||
bool isEditProfile = false;
|
bool isEditProfile = false;
|
||||||
|
|
||||||
// late final List<dynamic>? apiCountryData ;
|
// late final List<dynamic>? apiCountryData ;
|
||||||
|
|
||||||
late List<dynamic>? apiCountryData;
|
late List<dynamic>? apiCountryData;
|
||||||
@ -86,6 +87,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
|
|
||||||
String? selectedCountry;
|
String? selectedCountry;
|
||||||
String? selectedGender;
|
String? selectedGender;
|
||||||
|
|
||||||
// String? selectedGender = personalDetailsKey.currentState?.selectedGender;
|
// String? selectedGender = personalDetailsKey.currentState?.selectedGender;
|
||||||
|
|
||||||
String? selectedUserType;
|
String? selectedUserType;
|
||||||
@ -299,7 +301,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
// Fix the invalid JSON (dangerous if the format changes)
|
// Fix the invalid JSON (dangerous if the format changes)
|
||||||
final fixedJson = raw.replaceAllMapped(
|
final fixedJson = raw.replaceAllMapped(
|
||||||
RegExp(r'(\w+):'), // matches `service_id:`
|
RegExp(r'(\w+):'), // matches `service_id:`
|
||||||
(match) => '"${match.group(1)}":',
|
(match) => '"${match.group(1)}":',
|
||||||
);
|
);
|
||||||
|
|
||||||
List<dynamic> decodedList = jsonDecode(fixedJson);
|
List<dynamic> decodedList = jsonDecode(fixedJson);
|
||||||
@ -363,7 +365,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
final extraData =
|
final extraData =
|
||||||
GoRouterState.of(context).extra as Map<String, dynamic>?;
|
GoRouterState.of(context).extra as Map<String, dynamic>?;
|
||||||
|
|
||||||
if (extraData != null) {
|
if (extraData != null) {
|
||||||
print("extraData: ${extraData['selectedUser']}");
|
print("extraData: ${extraData['selectedUser']}");
|
||||||
@ -381,8 +383,8 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
|
|
||||||
// Handle selectedUser as a Map (not a List)
|
// Handle selectedUser as a Map (not a List)
|
||||||
apiselectedUser =
|
apiselectedUser =
|
||||||
extraData['selectedUser']
|
extraData['selectedUser']
|
||||||
as Map<String, dynamic>?; // Cast it as a Map
|
as Map<String, dynamic>?; // Cast it as a Map
|
||||||
isViewMode = extraData['isViewMode'] ?? false;
|
isViewMode = extraData['isViewMode'] ?? false;
|
||||||
isEditProfile = extraData['isEditProfile'] ?? false;
|
isEditProfile = extraData['isEditProfile'] ?? false;
|
||||||
});
|
});
|
||||||
@ -444,7 +446,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
userMap = {
|
userMap = {
|
||||||
for (var user in userList)
|
for (var user in userList)
|
||||||
user['user_id'].toString():
|
user['user_id'].toString():
|
||||||
"${user['first_name']} ${user['last_name']}",
|
"${user['first_name']} ${user['last_name']}",
|
||||||
};
|
};
|
||||||
userIdsApi = userMap.keys.toList();
|
userIdsApi = userMap.keys.toList();
|
||||||
});
|
});
|
||||||
@ -483,14 +485,14 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
layoutColor =
|
layoutColor =
|
||||||
layoutString != null
|
layoutString != null
|
||||||
? Color(int.parse(layoutString))
|
? Color(int.parse(layoutString))
|
||||||
: Colors.redAccent;
|
: Colors.redAccent;
|
||||||
|
|
||||||
bodyColor =
|
bodyColor =
|
||||||
bodyStringColor != null
|
bodyStringColor != null
|
||||||
? Color(int.parse(bodyStringColor))
|
? Color(int.parse(bodyStringColor))
|
||||||
: Colors.white;
|
: Colors.white;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,9 +658,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
// printFormData();
|
// printFormData();
|
||||||
|
|
||||||
bool isValid = travellerDetailsKey.currentState?.boolValidation() ?? false;
|
bool isValid = travellerDetailsKey.currentState?.boolValidation() ?? false;
|
||||||
if (selectedTab == "travel" ||
|
if (selectedRole == "5" || setSelectesUserType == true) {
|
||||||
selectedRole == "5" ||
|
|
||||||
setSelectesUserType == true) {
|
|
||||||
print("NO validation");
|
print("NO validation");
|
||||||
|
|
||||||
Map<String, dynamic> data = userDetials;
|
Map<String, dynamic> data = userDetials;
|
||||||
@ -702,30 +702,64 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
|
|
||||||
// block-submit-here
|
// block-submit-here
|
||||||
|
|
||||||
// Additional validation starts - travelDetailsData passport
|
final format = DateFormat("dd-MM-yyyy");
|
||||||
DateTime? start_Date = travelDetailsData?['date_of_issue'];
|
|
||||||
DateTime? end_Date = travelDetailsData?['date_of_expiry'];
|
|
||||||
|
|
||||||
if (start_Date != null && end_Date != null && start_Date.toString().isNotEmpty && end_Date.toString().isNotEmpty) {
|
DateTime? start_Date;
|
||||||
try {
|
DateTime? end_Date;
|
||||||
final format = DateFormat("dd-MM-yyyy");
|
|
||||||
final checkStartDate = format.parse("$start_Date");
|
|
||||||
final checkEndDate = format.parse("$end_Date");
|
|
||||||
|
|
||||||
if (checkEndDate.isBefore(checkStartDate)) {
|
try {
|
||||||
// return "End date cannot be earlier than start date";;
|
if (travelDetailsData?['date_of_issue'] != null &&
|
||||||
return ;
|
travelDetailsData!['date_of_issue'].toString().isNotEmpty) {
|
||||||
}
|
start_Date = format.parse(travelDetailsData!['date_of_issue']);
|
||||||
} catch (e) { // return "End date cannot be earlier than start date";
|
|
||||||
return ;
|
|
||||||
// errorMessages["end_date"] = "Invalid date format";
|
|
||||||
}
|
}
|
||||||
|
if (travelDetailsData?['date_of_expiry'] != null &&
|
||||||
|
travelDetailsData!['date_of_expiry'].toString().isNotEmpty) {
|
||||||
|
end_Date = format.parse(travelDetailsData!['date_of_expiry']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start_Date != null &&
|
||||||
|
end_Date != null &&
|
||||||
|
end_Date.isBefore(start_Date)) {
|
||||||
|
print("End date cannot be earlier than start date");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Invalid passport date format");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Additional validation starts - travelDetailsData passport
|
||||||
|
// DateTime? start_Date = travelDetailsData?['date_of_issue'];
|
||||||
|
// DateTime? end_Date = travelDetailsData?['date_of_expiry'];
|
||||||
|
//
|
||||||
|
// if (start_Date != null &&
|
||||||
|
// end_Date != null &&
|
||||||
|
// start_Date.toString().isNotEmpty &&
|
||||||
|
// end_Date.toString().isNotEmpty) {
|
||||||
|
// try {
|
||||||
|
// final format = DateFormat("dd-MM-yyyy");
|
||||||
|
// final checkStartDate = format.parse("$start_Date");
|
||||||
|
// final checkEndDate = format.parse("$end_Date");
|
||||||
|
//
|
||||||
|
// if (checkEndDate.isBefore(checkStartDate)) {
|
||||||
|
// // return "End date cannot be earlier than start date";;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// } catch (e) {
|
||||||
|
// // return "End date cannot be earlier than start date";
|
||||||
|
// return;
|
||||||
|
// // errorMessages["end_date"] = "Invalid date format";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// valid_from: 20-06-2025, valid_upto: 19-06-2025
|
// valid_from: 20-06-2025, valid_upto: 19-06-2025
|
||||||
DateTime? valid_from = data?['valid_from'];
|
DateTime? valid_from = data?['valid_from'];
|
||||||
DateTime? valid_upto = data?['valid_upto'];
|
DateTime? valid_upto = data?['valid_upto'];
|
||||||
|
|
||||||
if (valid_from != null && valid_upto != null && valid_from.toString().isNotEmpty && valid_upto.toString().isNotEmpty) {
|
if (valid_from != null &&
|
||||||
|
valid_upto != null &&
|
||||||
|
valid_from.toString().isNotEmpty &&
|
||||||
|
valid_upto.toString().isNotEmpty) {
|
||||||
try {
|
try {
|
||||||
final format = DateFormat("dd-MM-yyyy");
|
final format = DateFormat("dd-MM-yyyy");
|
||||||
final checkValidFrom = format.parse("$valid_from");
|
final checkValidFrom = format.parse("$valid_from");
|
||||||
@ -733,10 +767,11 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
|
|
||||||
if (checkValidUpto.isBefore(checkValidFrom)) {
|
if (checkValidUpto.isBefore(checkValidFrom)) {
|
||||||
// return "valid upto cannot be earlier than valid from";
|
// return "valid upto cannot be earlier than valid from";
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) { // return "valid upto cannot be earlier than valid from";
|
} catch (e) {
|
||||||
return ;
|
// return "valid upto cannot be earlier than valid from";
|
||||||
|
return;
|
||||||
// errorMessages["end_date"] = "Invalid date format";
|
// errorMessages["end_date"] = "Invalid date format";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -785,7 +820,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
if (data["mobile_no"] != null && data["mobile_no"].toString().isNotEmpty) {
|
if (data["mobile_no"] != null && data["mobile_no"].toString().isNotEmpty) {
|
||||||
if (!RegExp(r"^\d{10}$").hasMatch(data["mobile_no"].toString())) {
|
if (!RegExp(r"^\d{10}$").hasMatch(data["mobile_no"].toString())) {
|
||||||
errorMessages["mobile_no"] =
|
errorMessages["mobile_no"] =
|
||||||
"Enter 10 digits"; // Invalid mobile number format
|
"Enter 10 digits"; // Invalid mobile number format
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,7 +830,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
r"^\d{10}$",
|
r"^\d{10}$",
|
||||||
).hasMatch(data["alternate_mobile_no"].toString())) {
|
).hasMatch(data["alternate_mobile_no"].toString())) {
|
||||||
errorMessages["alternate_mobile_no"] =
|
errorMessages["alternate_mobile_no"] =
|
||||||
"Enter 10 digits"; // Invalid mobile number format
|
"Enter 10 digits"; // Invalid mobile number format
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,7 +1020,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
// ✅ Ensure UI updates
|
// ✅ Ensure UI updates
|
||||||
if (isMatch) {
|
if (isMatch) {
|
||||||
errorMessages["password"] =
|
errorMessages["password"] =
|
||||||
"New password is not similar to old password";
|
"New password is not similar to old password";
|
||||||
print(" Password match!");
|
print(" Password match!");
|
||||||
} else {
|
} else {
|
||||||
print(" Password NOT match!");
|
print(" Password NOT match!");
|
||||||
@ -1014,16 +1049,16 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
drawer: CustomDrawer(isDesktop: false),
|
drawer: CustomDrawer(isDesktop: false),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding:
|
padding:
|
||||||
isDesktop
|
isDesktop
|
||||||
? EdgeInsets.symmetric(
|
? EdgeInsets.symmetric(
|
||||||
horizontal:
|
horizontal:
|
||||||
MediaQuery.of(context).size.width *
|
MediaQuery.of(context).size.width *
|
||||||
0.1, // 30% of screen width as horizontal padding
|
0.1, // 30% of screen width as horizontal padding
|
||||||
vertical:
|
vertical:
|
||||||
MediaQuery.of(context).size.height *
|
MediaQuery.of(context).size.height *
|
||||||
0, // 5% of screen height as vertical padding
|
0, // 5% of screen height as vertical padding
|
||||||
)
|
)
|
||||||
: EdgeInsets.all(0),
|
: EdgeInsets.all(0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [Expanded(child: buildData(isDesktop, context))],
|
children: [Expanded(child: buildData(isDesktop, context))],
|
||||||
),
|
),
|
||||||
@ -1045,9 +1080,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
height:
|
height:
|
||||||
isDesktop
|
isDesktop
|
||||||
? MediaQuery.of(context).size.height * 0.98
|
? MediaQuery.of(context).size.height * 0.98
|
||||||
: MediaQuery.of(context).size.height,
|
: MediaQuery.of(context).size.height,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(0.0),
|
padding: EdgeInsets.all(0.0),
|
||||||
child: _buildUserDetails(isDesktop),
|
child: _buildUserDetails(isDesktop),
|
||||||
@ -1059,39 +1094,39 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child:
|
child:
|
||||||
isDesktop
|
isDesktop
|
||||||
? Row(
|
? Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (selectedTab != "personal")
|
if (selectedTab != "personal")
|
||||||
..._buildBack(isDesktop, layoutColor!),
|
..._buildBack(isDesktop, layoutColor!),
|
||||||
Spacer(), // spacing between buttons
|
Spacer(), // spacing between buttons
|
||||||
// Next or Submit based on role or user type
|
// Next or Submit based on role or user type
|
||||||
if (selectedTab == "travel" ||
|
if (selectedTab == "travel" ||
|
||||||
selectedRole == "5" ||
|
selectedRole == "5" ||
|
||||||
setSelectesUserType == true)
|
setSelectesUserType == true)
|
||||||
..._buildSubmit(isDesktop, layoutColor!)
|
..._buildSubmit(isDesktop, layoutColor!)
|
||||||
else
|
else
|
||||||
..._buildNext(isDesktop, layoutColor!),
|
..._buildNext(isDesktop, layoutColor!),
|
||||||
// (selectedTab == "travel" ||
|
// (selectedTab == "travel" ||
|
||||||
// selectedRole == "5" ||
|
// selectedRole == "5" ||
|
||||||
// setSelectesUserType == true)
|
// setSelectesUserType == true)
|
||||||
// ? _buildSubmit(isDesktop, layoutColor!)
|
// ? _buildSubmit(isDesktop, layoutColor!)
|
||||||
// : _buildNext(
|
// : _buildNext(
|
||||||
// isDesktop,
|
// isDesktop,
|
||||||
// layoutColor!,
|
// layoutColor!,
|
||||||
// ), // _buildGoBack(isDesktop, layoutColor!),
|
// ), // _buildGoBack(isDesktop, layoutColor!),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children:
|
children:
|
||||||
(selectedTab == "travel" ||
|
(selectedTab == "travel" ||
|
||||||
selectedRole == "5" ||
|
selectedRole == "5" ||
|
||||||
setSelectesUserType == true)
|
setSelectesUserType == true)
|
||||||
? _buildSubmit(isDesktop, layoutColor!)
|
? _buildSubmit(isDesktop, layoutColor!)
|
||||||
: _buildNext(isDesktop, layoutColor!),
|
: _buildNext(isDesktop, layoutColor!),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1136,9 +1171,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
isDesktop
|
isDesktop
|
||||||
? buildTabsForUser()
|
? buildTabsForUser()
|
||||||
: SingleChildScrollView(
|
: SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: buildTabsForUser(),
|
child: buildTabsForUser(),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
// color: Colors.yellow.shade50,
|
// color: Colors.yellow.shade50,
|
||||||
height: MediaQuery.of(context).size.height * 0.64,
|
height: MediaQuery.of(context).size.height * 0.64,
|
||||||
@ -1241,8 +1276,8 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
);
|
);
|
||||||
case "travel":
|
case "travel":
|
||||||
final fullName =
|
final fullName =
|
||||||
"${controllers["Fname"]?.text ?? ""} ${controllers["Lname"]?.text ?? ""}"
|
"${controllers["Fname"]?.text ?? ""} ${controllers["Lname"]?.text ?? ""}"
|
||||||
.trim();
|
.trim();
|
||||||
return TravellerDetails(
|
return TravellerDetails(
|
||||||
key: travellerDetailsKey,
|
key: travellerDetailsKey,
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
@ -1301,69 +1336,69 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end, // important
|
crossAxisAlignment: CrossAxisAlignment.end, // important
|
||||||
children:
|
children:
|
||||||
tabs.entries.map((entry) {
|
tabs.entries.map((entry) {
|
||||||
final targetTab = entry.key;
|
final targetTab = entry.key;
|
||||||
|
|
||||||
print("TargetsTAb: $targetTab");
|
print("TargetsTAb: $targetTab");
|
||||||
|
|
||||||
final isSelected = selectedTab == entry.key;
|
final isSelected = selectedTab == entry.key;
|
||||||
print("isSelected: $isSelected");
|
print("isSelected: $isSelected");
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
bool isValid = false;
|
bool isValid = false;
|
||||||
|
|
||||||
final currentTab = selectedTab;
|
final currentTab = selectedTab;
|
||||||
if (currentTab == "personal") {
|
if (currentTab == "personal") {
|
||||||
isValid = isValidData(userDetials);
|
isValid = isValidData(userDetials);
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
selectedTab = entry.key;
|
selectedTab = entry.key;
|
||||||
}
|
}
|
||||||
} else if (currentTab == "office" &&
|
} else if (currentTab == "office" &&
|
||||||
targetTab == "personal") {
|
targetTab == "personal") {
|
||||||
selectedTab = entry.key;
|
selectedTab = entry.key;
|
||||||
} else if (currentTab == "office") {
|
} else if (currentTab == "office") {
|
||||||
isValid = isValidDataTwo(userDetials);
|
isValid = isValidDataTwo(userDetials);
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
selectedTab = entry.key;
|
selectedTab = entry.key;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isValid =
|
isValid =
|
||||||
true; // Travel tab might not need validation at this point
|
true; // Travel tab might not need validation at this point
|
||||||
selectedTab = entry.key;
|
selectedTab = entry.key;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
right: 24.0,
|
right: 24.0,
|
||||||
), // space between tabs
|
), // space between tabs
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
entry.value,
|
entry.value,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color:
|
color:
|
||||||
isSelected ? Color(0xFF114D8B) : Color(0xFF475569),
|
isSelected ? Color(0xFF114D8B) : Color(0xFF475569),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
AnimatedContainer(
|
||||||
|
duration: Duration(milliseconds: 300),
|
||||||
|
height: 2,
|
||||||
|
width: isSelected ? 50 : 0, // small line
|
||||||
|
color: Color(0xFF114D8B),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
),
|
||||||
AnimatedContainer(
|
);
|
||||||
duration: Duration(milliseconds: 300),
|
}).toList(),
|
||||||
height: 2,
|
|
||||||
width: isSelected ? 50 : 0, // small line
|
|
||||||
color: Color(0xFF114D8B),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1373,17 +1408,17 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
return [
|
return [
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor:
|
cursor:
|
||||||
isViewMode
|
isViewMode
|
||||||
? SystemMouseCursors.forbidden
|
? SystemMouseCursors.forbidden
|
||||||
: SystemMouseCursors.click,
|
: SystemMouseCursors.click,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||||
foregroundColor:
|
foregroundColor:
|
||||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||||
disabledBackgroundColor:
|
disabledBackgroundColor:
|
||||||
layoutColor, // Ensure color remains when disabled
|
layoutColor, // Ensure color remains when disabled
|
||||||
disabledForegroundColor: Colors.white,
|
disabledForegroundColor: Colors.white,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
@ -1402,17 +1437,17 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
return [
|
return [
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor:
|
cursor:
|
||||||
isViewMode
|
isViewMode
|
||||||
? SystemMouseCursors.forbidden
|
? SystemMouseCursors.forbidden
|
||||||
: SystemMouseCursors.click,
|
: SystemMouseCursors.click,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||||
foregroundColor:
|
foregroundColor:
|
||||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||||
disabledBackgroundColor:
|
disabledBackgroundColor:
|
||||||
layoutColor, // Ensure color remains when disabled
|
layoutColor, // Ensure color remains when disabled
|
||||||
disabledForegroundColor: Colors.white,
|
disabledForegroundColor: Colors.white,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
@ -1433,17 +1468,17 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
return [
|
return [
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor:
|
cursor:
|
||||||
isViewMode
|
isViewMode
|
||||||
? SystemMouseCursors.forbidden
|
? SystemMouseCursors.forbidden
|
||||||
: SystemMouseCursors.click,
|
: SystemMouseCursors.click,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
isViewMode ? Colors.white : Colors.white, // Keep original color
|
isViewMode ? Colors.white : Colors.white, // Keep original color
|
||||||
foregroundColor:
|
foregroundColor:
|
||||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||||
disabledBackgroundColor:
|
disabledBackgroundColor:
|
||||||
layoutColor, // Ensure color remains when disabled
|
layoutColor, // Ensure color remains when disabled
|
||||||
disabledForegroundColor: Colors.white,
|
disabledForegroundColor: Colors.white,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
@ -1481,19 +1516,19 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
if (!isViewMode)
|
if (!isViewMode)
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor:
|
cursor:
|
||||||
isViewMode
|
isViewMode
|
||||||
? SystemMouseCursors.forbidden
|
? SystemMouseCursors.forbidden
|
||||||
: SystemMouseCursors.click,
|
: SystemMouseCursors.click,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
isViewMode ? layoutColor : layoutColor, // Keep original color
|
isViewMode ? layoutColor : layoutColor, // Keep original color
|
||||||
foregroundColor:
|
foregroundColor:
|
||||||
isViewMode
|
isViewMode
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: Colors.white, // Keep original color
|
: Colors.white, // Keep original color
|
||||||
disabledBackgroundColor:
|
disabledBackgroundColor:
|
||||||
layoutColor, // Ensure color remains when disabled
|
layoutColor, // Ensure color remains when disabled
|
||||||
disabledForegroundColor: Colors.white,
|
disabledForegroundColor: Colors.white,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
@ -1502,7 +1537,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
onPressed:
|
onPressed:
|
||||||
isViewMode ? null : handleSubmit, // Disable when in view mode
|
isViewMode ? null : handleSubmit, // Disable when in view mode
|
||||||
child: Text("Submit"),
|
child: Text("Submit"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
This is a placeholder for base href that will be replaced by the value of
|
This is a placeholder for base href that will be replaced by the value of
|
||||||
the `--base-href` argument provided to `flutter build`.
|
the `--base-href` argument provided to `flutter build`.
|
||||||
-->
|
-->
|
||||||
<base href="$FLUTTER_BASE_HREF">
|
<base href="/tstat/">
|
||||||
|
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user