diff --git a/lib/api/services/beneficiary_service.dart b/lib/api/services/beneficiary_service.dart index 075a7c6..990bb56 100644 --- a/lib/api/services/beneficiary_service.dart +++ b/lib/api/services/beneficiary_service.dart @@ -105,17 +105,17 @@ class BeneficiaryService { } } - Future deleteBeneficiary(String accountNo) async { - try { - final response = await _dio.delete('/api/beneficiary/$accountNo'); - - if (response.statusCode != 204) { - throw Exception('Failed to delete beneficiary'); - } - } on DioException catch (e) { - throw Exception('Network error: ${e.message}'); - } catch (e) { - throw Exception('Unexpected error: ${e.toString()}'); - } -} + Future deleteBeneficiary(String accountNo) async { + try { + final response = await _dio.delete('/api/beneficiary/$accountNo'); + + if (response.statusCode != 204) { + throw Exception('Failed to delete beneficiary'); + } + } on DioException catch (e) { + throw Exception('Network error: ${e.message}'); + } catch (e) { + throw Exception('Unexpected error: ${e.toString()}'); + } + } } diff --git a/lib/features/accounts/screens/account_statement_screen.dart b/lib/features/accounts/screens/account_statement_screen.dart index 34bcee1..63b2003 100644 --- a/lib/features/accounts/screens/account_statement_screen.dart +++ b/lib/features/accounts/screens/account_statement_screen.dart @@ -11,7 +11,11 @@ import 'transaction_details_screen.dart'; class AccountStatementScreen extends StatefulWidget { final String accountNo; final String balance; - const AccountStatementScreen({super.key, required this.accountNo, required this.balance,}); + const AccountStatementScreen({ + super.key, + required this.accountNo, + required this.balance, + }); @override State createState() => _AccountStatementScreen(); @@ -155,19 +159,20 @@ class _AccountStatementScreen extends State { fontWeight: FontWeight.bold, ), ), - Text(widget.accountNo, style: const TextStyle(fontSize: 17)), + Text(widget.accountNo, style: const TextStyle(fontSize: 17)), ], ), const SizedBox(height: 15), Row( children: [ - Text( + Text( "${AppLocalizations.of(context).availableBalance}: ", style: const TextStyle( fontSize: 17, ), ), - Text(' ₹ ${widget.balance}', style: const TextStyle(fontSize: 17)), + Text(' ₹ ${widget.balance}', + style: const TextStyle(fontSize: 17)), ], ), const SizedBox(height: 15), diff --git a/lib/features/beneficiaries/screens/add_beneficiary_screen.dart b/lib/features/beneficiaries/screens/add_beneficiary_screen.dart index d51ad71..877987a 100644 --- a/lib/features/beneficiaries/screens/add_beneficiary_screen.dart +++ b/lib/features/beneficiaries/screens/add_beneficiary_screen.dart @@ -46,7 +46,7 @@ class _AddBeneficiaryScreen extends State { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { setState(() { - accountType = AppLocalizations.of(context).savings; + accountType = 'Savings'; }); }); } @@ -87,18 +87,16 @@ class _AddBeneficiaryScreen extends State { final service = getIt(); try { - String beneficiaryName; - if(ifsc.toLowerCase().contains('kace')){ - beneficiaryName = await service.validateBeneficiaryWithinBank(accountNo); - } - - else{ - beneficiaryName = await service.validateBeneficiary( - accountNo: accountNo, - ifscCode: ifsc, - remitterName: remitter, - ); + if (ifsc.toLowerCase().contains('kace')) { + beneficiaryName = + await service.validateBeneficiaryWithinBank(accountNo); + } else { + beneficiaryName = await service.validateBeneficiary( + accountNo: accountNo, + ifscCode: ifsc, + remitterName: remitter, + ); } setState(() { @@ -129,8 +127,9 @@ class _AddBeneficiaryScreen extends State { // Ensure beneficiary is validated before proceeding to TPIN if (!_isBeneficiaryValidated) { ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Please validate beneficiary details first.')), + SnackBar( + content: Text(AppLocalizations.of(context) + .pleaseValidateBeneficiaryDetailsFirst)), ); return; } @@ -517,8 +516,8 @@ class _AddBeneficiaryScreen extends State { ), ), items: [ - AppLocalizations.of(context).savings, - AppLocalizations.of(context).current, + 'Savings', + 'Current', ] .map( (type) => DropdownMenuItem( diff --git a/lib/features/beneficiaries/screens/beneficiary_details_screen.dart b/lib/features/beneficiaries/screens/beneficiary_details_screen.dart index 0b190b0..e32b397 100644 --- a/lib/features/beneficiaries/screens/beneficiary_details_screen.dart +++ b/lib/features/beneficiaries/screens/beneficiary_details_screen.dart @@ -4,6 +4,8 @@ import 'package:kmobile/di/injection.dart'; import 'package:kmobile/widgets/bank_logos.dart'; import 'package:kmobile/api/services/beneficiary_service.dart'; +import '../../../l10n/app_localizations.dart'; + class BeneficiaryDetailsScreen extends StatelessWidget { final Beneficiary beneficiary; @@ -11,68 +13,73 @@ class BeneficiaryDetailsScreen extends StatelessWidget { final service = getIt(); - void _deleteBeneficiary(BuildContext context) async { - try { - await service.deleteBeneficiary(beneficiary.accountNo); - _showSuccessDialog(context); - } catch (e) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Failed to delete beneficiary: $e')), - ); - } -} - -void _showSuccessDialog(BuildContext context) { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Success'), - content: const Text('Beneficiary deleted successfully.'), - actions: [ - TextButton( - child: const Text('OK'), - onPressed: () { - Navigator.of(context).popUntil((route) => route.isFirst); - }, - ), - ], - ); - }, - ); -} - -void _showDeleteConfirmationDialog(BuildContext context) { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Delete Beneficiary'), - content: - const Text('Are you sure you want to delete this beneficiary?'), - actions: [ - TextButton( - child: const Text('Cancel'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - TextButton( - child: const Text('Delete'), - onPressed: () { - //Navigator.of(context).pop(); - _deleteBeneficiary(context); - }, - ), - ], - ); - }, - ); -} @override + void _deleteBeneficiary(BuildContext context) async { + try { + await service.deleteBeneficiary(beneficiary.accountNo); + _showSuccessDialog(context); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + '${AppLocalizations.of(context).failedToDeleteBeneficiary}: $e')), + ); + } + } + + void _showSuccessDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(AppLocalizations.of(context).success), + content: + Text(AppLocalizations.of(context).beneficiaryDeletedSuccessfully), + actions: [ + TextButton( + child: Text(AppLocalizations.of(context).ok), + onPressed: () { + Navigator.of(context).popUntil((route) => route.isFirst); + }, + ), + ], + ); + }, + ); + } + + void _showDeleteConfirmationDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(AppLocalizations.of(context).deleteBeneficiary), + content: Text(AppLocalizations.of(context) + .areYouSureYouWantToDeleteThisBeneficiary), + actions: [ + TextButton( + child: Text(AppLocalizations.of(context).cancel), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text(AppLocalizations.of(context).delete), + onPressed: () { + //Navigator.of(context).pop(); + _deleteBeneficiary(context); + }, + ), + ], + ); + }, + ); + } + + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('Beneficiary Details'), + title: Text(AppLocalizations.of(context).beneficiarydetails), ), body: Padding( padding: const EdgeInsets.all(16.0), @@ -95,11 +102,16 @@ void _showDeleteConfirmationDialog(BuildContext context) { ], ), const SizedBox(height: 24), - _buildDetailRow('Beneficiary Name', beneficiary.bankName ?? 'N/A'), - _buildDetailRow('Account No.', beneficiary.accountNo), - _buildDetailRow('Account Type', beneficiary.accountType), - _buildDetailRow('IFSC Code', beneficiary.ifscCode), - _buildDetailRow('Branch Name', beneficiary.branchName ?? 'N/A'), + _buildDetailRow('${AppLocalizations.of(context).bankName} ', + beneficiary.bankName ?? 'N/A'), + _buildDetailRow('${AppLocalizations.of(context).accountNumber} ', + beneficiary.accountNo), + _buildDetailRow('${AppLocalizations.of(context).accountType} ', + beneficiary.accountType), + _buildDetailRow('${AppLocalizations.of(context).ifscCode} ', + beneficiary.ifscCode), + _buildDetailRow('${AppLocalizations.of(context).branchName} ', + beneficiary.branchName ?? 'N/A'), const Spacer(), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -114,10 +126,10 @@ void _showDeleteConfirmationDialog(BuildContext context) { ElevatedButton.icon( onPressed: () { // Delete beneficiary option - _showDeleteConfirmationDialog(context); + _showDeleteConfirmationDialog(context); }, icon: const Icon(Icons.delete), - label: const Text('Delete'), + label: Text(AppLocalizations.of(context).delete), ), ], ), diff --git a/lib/features/dashboard/screens/dashboard_screen.dart b/lib/features/dashboard/screens/dashboard_screen.dart index 1105b69..80e3385 100644 --- a/lib/features/dashboard/screens/dashboard_screen.dart +++ b/lib/features/dashboard/screens/dashboard_screen.dart @@ -523,8 +523,10 @@ class _DashboardScreenState extends State { MaterialPageRoute( builder: (context) => AccountStatementScreen( - accountNo: users[selectedAccountIndex].accountNo!, - balance: users[selectedAccountIndex].availableBalance!, + accountNo: users[selectedAccountIndex] + .accountNo!, + balance: users[selectedAccountIndex] + .availableBalance!, ))); }), _buildQuickLink(Symbols.checkbook, diff --git a/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart b/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart index e0ad65b..f99d6a7 100644 --- a/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart +++ b/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart @@ -16,8 +16,8 @@ import 'package:kmobile/di/injection.dart'; import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart'; import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart'; import '../../../l10n/app_localizations.dart'; -import 'package:kmobile/api/services/payment_service.dart'; -import 'package:kmobile/data/models/transfer.dart'; +import 'package:kmobile/api/services/payment_service.dart'; +import 'package:kmobile/data/models/transfer.dart'; enum TransactionMode { neft, rtgs, imps } @@ -25,14 +25,14 @@ class FundTransferAmountScreen extends StatefulWidget { final String debitAccountNo; final Beneficiary creditBeneficiary; final String remitterName; - final bool isOwnBank; + final bool isOwnBank; const FundTransferAmountScreen({ super.key, required this.debitAccountNo, required this.creditBeneficiary, required this.remitterName, - this.isOwnBank = false, + this.isOwnBank = false, }); @override @@ -54,263 +54,266 @@ class _FundTransferAmountScreenState extends State { void _onProceed() { if (_formKey.currentState!.validate()) { final amount = double.tryParse(_amountController.text) ?? 0; - if (widget.isOwnBank) { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => TransactionPinScreen( - onPinCompleted: (pinScreenContext, tpin) async { - final transfer = Transfer( - fromAccount: widget.debitAccountNo, - toAccount: widget.creditBeneficiary.accountNo, - toAccountType: 'Savings', // Assuming 'SB' for savings - amount: _amountController.text, - tpin: tpin, - ); - - final paymentService = getIt(); - final paymentResponseFuture = - paymentService.processQuickPayWithinBank(transfer); - - Navigator.of(pinScreenContext).pushReplacement( - MaterialPageRoute( - builder: (_) => PaymentAnimationScreen( - paymentResponse: paymentResponseFuture), - ), - ); - }, - ), - ), - ); - } else { - if (_selectedMode == TransactionMode.rtgs && amount < 200000) { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text(AppLocalizations.of(context).invalidRtgs), - content: Text(AppLocalizations.of(context).invalidRtgsPopUp), - actions: [ - TextButton( - onPressed: () => Navigator.of(ctx).pop(), - child: Text(AppLocalizations.of(context).ok), - ), - ], + if (widget.isOwnBank) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => TransactionPinScreen( + onPinCompleted: (pinScreenContext, tpin) async { + final transfer = Transfer( + fromAccount: widget.debitAccountNo, + toAccount: widget.creditBeneficiary.accountNo, + toAccountType: 'Savings', // Assuming 'SB' for savings + amount: _amountController.text, + tpin: tpin, + ); + + final paymentService = getIt(); + final paymentResponseFuture = + paymentService.processQuickPayWithinBank(transfer); + + Navigator.of(pinScreenContext).pushReplacement( + MaterialPageRoute( + builder: (_) => PaymentAnimationScreen( + paymentResponse: paymentResponseFuture), + ), + ); + }, + ), ), ); - return; // Stop further execution - } + } else { + if (_selectedMode == TransactionMode.rtgs && amount < 200000) { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text(AppLocalizations.of(context).invalidRtgs), + content: Text(AppLocalizations.of(context).invalidRtgsPopUp), + actions: [ + TextButton( + onPressed: () => Navigator.of(ctx).pop(), + child: Text(AppLocalizations.of(context).ok), + ), + ], + ), + ); + return; // Stop further execution + } - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => TransactionPinScreen( - onPinCompleted: (pinScreenContext, tpin) async { - if (_selectedMode == TransactionMode.neft) { - final neftTx = NeftTransaction( - fromAccount: widget.debitAccountNo, - toAccount: widget.creditBeneficiary.accountNo, - amount: _amountController.text, - ifscCode: widget.creditBeneficiary.ifscCode, - remitterName: widget.remitterName, - beneficiaryName: widget.creditBeneficiary.name, - tpin: tpin, - ); - final neftService = getIt(); - - final completer = Completer(); - - Navigator.of(pinScreenContext).pushReplacement( - MaterialPageRoute( - builder: (_) => PaymentAnimationScreen( - paymentResponse: completer.future), - ), - ); - - try { - final neftResponse = - await neftService.processNeftTransaction(neftTx); - final paymentResponse = PaymentResponse( - isSuccess: neftResponse.message.toUpperCase() == 'SUCCESS', - date: DateTime.now(), - creditedAccount: neftTx.toAccount, - amount: neftTx.amount, - currency: 'INR', - utr: neftResponse.utr, + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => TransactionPinScreen( + onPinCompleted: (pinScreenContext, tpin) async { + if (_selectedMode == TransactionMode.neft) { + final neftTx = NeftTransaction( + fromAccount: widget.debitAccountNo, + toAccount: widget.creditBeneficiary.accountNo, + amount: _amountController.text, + ifscCode: widget.creditBeneficiary.ifscCode, + remitterName: widget.remitterName, + beneficiaryName: widget.creditBeneficiary.name, + tpin: tpin, ); - completer.complete(paymentResponse); - } on DioException catch (e) { - print(e); - String errorMessage; - if (e.response != null && e.response!.data != null) { - print('error has data'); - try { - // final error = jsonDecode(e.response!.toString())['error']; - final error = e.response?.data['error']; - print('actual error message $error'); - errorMessage = { - "INCORRECT_TPIN": "Please Enter the correct TPIN", - "INSUFFICIENT_FUNDS": - "Your account does not have sufficient balance" - }[error] ?? - "Something Went Wrong"; - } catch (_) { - print('error extracting errorMessage'); + final neftService = getIt(); + + final completer = Completer(); + + Navigator.of(pinScreenContext).pushReplacement( + MaterialPageRoute( + builder: (_) => PaymentAnimationScreen( + paymentResponse: completer.future), + ), + ); + + try { + final neftResponse = + await neftService.processNeftTransaction(neftTx); + final paymentResponse = PaymentResponse( + isSuccess: + neftResponse.message.toUpperCase() == 'SUCCESS', + date: DateTime.now(), + creditedAccount: neftTx.toAccount, + amount: neftTx.amount, + currency: 'INR', + utr: neftResponse.utr, + ); + completer.complete(paymentResponse); + } on DioException catch (e) { + print(e); + String errorMessage; + if (e.response != null && e.response!.data != null) { + print('error has data'); + try { + // final error = jsonDecode(e.response!.toString())['error']; + final error = e.response?.data['error']; + print('actual error message $error'); + errorMessage = { + "INCORRECT_TPIN": "Please Enter the correct TPIN", + "INSUFFICIENT_FUNDS": + "Your account does not have sufficient balance" + }[error] ?? + "Something Went Wrong"; + } catch (_) { + print('error extracting errorMessage'); + errorMessage = "Something Went Wrong"; + } + } else { + print('has has no data'); errorMessage = "Something Went Wrong"; } - } else { - print('has has no data'); - errorMessage = "Something Went Wrong"; + print('PaymentResponse generating'); + final paymentResponse = PaymentResponse( + isSuccess: false, + errorMessage: errorMessage, + ); + print('PaymentResponse generated'); + print(paymentResponse); + completer.complete(paymentResponse); + print("NEFT transaction failed with DioException."); // Add + } catch (e) { + print('generic exception'); + print(e.toString()); + final paymentResponse = PaymentResponse( + isSuccess: false, + errorMessage: AppLocalizations.of(pinScreenContext) + .somethingWentWrong, + ); + completer.complete(paymentResponse); + print( + "NEFT transaction failed with generic exception."); // Add } - print('PaymentResponse generating'); - final paymentResponse = PaymentResponse( - isSuccess: false, - errorMessage: errorMessage, - ); - print('PaymentResponse generated'); - print(paymentResponse); - completer.complete(paymentResponse); - print("NEFT transaction failed with DioException."); // Add - } catch (e) { - print('generic exception'); - print(e.toString()); - final paymentResponse = PaymentResponse( - isSuccess: false, - errorMessage: AppLocalizations.of(pinScreenContext) - .somethingWentWrong, - ); - completer.complete(paymentResponse); - print( - "NEFT transaction failed with generic exception."); // Add } - } - //IMPS transaction - else if (_selectedMode == TransactionMode.imps) { - final impsTx = ImpsTransaction( - fromAccount: widget.debitAccountNo, - toAccount: widget.creditBeneficiary.accountNo, - amount: _amountController.text, - ifscCode: widget.creditBeneficiary.ifscCode, - remitterName: widget.remitterName, - beneficiaryName: widget.creditBeneficiary.name, - tpin: tpin, - ); - final impsService = getIt(); - final completer = Completer(); - - Navigator.of(pinScreenContext).pushReplacement( - MaterialPageRoute( - builder: (_) => PaymentAnimationScreen( - paymentResponse: completer.future), - ), - ); - - try { - final impsResponse = - await impsService.processImpsTransaction(impsTx); - final paymentResponse = PaymentResponse( - isSuccess: impsResponse.message.toUpperCase() == 'SUCCESS', - date: DateTime.now(), - creditedAccount: impsTx.toAccount, - amount: impsTx.amount, - currency: 'INR', - utr: impsResponse.utr, + //IMPS transaction + else if (_selectedMode == TransactionMode.imps) { + final impsTx = ImpsTransaction( + fromAccount: widget.debitAccountNo, + toAccount: widget.creditBeneficiary.accountNo, + amount: _amountController.text, + ifscCode: widget.creditBeneficiary.ifscCode, + remitterName: widget.remitterName, + beneficiaryName: widget.creditBeneficiary.name, + tpin: tpin, ); - completer.complete(paymentResponse); - } on DioException catch (e) { - print('dio exception'); - print(e.toString()); + final impsService = getIt(); + final completer = Completer(); - final error = jsonDecode(e.response.toString())['error']; - var errorMessage = { - "INCORRECT_TPIN": "Please Enter the correct TPIN", - "INSUFFICIENT_FUNDS": - "Your account does not have sufficient balance" - }[error] ?? - "Something Went Wrong"; + Navigator.of(pinScreenContext).pushReplacement( + MaterialPageRoute( + builder: (_) => PaymentAnimationScreen( + paymentResponse: completer.future), + ), + ); - final paymentResponse = PaymentResponse( - isSuccess: false, - errorMessage: errorMessage, - ); - completer.complete(paymentResponse); - } catch (e) { - print('generic exception'); - print(e.toString()); - final paymentResponse = PaymentResponse( - isSuccess: false, - errorMessage: "Something went Wrong", - ); - completer.complete(paymentResponse); + try { + final impsResponse = + await impsService.processImpsTransaction(impsTx); + final paymentResponse = PaymentResponse( + isSuccess: + impsResponse.message.toUpperCase() == 'SUCCESS', + date: DateTime.now(), + creditedAccount: impsTx.toAccount, + amount: impsTx.amount, + currency: 'INR', + utr: impsResponse.utr, + ); + completer.complete(paymentResponse); + } on DioException catch (e) { + print('dio exception'); + print(e.toString()); + + final error = jsonDecode(e.response.toString())['error']; + var errorMessage = { + "INCORRECT_TPIN": "Please Enter the correct TPIN", + "INSUFFICIENT_FUNDS": + "Your account does not have sufficient balance" + }[error] ?? + "Something Went Wrong"; + + final paymentResponse = PaymentResponse( + isSuccess: false, + errorMessage: errorMessage, + ); + completer.complete(paymentResponse); + } catch (e) { + print('generic exception'); + print(e.toString()); + final paymentResponse = PaymentResponse( + isSuccess: false, + errorMessage: "Something went Wrong", + ); + completer.complete(paymentResponse); + } } - } - //RTGS - else { - final rtgsTx = RtgsTransaction( - fromAccount: widget.debitAccountNo, - toAccount: widget.creditBeneficiary.accountNo, - amount: _amountController.text, - ifscCode: widget.creditBeneficiary.ifscCode, - remitterName: widget.remitterName, - beneficiaryName: widget.creditBeneficiary.name, - tpin: tpin, - ); - final rtgsService = getIt(); - final completer = Completer(); - - Navigator.of(pinScreenContext).pushReplacement( - MaterialPageRoute( - builder: (_) => PaymentAnimationScreen( - paymentResponse: completer.future), - ), - ); - - try { - final rtgsResponse = - await rtgsService.processRtgsTransaction(rtgsTx); - final paymentResponse = PaymentResponse( - isSuccess: rtgsResponse.message.toUpperCase() == 'SUCCESS', - date: DateTime.now(), - creditedAccount: rtgsTx.toAccount, - amount: rtgsTx.amount, - currency: 'INR', - utr: rtgsResponse.utr, + //RTGS + else { + final rtgsTx = RtgsTransaction( + fromAccount: widget.debitAccountNo, + toAccount: widget.creditBeneficiary.accountNo, + amount: _amountController.text, + ifscCode: widget.creditBeneficiary.ifscCode, + remitterName: widget.remitterName, + beneficiaryName: widget.creditBeneficiary.name, + tpin: tpin, ); - completer.complete(paymentResponse); - } on DioException catch (e) { - print('dio exception'); - print(e.toString()); + final rtgsService = getIt(); + final completer = Completer(); - final error = jsonDecode(e.response.toString())['error']; - var errorMessage = { - "INCORRECT_TPIN": "Please Enter the correct TPIN", - "INSUFFICIENT_FUNDS": - "Your account does not have sufficient balance" - // ignore: use_build_context_synchronously - }[error] ?? - "Something Went Wrong"; + Navigator.of(pinScreenContext).pushReplacement( + MaterialPageRoute( + builder: (_) => PaymentAnimationScreen( + paymentResponse: completer.future), + ), + ); - final paymentResponse = PaymentResponse( - isSuccess: false, - errorMessage: errorMessage, - ); - completer.complete(paymentResponse); - } catch (e) { - print('generic exception'); - print(e.toString()); - final paymentResponse = PaymentResponse( - isSuccess: false, - errorMessage: "Something Went Wrong", - ); - completer.complete(paymentResponse); + try { + final rtgsResponse = + await rtgsService.processRtgsTransaction(rtgsTx); + final paymentResponse = PaymentResponse( + isSuccess: + rtgsResponse.message.toUpperCase() == 'SUCCESS', + date: DateTime.now(), + creditedAccount: rtgsTx.toAccount, + amount: rtgsTx.amount, + currency: 'INR', + utr: rtgsResponse.utr, + ); + completer.complete(paymentResponse); + } on DioException catch (e) { + print('dio exception'); + print(e.toString()); + + final error = jsonDecode(e.response.toString())['error']; + var errorMessage = { + "INCORRECT_TPIN": "Please Enter the correct TPIN", + "INSUFFICIENT_FUNDS": + "Your account does not have sufficient balance" + // ignore: use_build_context_synchronously + }[error] ?? + "Something Went Wrong"; + + final paymentResponse = PaymentResponse( + isSuccess: false, + errorMessage: errorMessage, + ); + completer.complete(paymentResponse); + } catch (e) { + print('generic exception'); + print(e.toString()); + final paymentResponse = PaymentResponse( + isSuccess: false, + errorMessage: "Something Went Wrong", + ); + completer.complete(paymentResponse); + } } - } - }, + }, + ), ), - ), - ); + ); + } } } - } @override Widget build(BuildContext context) { @@ -362,60 +365,61 @@ class _FundTransferAmountScreenState extends State { ), const SizedBox(height: 24), - if (!widget.isOwnBank) ...[ - // Transaction Mode Selection - Text( - AppLocalizations.of(context).selectTransactionType, - style: Theme.of(context).textTheme.titleMedium, - ), - const SizedBox(height: 12), - Container( - decoration: BoxDecoration( - color: Theme.of(context).cardColor, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: Colors.grey.shade300), + if (!widget.isOwnBank) ...[ + // Transaction Mode Selection + Text( + AppLocalizations.of(context).selectTransactionType, + style: Theme.of(context).textTheme.titleMedium, ), - child: ToggleButtons( - isSelected: [ - _selectedMode == TransactionMode.neft, - _selectedMode == TransactionMode.rtgs, - _selectedMode == TransactionMode.imps, - ], - onPressed: (index) { - setState(() { - _selectedMode = TransactionMode.values[index]; - }); - }, - borderRadius: BorderRadius.circular(10), - selectedColor: Theme.of(context).colorScheme.onPrimary, - fillColor: Theme.of(context).primaryColor, - color: Theme.of(context).colorScheme.onSurface, - borderColor: Colors.transparent, - selectedBorderColor: Colors.transparent, - splashColor: Theme.of(context).primaryColor.withOpacity(0.1), - highlightColor: - Theme.of(context).primaryColor.withOpacity(0.05), - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 24.0, vertical: 12.0), - child: Text(AppLocalizations.of(context).neft), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 24.0, vertical: 12.0), - child: Text(AppLocalizations.of(context).rtgs), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 24.0, vertical: 12.0), - child: Text(AppLocalizations.of(context).imps), - ), - ], + const SizedBox(height: 12), + Container( + decoration: BoxDecoration( + color: Theme.of(context).cardColor, + borderRadius: BorderRadius.circular(12), + border: Border.all(color: Colors.grey.shade300), + ), + child: ToggleButtons( + isSelected: [ + _selectedMode == TransactionMode.neft, + _selectedMode == TransactionMode.rtgs, + _selectedMode == TransactionMode.imps, + ], + onPressed: (index) { + setState(() { + _selectedMode = TransactionMode.values[index]; + }); + }, + borderRadius: BorderRadius.circular(10), + selectedColor: Theme.of(context).colorScheme.onPrimary, + fillColor: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.onSurface, + borderColor: Colors.transparent, + selectedBorderColor: Colors.transparent, + splashColor: + Theme.of(context).primaryColor.withOpacity(0.1), + highlightColor: + Theme.of(context).primaryColor.withOpacity(0.05), + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 24.0, vertical: 12.0), + child: Text(AppLocalizations.of(context).neft), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 24.0, vertical: 12.0), + child: Text(AppLocalizations.of(context).rtgs), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 24.0, vertical: 12.0), + child: Text(AppLocalizations.of(context).imps), + ), + ], + ), ), - ), - const SizedBox(height: 24), - ], + const SizedBox(height: 24), + ], // Amount TextFormField( controller: _amountController, diff --git a/lib/features/profile/preferences/color_theme_dialog.dart b/lib/features/profile/preferences/color_theme_dialog.dart index aa5d60a..18368e7 100644 --- a/lib/features/profile/preferences/color_theme_dialog.dart +++ b/lib/features/profile/preferences/color_theme_dialog.dart @@ -22,7 +22,7 @@ class ColorThemeDialog extends StatelessWidget { ), ListTile( leading: const CircleAvatar(backgroundColor: Colors.green), - title: const Text('Green'), + title: Text(AppLocalizations.of(context).green), onTap: () { context.read().changeTheme(ThemeType.green); Navigator.pop(context); @@ -30,7 +30,7 @@ class ColorThemeDialog extends StatelessWidget { ), ListTile( leading: const CircleAvatar(backgroundColor: Colors.orange), - title: const Text('Orange'), + title: Text(AppLocalizations.of(context).orange), onTap: () { context.read().changeTheme(ThemeType.orange); Navigator.pop(context); diff --git a/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart b/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart index fc6578b..8d515bf 100644 --- a/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart +++ b/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart @@ -53,7 +53,7 @@ class _QuickPayOutsideBankScreen extends State { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { setState(() { - accountType = AppLocalizations.of(context).savings; + accountType = 'Savings'; }); }); } @@ -572,8 +572,8 @@ class _QuickPayOutsideBankScreen extends State { ), ), items: [ - AppLocalizations.of(context).savings, - AppLocalizations.of(context).current, + 'Savings', + 'Current', ] .map( (e) => DropdownMenuItem(value: e, child: Text(e)), diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index cb42659..739975e 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -285,5 +285,8 @@ "areYouSureYouWantToDeleteThisBeneficiary": "Are you sure you want to delete this beneficiary?", "yourAccountDoesNotHaveSufficientBalance": "Your account does not have sufficient balance", "green": "Green", -"orange": "Orange" +"orange": "Orange", +"deleteBeneficiary": "Delete Beneficiary", +"beneficiarydetails": "Beneficiary Details", +"delete": "Delete" } diff --git a/lib/l10n/app_hi.arb b/lib/l10n/app_hi.arb index e59c241..e749f6e 100644 --- a/lib/l10n/app_hi.arb +++ b/lib/l10n/app_hi.arb @@ -285,5 +285,8 @@ "areYouSureYouWantToDeleteThisBeneficiary": "क्या आप वाकई इस लाभार्थी को हटाना चाहते हैं?", "yourAccountDoesNotHaveSufficientBalance": "आपके खाते में पर्याप्त शेष राशि नहीं है", "green": "हरा", - "orange": "नारंगी" + "orange": "नारंगी", + "deleteBeneficiary": "लाभार्थी हटाएं", +"beneficiarydetails": "लाभार्थी विवरण", +"delete": "मिटाओ" }