FIX_insurances plan type not set
This commit is contained in:
parent
5c8f8f9a8c
commit
c7ccf4cdae
File diff suppressed because one or more lines are too long
@ -6,7 +6,9 @@ class Env {
|
|||||||
static const String apiUrl = String.fromEnvironment(
|
static const String apiUrl = String.fromEnvironment(
|
||||||
'API_URL',
|
'API_URL',
|
||||||
// defaultValue: 'https://partner.nhanceindia.in/partner_api/api/', /* Live build (enable index.html line 18) */
|
// defaultValue: 'https://partner.nhanceindia.in/partner_api/api/', /* Live build (enable index.html line 18) */
|
||||||
defaultValue: 'https://venbait.in/nhance/partner/dev/api/', /* Test build (enable index.html line 19) */
|
defaultValue: 'https://venbait.in/nhance/partner/dev/api/', /* Test build (enable index.html line 19) */
|
||||||
|
|
||||||
|
|
||||||
// defaultValue: 'http://localhost/nhance_partner_be/', /* localhost build (enable index.html line 19) */
|
// defaultValue: 'http://localhost/nhance_partner_be/', /* localhost build (enable index.html line 19) */
|
||||||
);
|
);
|
||||||
// static const String baseUrl = String.fromEnvironment(
|
// static const String baseUrl = String.fromEnvironment(
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
'enquiry_vehicle_type_id_for_commission',
|
'enquiry_vehicle_type_id_for_commission',
|
||||||
|
|
||||||
//find Policy
|
//find Policy
|
||||||
'insurance_plan_type',
|
'insurance_plan_type_id',
|
||||||
];
|
];
|
||||||
late Map<String, TextEditingController> controllers;
|
late Map<String, TextEditingController> controllers;
|
||||||
String? selectedInsuranceId;
|
String? selectedInsuranceId;
|
||||||
@ -284,7 +284,6 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
? controllers["payment_mode"]?.text
|
? controllers["payment_mode"]?.text
|
||||||
: selectedPaymentMode,
|
: selectedPaymentMode,
|
||||||
"insurance_plan_type_id": selectedInsurancePlanTypeId,
|
"insurance_plan_type_id": selectedInsurancePlanTypeId,
|
||||||
// "insurance_plan_type": controllers["insurance_plan_type"]?.text.trim().isNotEmpty == true ? controllers['insurance_plan_type']?.text : selectedInsurancPlanType,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,23 +756,6 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
data['year_of_manufacture'],
|
data['year_of_manufacture'],
|
||||||
);
|
);
|
||||||
|
|
||||||
// selectedInsurancPlanType = safeText(data['insurance_plan_type']);
|
|
||||||
// controllers["insurance_plan_type"]?.text = safeText(data['insurance_plan_type']);
|
|
||||||
final planName = safeText(data['insurance_plan_type']);
|
|
||||||
|
|
||||||
final matchedPlan = filteredInsurancPlanTypeData.firstWhere(
|
|
||||||
(item) =>
|
|
||||||
item['insurance_plan_type']
|
|
||||||
.toString()
|
|
||||||
.toLowerCase() ==
|
|
||||||
planName.toLowerCase(),
|
|
||||||
orElse: () => {},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matchedPlan.isNotEmpty) {
|
|
||||||
selectedInsurancePlanTypeId = matchedPlan['id'].toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedInsuranceId = safeText(data['insurer_id']);
|
selectedInsuranceId = safeText(data['insurer_id']);
|
||||||
selectedAgentRentionRate = safeText(data['agent_retention_rate']);
|
selectedAgentRentionRate = safeText(data['agent_retention_rate']);
|
||||||
selectedManagerRentionRate = safeText(data['manager_retention_rate']);
|
selectedManagerRentionRate = safeText(data['manager_retention_rate']);
|
||||||
@ -786,6 +768,11 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
selectedVehicleTypeForEnquiryID = data['enquiry_vehicle_type_id_for_commission']?.toString() ?? '';
|
selectedVehicleTypeForEnquiryID = data['enquiry_vehicle_type_id_for_commission']?.toString() ?? '';
|
||||||
controllers["enquiry_reg_no_for_commission"]?.text = safeText(data['enquiry_reg_no_for_commission']);
|
controllers["enquiry_reg_no_for_commission"]?.text = safeText(data['enquiry_reg_no_for_commission']);
|
||||||
// controllers["rcNo"]!.text = safeText(data['rc_no']);
|
// controllers["rcNo"]!.text = safeText(data['rc_no']);
|
||||||
|
|
||||||
|
// 1. Set the State variable (This makes the Dropdown show the correct item)
|
||||||
|
selectedInsurancePlanTypeId = data['insurance_plan_type_id']?.toString();
|
||||||
|
// 2. Set the Controller (This ensures dataDetails() can pick it up if needed)
|
||||||
|
controllers["insurance_plan_type_id"]?.text = selectedInsurancePlanTypeId ?? '';
|
||||||
});
|
});
|
||||||
|
|
||||||
debugPrint('findPolicyApi response3:');
|
debugPrint('findPolicyApi response3:');
|
||||||
@ -1470,7 +1457,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildInsurancPlanType(BuildContext context) {
|
Widget buildInsurancPlanType(BuildContext context) {
|
||||||
final Map<String, dynamic>? selectedPlan =
|
final Map<String, dynamic>? selectedIPT =
|
||||||
selectedInsurancePlanTypeId != null
|
selectedInsurancePlanTypeId != null
|
||||||
? filteredInsurancPlanTypeData.firstWhere(
|
? filteredInsurancPlanTypeData.firstWhere(
|
||||||
(item) =>
|
(item) =>
|
||||||
@ -1491,28 +1478,46 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
|
||||||
DropdownSearch<Map<String, dynamic>>(
|
DropdownSearch<Map<String, dynamic>>(
|
||||||
key: dropDownKeyInsurancPlanType,
|
key: dropDownKeyInsurancPlanType,
|
||||||
|
|
||||||
items: (filter, _) => filteredInsurancPlanTypeData,
|
items: (filter, _) => filteredInsurancPlanTypeData,
|
||||||
|
// disabledItemFn: (item) => item['is_active'] == "0",
|
||||||
selectedItem:
|
|
||||||
selectedPlan != null && selectedPlan.isNotEmpty
|
|
||||||
? selectedPlan
|
|
||||||
: null,
|
|
||||||
|
|
||||||
itemAsString: (item) =>
|
|
||||||
item['insurance_plan_type'].toString(),
|
|
||||||
|
|
||||||
compareFn: (a, b) =>
|
compareFn: (a, b) =>
|
||||||
a['id'].toString() == b['id'].toString(),
|
a['id'].toString() == b['id'].toString(),
|
||||||
|
|
||||||
|
selectedItem: selectedIPT != null && selectedIPT.isNotEmpty
|
||||||
|
? selectedIPT
|
||||||
|
: null,
|
||||||
|
itemAsString: (item) => item['insurance_plan_type'].toString(),
|
||||||
|
|
||||||
|
// 2. Styling for the items in the list
|
||||||
|
popupProps: PopupProps.menu(
|
||||||
|
itemBuilder: (context, item, isSelected, isHovered) {
|
||||||
|
final bool isActive = item['is_active'] == "1";
|
||||||
|
return ListTile(
|
||||||
|
title: Text(
|
||||||
|
item['insurance_plan_type'].toString(),
|
||||||
|
style: TextStyle(
|
||||||
|
// Gray out text if inactive
|
||||||
|
color: isActive ? Colors.black : Colors.grey,
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Add a "Disabled" subtitle for clarity
|
||||||
|
subtitle: isActive ? null : const Text("Inactive", style: TextStyle(fontSize: 10, color: Colors.red)),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
onChanged: (val) {
|
onChanged: (val) {
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
// setState(() {
|
selectedInsurancePlanTypeId = val['id'].toString(); // ✅ store ID
|
||||||
selectedInsurancePlanTypeId =
|
// ✅ WRITE INTO CONTROLLER (CRITICAL)
|
||||||
val['id'].toString();
|
controllers['insurance_plan_type_id']?.text = selectedInsurancePlanTypeId!;
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user