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(
|
||||
'API_URL',
|
||||
// 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) */
|
||||
);
|
||||
// static const String baseUrl = String.fromEnvironment(
|
||||
|
||||
@ -94,7 +94,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
||||
'enquiry_vehicle_type_id_for_commission',
|
||||
|
||||
//find Policy
|
||||
'insurance_plan_type',
|
||||
'insurance_plan_type_id',
|
||||
];
|
||||
late Map<String, TextEditingController> controllers;
|
||||
String? selectedInsuranceId;
|
||||
@ -284,7 +284,6 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
||||
? controllers["payment_mode"]?.text
|
||||
: selectedPaymentMode,
|
||||
"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'],
|
||||
);
|
||||
|
||||
// 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']);
|
||||
selectedAgentRentionRate = safeText(data['agent_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() ?? '';
|
||||
controllers["enquiry_reg_no_for_commission"]?.text = safeText(data['enquiry_reg_no_for_commission']);
|
||||
// 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:');
|
||||
@ -1470,7 +1457,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
||||
}
|
||||
|
||||
Widget buildInsurancPlanType(BuildContext context) {
|
||||
final Map<String, dynamic>? selectedPlan =
|
||||
final Map<String, dynamic>? selectedIPT =
|
||||
selectedInsurancePlanTypeId != null
|
||||
? filteredInsurancPlanTypeData.firstWhere(
|
||||
(item) =>
|
||||
@ -1491,28 +1478,46 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
|
||||
DropdownSearch<Map<String, dynamic>>(
|
||||
key: dropDownKeyInsurancPlanType,
|
||||
|
||||
items: (filter, _) => filteredInsurancPlanTypeData,
|
||||
|
||||
selectedItem:
|
||||
selectedPlan != null && selectedPlan.isNotEmpty
|
||||
? selectedPlan
|
||||
: null,
|
||||
|
||||
itemAsString: (item) =>
|
||||
item['insurance_plan_type'].toString(),
|
||||
// disabledItemFn: (item) => item['is_active'] == "0",
|
||||
|
||||
compareFn: (a, b) =>
|
||||
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) {
|
||||
if (val != null) {
|
||||
// setState(() {
|
||||
selectedInsurancePlanTypeId =
|
||||
val['id'].toString();
|
||||
// });
|
||||
selectedInsurancePlanTypeId = val['id'].toString(); // ✅ store ID
|
||||
// ✅ WRITE INTO CONTROLLER (CRITICAL)
|
||||
controllers['insurance_plan_type_id']?.text = selectedInsurancePlanTypeId!;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user