Yojna & Cheque done

This commit is contained in:
2026-03-12 13:44:13 +05:30
parent 1da7574ddb
commit dfdc293309
26 changed files with 3687 additions and 422 deletions

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:kmobile/data/models/user.dart';
import 'package:kmobile/features/cheque/screens/cheque_enquiry_screen.dart';
import 'package:kmobile/features/cheque/screens/positive_pay_screen.dart';
import 'package:kmobile/features/cheque/screens/revoke_stop_screen.dart';
import 'package:kmobile/features/cheque/screens/stop_cheque_screen.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
import '../../../l10n/app_localizations.dart';
@@ -42,8 +44,6 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
child: ChequeManagementCardTile(
icon: Symbols.payments,
label: AppLocalizations.of(context).chequeEnquiryTitle,
subtitle:
AppLocalizations.of(context).chequeEnquirySubtitle,
onTap: () {
Navigator.push(
context,
@@ -61,7 +61,6 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
child: ChequeManagementCardTile(
icon: Symbols.block_sharp,
label: AppLocalizations.of(context).stopCheque,
subtitle: AppLocalizations.of(context).stopChequeSubtitle,
onTap: () {
Navigator.push(
context,
@@ -75,6 +74,40 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
},
),
),
Expanded(
child: ChequeManagementCardTile(
icon: Symbols.stop_circle,
label: AppLocalizations.of(context).revokeStop,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RevokeStopChequeScreen(
users: users,
selectedIndex: selectedAccountIndex,
),
),
);
},
),
),
Expanded(
child: ChequeManagementCardTile(
icon: Symbols.check_circle, // Using check_circle for Positive Pay
label: AppLocalizations.of(context).positivePayTitle,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PositivePayScreen(
users: users,
selectedIndex: selectedAccountIndex,
),
),
);
},
),
),
],
),
),
@@ -101,7 +134,6 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
class ChequeManagementCardTile extends StatelessWidget {
final IconData icon;
final String label;
final String? subtitle;
final VoidCallback onTap;
final bool disable;
@@ -109,7 +141,6 @@ class ChequeManagementCardTile extends StatelessWidget {
super.key,
required this.icon,
required this.label,
this.subtitle,
required this.onTap,
this.disable = false,
});
@@ -152,19 +183,6 @@ class ChequeManagementCardTile extends StatelessWidget {
: theme.colorScheme.onSurface,
),
),
if (subtitle != null)
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
subtitle!,
textAlign: TextAlign.center,
style: theme.textTheme.bodyMedium?.copyWith(
color: disable
? theme.disabledColor
: theme.colorScheme.onSurfaceVariant,
),
),
),
],
),
),
@@ -173,4 +191,4 @@ class ChequeManagementCardTile extends StatelessWidget {
),
);
}
}
}

View File

@@ -0,0 +1,334 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/data/models/user.dart';
import 'package:kmobile/di/injection.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart';
class PositivePayScreen extends StatefulWidget {
final List<User> users;
final int selectedIndex;
const PositivePayScreen({
super.key,
required this.users,
required this.selectedIndex,
});
@override
State<PositivePayScreen> createState() => _PositivePayScreenState();
}
class _PositivePayScreenState extends State<PositivePayScreen> {
User? _selectedAccount;
List<User> _filteredUsers = [];
final _formKey = GlobalKey<FormState>();
final _chequeNumberController = TextEditingController();
final _chequeDateController = TextEditingController();
final _amountController = TextEditingController();
final _payeeController = TextEditingController();
final _chequeService = getIt<ChequeService>();
String? _ciFromCheque;
String? _ciToCheque;
@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;
}
}
_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
void dispose() {
_chequeNumberController.dispose();
_chequeDateController.dispose();
_amountController.dispose();
_payeeController.dispose();
super.dispose();
}
Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(message),
],
),
),
actions: <Widget>[
TextButton(
child: Text(AppLocalizations.of(context).closeButton),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
AppLocalizations.of(context).positivePay, // Will be replaced by localization
),
centerTitle: false,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
const SizedBox(height: 16.0),
DropdownButtonFormField<User>(
value: _selectedAccount,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).accountNumber,
border: const OutlineInputBorder(),
),
items: _filteredUsers.map((user) {
return DropdownMenuItem<User>(
value: user,
child: Text(user.accountNo.toString()),
);
}).toList(),
onChanged: (User? newUser) {
setState(() {
_selectedAccount = newUser;
_loadChequeDetails();
});
},
validator: (value) {
if (value == null) {
return AppLocalizations.of(context).accountNumberRequired;
}
return null;
},
),
const SizedBox(height: 16.0),
TextFormField(
controller: _chequeNumberController,
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;
},
),
const SizedBox(height: 16.0),
TextFormField(
controller: _chequeDateController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).chequeIssuedDate,
border: const OutlineInputBorder(),
suffixIcon: const Icon(Icons.calendar_today),
),
readOnly: true,
onTap: () async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime.now(),
);
if (pickedDate != null) {
// Format the date as you wish
String formattedDate = "${pickedDate.year}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.day.toString().padLeft(2, '0')}";
_chequeDateController.text = formattedDate;
}
},
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context).pleaseSelectChequeIssuedDate;
}
return null;
},
),
const SizedBox(height: 16.0),
TextFormField(
controller: _payeeController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).payeeName,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 16.0),
TextFormField(
controller: _amountController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).amountLabel,
border: const OutlineInputBorder(),
prefixText: '',
),
keyboardType: const TextInputType.numberWithOptions(decimal: true),
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context).pleaseEnterAmount;
}
return null;
},
),
const SizedBox(height: 32.0),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
// Process data
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try {
final response = await _chequeService.registerPPS(
cheque_no: _chequeNumberController.text,
account_number:
_selectedAccount!.accountNo!,
issue_date:
_chequeDateController.text,
amount: _amountController.text,
payee_name: _payeeController.text,
tpin: pin,
);
if (!mounted) return;
String responseString = response.toString();
if(responseString == 'PPS Registered Successfully'){
_showResponseDialog('REGISTRATION SUCCESFUL',
'Your Positive Pay Request has been registered succesfully');
}
if(responseString.contains('Cheque already registered')){
_showResponseDialog('ERROR',
'Your Request for the selected cheque number has already been registered');
}
if(responseString.contains('INCORRECT_TPIN')){
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
}
} on DioException catch (e) {
try {
final errorBodyString =
e.toString().split('Exception: ')[1];
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
errorBody['error'] == 'INCORRECT_TPIN') {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
} else {
_showResponseDialog(
'Error', 'Internal Server Error');
}
} catch (_) {
_showResponseDialog(
'Error', 'Internal Server Error');
}
}
},
),
),
);
}
},
child: Text(AppLocalizations.of(context).proceedButton),
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,338 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/data/models/user.dart';
import 'package:kmobile/di/injection.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart';
class RevokeStopMultipleChequesScreen extends StatefulWidget {
final User selectedAccount;
final String date;
final String instrType;
final String fromCheque;
final String toCheque;
const RevokeStopMultipleChequesScreen(
{super.key,
required this.selectedAccount,
required this.date,
required this.instrType,
required this.fromCheque,
required this.toCheque});
@override
State<RevokeStopMultipleChequesScreen> createState() =>
_RevokeStopMultipleChequesScreenState();
}
class _RevokeStopMultipleChequesScreenState extends State<RevokeStopMultipleChequesScreen> {
final _formKey = GlobalKey<FormState>();
final _stopFromChequeNoController = TextEditingController();
final _stopToChequeNoController = TextEditingController();
final _stopIssueDateController = TextEditingController();
final _stopExpiryDateController = TextEditingController();
final _stopAmountController = TextEditingController();
final _chequeService = getIt<ChequeService>();
String? _selectedComment;
final _otherCommentController = TextEditingController();
bool _showOtherCommentField = false;
final List<String> _commentOptions = [
'Cheque Found',
'Cheque Fixed',
'Other'
];
Future<void> _selectDate(TextEditingController controller) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2101),
);
if (picked != null) {
setState(() {
controller.text =
'${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}';
});
}
}
Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(message),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Close'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).revokeMultipleStops),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: ListView(
children: [
Card(
elevation: 0,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: ListTile(
leading: Image.asset(
'assets/images/logo.png',
width: 40,
height: 40,
),
title: Text(widget.selectedAccount.accountNo!),
subtitle:
Text(AppLocalizations.of(context).accountNumberTitle),
),
),
const SizedBox(height: 24),
TextFormField(
controller: _stopFromChequeNoController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).fromChequeNumberHint,
border: const OutlineInputBorder(),
errorMaxLines: 2,
),
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context)
.pleaseEnterChequeNumberError;
}
final chequeNumber = int.tryParse(value);
final fromCheque = int.tryParse(widget.fromCheque);
final toCheque = int.tryParse(widget.toCheque);
if (chequeNumber == null ||
fromCheque == null ||
toCheque == null) {
return AppLocalizations.of(context)
.invalidChequeNumberFormatError;
}
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
return AppLocalizations.of(context).chequeNumberRangeError(
widget.fromCheque, widget.toCheque);
}
return null;
},
),
const SizedBox(height: 16),
TextFormField(
controller: _stopToChequeNoController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).toChequeNumberHint,
border: const OutlineInputBorder(),
errorMaxLines: 2,
),
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context)
.pleaseEnterChequeNumberError;
}
final chequeNumber = int.tryParse(value);
final fromCheque = int.tryParse(widget.fromCheque);
final toCheque = int.tryParse(widget.toCheque);
if (chequeNumber == null ||
fromCheque == null ||
toCheque == null) {
return AppLocalizations.of(context)
.invalidChequeNumberFormatError;
}
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
return AppLocalizations.of(context).chequeNumberRangeError(
widget.fromCheque, widget.toCheque);
}
return null;
},
),
const SizedBox(height: 16),
TextFormField(
initialValue: widget.instrType,
readOnly: true,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).instrumentTypeLabel,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 16),
TextFormField(
controller: _stopIssueDateController,
readOnly: true,
onTap: () => _selectDate(_stopIssueDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeIssueDate,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopIssueDateController),
),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopExpiryDateController,
readOnly: true,
onTap: () => _selectDate(_stopExpiryDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeExpiryDate,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopExpiryDateController),
),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopAmountController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeAmount,
prefixText: '',
border: const OutlineInputBorder(),
),
keyboardType: TextInputType.number,
),
const SizedBox(height: 16),
DropdownButtonFormField<String>(
value: _selectedComment,
items: _commentOptions.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (newValue) {
setState(() {
_selectedComment = newValue;
_showOtherCommentField = newValue == 'Other';
});
},
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeComment,
border: const OutlineInputBorder(),
),
),
if (_showOtherCommentField)
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: TextFormField(
controller: _otherCommentController,
decoration: const InputDecoration(
labelText: "Other Reasons :",
border: OutlineInputBorder(),
),
validator: (value) {
return null;
},
),
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try {
final response = await _chequeService.revokeStop(
accountno: widget.selectedAccount.accountNo!,
removeFromChequeNo:
_stopFromChequeNoController.text,
instrType: widget.instrType,
removeToChequeNo:
_stopToChequeNoController.text,
removeIssueDate: _stopIssueDateController.text,
removeExpiryDate: _stopExpiryDateController.text,
removeAmount: _stopAmountController.text,
removeComment: _selectedComment == 'Other'
? _otherCommentController.text
: _selectedComment ?? '',
tpin: pin,
);
if (!mounted) return;
final decodedResponse = jsonDecode(response);
String responseString = response.toString(); // used as the case only for incorrect TPIN
final status = decodedResponse['status'];
final message = decodedResponse['message'];
final code = decodedResponse['code'];
if (status == 'SUCCESS') {
_showResponseDialog('Success', message);
} if (status == 'ERROR') {
String errMessage = "error";
if(code == '0172') {
errMessage = 'The selected Cheque is not stopped';
} else if(code == '0748') {
errMessage = 'The selected Cheque is already presented';
}
_showResponseDialog('Error', errMessage);
}
if(responseString.contains('INCORRECT_TPIN')){
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
}
} on Exception catch (e) {
try {
final errorBodyString =
e.toString().split('Exception: ')[1];
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
errorBody['error'] == 'INCORRECT_TPIN') {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
} else {
_showResponseDialog(
'Error', 'Internal Server Error');
}
} catch (_) {
_showResponseDialog(
'Error', 'Internal Server Error');
}
}
},
),
),
);
}
},
child: Text(AppLocalizations.of(context).revokeStopButton),
),
],
),
),
),
);
}
}

View File

@@ -1,351 +1,361 @@
// import 'package:kmobile/data/models/user.dart';
// import 'package:kmobile/di/injection.dart';
// import 'package:flutter/material.dart';
// import 'package:kmobile/api/services/cheque_service.dart';
// // import 'package:kmobile/features/cheque/screens/revoke_stop_multiple_screen.dart';
// // import 'package:kmobile/features/cheque/screens/revoke_stop_single_screen.dart';
// import 'package:kmobile/l10n/app_localizations.dart';
import 'package:kmobile/data/models/user.dart';
import 'package:kmobile/di/injection.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/features/cheque/screens/revoke%20_stop_multiple_screen.dart';
import 'package:kmobile/features/cheque/screens/revoke_stop_single_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart';
// class RevokeStopChequeScreen extends StatefulWidget {
// final List<User> users;
// final int selectedIndex;
class RevokeStopChequeScreen extends StatefulWidget {
final List<User> users;
final int selectedIndex;
// const RevokeStopChequeScreen(
// {
// super.key,
// required this.users,
// required this.selectedIndex,
// });
const RevokeStopChequeScreen(
{
super.key,
required this.users,
required this.selectedIndex,
});
// @override
// State<RevokeStopChequeScreen> createState() => _RevokeStopChequeScreenState();
// }
@override
State<RevokeStopChequeScreen> createState() => _RevokeStopChequeScreenState();
}
// class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
// User? _selectedAccount;
// var service = getIt<ChequeService>();
// bool _isLoading = true;
// List<Cheque> _stCheques = [];
// List<User> _filteredUsers = [];
class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
User? _selectedAccount;
var service = getIt<ChequeService>();
bool _isLoading = true;
List<Cheque> _stCheques = [];
List<User> _filteredUsers = [];
String? _ciFromCheque;
String? _ciToCheque;
// @override
// void initState() {
// super.initState();
// _filteredUsers = widget.users
// .where((user) => ['SA', 'SB', 'CA', 'CC'].contains(user.accountType))
// .toList();
@override
void initState() {
super.initState();
_filteredUsers = widget.users
.where((user) => ['SA', 'SB', 'CA', 'CC'].contains(user.accountType))
.toList();
// 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;
// }
// }
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;
}
}
// _loadCheques();
// }
_loadCheques();
}
// Future<void> _loadCheques() async {
// if (_selectedAccount == null) {
// setState(() {
// _isLoading = false;
// _stCheques = [];
// });
// return;
// }
// setState(() {
// _isLoading = true;
// });
Future<void> _loadCheques() async {
if (_selectedAccount == null) {
setState(() {
_isLoading = false;
_stCheques = [];
});
return;
}
setState(() {
_isLoading = true;
});
// 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';
// }
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 service.ChequeEnquiry(
// accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
// final stCheques = data.where((cheque) => cheque.type == 'ST').toList();
// setState(() {
// _stCheques = stCheques;
// _isLoading = false;
// });
// } catch (e) {
// setState(() {
// _isLoading = false;
// _stCheques = [];
// });
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text('Failed to fetch cheque status: ${e.toString()}'),
// ),
// );
// }
// }
try {
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) {
setState(() {
_isLoading = false;
_stCheques = [];
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Failed to fetch cheque status: ${e.toString()}'),
),
);
}
}
// String _getAccountTypeDisplayName(String accountType) {
// switch (accountType.toLowerCase()) {
// case 'sa':
// return AppLocalizations.of(context).savingsAccount;
// case 'sb':
// return AppLocalizations.of(context).savingsAccount;
// case 'ca':
// return "Current Account";
// case 'cc':
// return "Cash Credit Account";
// default:
// return accountType;
// }
// }
String _getAccountTypeDisplayName(String accountType) {
switch (accountType.toLowerCase()) {
case 'sa':
return AppLocalizations.of(context).savingsAccount;
case 'sb':
return AppLocalizations.of(context).savingsAccount;
case 'ca':
return "Current Account";
case 'cc':
return "Cash Credit Account";
default:
return accountType;
}
}
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// title: Text(AppLocalizations.of(context).revokeStop),
// centerTitle: false,
// ),
// body: Stack(
// children: [
// Padding(
// padding: const EdgeInsets.all(16.0),
// child: Column(children: [
// Card(
// elevation: 4,
// margin: const EdgeInsets.symmetric(vertical: 8.0),
// child: Padding(
// padding: const EdgeInsets.all(16.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// AppLocalizations.of(context).accountNumber,
// style: const TextStyle(
// fontWeight: FontWeight.bold, fontSize: 18),
// ),
// const SizedBox(width: 16),
// if (_selectedAccount != null)
// Expanded(
// child: DropdownButton<User>(
// value: _selectedAccount,
// onChanged: (User? newUser) {
// if (newUser != null) {
// setState(() {
// _selectedAccount = newUser;
// _loadCheques();
// });
// }
// },
// items: _filteredUsers.map((user) {
// return DropdownMenuItem<User>(
// value: user,
// child: Text(user.accountNo.toString()),
// );
// }).toList(),
// ),
// )
// else
// Text(AppLocalizations.of(context).noAccountsFound),
// ],
// ),
// ),
// ),
// const SizedBox(height: 20),
// Row(
// children: [
// Expanded(
// child: Card(
// color: Theme.of(context).colorScheme.primaryContainer,
// elevation: 4,
// child: InkWell(
// onTap: () {
// if (_selectedAccount != null &&
// _stCheques.isNotEmpty) {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// RevokeStopSingleChequeScreen(
// selectedAccount: _selectedAccount!,
// date: _stCheques.first.Date!,
// instrType: _stCheques.first.InstrType!,
// fromCheque: _stCheques.first.fromCheque!,
// toCheque: _stCheques.first.toCheque!,
// ),
// ),
// );
// } else {
// ScaffoldMessenger.of(context).showSnackBar(
// const SnackBar(
// content: Text("No stopped cheques present"),
// ),
// );
// }
// },
// child: Padding(
// padding: const EdgeInsets.all(16.0),
// child: Center(
// child: Text(
// AppLocalizations.of(context).revokeSingleStopTitle,
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 16,
// fontWeight: FontWeight.bold,
// color: Theme.of(context)
// .colorScheme
// .onPrimaryContainer,
// ),
// ),
// ),
// ),
// ),
// ),
// ),
// const SizedBox(width: 10),
// Expanded(
// child: Card(
// color: Theme.of(context).colorScheme.primaryContainer,
// elevation: 4,
// child: InkWell(
// onTap: () {
// if (_selectedAccount != null &&
// _stCheques.isNotEmpty) {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// RevokeStopMultipleChequesScreen(
// selectedAccount: _selectedAccount!,
// date: _stCheques.first.Date!,
// instrType: _stCheques.first.InstrType!,
// fromCheque: _stCheques.first.fromCheque!,
// toCheque: _stCheques.first.toCheque!,
// ),
// ),
// );
// } else {
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text(AppLocalizations.of(context)
// .pleaseSelectAccountFirst),
// ),
// );
// }
// },
// child: Padding(
// padding: const EdgeInsets.all(16.0),
// child: Center(
// child: Text(
// AppLocalizations.of(context).revokeMultipleStops,
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 16,
// fontWeight: FontWeight.bold,
// color: Theme.of(context)
// .colorScheme
// .onSecondaryContainer,
// ),
// ),
// ),
// ),
// ),
// ),
// ),
// ],
// ),
// const SizedBox(height: 20),
// Expanded(
// child: _isLoading
// ? const Center(child: CircularProgressIndicator())
// : _stCheques.isEmpty
// ? Center(
// child: Text(AppLocalizations.of(context)
// .noChequeIssuedStatus))
// : ListView.builder(
// itemCount: _stCheques.length,
// itemBuilder: (context, index) {
// return _buildSTTile(context, _stCheques[index]);
// },
// ),
// ),
// ]),
// ),
// IgnorePointer(
// child: Center(
// child: Opacity(
// opacity: 0.07, // Reduced opacity
// child: ClipOval(
// child: Image.asset(
// 'assets/images/logo.png',
// width: 200, // Adjust size as needed
// height: 200, // Adjust size as needed
// ),
// ),
// ),
// ),
// ),
// ],
// ),
// );
// }
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).revokeStop),
centerTitle: false,
),
body: Stack(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(children: [
Card(
elevation: 4,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppLocalizations.of(context).accountNumber,
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
),
const SizedBox(width: 16),
if (_selectedAccount != null)
Expanded(
child: DropdownButton<User>(
value: _selectedAccount,
onChanged: (User? newUser) {
if (newUser != null) {
setState(() {
_selectedAccount = newUser;
_loadCheques();
});
}
},
items: _filteredUsers.map((user) {
return DropdownMenuItem<User>(
value: user,
child: Text(user.accountNo.toString()),
);
}).toList(),
),
)
else
Text(AppLocalizations.of(context).noAccountsFound),
],
),
),
),
const SizedBox(height: 20),
Row(
children: [
Expanded(
child: Card(
color: Theme.of(context).colorScheme.primaryContainer,
elevation: 4,
child: InkWell(
onTap: () {
if (_selectedAccount != null &&
_stCheques.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
RevokeStopSingleChequeScreen(
selectedAccount: _selectedAccount!,
date: _stCheques.first.Date!,
instrType: _stCheques.first.InstrType!,
fromCheque: _ciFromCheque ?? _stCheques.first.fromCheque!,
toCheque: _ciToCheque ?? _stCheques.first.toCheque!,
),
),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("No stopped cheques present"),
),
);
}
},
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Center(
child: Text(
AppLocalizations.of(context).revokeSingleStopTitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.colorScheme
.onPrimaryContainer,
),
),
),
),
),
),
),
const SizedBox(width: 10),
Expanded(
child: Card(
color: Theme.of(context).colorScheme.primaryContainer,
elevation: 4,
child: InkWell(
onTap: () {
if (_selectedAccount != null &&
_stCheques.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
RevokeStopMultipleChequesScreen(
selectedAccount: _selectedAccount!,
date: _stCheques.first.Date!,
instrType: _stCheques.first.InstrType!,
fromCheque: _ciFromCheque ?? _stCheques.first.fromCheque!,
toCheque: _ciToCheque ?? _stCheques.first.toCheque!,
),
),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context)
.pleaseSelectAccountFirst),
),
);
}
},
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Center(
child: Text(
AppLocalizations.of(context).revokeMultipleStops,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.colorScheme
.onSecondaryContainer,
),
),
),
),
),
),
),
],
),
const SizedBox(height: 20),
Expanded(
child: _isLoading
? const Center(child: CircularProgressIndicator())
: _stCheques.isEmpty
? Center(
child: Text(AppLocalizations.of(context)
.noChequeIssuedStatus))
: ListView.builder(
itemCount: _stCheques.length,
itemBuilder: (context, index) {
return _buildSTTile(context, _stCheques[index]);
},
),
),
]),
),
IgnorePointer(
child: Center(
child: Opacity(
opacity: 0.07, // Reduced opacity
child: ClipOval(
child: Image.asset(
'assets/images/logo.png',
width: 200, // Adjust size as needed
height: 200, // Adjust size as needed
),
),
),
),
),
],
),
);
}
// Widget _buildSTTile(BuildContext context, Cheque cheque) {
// return Card(
// margin: const EdgeInsets.symmetric(
// vertical: 8.0,
// ),
// child: Padding(
// padding: const EdgeInsets.all(16.0),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(AppLocalizations.of(context).stopChequeLabel,
// style: Theme.of(context).textTheme.titleLarge),
// const SizedBox(height: 8),
// _buildInfoRow('From Cheque:', cheque.fromCheque),
// _buildInfoRow('To Cheque:', cheque.toCheque),
// _buildInfoRow('Account Type:',
// _getAccountTypeDisplayName(_selectedAccount!.accountType!)),
// _buildInfoRow('Branch Code:', cheque.branchCode),
// _buildInfoRow('Stop Issue Date:', cheque.stopIssueDate),
// _buildInfoRow('Stop Expiry Date:', cheque.StopExpiryDate),
// _buildInfoRow('Cheques Count:', cheque.Chequescount),
// ],
// ),
// ),
// );
// }
Widget _buildSTTile(BuildContext context, Cheque cheque) {
return Card(
margin: const EdgeInsets.symmetric(
vertical: 8.0,
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppLocalizations.of(context).stopChequeLabel,
style: Theme.of(context).textTheme.titleLarge),
const SizedBox(height: 8),
_buildInfoRow('From Cheque:', cheque.fromCheque),
_buildInfoRow('To Cheque:', cheque.toCheque),
_buildInfoRow('Account Type:',
_getAccountTypeDisplayName(_selectedAccount!.accountType!)),
_buildInfoRow('Branch Code:', cheque.branchCode),
_buildInfoRow('Stop Issue Date:', cheque.stopIssueDate),
_buildInfoRow('Stop Expiry Date:', cheque.StopExpiryDate),
_buildInfoRow('Cheques Count:', cheque.Chequescount),
],
),
),
);
}
// Widget _buildInfoRow(String label, String? value) {
// return Padding(
// padding: const EdgeInsets.symmetric(vertical: 4.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(label, style: const TextStyle(fontWeight: FontWeight.bold)),
// Text(value ?? ''),
// ],
// ),
// );
// }
// }
Widget _buildInfoRow(String label, String? value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(label, style: const TextStyle(fontWeight: FontWeight.bold)),
Text(value ?? ''),
],
),
);
}
}

View File

@@ -0,0 +1,304 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:kmobile/data/models/user.dart';
import 'package:kmobile/di/injection.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart';
class RevokeStopSingleChequeScreen extends StatefulWidget {
final User selectedAccount;
final String date;
final String instrType;
final String fromCheque;
final String toCheque;
const RevokeStopSingleChequeScreen(
{super.key,
required this.selectedAccount,
required this.date,
required this.instrType,
required this.fromCheque,
required this.toCheque});
@override
State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState();
}
class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> {
final _formKey = GlobalKey<FormState>();
final _stopFromChequeNoController = TextEditingController();
final _stopIssueDateController = TextEditingController();
final _stopExpiryDateController = TextEditingController();
final _stopAmountController = TextEditingController();
final _chequeService = getIt<ChequeService>();
String? _selectedComment;
final _otherCommentController = TextEditingController();
bool _showOtherCommentField = false;
final List<String> _commentOptions = [
'Cheque Found',
'Cheque Fixed',
'Other'
];
Future<void> _selectDate(TextEditingController controller) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2101),
);
if (picked != null) {
setState(() {
controller.text =
'${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}';
});
}
}
Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(message),
],
),
),
actions: <Widget>[
TextButton(
child: Text(AppLocalizations.of(context).closeButton),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).revokeSingleStopTitle)),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: ListView(
children: [
Card(
elevation: 0,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: ListTile(
leading: Image.asset(
'assets/images/logo.png',
width: 40,
height: 40,
),
title: Text(widget.selectedAccount.accountNo!),
subtitle:
Text(AppLocalizations.of(context).accountNumberLabel),
),
),
const SizedBox(height: 24),
TextFormField(
controller: _stopFromChequeNoController,
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)
.pleaseEnterChequeNumberError;
}
final chequeNumber = int.tryParse(value);
final fromCheque = int.tryParse(widget.fromCheque);
final toCheque = int.tryParse(widget.toCheque);
if (chequeNumber == null ||
fromCheque == null ||
toCheque == null) {
return AppLocalizations.of(context)
.invalidChequeNumberFormatError;
}
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
return AppLocalizations.of(context).chequeNumberRangeError(
widget.fromCheque, widget.toCheque);
}
return null;
},
),
const SizedBox(height: 16),
TextFormField(
initialValue: widget.instrType,
readOnly: true,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).instrumentTypeLabel,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 16),
TextFormField(
controller: _stopIssueDateController,
readOnly: true,
onTap: () => _selectDate(_stopIssueDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeIssueDate,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopIssueDateController),
),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopExpiryDateController,
readOnly: true,
onTap: () => _selectDate(_stopExpiryDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeExpiryDate,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopExpiryDateController),
),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopAmountController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeAmount,
border: const OutlineInputBorder(),
),
keyboardType: TextInputType.number,
),
const SizedBox(height: 16),
DropdownButtonFormField<String>(
value: _selectedComment,
items: _commentOptions.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (newValue) {
setState(() {
_selectedComment = newValue;
_showOtherCommentField = newValue == 'Other';
});
},
decoration: InputDecoration(
labelText: AppLocalizations.of(context).revokeComment,
border: const OutlineInputBorder(),
),
),
if (_showOtherCommentField)
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: TextFormField(
controller: _otherCommentController,
decoration: const InputDecoration(
labelText: "Other Reasons :",
border: OutlineInputBorder(),
),
validator: (value) {
return null;
},
),
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try {
final response = await _chequeService.revokeStop(
accountno: widget.selectedAccount.accountNo!,
removeFromChequeNo:
_stopFromChequeNoController.text,
instrType: widget.instrType,
removeToChequeNo:
_stopFromChequeNoController.text,
removeIssueDate: _stopIssueDateController.text,
removeExpiryDate: _stopExpiryDateController.text,
removeAmount: _stopAmountController.text,
removeComment: _selectedComment == 'Other'
? _otherCommentController.text
: _selectedComment ?? '',
tpin: pin,
);
if (!mounted) return;
final decodedResponse = jsonDecode(response);
String responseString = response.toString(); // used as the case only for incorrect TPIN
final status = decodedResponse['status'];
final message = decodedResponse['message'];
final code = decodedResponse['code'];
if (status == 'SUCCESS') {
_showResponseDialog('Success', message);
} if (status == 'ERROR') {
String errMessage = "error";
if(code == '0172') {
errMessage = 'The selected Cheque is not stopped';
} else if(code == '0748') {
errMessage = 'The selected Cheque is already presented';
}
_showResponseDialog('Error', errMessage);
}
if(responseString.contains('INCORRECT_TPIN')){
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
}
} on DioException catch (e) {
try {
final errorBodyString =
e.toString().split('Exception: ')[1];
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
errorBody['error'] == 'INCORRECT_TPIN') {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
} else {
_showResponseDialog(
'Error', 'Internal Server Error');
}
} catch (_) {
_showResponseDialog(
'Error', 'Internal Server Error');
}
}
},
),
),
);
}
},
child: Text(AppLocalizations.of(context).revokeStopButton),
),
],
),
),
),
);
}
}

View File

@@ -309,6 +309,7 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
);
if (!mounted) return;
final decodedResponse = jsonDecode(response);
String responseString = response.toString(); // used as the case only for incorrect TPIN
final status = decodedResponse['status'];
final message = decodedResponse['message'];
final code = decodedResponse['code'];
@@ -323,6 +324,10 @@ class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
}
_showResponseDialog('Error', errMessage);
}
if(responseString.contains('INCORRECT_TPIN')){
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
}
} on Exception catch (e) {
try {
final errorBodyString =

View File

@@ -278,7 +278,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
);
if (!mounted) return;
final decodedResponse = jsonDecode(response);
String responseString = response.toString(); // used as the case only for incorrect TPIN
final status = decodedResponse['status'];
final message = decodedResponse['message'];
final code = decodedResponse['code'];
@@ -293,12 +293,16 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
}
_showResponseDialog('Error', errMessage);
}
if(responseString.contains('INCORRECT_TPIN')){
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
}
} on DioException catch (e) {
try {
final errorBodyString =
e.toString().split('Exception: ')[1];
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
errorBody['error'] == 'INCORRECT_TPIN') {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');