Itinerary List Dropdown

This commit is contained in:
Venba Team 2025-03-28 18:03:15 +05:30
parent 4a1624acde
commit 23e6c1608a
6 changed files with 57 additions and 10 deletions

View File

@ -377,8 +377,6 @@ class _VisaScreenState extends State<VisaScreen> {
// List<String> countryNames = countryList.map((item) => item['country_name'] as String).toList();
//
late Map<String, String> countryMap; // Mapping country_code -> country_name
late List<String> countryCodes; // List of country codes

View File

@ -31,7 +31,7 @@ class FlightListWidget extends StatelessWidget {
horizontalInside: BorderSide(color: Colors.black12), // Only horizontal lines
),
columns: const [
DataColumn(label: Text('#')),
// DataColumn(label: Text('#')),
DataColumn(label: Text('Trip Type')),
DataColumn(label: Text('From')),
DataColumn(label: Text('To')),
@ -61,7 +61,7 @@ class FlightListWidget extends StatelessWidget {
return DataRow(cells: [
DataCell(Text(item["indx"]?.toString() ?? "N/A")),
// DataCell(Text(item["indx"]?.toString() ?? "N/A")),
DataCell(Text(item["trip_type"]?.toString() ?? "N/A")),
DataCell(Text(item["trips"].isNotEmpty ? item["trips"][0]["from_place"]?.toString() ?? "N/A" : "N/A")),
DataCell(Text(item["trips"].isNotEmpty ? item["trips"][0]["to_place"]?.toString() ?? "N/A" : "N/A")),

View File

@ -7,8 +7,10 @@ class ForexListWidget extends StatelessWidget{
final List<Map<String,dynamic>> forexList;
final Function(bool, Map<String,dynamic>, String)onOpen;
final Function(Map<String,dynamic>) onDeleteForex;
final List<dynamic>? apiCountryData;
const ForexListWidget({super.key, required this.forexList, required this.onOpen, required this.onDeleteForex});
const ForexListWidget({super.key, required this.forexList, required this.onOpen,
required this.onDeleteForex,required this.apiCountryData});
@override
Widget build(BuildContext context) {
@ -59,12 +61,26 @@ class ForexListWidget extends StatelessWidget{
}
List<DataRow> _buildDataRows() {
List<dynamic> countryList = apiCountryData ?? [];
List<Map<String, dynamic>> filteredList = forexList
.where((item) => item["is_active"] == "1")
.toList();
print("filteredList- $filteredList");
String getRequestForCountry(String? countryCode) {
if (countryCode == null) return "N/A";
return countryList
.firstWhere(
(element) => element["country_code"].toString() == countryCode,
orElse: () => {"country_name": "N/A"},
)["country_name"]
.toString();
}
return filteredList.asMap().entries.map((entry) {
Map<String,dynamic> item = entry.value;
@ -73,7 +89,8 @@ class ForexListWidget extends StatelessWidget{
// DataCell(Text(item["indx"]?.toString() ?? "N/A")), // Index column
DataCell(Text(item["start_date"] ?? "N/A")),
DataCell(Text(item["end_date"] ?? "N/A")),
DataCell(Text(item["country_code"] ?? "N/A")),
DataCell( Text(getRequestForCountry( item["country_code"]!.toString()))),
// DataCell(Text(item["country_code"] ?? "N/A")),
DataCell(Text(item["perdiem_amount"] ?? "N/A")),
DataCell(Row(
children: [

View File

@ -6,7 +6,9 @@ class InsuranceListWidget extends StatelessWidget {
final List<Map<String,dynamic>> insuranceList;
final Function(bool, Map<String,dynamic>, String)onOpen;
final Function(Map<String,dynamic>)onDeleteInsurance;
const InsuranceListWidget({super.key, required this.insuranceList, required this.onOpen,required this.onDeleteInsurance});
final Map<String, dynamic>? apiData;
const InsuranceListWidget({super.key, required this.insuranceList, required this.onOpen,required this.apiData,
required this.onDeleteInsurance});
@override
Widget build(BuildContext context) {
@ -51,17 +53,33 @@ class InsuranceListWidget extends StatelessWidget {
List<DataRow> _buildDataRows() {
List<Map<String, dynamic>> filteredList = insuranceList
.where((item) => item["is_active"] == "1")
.toList();
print("filteredList- $filteredList");
List<dynamic> insurancetypeList = apiData?['insurance_type_of_insurance'] ?? [];
String getRequestForInsuranceType(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
return insurancetypeList
.firstWhere(
(element) => element["dropdown_key"].toString() == specialRequestKey,
orElse: () => {"dropdown_value": "N/A"},
)["dropdown_value"]
.toString();
}
return filteredList.asMap().entries.map((entry) {
Map<String,dynamic> item = entry.value;
return DataRow(cells: [
// DataCell(Text(item["indx"]?.toString() ?? "N/A")), // Index column
DataCell(Text(item["type_of_insurance"]!)),
// DataCell(Text(item["type_of_insurance"]!)),
DataCell( Text(getRequestForInsuranceType( item["type_of_insurance"]!.toString()))),
DataCell(Text(item["start_date"]!)),
DataCell(Text(item["end_date"]!)),
DataCell(Row(

View File

@ -58,6 +58,7 @@ class VisaListWidget extends StatelessWidget {
print("filteredList- $filteredList");
List<dynamic> visatypeList = apiData?['visa_type_of_visa'] ?? [];
List<dynamic> countryList = apiCountryData ?? [];
String getRequestForVisa(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
@ -70,6 +71,17 @@ class VisaListWidget extends StatelessWidget {
.toString();
}
String getRequestForCountry(String? countryCode) {
if (countryCode == null) return "N/A";
return countryList
.firstWhere(
(element) => element["country_code"].toString() == countryCode,
orElse: () => {"country_name": "N/A"},
)["country_name"]
.toString();
}
return filteredList.asMap().entries.map((entry){
@ -81,7 +93,8 @@ class VisaListWidget extends StatelessWidget {
// DataCell(Text(item["indx"]?.toString() ?? "N/A")),
// DataCell(Text(item["type_of_visa"]!)),
DataCell( Text(getRequestForVisa( item["type_of_visa"]!.toString()))),
DataCell(Text(item["country_code"]!)),
DataCell( Text(getRequestForCountry( item["country_code"]!.toString()))),
// DataCell(Text(item["country_code"]!)),
DataCell(Text(item["start_date"]!)),
DataCell(Row(
children: [

View File

@ -315,7 +315,7 @@ class _DynamicItineraryState extends State<DynamicItinerary> {
break;
case "Insurance":
selectedListWidget = InsuranceListWidget(insuranceList : itineraryData["Insurance"]!,
onOpen: handleEdit,
onOpen: handleEdit, apiData: widget.apiData,
onDeleteInsurance:(data) => handleItinerarydelete("Insurance", data),);
break;
case "Visa":
@ -326,6 +326,7 @@ class _DynamicItineraryState extends State<DynamicItinerary> {
break;
case "Forex":
selectedListWidget = ForexListWidget(forexList: itineraryData["Forex"]!,
apiCountryData : widget.apiCountryData,
onOpen: handleEdit,
onDeleteForex: (data) => handleItinerarydelete("Forex", data),);
break;