user passport changes

This commit is contained in:
venbaittech 2025-06-06 18:05:58 +05:30
parent fe6ccab809
commit f48680c2a5
5 changed files with 132 additions and 43 deletions

View File

@ -349,7 +349,7 @@ class _UserSelectionDialogState extends State<UserSelectionDialog> {
mainAxisSize: mainAxisSize:
MainAxisSize.min, // Ensures content doesn't expand unnecessarily MainAxisSize.min, // Ensures content doesn't expand unnecessarily
children: [ children: [
widget.title == "Others" widget.title == "Others (Non Employee)"
? Text( ? Text(
"Please Select Other User", "Please Select Other User",
style: GoogleFonts.poppins(fontSize: 14), style: GoogleFonts.poppins(fontSize: 14),
@ -367,7 +367,7 @@ class _UserSelectionDialogState extends State<UserSelectionDialog> {
setState(() { setState(() {
_showTravellerForm = false; _showTravellerForm = false;
}); });
widget.title == "Others" widget.title == "Others (Non Employee)"
? _filterTravellers(query) ? _filterTravellers(query)
: _filterUsers(query); : _filterUsers(query);
}, },
@ -395,7 +395,7 @@ class _UserSelectionDialogState extends State<UserSelectionDialog> {
SizedBox(height: 10), SizedBox(height: 10),
if (widget.title == "Others") ...[ if (widget.title == "Others (Non Employee)") ...[
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [

View File

@ -686,7 +686,7 @@ class FlightScreenState extends State<FlightScreen> {
child: Column( child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(20.0), padding: const EdgeInsets.only(top: 30.0),
child: Center( child: Center(
child: Column(children: _buildAccomadtionForm(isDesktop)), child: Column(children: _buildAccomadtionForm(isDesktop)),
), ),
@ -1809,7 +1809,7 @@ class FlightScreenState extends State<FlightScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldWrapper( CustomTextFieldItnerarySubWrapper(
// use same wrapper as class // use same wrapper as class
isFocused: focusStates["_visa1Focused"] ?? false, isFocused: focusStates["_visa1Focused"] ?? false,
isDesktop: isDesktop, isDesktop: isDesktop,

View File

@ -2583,7 +2583,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
List<Map<String, String>> options = [ List<Map<String, String>> options = [
{"title": "Self", "value": "Option 1"}, {"title": "Self", "value": "Option 1"},
{"title": "Other Employee", "value": "Option 2"}, {"title": "Other Employee", "value": "Option 2"},
{"title": "Others", "value": "Option 3"}, {"title": "Others (Non Employee)", "value": "Option 3"},
]; ];
print(" layoutColor: ${widget.layoutColor}"); print(" layoutColor: ${widget.layoutColor}");
@ -2899,8 +2899,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
// ), // ),
// ), // ),
CustomTextFieldWrapper( CustomTextFieldWrapper(
isFocused: false, // isFocused: false,
// isFocused: _isdescriptionFocused, isFocused: _isdescriptionFocused,
// width: isDesktop // width: isDesktop
// ? MediaQuery.of(context).size.width * 0.38 // ? MediaQuery.of(context).size.width * 0.38
// : MediaQuery.of(context).size.width * 0.85, // : MediaQuery.of(context).size.width * 0.85,

View File

@ -49,7 +49,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
// late List<Map<String, dynamic>?> travelDetailsData; // late List<Map<String, dynamic>?> travelDetailsData;
Map<String, dynamic>? travelDetailsData; Map<String, dynamic>? travelDetailsData;
Map<String, dynamic>? travelDetailsDataFromAPI; Map<String, dynamic>? travelDetailsDataFromAPI;
Map<String, String> errorMessagesTravel = {};
late TabController _tabController; late TabController _tabController;
String? userId; String? userId;
@ -580,6 +580,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
// travelDetailsData = [travellerDetailsKey.currentState?.travel_Detials]; // travelDetailsData = [travellerDetailsKey.currentState?.travel_Detials];
travelDetailsData = travellerDetailsKey.currentState?.travel_Detials; travelDetailsData = travellerDetailsKey.currentState?.travel_Detials;
errorMessagesTravel = travellerDetailsKey.currentState!.errorMessages;
print("TRAVEL DETAILS FROM CHILD: $travelDetailsData"); print("TRAVEL DETAILS FROM CHILD: $travelDetailsData");
@ -655,6 +656,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
// printFormData(); // printFormData();
travelDetailsData = travellerDetailsKey.currentState?.travel_Detials; travelDetailsData = travellerDetailsKey.currentState?.travel_Detials;
print("travelDetailsData - $travelDetailsData");
errorMessagesTravel = travellerDetailsKey.currentState!.errorMessages;
print("TRAVEL DETAILS FROM CHILD"); print("TRAVEL DETAILS FROM CHILD");
// print("TRAVEL DETAILS FROM CHILD: $travelDetailsData"); // print("TRAVEL DETAILS FROM CHILD: $travelDetailsData");
@ -668,7 +672,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
// Map<String, dynamic> data = userDetials; // Map<String, dynamic> data = userDetials;
if (!isValidData(data) && isValidDataTwo(data)) { if (!isValidData(data) &&
isValidDataTwo(data) &&
errorMessagesTravel.isNotEmpty) {
print("USERDETAILS : $userDetials"); print("USERDETAILS : $userDetials");
print("Validation Failed: Required fields are missing."); print("Validation Failed: Required fields are missing.");
setState(() {}); setState(() {});
@ -677,7 +683,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
print("USERDETAILS : $userDetials"); print("USERDETAILS : $userDetials");
orgId = await getOrgId(); orgId = await getOrgId();
createUserData(userDetials); // createUserData(userDetials);
} }
} }

View File

@ -62,6 +62,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
String? selectedFileNames; String? selectedFileNames;
Uint8List? passportDocumentBytes; Uint8List? passportDocumentBytes;
String? passportFileUrlFromApi; String? passportFileUrlFromApi;
String? _selectedTripType;
// String? selectedPurpose; // String? selectedPurpose;
// String? selectedCountry; // String? selectedCountry;
@ -107,7 +108,6 @@ class TravellerDetailsState extends State<TravellerDetails> {
List<String> dataHeader = [ List<String> dataHeader = [
"Fname", "Fname",
"Mname", "Mname",
"Lname", "Lname",
"nationality", "nationality",
"d_meal_pref", "d_meal_pref",
@ -310,9 +310,10 @@ class TravellerDetailsState extends State<TravellerDetails> {
Map<String, dynamic> get travel_Detials { Map<String, dynamic> get travel_Detials {
Map<String, dynamic> data = { Map<String, dynamic> data = {
// "given_Name": controllers["Fname"]?.text, "passport_firstname": controllers["Fname"]?.text,
// "last_Name": controllers["Lname"]?.text, "passport_middlename": controllers["Mname"]?.text,
// "nationality": controllers["nationality"]?.text, "passport_lastname": controllers["Lname"]?.text,
"nationality": _selectedTripType,
"passport_number": controllers["passportNumber"]?.text ?? '', "passport_number": controllers["passportNumber"]?.text ?? '',
"place_of_issue": controllers["placeOfIssue"]?.text, "place_of_issue": controllers["placeOfIssue"]?.text,
"date_of_issue": controllers["dateOfIssue"]?.text, "date_of_issue": controllers["dateOfIssue"]?.text,
@ -502,6 +503,17 @@ class TravellerDetailsState extends State<TravellerDetails> {
print("Updatewidget.travelDetails"); print("Updatewidget.travelDetails");
print(widget.travelDetails); print(widget.travelDetails);
controllers["Fname"]?.text =
widget.travelDetails?["passport_firstname"] ?? "";
controllers["Mname"]?.text =
widget.travelDetails?["passport_middlename"] ?? "";
controllers["Lname"]?.text =
widget.travelDetails?["passport_lastname"] ?? "";
_selectedTripType = widget.travelDetails?["nationality"] ?? "";
controllers["passportNumber"]?.text = controllers["passportNumber"]?.text =
widget.travelDetails?["passport_number"] ?? ""; widget.travelDetails?["passport_number"] ?? "";
controllers["placeOfIssue"]?.text = controllers["placeOfIssue"]?.text =
@ -1133,6 +1145,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
} }
Widget buildNationality() { Widget buildNationality() {
List<String> nationalityOptions = ["Indian", "International"];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -1154,23 +1167,54 @@ class TravellerDetailsState extends State<TravellerDetails> {
isDesktop: widget.isDesktop, isDesktop: widget.isDesktop,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: TextField( child: DropdownSearch<String>(
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black), selectedItem: _selectedTripType,
controller: controllers["nationality"],
enabled: !widget.isViewMode, enabled: !widget.isViewMode,
onChanged: (value) {
_clearError("last_name"); popupProps: PopupProps.menu(
}, showSearchBox: false, // Set true if you want search
decoration: InputDecoration( fit: FlexFit.loose,
labelText: "Nationality", constraints: BoxConstraints(maxHeight: 200),
labelStyle: GoogleFonts.poppins( itemBuilder:
fontSize: 12, (context, item, isSelected) => Container(
color: Colors.grey, color: Colors.white,
), padding: EdgeInsets.symmetric(
floatingLabelBehavior: FloatingLabelBehavior.never, horizontal: 10,
border: InputBorder.none, vertical: 6,
contentPadding: EdgeInsets.symmetric(vertical: 16), ),
child: Text(
item,
style: GoogleFonts.poppins(fontSize: 11.5),
),
),
), ),
items: nationalityOptions,
dropdownDecoratorProps: DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 1),
),
),
dropdownBuilder:
(context, selectedItem) => Align(
alignment: Alignment.centerLeft,
child: Text(
selectedItem ?? "Select",
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
),
),
onChanged:
widget.isViewMode
? null
: (String? newValue) {
setState(() {
_selectedTripType = newValue;
print("_selectedTripType - $_selectedTripType");
});
},
), ),
), ),
), ),
@ -1200,8 +1244,30 @@ class TravellerDetailsState extends State<TravellerDetails> {
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black), style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
controller: controllers["passportNumber"], controller: controllers["passportNumber"],
enabled: !widget.isViewMode, enabled: !widget.isViewMode,
inputFormatters: [
// limit to 8 characters
FilteringTextInputFormatter.allow(
RegExp(r'[a-zA-Z0-9]'),
), // allow only letters and digits
if (_selectedTripType == "Indian")
LengthLimitingTextInputFormatter(8),
],
onChanged: (value) { onChanged: (value) {
_clearError("passport_number"); _clearError("passport_number");
final regex = RegExp(r'^[a-zA-Z0-9]{0,8}$');
if (!regex.hasMatch(value)) {
setState(() {
if (_selectedTripType == "Indian") {
errorMessages["passport_number"] =
"Only 8 characters allowed (letters & numbers)";
}
});
return;
} else {
setState(() {
errorMessages.remove("passport_number");
});
}
apiCheckDuplicate( apiCheckDuplicate(
"Passport Number", "Passport Number",
"passport_number", "passport_number",
@ -1372,29 +1438,46 @@ class TravellerDetailsState extends State<TravellerDetails> {
DateTime today = DateTime(now.year, now.month, now.day); DateTime today = DateTime(now.year, now.month, now.day);
// DateTime today = DateTime(now.year now.day, now.month,); // DateTime today = DateTime(now.year now.day, now.month,);
// Parse dateOfIssue safely
DateTime firstDate;
try {
firstDate = DateFormat(
"yyyy-MM-dd",
).parse(controllers["dateOfIssue"]!.text);
} catch (e) {
firstDate = today; // fallback if parsing fails
}
DateTime? pickedDate = await showDatePicker( DateTime? pickedDate = await showDatePicker(
context: context, context: context,
initialDate: initialDate:
_selectedDateOfExpiry != null && _selectedDateOfExpiry != null &&
_selectedDateOfExpiry!.isAfter(today) _selectedDateOfExpiry!.isAfter(firstDate)
? _selectedDateOfExpiry! ? _selectedDateOfExpiry!
: today, : today,
// firstDate: today, firstDate: firstDate,
firstDate: DateTime(1900), // firstDate: DateTime(1900),
lastDate: DateTime(2100), lastDate: DateTime(2100),
); );
if (pickedDate != null && pickedDate != _selectedDateOfExpiry) { if (pickedDate != null) {
setState(() { _selectedDateOfExpiry = pickedDate;
_selectedDateOfExpiry = pickedDate; controllers["dateOfExpiry"]?.text = DateFormat(
controllers["dateOfExpiry"]?.text = DateFormat( "yyyy-MM-dd",
'dd-MM-yyyy', ).format(pickedDate);
).format(pickedDate);
// controllers["dateOfExpiry"]?.text =
// DateFormat('dd-MM-yyyy').format(pickedDate);
});
} }
// if (pickedDate != null && pickedDate != _selectedDateOfExpiry) {
// setState(() {
// _selectedDateOfExpiry = pickedDate;
// controllers["dateOfExpiry"]?.text = DateFormat(
// 'dd-MM-yyyy',
// ).format(pickedDate);
//
// // controllers["dateOfExpiry"]?.text =
// // DateFormat('dd-MM-yyyy').format(pickedDate);
// });
// }
} }
return Column( return Column(