PMJBY/SBY enquiry created
This commit is contained in:
@@ -33,6 +33,48 @@ class _PMJJBYScreenState extends State<PMJJBYScreen> {
|
||||
late final _policyNumberController = TextEditingController(text: widget.initialData?['policynumber']?.toString());
|
||||
late final _premiumAmountController = TextEditingController(text: widget.initialData?['premiumamount']?.toString());
|
||||
late final _stateController = TextEditingController(text: widget.initialData?['state']?.toString());
|
||||
|
||||
// Mapping options
|
||||
final Map<String, String> _healthStatusOptions = {
|
||||
'1': 'Excellent',
|
||||
'2': 'Good',
|
||||
'3': 'Bad',
|
||||
};
|
||||
|
||||
final Map<String, String> _relationshipOptions = {
|
||||
'01': 'Self',
|
||||
'02': 'Wife',
|
||||
'03': 'Father',
|
||||
'04': 'Mother',
|
||||
'05': 'Son',
|
||||
'06': 'Daughter',
|
||||
'07': 'Brother',
|
||||
'08': 'Sister',
|
||||
'09': 'Father-in-law',
|
||||
'10': 'Mother-in-law',
|
||||
'11': 'Grandson',
|
||||
'12': 'Granddaughter',
|
||||
'13': 'Grandfather',
|
||||
'14': 'Grandmother',
|
||||
'15': 'Brother-in-law',
|
||||
'16': 'Sister-in-law',
|
||||
'17': 'Husband',
|
||||
'18': 'Guardian',
|
||||
'99': 'Others',
|
||||
};
|
||||
|
||||
final Map<String, String> _minorOptions = {
|
||||
'Y': 'Yes',
|
||||
'N': 'No',
|
||||
};
|
||||
|
||||
final Map<String, String> _ruralOptions = {
|
||||
'R': 'Rural',
|
||||
'U': 'Urban',
|
||||
'S': 'Semi-Urban',
|
||||
'M': 'Metro',
|
||||
};
|
||||
|
||||
final _healthStatusController = TextEditingController();
|
||||
final _collectionChannelController = TextEditingController();
|
||||
final _nomineeNameController = TextEditingController();
|
||||
@@ -41,6 +83,26 @@ class _PMJJBYScreenState extends State<PMJJBYScreen> {
|
||||
final _nomineeMinorController = TextEditingController();
|
||||
final _ruralCategoryController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Initialize dropdown controllers if data exists in initialData
|
||||
if (widget.initialData != null) {
|
||||
if (widget.initialData!.containsKey('ruralcategory')) {
|
||||
_ruralCategoryController.text = widget.initialData!['ruralcategory'].toString();
|
||||
}
|
||||
if (widget.initialData!.containsKey('healthstatus')) {
|
||||
_healthStatusController.text = widget.initialData!['healthstatus'].toString();
|
||||
}
|
||||
if (widget.initialData!.containsKey('nomineerelationship')) {
|
||||
_nomineeRelationshipController.text = widget.initialData!['nomineerelationship'].toString();
|
||||
}
|
||||
if (widget.initialData!.containsKey('nomineeminor')) {
|
||||
_nomineeMinorController.text = widget.initialData!['nomineeminor'].toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_aadhaarController.dispose();
|
||||
@@ -180,22 +242,22 @@ class _PMJJBYScreenState extends State<PMJJBYScreen> {
|
||||
_buildTextField(_pincodeController, 'Pincode', keyboardType: TextInputType.number, readOnly: _isFetched('pincode')),
|
||||
_buildTextField(_stateController, 'State', readOnly: _isFetched('state')),
|
||||
_buildTextField(_countryController, 'Country', readOnly: _isFetched('country')),
|
||||
_buildTextField(_ruralCategoryController, 'Rural Category'),
|
||||
_buildDropdownField(_ruralCategoryController, 'Rural Category', _ruralOptions, readOnly: _isFetched('ruralcategory')),
|
||||
const Divider(height: 32),
|
||||
const Text('Policy Details', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(_policyNumberController, 'Policy Number', readOnly: _isFetched('policynumber')),
|
||||
_buildTextField(_premiumAmountController, 'Premium Amount', keyboardType: TextInputType.number, readOnly: _isFetched('premiumamount')),
|
||||
_buildTextField(_financialYearController, 'Financial Year', readOnly: _isFetched('financialyear')),
|
||||
_buildTextField(_healthStatusController, 'Health Status'),
|
||||
_buildDropdownField(_healthStatusController, 'Health Status', _healthStatusOptions),
|
||||
_buildTextField(_collectionChannelController, 'Collection Channel'),
|
||||
const Divider(height: 32),
|
||||
const Text('Nominee Details', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(_nomineeNameController, 'Nominee Name'),
|
||||
_buildTextField(_nomineeAddressController, 'Nominee Address'),
|
||||
_buildTextField(_nomineeRelationshipController, 'Nominee Relationship'),
|
||||
_buildTextField(_nomineeMinorController, 'Nominee Minor (Yes/No)'),
|
||||
_buildDropdownField(_nomineeRelationshipController, 'Nominee Relationship', _relationshipOptions, readOnly: _isFetched('nomineerelationship')),
|
||||
_buildDropdownField(_nomineeMinorController, 'Nominee Minor', _minorOptions, readOnly: _isFetched('nomineeminor')),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: _handleRegister,
|
||||
@@ -220,6 +282,36 @@ class _PMJJBYScreenState extends State<PMJJBYScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDropdownField(
|
||||
TextEditingController controller, String label, Map<String, String> options,
|
||||
{bool readOnly = false}) {
|
||||
// Determine current value
|
||||
String? currentValue = options.containsKey(controller.text) ? controller.text : null;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: DropdownButtonFormField<String>(
|
||||
value: currentValue,
|
||||
onChanged: readOnly ? null : (newValue) {
|
||||
setState(() {
|
||||
controller.text = newValue ?? '';
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
border: const OutlineInputBorder(),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
||||
),
|
||||
items: options.entries.map((entry) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: entry.key,
|
||||
child: Text("${entry.key} - ${entry.value}"),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTextField(TextEditingController controller, String label, {TextInputType keyboardType = TextInputType.text, bool readOnly = false}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
|
||||
Reference in New Issue
Block a user