Manage Beneficiary
This commit is contained in:
@@ -103,10 +103,10 @@ class BeneficiaryService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<dynamic>> fetchBeneficiaryList() async {
|
Future<List<Beneficiary>> fetchBeneficiaryList() async{
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get(
|
final response = await _dio.get(
|
||||||
"/api/beneficiaries/get", // replace with actual path
|
"/api/beneficiary/get",
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -115,8 +115,8 @@ class BeneficiaryService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
// Assuming API returns JSON array of beneficiaries
|
return Beneficiary.listFromJson(response.data);
|
||||||
return response.data as List<dynamic>;
|
|
||||||
} else {
|
} else {
|
||||||
throw Exception("Failed to fetch beneficiaries");
|
throw Exception("Failed to fetch beneficiaries");
|
||||||
}
|
}
|
||||||
|
@@ -1,23 +1,32 @@
|
|||||||
|
|
||||||
|
|
||||||
class Beneficiary {
|
class Beneficiary {
|
||||||
final String accountNo;
|
final String accountNo;
|
||||||
final String accountType;
|
final String accountType;
|
||||||
final String name;
|
final String name;
|
||||||
final String ifscCode;
|
final String ifscCode;
|
||||||
|
final String? bankName;
|
||||||
|
final String? branchName;
|
||||||
|
|
||||||
Beneficiary({
|
Beneficiary({
|
||||||
required this.accountNo,
|
required this.accountNo,
|
||||||
required this.accountType,
|
required this.accountType,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.ifscCode,
|
required this.ifscCode,
|
||||||
|
this.bankName,
|
||||||
|
this.branchName,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Beneficiary.fromJson(Map<String, dynamic> json) {
|
factory Beneficiary.fromJson(Map<String, dynamic> json) {
|
||||||
|
print('==============================');
|
||||||
|
print(json);
|
||||||
return Beneficiary(
|
return Beneficiary(
|
||||||
accountNo: json['accountNo'] ?? '',
|
accountNo: json['accountNo'] ?? '',
|
||||||
accountType: json['accountType'] ?? '',
|
accountType: json['accountType'] ?? '',
|
||||||
name: json['name'] ?? '',
|
name: json['name'] ?? '',
|
||||||
ifscCode: json['ifscCode'] ?? '',
|
ifscCode: json['ifscCode'] ?? '',
|
||||||
|
bankName: json['bankName'] ?? '',
|
||||||
|
branchName: json['branchName'] ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,6 +39,12 @@ class Beneficiary {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static List<Beneficiary> listFromJson(List<dynamic> jsonList) {
|
||||||
|
final beneficiaryList = jsonList.map((beneficiary) => Beneficiary.fromJson(beneficiary)).toList();
|
||||||
|
print(beneficiaryList);
|
||||||
|
return beneficiaryList;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Beneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name)';
|
return 'Beneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name)';
|
||||||
|
45
lib/data/models/beneficiary_recieve.dart
Normal file
45
lib/data/models/beneficiary_recieve.dart
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
class BeneficiaryRecieve {
|
||||||
|
final String accountNo;
|
||||||
|
final String accountType;
|
||||||
|
final String name;
|
||||||
|
final String ifscCode;
|
||||||
|
final String bankName;
|
||||||
|
final String branchName;
|
||||||
|
|
||||||
|
|
||||||
|
BeneficiaryRecieve({
|
||||||
|
required this.accountNo,
|
||||||
|
required this.accountType,
|
||||||
|
required this.name,
|
||||||
|
required this.ifscCode,
|
||||||
|
required this.bankName,
|
||||||
|
required this.branchName,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory BeneficiaryRecieve.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BeneficiaryRecieve(
|
||||||
|
accountNo: json['account_no'] ?? '',
|
||||||
|
accountType: json['account_type'] ?? '',
|
||||||
|
name: json['name'] ?? '',
|
||||||
|
ifscCode: json['ifsc_code'] ?? '',
|
||||||
|
bankName: json['bank_name'] ?? '',
|
||||||
|
branchName: json['branch_name'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'account_no': accountNo,
|
||||||
|
'account_type': accountType,
|
||||||
|
'name': name,
|
||||||
|
'ifsc_code' : ifscCode,
|
||||||
|
'bank_name' : bankName,
|
||||||
|
'branch_name' : branchName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'ListBeneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name, bankName: $bankName, branchName: $branchName)';
|
||||||
|
}
|
||||||
|
}
|
@@ -18,9 +18,12 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
// Automatically go to login after 6 seconds
|
// Automatically go to login after 6 seconds
|
||||||
Timer(const Duration(seconds: 6), () {
|
// Timer(const Duration(seconds: 6), () {
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
// );
|
||||||
widget.onContinue();
|
widget.onContinue();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import '../../../di/injection.dart';
|
import '../../../di/injection.dart';
|
||||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
@@ -103,7 +102,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
|||||||
var service = getIt<BeneficiaryService>();
|
var service = getIt<BeneficiaryService>();
|
||||||
//final BeneficiaryService _service = BeneficiaryService();
|
//final BeneficiaryService _service = BeneficiaryService();
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
List<dynamic> _beneficiaries = [];
|
List<Beneficiary> _beneficiaries = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -158,14 +157,14 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
|||||||
radius: 24,
|
radius: 24,
|
||||||
backgroundColor: Theme.of(context).primaryColor.withOpacity(0.2),
|
backgroundColor: Theme.of(context).primaryColor.withOpacity(0.2),
|
||||||
child: Text(
|
child: Text(
|
||||||
item['name'] != null && item['name'].isNotEmpty
|
item.name.isNotEmpty
|
||||||
? item['name'][0].toUpperCase()
|
? item.name[0].toUpperCase()
|
||||||
: '?',
|
: '?',
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(item['name'] ?? 'Unknown'),
|
title: Text(item.name ?? 'Unknown'),
|
||||||
subtitle: Text(item['accountNumber'] ?? 'No account number'),
|
subtitle: Text(item.accountNo ?? 'No account number'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@@ -202,7 +202,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
backgroundColor:Theme.of(context).scaffoldBackgroundColor,
|
backgroundColor:Theme.of(context).scaffoldBackgroundColor,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).kMobile,
|
AppLocalizations.of(context).kconnect,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
@@ -482,7 +482,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
const FundTransferBeneficiaryScreen()));
|
const FundTransferBeneficiaryScreen()));
|
||||||
}, disable: true),
|
}, disable: false),
|
||||||
_buildQuickLink(Symbols.server_person,
|
_buildQuickLink(Symbols.server_person,
|
||||||
AppLocalizations.of(context).accountInfo, () {
|
AppLocalizations.of(context).accountInfo, () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
|
Reference in New Issue
Block a user