traveller
This commit is contained in:
parent
954fc5873e
commit
3b24228080
529
lib/Screens/traveller/travellerDetails.dart
Normal file
529
lib/Screens/traveller/travellerDetails.dart
Normal file
@ -0,0 +1,529 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
import '../../config/apiUrl.dart';
|
||||||
|
import '../../services/apiService.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
import '../../widgets/custom_text_forex.dart';
|
||||||
|
import 'travellerList.dart';
|
||||||
|
|
||||||
|
class TravellerData extends StatefulWidget {
|
||||||
|
final Future<List<dynamic>> Function() fetchGetTraveller;
|
||||||
|
final bool isDesktop;
|
||||||
|
final Color? layoutColor;
|
||||||
|
|
||||||
|
final int? travellerId; // <-- Add this
|
||||||
|
final Map<String, dynamic>? travellerData;
|
||||||
|
|
||||||
|
const TravellerData(
|
||||||
|
{super.key,
|
||||||
|
required this.isDesktop,
|
||||||
|
this.layoutColor,
|
||||||
|
required this.fetchGetTraveller,
|
||||||
|
this.travellerId,
|
||||||
|
this.travellerData});
|
||||||
|
|
||||||
|
@override
|
||||||
|
TravellerDataState createState() => TravellerDataState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class TravellerDataState extends State<TravellerData> {
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
|
Map<String, dynamic>? apiData;
|
||||||
|
|
||||||
|
final Map<String, FocusNode> focusNodes = {
|
||||||
|
"name": FocusNode(),
|
||||||
|
"description": FocusNode(),
|
||||||
|
};
|
||||||
|
|
||||||
|
final Map<String, TextEditingController> controllers = {};
|
||||||
|
Map<String, String> errorMessages = {};
|
||||||
|
|
||||||
|
String? selectedName;
|
||||||
|
String? selectedDescription;
|
||||||
|
String? userId;
|
||||||
|
int? travellerDataId;
|
||||||
|
late String isActive = "1";
|
||||||
|
|
||||||
|
List<String> dataHeader = [
|
||||||
|
"first_name",
|
||||||
|
"last_name",
|
||||||
|
"email",
|
||||||
|
"mobile",
|
||||||
|
];
|
||||||
|
|
||||||
|
Map<String, dynamic> travellerDetails() {
|
||||||
|
final data = {
|
||||||
|
// "traveller_id": int.parse(travellerId),
|
||||||
|
"first_name": controllers["first_name"]?.text,
|
||||||
|
"last_name": controllers["last_name"]?.text,
|
||||||
|
"email": controllers["email"]?.text,
|
||||||
|
"mobile": controllers["mobile"]?.text,
|
||||||
|
"is_active": isActive,
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
|
||||||
|
apiData = null;
|
||||||
|
for (var field in dataHeader) {
|
||||||
|
controllers[field] = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget.travellerId != null) {
|
||||||
|
print('Editing D ID: ${widget.travellerId}');
|
||||||
|
updateTravellerDetails();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _clearError() {
|
||||||
|
setState(() {
|
||||||
|
errorMessages.clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
for (var controller in controllers.values) {
|
||||||
|
controller.dispose();
|
||||||
|
}
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTravellerDetails() {
|
||||||
|
print("Inside Update Function - ${widget.travellerData}");
|
||||||
|
|
||||||
|
final data = widget.travellerData;
|
||||||
|
|
||||||
|
if (data == null) return;
|
||||||
|
setState(() {
|
||||||
|
controllers['first_name']?.text = data['first_name'] ?? '';
|
||||||
|
controllers['last_name']?.text = data['last_name'] ?? '';
|
||||||
|
controllers['email']?.text = data['email'].toString();
|
||||||
|
controllers['mobile']?.text = data['mobile'].toString();
|
||||||
|
isActive = data["is_active"];
|
||||||
|
final travellerId = int.tryParse(data['traveller_id'].toString());
|
||||||
|
travellerDataId = travellerId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void toggleStatus() {
|
||||||
|
setState(() {
|
||||||
|
isActive = isActive == "1" ? "0" : "1";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validateData() {
|
||||||
|
errorMessages.clear();
|
||||||
|
|
||||||
|
final data = {
|
||||||
|
"first_name": controllers["first_name"]?.text,
|
||||||
|
"last_name": controllers["last_name"]?.text,
|
||||||
|
"email": controllers["email"]?.text,
|
||||||
|
"mobile": controllers["mobile"]?.text,
|
||||||
|
};
|
||||||
|
|
||||||
|
final requiredFields = ["first_name","last_name","email","mobile"];
|
||||||
|
bool hasFocused = false;
|
||||||
|
|
||||||
|
// Check validation for each field
|
||||||
|
for (String field in requiredFields) {
|
||||||
|
if (data[field] == null || data[field]!.trim().isEmpty) {
|
||||||
|
errorMessages[field] = "Required";
|
||||||
|
|
||||||
|
if (!hasFocused) {
|
||||||
|
focusNodes[field]?.requestFocus();
|
||||||
|
hasFocused = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data["mobile"] != null && data["mobile"].toString().isNotEmpty) {
|
||||||
|
if (!RegExp(r"^\d{10}$").hasMatch(data["mobile"].toString())) {
|
||||||
|
errorMessages["mobile"] =
|
||||||
|
"Enter 10 digits"; // Invalid mobile number format
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data["email"] != null && data["email"].toString().isNotEmpty) {
|
||||||
|
if (!RegExp(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")
|
||||||
|
.hasMatch(data["email"].toString())) {
|
||||||
|
errorMessages["email"] = "Invalid email format"; // Invalid email format
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorMessages.isEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> handleSubmit() async {
|
||||||
|
userId = await getUserId();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
// This triggers UI rebuild with error messages
|
||||||
|
if (validateData()) {
|
||||||
|
postTravellerData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final travellerData1 = travellerDetails();
|
||||||
|
print("submit data - $travellerData1");
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> postTravellerData({int isActive = 1}) async {
|
||||||
|
// final remarksData = getData();
|
||||||
|
|
||||||
|
final travellerData = travellerDetails();
|
||||||
|
|
||||||
|
print("initially value of the Traveller - $travellerData");
|
||||||
|
// static here
|
||||||
|
final orgId = await getOrgId();
|
||||||
|
|
||||||
|
final String apiUrldata;
|
||||||
|
travellerData["org_id"] = orgId;
|
||||||
|
|
||||||
|
if (travellerDataId != null) {
|
||||||
|
print("for edit traveller id - $travellerDataId");
|
||||||
|
apiUrldata = '$apiUrl/api/travellers/update/$travellerDataId';
|
||||||
|
travellerData["traveller_id"] = travellerDataId.toString();
|
||||||
|
travellerData["updated_by"] = userId;
|
||||||
|
(travellerData.containsKey("created_by")) ? travellerData.remove("created_by") : '' ;
|
||||||
|
} else {
|
||||||
|
print("for add Traveller id - null");
|
||||||
|
apiUrldata = '$apiUrl/api/travellers/create';
|
||||||
|
print("called apiUrl - $apiUrldata");
|
||||||
|
travellerData["created_by"] = userId;
|
||||||
|
}
|
||||||
|
print("recently Traveller data - $travellerData");
|
||||||
|
final token = await getToken(); // Fetch token
|
||||||
|
|
||||||
|
if (token == null) {
|
||||||
|
throw Exception('Token not found. Please log in.');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final uri = Uri.parse(apiUrldata);
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
};
|
||||||
|
final body = jsonEncode(travellerData);
|
||||||
|
|
||||||
|
final response = travellerDataId != null
|
||||||
|
? await http.put(uri, headers: headers, body: body)
|
||||||
|
: await http.post(uri, headers: headers, body: body);
|
||||||
|
|
||||||
|
|
||||||
|
switch (response.statusCode) {
|
||||||
|
case 200:
|
||||||
|
print("Update - Response: ${response.body}");
|
||||||
|
_clearError();
|
||||||
|
widget.fetchGetTraveller();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 201:
|
||||||
|
print("Save - Response: ${response.body}");
|
||||||
|
_clearError();
|
||||||
|
await widget.fetchGetTraveller();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
print("Failed to submit traveller. Status: ${response.statusCode}");
|
||||||
|
print("Error: ${response.body}");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
print(" Error submitting plan: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
return AlertDialog(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(34, 30, 34, 30),
|
||||||
|
// contentPadding: const EdgeInsets.fromLTRB(24, 20, 24, 10),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
content: SizedBox(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// Row 1: Title + Edit + Delete buttons
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
(travellerDataId != null) ? 'Edit Traveller' : 'Create Traveller',
|
||||||
|
style: GoogleFonts.poppins(fontSize: 15, color: Colors.black),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Divider(
|
||||||
|
thickness: 0.2,
|
||||||
|
color: Colors.blueGrey.shade100,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"First Name",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
CustomTextFieldForexWrapper(
|
||||||
|
isFocused: false,
|
||||||
|
isDesktop: widget.isDesktop,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: TextField(
|
||||||
|
controller: controllers["first_name"],
|
||||||
|
focusNode: focusNodes["first_name"],
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: "First Name",
|
||||||
|
labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if (errorMessages["first_name"] != null) ...[
|
||||||
|
SizedBox(height: 5), // Space before error message
|
||||||
|
Text(
|
||||||
|
errorMessages["first_name"]!,
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Last Name",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
CustomTextFieldForexWrapper(
|
||||||
|
isFocused: false,
|
||||||
|
isDesktop: widget.isDesktop,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: TextField(
|
||||||
|
controller: controllers["last_name"],
|
||||||
|
focusNode: focusNodes["last_name"],
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: "Last Name",
|
||||||
|
labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if (errorMessages["last_name"] != null) ...[
|
||||||
|
SizedBox(height: 5), // Space before error message
|
||||||
|
Text(
|
||||||
|
errorMessages["last_name"]!,
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Email",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
CustomTextFieldForexWrapper(
|
||||||
|
isFocused: false,
|
||||||
|
isDesktop: widget.isDesktop,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: TextField(
|
||||||
|
controller: controllers["email"],
|
||||||
|
focusNode: focusNodes["email"],
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: "Email",
|
||||||
|
labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if (errorMessages["email"] != null) ...[
|
||||||
|
SizedBox(height: 5), // Space before error message
|
||||||
|
Text(
|
||||||
|
errorMessages["email"]!,
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Mobile",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
CustomTextFieldForexWrapper(
|
||||||
|
isFocused: false,
|
||||||
|
isDesktop: widget.isDesktop,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: TextField(
|
||||||
|
controller: controllers["mobile"],
|
||||||
|
focusNode: focusNodes["mobile"],
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: "Mobile",
|
||||||
|
labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if (errorMessages["mobile"] != null) ...[
|
||||||
|
SizedBox(height: 5), // Space before error message
|
||||||
|
Text(
|
||||||
|
errorMessages["mobile"]!,
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
if (travellerDataId != null)
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Change Status ",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
|
),
|
||||||
|
Tooltip(
|
||||||
|
message:
|
||||||
|
isActive == "1" ? "Tap to deactivate" : "Tap to activate",
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: toggleStatus,
|
||||||
|
child: Text(
|
||||||
|
isActive == "1" ? "Active" : "Inactive",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
color: isActive == "1" ? Colors.green : Colors.red,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (travellerDataId != null)
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
// SizedBox(
|
||||||
|
// child: ElevatedButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// // You can get text from commentController.text
|
||||||
|
// Navigator.of(context).pop(); // Close the modal
|
||||||
|
// },
|
||||||
|
// style: ElevatedButton.styleFrom(
|
||||||
|
// backgroundColor: widget.layoutColor,
|
||||||
|
// shape: RoundedRectangleBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(8),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// child: Text('Cancel',
|
||||||
|
// style: GoogleFonts.poppins(
|
||||||
|
// fontSize: 13, color: Colors.white)),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// SizedBox(
|
||||||
|
// width: 10,
|
||||||
|
// ),
|
||||||
|
SizedBox(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
handleSubmit();
|
||||||
|
// You can get text from commentController.text
|
||||||
|
// Navigator.of(context).pop(); // Close the modal
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: widget.layoutColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text('Save',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 11, color: Colors.white)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
// : SizedBox.shrink(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
869
lib/Screens/traveller/travellerList.dart
Normal file
869
lib/Screens/traveller/travellerList.dart
Normal file
@ -0,0 +1,869 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import '../../config/apiUrl.dart';
|
||||||
|
import '../../routes/custom_appBar.dart';
|
||||||
|
import '../../routes/custom_drawer.dart';
|
||||||
|
import '../../services/apiService.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
import '../../utils/pagination.dart';
|
||||||
|
import 'travellerDetails.dart';
|
||||||
|
|
||||||
|
class TravellerList extends StatefulWidget {
|
||||||
|
const TravellerList({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
TravellerListState createState() => TravellerListState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class TravellerListState extends State<TravellerList> {
|
||||||
|
final GlobalKey<TravellerListState> travellerListKey =
|
||||||
|
GlobalKey<TravellerListState>();
|
||||||
|
|
||||||
|
final ApiService apiService = ApiService();
|
||||||
|
late Future<List<dynamic>> futureTraveller;
|
||||||
|
|
||||||
|
late Map<String, dynamic> depSingleData;
|
||||||
|
String? selectedTravellerId;
|
||||||
|
String? orgId;
|
||||||
|
|
||||||
|
Color? layoutColor;
|
||||||
|
Color? bodyColor;
|
||||||
|
|
||||||
|
List allTraveller = [];
|
||||||
|
List filteredTraveller = [];
|
||||||
|
TextEditingController searchController = TextEditingController();
|
||||||
|
|
||||||
|
int currentPage = 0;
|
||||||
|
int itemsPerPage = 10;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
futureTraveller = fetchGetTraveller();
|
||||||
|
|
||||||
|
futureTraveller.then((object) {
|
||||||
|
setState(() {
|
||||||
|
allTraveller = object;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
loadInitialData();
|
||||||
|
});
|
||||||
|
|
||||||
|
// futurePlans = fetchPlans();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadInitialData() async {
|
||||||
|
String? layoutString = await getLayoutColor();
|
||||||
|
String? bodyStringColor = await getBodyColor();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
layoutColor = layoutString != null
|
||||||
|
? Color(int.parse(layoutString))
|
||||||
|
: Colors.redAccent;
|
||||||
|
|
||||||
|
bodyColor = bodyStringColor != null
|
||||||
|
? Color(int.parse(bodyStringColor))
|
||||||
|
: Colors.white;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getToken() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
return prefs.getString('auth_token');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<dynamic>> refreshData() {
|
||||||
|
print("Calling Refresh Data");
|
||||||
|
|
||||||
|
futureTraveller = fetchGetTraveller();
|
||||||
|
|
||||||
|
return futureTraveller.then((object) {
|
||||||
|
print("Calling Refresh Data $object");
|
||||||
|
setState(() {
|
||||||
|
allTraveller = object;
|
||||||
|
});
|
||||||
|
return object;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<dynamic>> fetchGetTraveller() async {
|
||||||
|
String? ordId = await getOrgId();
|
||||||
|
final String apiUrlData = '$apiUrl/api/travellers?org_id=$ordId';
|
||||||
|
|
||||||
|
|
||||||
|
final String? token = await getToken();
|
||||||
|
|
||||||
|
print("Fetch Traveller");
|
||||||
|
print("2KN Here : $token");
|
||||||
|
|
||||||
|
if (token == null) {
|
||||||
|
throw Exception('Token not found. Please log in.');
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await http.get(
|
||||||
|
Uri.parse(apiUrlData),
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
print("called api : $apiUrlData");
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final data = json.decode(response.body);
|
||||||
|
return data['data']; // Returning raw JSON list
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load users');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void filterTraveller(String query) {
|
||||||
|
// print("all before filtering: $query");
|
||||||
|
// final lowerQuery = query.toLowerCase();
|
||||||
|
// setState(() {
|
||||||
|
// filteredTraveller = allTraveller.where((object) {
|
||||||
|
// return (object['traveller_id']?.toLowerCase().contains(lowerQuery) ??
|
||||||
|
// false) ||
|
||||||
|
// (object['description']?.toLowerCase().contains(lowerQuery) ?? false) ||
|
||||||
|
// (object['user']?.toLowerCase().contains(lowerQuery) ?? false) ||
|
||||||
|
// (object['is_active']?.toLowerCase().contains(lowerQuery) ?? false);
|
||||||
|
// }).toList();
|
||||||
|
// });
|
||||||
|
// print("filteredPlans: $filteredTraveller");
|
||||||
|
|
||||||
|
print("all before filtering: $query");
|
||||||
|
final lowerQuery = query.toLowerCase();
|
||||||
|
setState(() {
|
||||||
|
filteredTraveller = allTraveller.where((object) {
|
||||||
|
final isActiveStatus =
|
||||||
|
object['is_active'] == "1" ? "active" : "inactive";
|
||||||
|
return (object['traveller_id']?.toLowerCase().contains(lowerQuery) ??
|
||||||
|
false) ||
|
||||||
|
(object['name']?.toLowerCase().contains(lowerQuery) ?? false) ||
|
||||||
|
(object['description']?.toLowerCase().contains(lowerQuery) ??
|
||||||
|
false) ||
|
||||||
|
(isActiveStatus.contains(lowerQuery));
|
||||||
|
}).toList();
|
||||||
|
});
|
||||||
|
print("filteredTraveller: $filteredTraveller");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ResponsiveBuilder(builder: (context, sizingInfo) {
|
||||||
|
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Color(0xFFf5f5f5),
|
||||||
|
// appBar: isDesktop ? null : const CustomAppBar(title: 'User Management'),
|
||||||
|
// drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
|
||||||
|
appBar: CustomAppBar(isDesktop: isDesktop),
|
||||||
|
drawer: CustomDrawer(isDesktop: false),
|
||||||
|
body: Padding(
|
||||||
|
padding: isDesktop
|
||||||
|
? EdgeInsets.symmetric(
|
||||||
|
horizontal: MediaQuery.of(context).size.width *
|
||||||
|
0.1, // 30% of screen width as horizontal padding
|
||||||
|
vertical: MediaQuery.of(context).size.height *
|
||||||
|
0, // 5% of screen height as vertical padding
|
||||||
|
)
|
||||||
|
: EdgeInsets.all(0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// if (isDesktop) CustomDrawer(isDesktop: true),
|
||||||
|
// const Expanded(child: Center(child: Text("User Page Content"))),
|
||||||
|
Expanded(child: buildGroupList(isDesktop)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildGroupList(bool isDesktop) {
|
||||||
|
return Container(
|
||||||
|
margin: isDesktop ? const EdgeInsets.only(top: 10.0, bottom: 10.0) : null,
|
||||||
|
padding: const EdgeInsets.all(1),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
|
||||||
|
),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// // color: Colors.amber,
|
||||||
|
// // color: bodyColor,
|
||||||
|
// color: Color(0xFFE1F5FE),
|
||||||
|
// border: Border.all(
|
||||||
|
// color: Colors.white,
|
||||||
|
// // color: Color(0xFFF7F7FB),
|
||||||
|
// width: 3.5)),
|
||||||
|
child: buildUserTable(isDesktop),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildUserTable(bool isDesktop) {
|
||||||
|
return Container(
|
||||||
|
// margin: isDesktop
|
||||||
|
// ? EdgeInsets.all(10.0)
|
||||||
|
// : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0),
|
||||||
|
// padding: const EdgeInsets.all(10),
|
||||||
|
height: isDesktop
|
||||||
|
? MediaQuery.of(context).size.height * 0.98
|
||||||
|
: MediaQuery.of(context).size.height,
|
||||||
|
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: Container(
|
||||||
|
color: Colors.white,
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
// Divider(
|
||||||
|
// thickness: 0.2, // how "thick" the line is
|
||||||
|
// color: Colors.grey, // optional
|
||||||
|
// ),
|
||||||
|
Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Traveller Details',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: isDesktop ? 16 : 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (isDesktop)
|
||||||
|
SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.16,
|
||||||
|
),
|
||||||
|
|
||||||
|
if (isDesktop)
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.2,
|
||||||
|
height: 40,
|
||||||
|
child: TextField(
|
||||||
|
controller: searchController,
|
||||||
|
onChanged: filterTraveller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Search ...",
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
fontSize: 12, color: Color(0xFF9E9DBD)),
|
||||||
|
prefixIcon: Icon(
|
||||||
|
Icons.search,
|
||||||
|
color: Color(0xFF9E9DBD),
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.grey.shade200, width: 0.5),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.grey.shade300, width: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// SizedBox(width: 16),
|
||||||
|
Spacer(),
|
||||||
|
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Color(0xFF114D8B),
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
disabledBackgroundColor: Color(0xFF114D8B),
|
||||||
|
disabledForegroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side:
|
||||||
|
BorderSide(color: Color(0xFF114D8B), width: 2),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 20, vertical: 12),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => TravellerData(
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
layoutColor: layoutColor!,
|
||||||
|
fetchGetTraveller: refreshData,
|
||||||
|
|
||||||
|
// role:
|
||||||
|
// "Travel Agent"
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize:
|
||||||
|
MainAxisSize.min, // Ensures content fits nicely
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Add Traveller",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: isDesktop ? 13 : 11,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 8), // spacing between icon and text
|
||||||
|
Icon(
|
||||||
|
Icons.add_circle_outline_rounded,
|
||||||
|
size: 15,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
if (!isDesktop)
|
||||||
|
SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
isDesktop
|
||||||
|
? SizedBox.shrink()
|
||||||
|
: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
|
height: 35,
|
||||||
|
child: TextField(
|
||||||
|
controller: searchController,
|
||||||
|
onChanged: filterTraveller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Search ...",
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
fontSize: 12, color: Color(0xFF9E9DBD)),
|
||||||
|
prefixIcon: Icon(
|
||||||
|
Icons.search,
|
||||||
|
color: Color(0xFF9E9DBD),
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.grey.shade200,
|
||||||
|
width: 0.5),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.grey.shade300, width: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// SizedBox(width: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
FutureBuilder<List<dynamic>>(
|
||||||
|
future: futureTraveller,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
} else if (snapshot.hasError ||
|
||||||
|
!snapshot.hasData ||
|
||||||
|
snapshot.data!.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// const Icon(Icons.error_outline,
|
||||||
|
// color: Colors.redAccent, size: 60),
|
||||||
|
// const SizedBox(height: 16),
|
||||||
|
// Text(
|
||||||
|
// "Oops!",
|
||||||
|
// style: GoogleFonts.poppins(
|
||||||
|
// fontSize: 20,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// color: Colors.redAccent),
|
||||||
|
// ),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
"No Traveller Available ",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.grey),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
"Please Create Traveller Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 16, color: Colors.grey),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/* Here collect the list to displayed the data in table or card Used */
|
||||||
|
List<dynamic> object = filteredTraveller.isNotEmpty
|
||||||
|
? filteredTraveller
|
||||||
|
: allTraveller;
|
||||||
|
|
||||||
|
/* List is Sorting here */
|
||||||
|
object.sort((a, b) {
|
||||||
|
DateTime dateA = DateTime.parse(a['created_on']);
|
||||||
|
DateTime dateB = DateTime.parse(b['created_on']);
|
||||||
|
|
||||||
|
return dateB
|
||||||
|
.compareTo(dateA); // Descending: newest first
|
||||||
|
});
|
||||||
|
|
||||||
|
/* For pagination for list ... */
|
||||||
|
List paginatedTraveller = object
|
||||||
|
.skip(currentPage * itemsPerPage)
|
||||||
|
.take(itemsPerPage)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
/* Table ... */
|
||||||
|
Widget table = LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
double minWidth =
|
||||||
|
isDesktop ? constraints.maxWidth : 1300;
|
||||||
|
|
||||||
|
return ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(minWidth: minWidth),
|
||||||
|
child: DataTable(
|
||||||
|
dividerThickness: 0.5,
|
||||||
|
columnSpacing: isDesktop ? 24.0 : 16.0,
|
||||||
|
border: TableBorder(
|
||||||
|
horizontalInside: BorderSide(
|
||||||
|
width: 0.5, color: Colors.grey.shade200),
|
||||||
|
),
|
||||||
|
columns: [
|
||||||
|
DataColumn(
|
||||||
|
label: Text(
|
||||||
|
'Name',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
)),
|
||||||
|
DataColumn(
|
||||||
|
label: Text(
|
||||||
|
'Email',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
)),
|
||||||
|
DataColumn(
|
||||||
|
label: Text(
|
||||||
|
'Mobile',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
)),
|
||||||
|
DataColumn(
|
||||||
|
label: Text(
|
||||||
|
'Status',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
)),
|
||||||
|
DataColumn(
|
||||||
|
label: Text(
|
||||||
|
'Actions',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
rows: paginatedTraveller.map((tableObject) {
|
||||||
|
String fullName = '${tableObject['first_name'] ?? ''} ${tableObject['last_name'] ?? ''}';
|
||||||
|
String travellerId =
|
||||||
|
tableObject['traveller_id']
|
||||||
|
.toString(); // Get user ID
|
||||||
|
bool isSelected =
|
||||||
|
selectedTravellerId == travellerId;
|
||||||
|
|
||||||
|
return DataRow(cells: [
|
||||||
|
DataCell(Text(fullName ?? 'N/A',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
))),
|
||||||
|
DataCell(
|
||||||
|
Text(tableObject['email'] ?? 'N/A',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
),
|
||||||
|
softWrap: true,
|
||||||
|
overflow: TextOverflow.ellipsis)),
|
||||||
|
DataCell(
|
||||||
|
Text(tableObject['mobile'] ?? 'N/A',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
),
|
||||||
|
softWrap: true,
|
||||||
|
overflow: TextOverflow.ellipsis)),
|
||||||
|
DataCell(
|
||||||
|
Text(
|
||||||
|
tableObject['is_active'] == "1"
|
||||||
|
? 'Active'
|
||||||
|
: 'Inactive',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
color: tableObject['is_active'] == "1"
|
||||||
|
? Colors.green
|
||||||
|
: Colors.red,
|
||||||
|
),
|
||||||
|
softWrap: true,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DataCell(
|
||||||
|
// UserActionsMenu(
|
||||||
|
// user: forex,
|
||||||
|
// getUserDetails: (id) =>
|
||||||
|
// apiService.getSingleUser(id),
|
||||||
|
// ),
|
||||||
|
GestureDetector(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15),
|
||||||
|
onTap: () async {
|
||||||
|
// final userId = getUserId(user['user_id']);
|
||||||
|
// final usersData = await getUserDetails(userId);
|
||||||
|
//
|
||||||
|
final travellerId = int.tryParse(
|
||||||
|
tableObject['traveller_id']
|
||||||
|
.toString());
|
||||||
|
|
||||||
|
if (travellerId != null) {
|
||||||
|
print(
|
||||||
|
"Table cell - traveller Id -- $travellerId");
|
||||||
|
final data = await apiService
|
||||||
|
.getTravellerDetailsFind(
|
||||||
|
travellerId);
|
||||||
|
print("TravellerId -- $data");
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) =>
|
||||||
|
TravellerData(
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
travellerId:
|
||||||
|
travellerId, // Pass the ID
|
||||||
|
travellerData: data,
|
||||||
|
layoutColor: layoutColor!,
|
||||||
|
// fetchGetForex: fetchGetForex,
|
||||||
|
fetchGetTraveller: refreshData,
|
||||||
|
// role:
|
||||||
|
// "Travel Agent"
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
print("Invalid ID");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Card ... */
|
||||||
|
Widget buildMobileCardView(List<dynamic> paginatedUser) {
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: paginatedUser.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final cardObject = paginatedUser[index];
|
||||||
|
String fullName = '${cardObject['first_name'] ?? ''} ${cardObject['last_name'] ?? ''}';
|
||||||
|
return Card(
|
||||||
|
color: Colors.white,
|
||||||
|
margin: EdgeInsets.symmetric(
|
||||||
|
horizontal: 12, vertical: 6),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
elevation: 3,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Status and Employee Code
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
fullName ?? 'N/A',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 10,
|
||||||
|
color: Colors.black87,
|
||||||
|
fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
|
||||||
|
GestureDetector(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/IconsImg/edit.png',
|
||||||
|
width: 20,
|
||||||
|
height: 15),
|
||||||
|
onTap: () async {
|
||||||
|
// final userId = getUserId(user['user_id']);
|
||||||
|
// final usersData = await getUserDetails(userId);
|
||||||
|
//
|
||||||
|
final travellerId = int.tryParse(
|
||||||
|
cardObject['traveller_id']
|
||||||
|
.toString());
|
||||||
|
|
||||||
|
if (travellerId != null) {
|
||||||
|
print(
|
||||||
|
"travellerId -- $travellerId");
|
||||||
|
final data = await apiService
|
||||||
|
.getTravellerDetailsFind(
|
||||||
|
travellerId);
|
||||||
|
print("TravellerId -- $data");
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) =>
|
||||||
|
TravellerData(
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
travellerId:
|
||||||
|
travellerId, // Pass the ID
|
||||||
|
travellerData: data,
|
||||||
|
layoutColor: layoutColor!,
|
||||||
|
// fetchGetTraveller: fetchGetTraveller,
|
||||||
|
fetchGetTraveller:
|
||||||
|
refreshData,
|
||||||
|
// role:
|
||||||
|
// "Travel Agent"
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
print("Invalid ID");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// PopupMenuButton<int>(
|
||||||
|
// color: Colors.white,
|
||||||
|
// padding: EdgeInsets.zero,
|
||||||
|
// offset: Offset(0, 30),
|
||||||
|
// icon: Icon(
|
||||||
|
// Icons.more_vert,
|
||||||
|
// color: Color(0xFF475569),
|
||||||
|
// size: 14,
|
||||||
|
// ),
|
||||||
|
// itemBuilder: (context) => [
|
||||||
|
// CustomPopupMenuEntry(
|
||||||
|
// child: Container(
|
||||||
|
// padding: EdgeInsets.symmetric(
|
||||||
|
// horizontal: 8, vertical: 8),
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisSize:
|
||||||
|
// MainAxisSize.min,
|
||||||
|
// mainAxisAlignment:
|
||||||
|
// MainAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// IconButton(
|
||||||
|
// icon: Icon(
|
||||||
|
// Icons
|
||||||
|
// .remove_red_eye,
|
||||||
|
// color: Color(
|
||||||
|
// 0xFF475569),
|
||||||
|
// size: 18),
|
||||||
|
// onPressed: () {
|
||||||
|
// print(
|
||||||
|
// "USerDAta - $user");
|
||||||
|
// // dynamic usersData = apiService
|
||||||
|
// // .getSingleUser(user[
|
||||||
|
// // 'user_id']
|
||||||
|
// // is String
|
||||||
|
// // ? int.parse(user[
|
||||||
|
// // 'user_id'])
|
||||||
|
// // : user[
|
||||||
|
// // 'user_id']);
|
||||||
|
// //
|
||||||
|
// // print(
|
||||||
|
// // "USerDAta - $usersData");
|
||||||
|
//
|
||||||
|
// context.go(
|
||||||
|
// "/CreateUserDetails",
|
||||||
|
// extra: {
|
||||||
|
// "selectedUser":
|
||||||
|
// user,
|
||||||
|
// "isViewMode": true
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }),
|
||||||
|
// IconButton(
|
||||||
|
// icon: Image.asset(
|
||||||
|
// 'assets/images/IconsImg/edit.png',
|
||||||
|
// width: 20,
|
||||||
|
// height: 15),
|
||||||
|
// onPressed: () {
|
||||||
|
// context.go(
|
||||||
|
// "/CreateUserDetails",
|
||||||
|
// extra: {
|
||||||
|
// "selectedUser":
|
||||||
|
// user,
|
||||||
|
// "isViewMode": false
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(height: 2),
|
||||||
|
// Trip Id and Trip Name
|
||||||
|
// Name
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
cardObject['email'] ?? '',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 10,
|
||||||
|
color: Colors.black87),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
cardObject['mobile'] ?? '',
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 10,
|
||||||
|
color: Colors.black87),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Actions
|
||||||
|
// Actions
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Expanded(
|
||||||
|
child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: isDesktop
|
||||||
|
? (searchController.text.isNotEmpty &&
|
||||||
|
filteredTraveller.isEmpty
|
||||||
|
? Center(
|
||||||
|
child: Text(
|
||||||
|
"No matches found",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.grey),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
child: table,
|
||||||
|
))
|
||||||
|
: (searchController.text.isNotEmpty &&
|
||||||
|
filteredTraveller.isEmpty
|
||||||
|
? Center(
|
||||||
|
child: Text(
|
||||||
|
"No matches found",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.grey),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: buildMobileCardView(
|
||||||
|
paginatedTraveller)),
|
||||||
|
),
|
||||||
|
// Expanded(
|
||||||
|
// child: isDesktop
|
||||||
|
// ? SingleChildScrollView(
|
||||||
|
// scrollDirection: Axis.vertical,
|
||||||
|
// child: table, // <-- your existing table
|
||||||
|
// )
|
||||||
|
// : buildMobileCardView(paginatedTraveller),
|
||||||
|
// ),
|
||||||
|
PaginationControls(
|
||||||
|
currentPage: currentPage,
|
||||||
|
itemsPerPage: itemsPerPage,
|
||||||
|
totalItems: object.length,
|
||||||
|
activeColor: layoutColor, // your theme color
|
||||||
|
onPageChanged: (page) {
|
||||||
|
setState(() {
|
||||||
|
currentPage = page;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onItemsPerPageChanged: (items) {
|
||||||
|
setState(() {
|
||||||
|
itemsPerPage = items;
|
||||||
|
currentPage = 0;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1035,7 +1035,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Passport Number",
|
"Passport Number",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1072,7 +1074,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Place of Issue",
|
"Place of Issue",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1134,7 +1138,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Date of Issue",
|
"Date of Issue",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1215,7 +1221,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Date of Expiry",
|
"Date of Expiry",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1298,7 +1306,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Passport Document",
|
"Passport Document",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1487,7 +1497,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Id Number",
|
"Id Number",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1531,7 +1543,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Id Type",
|
"Id Type",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1606,7 +1620,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Full Name As ID",
|
"Full Name As ID",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1691,7 +1707,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Seat Preference",
|
"Seat Preference",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1769,7 +1787,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Meal Preference",
|
"Meal Preference",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1809,7 +1829,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Additional Information",
|
"Additional Information",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1896,7 +1918,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Seat Preference",
|
"Seat Preference",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -1979,7 +2003,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Meal Preference",
|
"Meal Preference",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2019,7 +2045,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Additional Information",
|
"Additional Information",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2072,7 +2100,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Emergency Contact Number",
|
"Emergency Contact Number",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2150,7 +2180,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Forex Pre-Paid Card Number",
|
"Forex Pre-Paid Card Number",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2214,7 +2246,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Forex Expiry Date",
|
"Forex Expiry Date",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2370,7 +2404,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Airline",
|
"Airline",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2500,7 +2536,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Frequent Flyer Information",
|
"Frequent Flyer Information",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2643,7 +2681,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Hotel",
|
"Hotel",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2735,8 +2775,10 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Hotel Membership Number",
|
"Hotel Membership Number",
|
||||||
style: GoogleFonts.poppins(
|
style:GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74)),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -2887,7 +2929,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Country",
|
"Country",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -3009,7 +3053,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Visa Type",
|
"Visa Type",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -3088,7 +3134,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"ValidFrom",
|
"ValidFrom",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
@ -3168,7 +3216,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
|||||||
Text(
|
Text(
|
||||||
"Valid UpTo",
|
"Valid UpTo",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF575A74))
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldUserTravellerWrapper(
|
CustomTextFieldUserTravellerWrapper(
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import '../Screens/department/department_list.dart';
|
|||||||
import '../Screens/costCenter/costCenter_list.dart';
|
import '../Screens/costCenter/costCenter_list.dart';
|
||||||
import '../Screens/dashboard/status_dashboard.dart';
|
import '../Screens/dashboard/status_dashboard.dart';
|
||||||
import '../Screens/hotels/hotels_list.dart';
|
import '../Screens/hotels/hotels_list.dart';
|
||||||
|
import '../Screens/traveller/travellerList.dart';
|
||||||
|
|
||||||
final GoRouter router = GoRouter(
|
final GoRouter router = GoRouter(
|
||||||
routes: [
|
routes: [
|
||||||
@ -153,6 +154,10 @@ final GoRouter router = GoRouter(
|
|||||||
path: '/statusdashboard',
|
path: '/statusdashboard',
|
||||||
builder: (context, state) => StatusDashboard(),
|
builder: (context, state) => StatusDashboard(),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/traveller',
|
||||||
|
builder: (context, state) => TravellerList(),
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/CreateGroup',
|
path: '/CreateGroup',
|
||||||
pageBuilder: (context, state) => MaterialPage(
|
pageBuilder: (context, state) => MaterialPage(
|
||||||
|
|||||||
@ -100,6 +100,13 @@ class OrganizationSettingState extends State<OrganizationSetting> {
|
|||||||
'label': 'Hotels',
|
'label': 'Hotels',
|
||||||
'description': 'Create and Edit Hotels'
|
'description': 'Create and Edit Hotels'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'value': '/traveller',
|
||||||
|
'icon': Icons.travel_explore,
|
||||||
|
'label': 'Traveller',
|
||||||
|
'description': 'Create and Edit Traveller'
|
||||||
|
},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// List<Widget> rows = [];
|
// List<Widget> rows = [];
|
||||||
|
|||||||
@ -1190,4 +1190,48 @@ class ApiService {
|
|||||||
throw Exception('Failed to load plans');
|
throw Exception('Failed to load plans');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getTravellerDetailsFind(int id) async {
|
||||||
|
final String apiUrldata = '$apiUrl/api/travellers/find?traveller_id=$id';
|
||||||
|
|
||||||
|
|
||||||
|
//c
|
||||||
|
final token = await getToken();
|
||||||
|
|
||||||
|
if (token == null) {
|
||||||
|
throw Exception('Token not found. Please log in.');
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await http.get(
|
||||||
|
Uri.parse(apiUrldata),
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer $token',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
try {
|
||||||
|
final data = json.decode(response.body);
|
||||||
|
|
||||||
|
if (!data.containsKey('data') || data['data'] is! List) {
|
||||||
|
throw Exception("Invalid response format: 'data' field is missing or not a List");
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Map<String, dynamic>> listData =
|
||||||
|
List<Map<String, dynamic>>.from(data['data']);
|
||||||
|
|
||||||
|
if (listData.isEmpty) {
|
||||||
|
throw Exception("No Traveller data found with ID $id");
|
||||||
|
}
|
||||||
|
|
||||||
|
return listData[0];
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Error parsing response: $e');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load Hotel details');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user