PM Scheme craete done
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'dart:developer';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/core/errors/exceptions.dart';
|
||||
import 'package:kmobile/data/models/ifsc.dart';
|
||||
|
||||
|
||||
class YojnaService {
|
||||
final Dio _dio;
|
||||
@@ -106,4 +105,74 @@ String? ruralcategory,
|
||||
);
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
Future secondvalidationPMSBY({
|
||||
String? aadharno,
|
||||
String? accountno,
|
||||
String? address1,
|
||||
String? address2,
|
||||
String? availablebalance,
|
||||
String? city,
|
||||
String? country,
|
||||
String? customerdob,
|
||||
String? customername,
|
||||
String? customerno,
|
||||
String? emailid,
|
||||
String? financialyear,
|
||||
String? gender,
|
||||
String? married,
|
||||
String? mobileno,
|
||||
String? pan,
|
||||
String? pincode,
|
||||
String? policyno,
|
||||
String? premiumamount,
|
||||
String? state,
|
||||
String? healthstatus,
|
||||
String? nomineename,
|
||||
String? nomineeadress,
|
||||
String? relationwithnominee,
|
||||
String? nomineeminor,
|
||||
String? collectionchannel,
|
||||
String? ruralcategory,
|
||||
String? policystatus,
|
||||
}) async {
|
||||
final response = await _dio.post(
|
||||
'/api/gov-scheme/create/PMSBY',
|
||||
options: Options(
|
||||
validateStatus: (int? status) => true,
|
||||
receiveDataWhenStatusError: true,
|
||||
),
|
||||
data: {
|
||||
"aadharno": aadharno,
|
||||
"accountno": accountno,
|
||||
"address1": address1,
|
||||
"address2": address2,
|
||||
"availablebalance": availablebalance,
|
||||
"city": city,
|
||||
"country": country,
|
||||
"customerdob": customerdob,
|
||||
"customername": customername,
|
||||
"customerno": customerno,
|
||||
"emailid": emailid,
|
||||
"financialyear": financialyear,
|
||||
"gender": gender,
|
||||
"married": married,
|
||||
"mobileno": mobileno,
|
||||
"pan": pan,
|
||||
"pincode": pincode,
|
||||
"policyno": policyno,
|
||||
"premiumamount": premiumamount,
|
||||
"state": state,
|
||||
"healthstatus": healthstatus,
|
||||
"nomineename": nomineename,
|
||||
"nomineeadress": nomineeadress,
|
||||
"relationwithnominee": relationwithnominee,
|
||||
"nomineeminor": nomineeminor,
|
||||
"collectionchannel": collectionchannel,
|
||||
"ruralcategory": ruralcategory,
|
||||
"policystatus": policystatus,
|
||||
},
|
||||
);
|
||||
return response.toString();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
|
||||
final _amountController = TextEditingController();
|
||||
final _payeeController = TextEditingController();
|
||||
final _chequeService = getIt<ChequeService>();
|
||||
String? _ciFromCheque;
|
||||
String? _ciToCheque;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -53,6 +55,53 @@ class _PositivePayScreenState extends State<PositivePayScreen> {
|
||||
_selectedAccount = _filteredUsers.first;
|
||||
}
|
||||
}
|
||||
_loadChequeDetails();
|
||||
}
|
||||
|
||||
Future<void> _loadChequeDetails() async {
|
||||
if (_selectedAccount == null) return;
|
||||
|
||||
String instrType;
|
||||
switch (_selectedAccount!.accountType) {
|
||||
case 'SA':
|
||||
case 'SB':
|
||||
instrType = '10';
|
||||
break;
|
||||
case 'CA':
|
||||
instrType = '11';
|
||||
break;
|
||||
case 'CC':
|
||||
instrType = '13';
|
||||
break;
|
||||
default:
|
||||
instrType = '10';
|
||||
}
|
||||
|
||||
try {
|
||||
final data = await _chequeService.ChequeEnquiry(
|
||||
accountNumber: _selectedAccount!.accountNo!,
|
||||
instrType: instrType,
|
||||
);
|
||||
final ciCheque = data.where((cheque) => cheque.type == 'CI').toList();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
if (ciCheque.isNotEmpty) {
|
||||
_ciFromCheque = ciCheque.first.fromCheque;
|
||||
_ciToCheque = ciCheque.first.toCheque;
|
||||
} else {
|
||||
_ciFromCheque = null;
|
||||
_ciToCheque = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_ciFromCheque = null;
|
||||
_ciToCheque = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -123,6 +172,7 @@ Future<void> _showResponseDialog(String title, String message) async {
|
||||
onChanged: (User? newUser) {
|
||||
setState(() {
|
||||
_selectedAccount = newUser;
|
||||
_loadChequeDetails();
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
@@ -138,12 +188,25 @@ Future<void> _showResponseDialog(String title, String message) async {
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).chequeNumberLabel,
|
||||
border: const OutlineInputBorder(),
|
||||
errorMaxLines: 2,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).pleaseEnterChequeNumber;
|
||||
}
|
||||
final chequeNumber = int.tryParse(value);
|
||||
final fromCheque = int.tryParse(_ciFromCheque ?? '');
|
||||
final toCheque = int.tryParse(_ciToCheque ?? '');
|
||||
if (chequeNumber == null) {
|
||||
return AppLocalizations.of(context).invalidChequeNumberFormatError;
|
||||
}
|
||||
if (fromCheque != null && toCheque != null) {
|
||||
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||
return AppLocalizations.of(context).chequeNumberRangeError(
|
||||
_ciFromCheque!, _ciToCheque!);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
@@ -136,10 +136,10 @@ class _RevokeStopMultipleChequesScreenState extends State<RevokeStopMultipleCheq
|
||||
return AppLocalizations.of(context)
|
||||
.invalidChequeNumberFormatError;
|
||||
}
|
||||
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||
// return AppLocalizations.of(context).chequeNumberRangeError(
|
||||
// widget.fromCheque, widget.toCheque);
|
||||
// }
|
||||
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||
return AppLocalizations.of(context).chequeNumberRangeError(
|
||||
widget.fromCheque, widget.toCheque);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
@@ -166,10 +166,10 @@ class _RevokeStopMultipleChequesScreenState extends State<RevokeStopMultipleCheq
|
||||
return AppLocalizations.of(context)
|
||||
.invalidChequeNumberFormatError;
|
||||
}
|
||||
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||
// return AppLocalizations.of(context).chequeNumberRangeError(
|
||||
// widget.fromCheque, widget.toCheque);
|
||||
// }
|
||||
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||
return AppLocalizations.of(context).chequeNumberRangeError(
|
||||
widget.fromCheque, widget.toCheque);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
@@ -27,6 +27,8 @@ class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
|
||||
bool _isLoading = true;
|
||||
List<Cheque> _stCheques = [];
|
||||
List<User> _filteredUsers = [];
|
||||
String? _ciFromCheque;
|
||||
String? _ciToCheque;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -86,8 +88,16 @@ class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
|
||||
final data = await service.ChequeEnquiry(
|
||||
accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
|
||||
final stCheques = data.where((cheque) => cheque.type == 'ST').toList();
|
||||
final ciCheque = data.where((cheque) => cheque.type == 'CI').toList();
|
||||
setState(() {
|
||||
_stCheques = stCheques;
|
||||
if (ciCheque.isNotEmpty) {
|
||||
_ciFromCheque = ciCheque.first.fromCheque;
|
||||
_ciToCheque = ciCheque.first.toCheque;
|
||||
} else {
|
||||
_ciFromCheque = null;
|
||||
_ciToCheque = null;
|
||||
}
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -189,8 +199,8 @@ class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
|
||||
selectedAccount: _selectedAccount!,
|
||||
date: _stCheques.first.Date!,
|
||||
instrType: _stCheques.first.InstrType!,
|
||||
fromCheque: _stCheques.first.fromCheque!,
|
||||
toCheque: _stCheques.first.toCheque!,
|
||||
fromCheque: _ciFromCheque ?? _stCheques.first.fromCheque!,
|
||||
toCheque: _ciToCheque ?? _stCheques.first.toCheque!,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -238,8 +248,8 @@ class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
|
||||
selectedAccount: _selectedAccount!,
|
||||
date: _stCheques.first.Date!,
|
||||
instrType: _stCheques.first.InstrType!,
|
||||
fromCheque: _stCheques.first.fromCheque!,
|
||||
toCheque: _stCheques.first.toCheque!,
|
||||
fromCheque: _ciFromCheque ?? _stCheques.first.fromCheque!,
|
||||
toCheque: _ciToCheque ?? _stCheques.first.toCheque!,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -133,10 +133,10 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
|
||||
return AppLocalizations.of(context)
|
||||
.invalidChequeNumberFormatError;
|
||||
}
|
||||
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||
// return AppLocalizations.of(context).chequeNumberRangeError(
|
||||
// widget.fromCheque, widget.toCheque);
|
||||
// }
|
||||
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||
return AppLocalizations.of(context).chequeNumberRangeError(
|
||||
widget.fromCheque, widget.toCheque);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
@@ -641,9 +641,13 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const GovSchemeScreen()));
|
||||
}),
|
||||
builder: (context) => GovSchemeScreen(
|
||||
users: users,
|
||||
selectedIndex: selectedAccountIndex,
|
||||
)));
|
||||
},
|
||||
disable: isPaymentDisabled,
|
||||
),
|
||||
_buildQuickLink(
|
||||
Symbols.checkbook,
|
||||
AppLocalizations.of(context).chequeManagement,
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/data/models/user.dart';
|
||||
import 'package:kmobile/features/yojna/screens/pm_main_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class GovSchemeScreen extends StatefulWidget {
|
||||
const GovSchemeScreen({super.key});
|
||||
final List<User> users;
|
||||
final int selectedIndex;
|
||||
const GovSchemeScreen({
|
||||
super.key,
|
||||
required this.users,
|
||||
required this.selectedIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
State<GovSchemeScreen> createState() => _GovSchemeScreenState();
|
||||
@@ -32,7 +39,10 @@ class _GovSchemeScreenState extends State<GovSchemeScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const PMMainScreen(),
|
||||
builder: (context) => PMMainScreen(
|
||||
users: widget.users,
|
||||
selectedIndex: widget.selectedIndex,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/yojna_service.dart';
|
||||
import 'package:kmobile/data/models/user.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/yojna/screens/pmjjby_screen.dart';
|
||||
import 'package:kmobile/features/yojna/screens/pmsby_screen.dart';
|
||||
import 'package:kmobile/l10n/app_localizations.dart';
|
||||
|
||||
class PMMainScreen extends StatefulWidget {
|
||||
const PMMainScreen({super.key});
|
||||
final List<User> users;
|
||||
final int selectedIndex;
|
||||
const PMMainScreen({
|
||||
super.key,
|
||||
required this.users,
|
||||
required this.selectedIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PMMainScreen> createState() => _PMMainScreenState();
|
||||
}
|
||||
|
||||
class _PMMainScreenState extends State<PMMainScreen> {
|
||||
final TextEditingController _accountController = TextEditingController();
|
||||
User? _selectedAccount;
|
||||
List<User> _filteredUsers = [];
|
||||
String? _selectedScheme;
|
||||
|
||||
final List<String> _schemes = [
|
||||
@@ -20,16 +29,39 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
||||
'Pradhan Mantri Suraksha Bima Yojana (PMSBY)',
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_filteredUsers = widget.users
|
||||
.where((user) => ['SA', 'SB', 'CA', 'CC'].contains(user.accountType))
|
||||
.toList();
|
||||
// Pre-fill the account number if possible
|
||||
if (widget.users.isNotEmpty && widget.selectedIndex < widget.users.length) {
|
||||
if (_filteredUsers.isNotEmpty) {
|
||||
if (_filteredUsers.contains(widget.users[widget.selectedIndex])) {
|
||||
_selectedAccount = widget.users[widget.selectedIndex];
|
||||
} else {
|
||||
_selectedAccount = _filteredUsers.first;
|
||||
}
|
||||
} else {
|
||||
_selectedAccount = widget.users[widget.selectedIndex];
|
||||
}
|
||||
} else {
|
||||
if (_filteredUsers.isNotEmpty) {
|
||||
_selectedAccount = _filteredUsers.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_accountController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _handleCreate() async {
|
||||
if (_accountController.text.isEmpty) {
|
||||
if (_selectedAccount == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Please enter account number')),
|
||||
const SnackBar(content: Text('Please select account number')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -61,7 +93,7 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
||||
final response = await getIt<YojnaService>().fetchpmydetails(
|
||||
scheme: schemeCode,
|
||||
action: 'C',
|
||||
accountno: _accountController.text,
|
||||
accountno: _selectedAccount!.accountNo!,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
@@ -76,7 +108,13 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PMJJBYScreen(initialData: data),
|
||||
builder: (context) {
|
||||
if (_selectedScheme!.contains('PMJJBY')) {
|
||||
return PMJJBYScreen(initialData: data);
|
||||
} else {
|
||||
return PMSBYScreen(initialData: data);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
@@ -124,15 +162,32 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextField(
|
||||
controller: _accountController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Account Number',
|
||||
border: OutlineInputBorder(),
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 20, horizontal: 12),
|
||||
DropdownButtonFormField<User>(
|
||||
value: _selectedAccount,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).accountNumber,
|
||||
border: const OutlineInputBorder(),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 20, horizontal: 12),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
items: _filteredUsers.map((user) {
|
||||
return DropdownMenuItem<User>(
|
||||
value: user,
|
||||
child: Text(user.accountNo.toString()),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (User? newUser) {
|
||||
setState(() {
|
||||
_selectedAccount = newUser;
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null) {
|
||||
return AppLocalizations.of(context)
|
||||
.accountNumberRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<String>(
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/yojna_service.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
|
||||
class PMSBYScreen extends StatefulWidget {
|
||||
final Map<String, dynamic>? initialData;
|
||||
const PMSBYScreen({super.key, this.initialData});
|
||||
|
||||
@override
|
||||
State<PMSBYScreen> createState() => _PMSBYScreenState();
|
||||
}
|
||||
|
||||
class _PMSBYScreenState extends State<PMSBYScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
// Controllers for all requested fields
|
||||
late final _aadhaarController = TextEditingController(text: widget.initialData?['aadharno']?.toString());
|
||||
late final _accountNoController = TextEditingController(text: widget.initialData?['accountno']?.toString());
|
||||
late final _balanceController = TextEditingController(text: widget.initialData?['availablebalance']?.toString());
|
||||
late final _countryController = TextEditingController(text: widget.initialData?['country']?.toString() ?? 'IN');
|
||||
late final _dobController = TextEditingController(text: widget.initialData?['customerdob']?.toString());
|
||||
late final _nameController = TextEditingController(text: widget.initialData?['customername']?.toString());
|
||||
late final _customerNoController = TextEditingController(text: widget.initialData?['customerno']?.toString());
|
||||
late final _acctOpeningDateController = TextEditingController(text: widget.initialData?['dateofacctopening']?.toString());
|
||||
late final _emailController = TextEditingController(text: widget.initialData?['emailid']?.toString());
|
||||
late final _financialYearController = TextEditingController(text: widget.initialData?['financialyear']?.toString());
|
||||
late final _genderController = TextEditingController(text: widget.initialData?['gender']?.toString());
|
||||
late final _ifscController = TextEditingController(text: widget.initialData?['ifsccode']?.toString());
|
||||
late final _marriedController = TextEditingController(text: widget.initialData?['married']?.toString());
|
||||
late final _mobileController = TextEditingController(text: widget.initialData?['mobileno']?.toString());
|
||||
late final _panController = TextEditingController(text: widget.initialData?['pan']?.toString());
|
||||
late final _pincodeController = TextEditingController(text: widget.initialData?['pincode']?.toString());
|
||||
late final _policyNumberController = TextEditingController(text: widget.initialData?['policyno']?.toString());
|
||||
late final _premiumAmountController = TextEditingController(text: widget.initialData?['premiumamount']?.toString());
|
||||
late final _stateController = TextEditingController(text: widget.initialData?['state']?.toString());
|
||||
late final _address1Controller = TextEditingController(text: widget.initialData?['address1']?.toString());
|
||||
late final _address2Controller = TextEditingController(text: widget.initialData?['address2']?.toString());
|
||||
late final _cityController = TextEditingController(text: widget.initialData?['city']?.toString());
|
||||
late final _relationWithNomineeController = TextEditingController(text: widget.initialData?['relationwithnominee']?.toString());
|
||||
late final _policyStatusController = TextEditingController(text: widget.initialData?['policystatus']?.toString());
|
||||
|
||||
final _healthStatusController = TextEditingController();
|
||||
final _collectionChannelController = TextEditingController();
|
||||
final _nomineeNameController = TextEditingController();
|
||||
final _nomineeAddressController = TextEditingController();
|
||||
final _nomineeRelationshipController = TextEditingController();
|
||||
final _nomineeMinorController = TextEditingController();
|
||||
final _ruralCategoryController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_aadhaarController.dispose();
|
||||
_accountNoController.dispose();
|
||||
_balanceController.dispose();
|
||||
_countryController.dispose();
|
||||
_dobController.dispose();
|
||||
_nameController.dispose();
|
||||
_customerNoController.dispose();
|
||||
_acctOpeningDateController.dispose();
|
||||
_emailController.dispose();
|
||||
_financialYearController.dispose();
|
||||
_genderController.dispose();
|
||||
_ifscController.dispose();
|
||||
_marriedController.dispose();
|
||||
_mobileController.dispose();
|
||||
_panController.dispose();
|
||||
_pincodeController.dispose();
|
||||
_policyNumberController.dispose();
|
||||
_premiumAmountController.dispose();
|
||||
_stateController.dispose();
|
||||
_address1Controller.dispose();
|
||||
_address2Controller.dispose();
|
||||
_cityController.dispose();
|
||||
_relationWithNomineeController.dispose();
|
||||
_policyStatusController.dispose();
|
||||
_healthStatusController.dispose();
|
||||
_collectionChannelController.dispose();
|
||||
_nomineeNameController.dispose();
|
||||
_nomineeAddressController.dispose();
|
||||
_nomineeRelationshipController.dispose();
|
||||
_nomineeMinorController.dispose();
|
||||
_ruralCategoryController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool _isFetched(String key) {
|
||||
return widget.initialData != null &&
|
||||
widget.initialData!.containsKey(key) &&
|
||||
widget.initialData![key]?.toString().isNotEmpty == true;
|
||||
}
|
||||
|
||||
Future<void> _handleRegister() async {
|
||||
// Show loading spinner
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
|
||||
try {
|
||||
final response = await getIt<YojnaService>().secondvalidationPMSBY(
|
||||
aadharno: _aadhaarController.text,
|
||||
accountno: _accountNoController.text,
|
||||
address1: _address1Controller.text,
|
||||
address2: _address2Controller.text,
|
||||
availablebalance: _balanceController.text,
|
||||
city: _cityController.text,
|
||||
country: _countryController.text,
|
||||
customerdob: _dobController.text,
|
||||
customername: _nameController.text,
|
||||
customerno: _customerNoController.text,
|
||||
emailid: _emailController.text,
|
||||
financialyear: _financialYearController.text,
|
||||
gender: _genderController.text,
|
||||
married: _marriedController.text,
|
||||
mobileno: _mobileController.text,
|
||||
pan: _panController.text,
|
||||
pincode: _pincodeController.text,
|
||||
policyno: _policyNumberController.text,
|
||||
premiumamount: _premiumAmountController.text,
|
||||
state: _stateController.text,
|
||||
healthstatus: _healthStatusController.text,
|
||||
nomineename: _nomineeNameController.text,
|
||||
nomineeadress: _nomineeAddressController.text,
|
||||
relationwithnominee: _relationWithNomineeController.text,
|
||||
nomineeminor: _nomineeMinorController.text,
|
||||
collectionchannel: _collectionChannelController.text,
|
||||
ruralcategory: _ruralCategoryController.text,
|
||||
policystatus: _policyStatusController.text,
|
||||
);
|
||||
String x = response.toString();
|
||||
if(x.contains('RECORD ALREADY EXISTS')){
|
||||
x= "A record already exists for this request. Your submission has been registered previously.";
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
// Close loading spinner
|
||||
Navigator.pop(context);
|
||||
// Show response dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Response'),
|
||||
content: SingleChildScrollView(child: Text(x)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
},
|
||||
child: const Text('Close'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
Navigator.pop(context); // Close loading spinner
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error: ${e.toString()}')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('PMSBY Registration'),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildTextField(_nameController, 'Customer Name', readOnly: _isFetched('customername')),
|
||||
_buildTextField(_customerNoController, 'Customer No', readOnly: _isFetched('customerno')),
|
||||
_buildTextField(_accountNoController, 'Account No', keyboardType: TextInputType.number, readOnly: _isFetched('accountno')),
|
||||
_buildTextField(_balanceController, 'Available Balance', keyboardType: TextInputType.number, readOnly: _isFetched('availablebalance')),
|
||||
_buildTextField(_aadhaarController, 'Aadhaar No', keyboardType: TextInputType.number, readOnly: _isFetched('aadharno')),
|
||||
_buildTextField(_dobController, 'Customer DOB (DD/MM/YYYY)', readOnly: _isFetched('customerdob')),
|
||||
_buildTextField(_genderController, 'Gender', readOnly: _isFetched('gender')),
|
||||
_buildTextField(_marriedController, 'Married (Yes/No)', readOnly: _isFetched('married')),
|
||||
_buildTextField(_mobileController, 'Mobile No', keyboardType: TextInputType.phone, readOnly: _isFetched('mobileno')),
|
||||
_buildTextField(_emailController, 'Email ID', keyboardType: TextInputType.emailAddress, readOnly: _isFetched('emailid')),
|
||||
_buildTextField(_address1Controller, 'Address 1', readOnly: _isFetched('address1')),
|
||||
_buildTextField(_address2Controller, 'Address 2', readOnly: _isFetched('address2')),
|
||||
_buildTextField(_cityController, 'City', readOnly: _isFetched('city')),
|
||||
_buildTextField(_panController, 'PAN', readOnly: _isFetched('pan')),
|
||||
_buildTextField(_ifscController, 'IFSC Code', readOnly: _isFetched('ifsccode')),
|
||||
_buildTextField(_acctOpeningDateController, 'Date of Acct Opening', readOnly: _isFetched('dateofacctopening')),
|
||||
_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'),
|
||||
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('policyno')),
|
||||
_buildTextField(_premiumAmountController, 'Premium Amount', keyboardType: TextInputType.number, readOnly: _isFetched('premiumamount')),
|
||||
_buildTextField(_financialYearController, 'Financial Year', readOnly: _isFetched('financialyear')),
|
||||
_buildTextField(_policyStatusController, 'Policy Status', readOnly: _isFetched('policystatus')),
|
||||
_buildTextField(_healthStatusController, 'Health Status'),
|
||||
_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(_relationWithNomineeController, 'Relation with Nominee', readOnly: _isFetched('relationwithnominee')),
|
||||
_buildTextField(_nomineeRelationshipController, 'Nominee Relationship'),
|
||||
_buildTextField(_nomineeMinorController, 'Nominee Minor (Yes/No)'),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: _handleRegister,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Register',
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTextField(TextEditingController controller, String label, {TextInputType keyboardType = TextInputType.text, bool readOnly = false}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
readOnly: readOnly,
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
border: const OutlineInputBorder(),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
||||
),
|
||||
keyboardType: keyboardType,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user