particular file traveller
This commit is contained in:
parent
3104812979
commit
dca5c4ba6b
@ -150,11 +150,15 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
|
||||
Future<void> apiCheckDuplicate(String label, String field, String value, String? userId) async {
|
||||
var newField = "";
|
||||
try {
|
||||
if(field == "forex_card_num"){
|
||||
field = "forex_pre_paid_card_number";
|
||||
}
|
||||
final response = await apiService.CheckDuplicate(label, field, value, userId);
|
||||
if(field == "forex_card_num"){
|
||||
newField = "forex_pre_paid_card_number";
|
||||
}
|
||||
if(field == "passportNumber"){
|
||||
newField = "passport_number";
|
||||
}
|
||||
final response = await apiService.CheckDuplicate(label, newField, value, userId);
|
||||
if (response.isNotEmpty) {
|
||||
_clearError(field);
|
||||
widget.errorMessages[field] = response['message'] ?? "$label already exists";
|
||||
@ -1107,7 +1111,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
controller: controllers["passportNumber"],
|
||||
enabled: !widget.isViewMode,
|
||||
onChanged: (value) {
|
||||
_clearError("last_name");
|
||||
_clearError("passportNumber");
|
||||
apiCheckDuplicate("Passport Number", "passportNumber",value,widget.userIdApi);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: "Passport Number",
|
||||
@ -2469,7 +2474,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 20, left: 8), // 👈 Add top padding here
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||
icon: Icon(Icons.remove_circle_sharp, color: Colors.red, size: 15),
|
||||
tooltip: 'Cancel the Details',
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@ -2491,7 +2496,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
buildFrequentFlierInformation(entry),
|
||||
SizedBox(width: 15),
|
||||
IconButton(
|
||||
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||
icon: Icon(Icons.remove_circle_sharp, color: Colors.red, size: 15),
|
||||
tooltip: 'Cancel the Details',
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@ -2784,7 +2789,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 20, left: 8), // 👈 Add top padding here
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||
icon: Icon(Icons.remove_circle_sharp, color: Colors.red, size: 15),
|
||||
tooltip: 'Cancel the Details',
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@ -2804,7 +2809,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 8),
|
||||
buildHotelMembershipNum(entry),
|
||||
IconButton(
|
||||
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||
icon: Icon(Icons.remove_circle_sharp, color: Colors.red, size: 15),
|
||||
tooltip: 'Cancel the Details',
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@ -3037,7 +3042,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 20, left: 8), // 👈 Add top padding here
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||
icon: Icon(Icons.remove_circle_sharp, color: Colors.red, size: 15),
|
||||
tooltip: 'Cancel the Details',
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@ -3061,7 +3066,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 8),
|
||||
buildVisaValidUpTo(entry),
|
||||
IconButton(
|
||||
icon: Icon(Icons.horizontal_rule, color: Colors.red, size: 15),
|
||||
icon: Icon(Icons.remove_circle_sharp, color: Colors.red, size: 15),
|
||||
tooltip: 'Cancel the Details',
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@ -3181,6 +3186,113 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
|
||||
Widget buildVisaType(entry) {
|
||||
if (apiData == null || apiData?['visa_type_of_visa'] == null) {
|
||||
return Center(
|
||||
child: Transform.scale(
|
||||
scale: 0.5,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<dynamic> purposeList = apiData?['visa_type_of_visa'];
|
||||
|
||||
// Map for id => name
|
||||
Map<String, String> visaTypeMap = {
|
||||
for (var item in purposeList)
|
||||
item['dropdown_key'].toString(): item['dropdown_value'].toString(),
|
||||
};
|
||||
|
||||
// Selected value from entry
|
||||
String? selectedPurpose = entry['visa_type_id']?.toString();
|
||||
|
||||
if (!visaTypeMap.containsKey(selectedPurpose)) {
|
||||
selectedPurpose = null;
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Visa Type",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF575A74),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
CustomTextFieldUserTravellerWrapper(
|
||||
width: widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.17
|
||||
: null,
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: DropdownSearch<String>(
|
||||
selectedItem: visaTypeMap[selectedPurpose],
|
||||
enabled: purposeList.isNotEmpty,
|
||||
popupProps: PopupProps.menu(
|
||||
showSearchBox: true,
|
||||
fit: FlexFit.loose,
|
||||
constraints: BoxConstraints(maxHeight: 200),
|
||||
itemBuilder: (context, item, isSelected) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
child: Text(
|
||||
item,
|
||||
style: GoogleFonts.poppins(fontSize: 11.5),
|
||||
),
|
||||
),
|
||||
searchFieldProps: TextFieldProps(
|
||||
decoration: InputDecoration(
|
||||
hintText: "Search Visa Type...",
|
||||
hintStyle: GoogleFonts.poppins(fontSize: 11.5),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
items: visaTypeMap.values.toList(),
|
||||
|
||||
dropdownDecoratorProps: DropDownDecoratorProps(
|
||||
dropdownSearchDecoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 1),
|
||||
),
|
||||
),
|
||||
dropdownBuilder: (context, selectedItem) => Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
selectedItem ?? "Select Visa Type",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
onChanged: (newValue) {
|
||||
if (newValue == null) return;
|
||||
|
||||
final selectedId = visaTypeMap.entries
|
||||
.firstWhere((entry) => entry.value == newValue)
|
||||
.key;
|
||||
|
||||
setState(() {
|
||||
entry['visa_type_id'] = selectedId;
|
||||
});
|
||||
|
||||
print(
|
||||
"Updating form data: visa_type_id -> $selectedId",
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildVisaType3(entry) {
|
||||
if (apiData == null || apiData?['visa_type_of_visa'] == null) {
|
||||
return Center(
|
||||
child: Transform.scale(scale: 0.5, child: CircularProgressIndicator()),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user