APY integrated without testing...

This commit is contained in:
2026-03-18 12:36:41 +05:30
parent 075cb3aaad
commit 8744e69ef7
29 changed files with 1069 additions and 498 deletions

View File

@@ -1,5 +1,7 @@
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/apy_register_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart';
@@ -20,6 +22,7 @@ class _APYScreenState extends State<APYScreen> {
User? _selectedAccount;
List<User> _filteredUsers = [];
final _formKey = GlobalKey<FormState>();
bool _isLoading = false;
@override
void initState() {
@@ -27,7 +30,7 @@ class _APYScreenState extends State<APYScreen> {
_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) {
@@ -111,58 +114,51 @@ class _APYScreenState extends State<APYScreen> {
),
const SizedBox(height: 24),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
final mockData = {
"accountno": _selectedAccount?.accountNo ?? "50069506061",
"customerfirstname": "TAMANA",
"customermiddlename": "",
"customerlastname": "",
"availablebalance": "634000",
"customerdob": "06061998",
"emailid": "",
"gender": "F",
"married": "Y",
"nomineename": "shubham Kada",
"relationwithsubscriber": "S",
"mobilenumber": "",
"nomineeminor": "N",
"customerno": "30028309887",
"beneficaryofothersociatysecurityschemes": "N",
"whetherincometaxpayer": "N",
"customertitle": "02",
"aadharno": "",
"nameofspouse": "shubham kada",
"ageofjoining": "27",
"pensionamtoptedfor": "1000",
"montlycontributioncalculate": "90",
"collectionchannel": "1",
"subsequentContributionDebitDate": "02012026",
"secondnomineeminor": "N",
"secondnomineename": "shubham kad",
"secondrelationshipwithsubscriber": "",
"pincode": "176215",
"fatcacrsapplicable": "N",
"countryofbirth": "India",
"countryofcitizenship": "India",
"countryofresidencefortaxpurpose": "India",
"uspersonflag": "N",
"fatcadeclarationcount": "",
"documentevidencingcitizenshipflag": "",
"reasonfornoevidence": "",
"nameofdocumentforcitizenshipevidence": "",
"modeofcollection": "Transfer Voucher",
"contributionType": "C"
};
onPressed: _isLoading
? null
: () async {
if (_formKey.currentState!.validate()) {
setState(() {
_isLoading = true;
});
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => APYRegisterScreen(initialData: mockData),
),
);
}
},
try {
final response = await getIt<YojnaService>()
.fetchpapydetails(
accountno: _selectedAccount!.accountNo ?? '');
if (mounted) {
if (response != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => APYRegisterScreen(
initialData: response),
),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
"Failed to fetch details. Please try again.")),
);
}
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Error: ${e.toString()}")),
);
}
} finally {
if (mounted) {
setState(() {
_isLoading = false;
});
}
}
}
},
style: ElevatedButton.styleFrom(
backgroundColor:
Theme.of(context).colorScheme.primaryContainer,
@@ -174,11 +170,19 @@ class _APYScreenState extends State<APYScreen> {
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
l10n.proceedButton,
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold),
),
child: _isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
),
)
: Text(
l10n.proceedButton,
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold),
),
),
],
),
@@ -187,3 +191,4 @@ class _APYScreenState extends State<APYScreen> {
);
}
}