Revoke Stop base made

This commit is contained in:
2026-01-22 16:57:36 +05:30
parent 76acc2e330
commit 5f8c88342e
5 changed files with 723 additions and 341 deletions

View File

@@ -130,4 +130,36 @@ class ChequeService {
); );
return response.toString(); return response.toString();
} }
Future revokeStop({
required String accountno,
required String removeFromChequeNo,
required String instrType,
String? removeToChequeNo,
String? removeIssueDate,
String? removeExpiryDate,
String? removeAmount,
String? removeComment,
required String tpin,
}) async {
final response = await _dio.post(
'/api/cheque/revoke_stop',
options: Options(
validateStatus: (int? status) => true,
receiveDataWhenStatusError: true,
),
data: {
'accountNumber': accountno,
'removeFromChequeNo': removeFromChequeNo,
'instrumentType': instrType,
'removeToChequeNo': removeToChequeNo,
'removeIssueDate': removeIssueDate,
'removeExpiryDate': removeExpiryDate,
'removeAmount': removeAmount,
'removeComment': removeComment,
'tpin': tpin,
},
);
return response.toString();
}
} }

View File

@@ -76,24 +76,24 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
}, },
), ),
), ),
// Expanded( Expanded(
// child: ChequeManagementCardTile( child: ChequeManagementCardTile(
// icon: Symbols.block_sharp, icon: Symbols.block_sharp,
// label: "Revoke Stop", label: "Revoke Stop",
// subtitle: "Revoke your stopped cheques so as to reuse it", subtitle: "Revoke your stopped cheques so as to reuse it",
// onTap: () { onTap: () {
// Navigator.push( Navigator.push(
// context, context,
// MaterialPageRoute( MaterialPageRoute(
// builder: (context) => RevokeStopSingleChequeScreen( builder: (context) => RevokeStopSingleChequeScreen(
// users: users, users: users,
// selectedIndex: selectedAccountIndex, selectedIndex: selectedAccountIndex,
// ), ),
// ), ),
// ); );
// }, },
// ), ),
// ), ),
], ],
), ),
), ),

View File

@@ -1,332 +1,351 @@
// import 'dart:convert'; import 'package:kmobile/data/models/user.dart';
// import 'package:dio/dio.dart'; import 'package:kmobile/di/injection.dart';
// import 'package:kmobile/data/models/user.dart'; import 'package:flutter/material.dart';
// import 'package:kmobile/di/injection.dart'; import 'package:kmobile/api/services/cheque_service.dart';
// import 'package:flutter/material.dart'; import 'package:kmobile/features/cheque/screens/stop_multiple_cheques_screen.dart';
// import 'package:kmobile/api/services/cheque_service.dart'; import 'package:kmobile/features/cheque/screens/stop_single_cheque_screen.dart';
// import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart'; import 'package:kmobile/l10n/app_localizations.dart';
// import 'package:kmobile/l10n/app_localizations.dart';
// class RevokeStopSingleChequeScreen extends StatefulWidget { class RevokeStopSingleChequeScreen extends StatefulWidget {
// final User selectedAccount; final List<User> users;
// final String date; final int selectedIndex;
// final String instrType;
// final String fromCheque;
// final String toCheque;
// const RevokeStopSingleChequeScreen( const RevokeStopSingleChequeScreen(
// {super.key, {
// required this.selectedAccount, super.key,
// required this.date, required this.users,
// required this.instrType, required this.selectedIndex,
// required this.fromCheque, });
// required this.toCheque});
// @override @override
// State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState(); State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState();
// } }
// class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> { class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> {
// final _formKey = GlobalKey<FormState>(); User? _selectedAccount;
// final _stopFromChequeNoController = TextEditingController(); var service = getIt<ChequeService>();
// final _stopIssueDateController = TextEditingController(); bool _isLoading = true;
// final _stopExpiryDateController = TextEditingController(); Cheque? _stCheque;
// final _stopAmountController = TextEditingController(); List<User> _filteredUsers = [];
// final _chequeService = getIt<ChequeService>();
// String? _selectedComment; @override
// final _otherCommentController = TextEditingController(); void initState() {
// bool _showOtherCommentField = false; super.initState();
// final List<String> _commentOptions = [ _filteredUsers = widget.users
// 'Cheque Lost', .where((user) => ['SA', 'SB', 'CA', 'CC'].contains(user.accountType))
// 'Cheque Stolen', .toList();
// 'Cheque Missing',
// 'Cheque Damaged',
// 'Other'
// ];
// String _formatDate(String dateString) { if (widget.users.isNotEmpty && widget.selectedIndex < widget.users.length) {
// if (dateString.length != 8) { if (_filteredUsers.isNotEmpty) {
// return dateString; // Return as is if not in expected ddmmyyyy format if (_filteredUsers.contains(widget.users[widget.selectedIndex])) {
// } _selectedAccount = widget.users[widget.selectedIndex];
// try { } else {
// final day = dateString.substring(0, 2); _selectedAccount = _filteredUsers.first;
// final month = dateString.substring(2, 4); }
// final year = dateString.substring(4, 8); } else {
// return '$day/$month/$year'; _selectedAccount = widget.users[widget.selectedIndex];
// } catch (e) { }
// return dateString; // Return original string on error } else {
// } if (_filteredUsers.isNotEmpty) {
// } _selectedAccount = _filteredUsers.first;
}
}
// Future<void> _selectDate(TextEditingController controller) async { _loadCheques();
// 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 { Future<void> _loadCheques() async {
// return showDialog<void>( if (_selectedAccount == null) {
// context: context, setState(() {
// barrierDismissible: false, // user must tap button! _isLoading = false;
// builder: (BuildContext context) { _stCheque = null;
// return AlertDialog( });
// title: Text(title), return;
// content: SingleChildScrollView( }
// child: ListBody( setState(() {
// children: <Widget>[ _isLoading = true;
// Text(message), });
// ],
// ),
// ),
// actions: <Widget>[
// TextButton(
// child: Text(AppLocalizations.of(context).closeButton),
// onPressed: () {
// Navigator.of(context).pop();
// },
// ),
// ],
// );
// },
// );
// }
// @override String instrType;
// Widget build(BuildContext context) { switch (_selectedAccount!.accountType) {
// return Scaffold( case 'SA':
// appBar: AppBar( case 'SB':
// title: const Text("Revoke Stop")), instrType = '10';
// ); break;
// body: Padding( case 'CA':
// padding: const EdgeInsets.all(16.0), instrType = '11';
// child: Form( break;
// key: _formKey, case 'CC':
// child: ListView( instrType = '13';
// children: [ break;
// Card( default:
// elevation: 0, instrType = '10';
// margin: const EdgeInsets.symmetric(vertical: 8.0), }
// child: ListTile(
// leading: Image.asset( try {
// 'assets/images/logo.png', final data = await service.ChequeEnquiry(
// width: 40, accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
// height: 40, final stCheques = data.where((cheque) => cheque.type == 'ST').toList();
// ), setState(() {
// title: Text(widget.selectedAccount.accountNo!), _stCheque = stCheques.isNotEmpty ? stCheques.first : null;
// subtitle: _isLoading = false;
// Text(AppLocalizations.of(context).accountNumberLabel), });
// ), } catch (e) {
// ), setState(() {
// const SizedBox(height: 24), _isLoading = false;
// TextFormField( _stCheque = null;
// controller: _stopFromChequeNoController, });
// decoration: InputDecoration( ScaffoldMessenger.of(context).showSnackBar(
// labelText: AppLocalizations.of(context).chequeNumberLabel, SnackBar(
// border: OutlineInputBorder(), content: Text('Failed to fetch cheque status: ${e.toString()}'),
// errorMaxLines: 2, ),
// ), );
// keyboardType: TextInputType.number, }
// validator: (value) { }
// if (value == null || value.isEmpty) {
// return AppLocalizations.of(context) String _getAccountTypeDisplayName(String accountType) {
// .pleaseEnterChequeNumberError; switch (accountType.toLowerCase()) {
// } case 'sa':
// final chequeNumber = int.tryParse(value); return AppLocalizations.of(context).savingsAccount;
// final fromCheque = int.tryParse(widget.fromCheque); case 'sb':
// final toCheque = int.tryParse(widget.toCheque); return AppLocalizations.of(context).savingsAccount;
// if (chequeNumber == null || case 'ca':
// fromCheque == null || return "Current Account";
// toCheque == null) { case 'cc':
// return AppLocalizations.of(context) return "Cash Credit Account";
// .invalidChequeNumberFormatError; default:
// } return accountType;
// if (chequeNumber < fromCheque || chequeNumber > toCheque) { }
// return AppLocalizations.of(context).chequeNumberRangeError( }
// widget.fromCheque, widget.toCheque);
// } @override
// return null; Widget build(BuildContext context) {
// }, return Scaffold(
// ), appBar: AppBar(
// const SizedBox(height: 16), title: Text(AppLocalizations.of(context).stopChequeTitle),
// TextFormField( centerTitle: false,
// initialValue: widget.instrType, ),
// readOnly: true, body: Stack(
// decoration: InputDecoration( children: [
// labelText: AppLocalizations.of(context).instrumentTypeLabel, Padding(
// border: const OutlineInputBorder(), padding: const EdgeInsets.all(16.0),
// ), child: Column(
// ), children: [
// const SizedBox(height: 16), Card(
// TextFormField( elevation: 4,
// controller: _stopIssueDateController, margin: const EdgeInsets.symmetric(vertical: 8.0),
// readOnly: true, child: Padding(
// onTap: () => _selectDate(_stopIssueDateController), padding: const EdgeInsets.all(16.0),
// decoration: InputDecoration( child: Row(
// labelText: AppLocalizations.of(context).stopIssueDateLabel, mainAxisAlignment: MainAxisAlignment.spaceBetween,
// border: const OutlineInputBorder(), children: [
// suffixIcon: IconButton( Text(
// icon: const Icon(Icons.calendar_today), AppLocalizations.of(context).accountNumber,
// onPressed: () => _selectDate(_stopIssueDateController), style: const TextStyle(
// ), fontWeight: FontWeight.bold, fontSize: 18),
// ), ),
// keyboardType: TextInputType.datetime, const SizedBox(width: 16),
// ), if (_selectedAccount != null)
// const SizedBox(height: 16), Expanded(
// TextFormField( child: DropdownButton<User>(
// controller: _stopExpiryDateController, value: _selectedAccount,
// readOnly: true, onChanged: (User? newUser) {
// onTap: () => _selectDate(_stopExpiryDateController), if (newUser != null) {
// decoration: InputDecoration( setState(() {
// labelText: AppLocalizations.of(context).stopExpiryDateLabel, _selectedAccount = newUser;
// border: const OutlineInputBorder(), _loadCheques();
// suffixIcon: IconButton( });
// icon: const Icon(Icons.calendar_today), }
// onPressed: () => _selectDate(_stopExpiryDateController), },
// ), items: _filteredUsers.map((user) {
// ), return DropdownMenuItem<User>(
// keyboardType: TextInputType.datetime, value: user,
// ), child: Text(user.accountNo.toString()),
// const SizedBox(height: 16), );
// TextFormField( }).toList(),
// controller: _stopAmountController, ),
// decoration: InputDecoration( )
// labelText: AppLocalizations.of(context).stopAmountHint, else
// border: const OutlineInputBorder(), Text(AppLocalizations.of(context).noAccountsFound),
// ), ],
// keyboardType: TextInputType.number, ),
// ), ),
// const SizedBox(height: 16), ),
// DropdownButtonFormField<String>( const SizedBox(height: 20),
// value: _selectedComment, Row(
// items: _commentOptions.map((String value) { children: [
// return DropdownMenuItem<String>( Expanded(
// value: value, child: Card(
// child: Text(value), color: Theme.of(context).colorScheme.primaryContainer,
// ); elevation: 4,
// }).toList(), child: InkWell(
// onChanged: (newValue) { onTap: () {
// setState(() { if (_selectedAccount != null && _stCheque != null) {
// _selectedComment = newValue; Navigator.push(
// _showOtherCommentField = newValue == 'Other'; context,
// }); MaterialPageRoute(
// }, builder: (context) => StopSingleChequeScreen(
// decoration: InputDecoration( selectedAccount: _selectedAccount!,
// labelText: AppLocalizations.of(context).stopCommentHint, date: _stCheque!.Date!,
// border: const OutlineInputBorder(), instrType: _stCheque!.InstrType!,
// ), fromCheque: _stCheque!.fromCheque!,
// ), toCheque: _stCheque!.toCheque!,
// if (_showOtherCommentField) ),
// Padding( ),
// padding: const EdgeInsets.only(top: 16.0), );
// child: TextFormField( } else {
// controller: _otherCommentController, ScaffoldMessenger.of(context).showSnackBar(
// decoration: const InputDecoration( SnackBar(
// labelText: "Other Reasons :", content: Text(AppLocalizations.of(context)
// border: OutlineInputBorder(), .noChequebookToStop),
// ), ),
// validator: (value) { );
// return null; }
// }, },
// ), child: Padding(
// ), padding: const EdgeInsets.all(16.0),
// const SizedBox(height: 16), child: Center(
// TextFormField( child: Text(
// initialValue: _formatDate(widget.date), AppLocalizations.of(context)
// readOnly: true, .stopSingleChequeTitle,
// decoration: InputDecoration( textAlign: TextAlign.center,
// labelText: style: TextStyle(
// AppLocalizations.of(context).chequebookIssueDateHint, fontSize: 16,
// border: const OutlineInputBorder(), fontWeight: FontWeight.bold,
// ), color: Theme.of(context)
// ), .colorScheme
// const SizedBox(height: 32), .onPrimaryContainer,
// ElevatedButton( ),
// onPressed: () { ),
// if (_formKey.currentState!.validate()) { ),
// Navigator.push( ),
// context, ),
// MaterialPageRoute( ),
// builder: (context) => TransactionPinScreen( ),
// onPinCompleted: (ctx, pin) async { const SizedBox(width: 10),
// Navigator.pop(context); Expanded(
// try { child: Card(
// final response = await _chequeService.stopCheque( color: Theme.of(context).colorScheme.primaryContainer,
// accountno: widget.selectedAccount.accountNo!, elevation: 4,
// stopFromChequeNo: child: InkWell(
// _stopFromChequeNoController.text, onTap: () {
// instrType: widget.instrType, if (_selectedAccount != null) {
// stopToChequeNo: Navigator.push(
// _stopFromChequeNoController.text, context,
// stopIssueDate: _stopIssueDateController.text, MaterialPageRoute(
// stopExpiryDate: _stopExpiryDateController.text, builder: (context) =>
// stopAmount: _stopAmountController.text, StopMultipleChequesScreen(
// stopComment: _selectedComment == 'Other' selectedAccount: _selectedAccount!,
// ? _otherCommentController.text date: _stCheque!.Date!,
// : _selectedComment ?? '', instrType: _stCheque!.InstrType!,
// chequeIssueDate: widget.date, fromCheque: _stCheque!.fromCheque!,
// tpin: pin, toCheque: _stCheque!.toCheque!,
// ); ),
// if (!mounted) return; ),
// final decodedResponse = jsonDecode(response); );
// String responseString = response.toString(); // used as the case only for incorrect TPIN } else {
// final status = decodedResponse['status']; ScaffoldMessenger.of(context).showSnackBar(
// final message = decodedResponse['message']; SnackBar(
// final code = decodedResponse['code']; content: Text(AppLocalizations.of(context)
// if (status == 'SUCCESS') { .pleaseSelectAccountFirst),
// _showResponseDialog('Success', message); ),
// } if (status == 'ERROR') { );
// String errMessage = "error"; }
// if(code == '0429') { },
// errMessage = 'The selected Cheque is already stopped'; child: Padding(
// } else if(code == '0748') { padding: const EdgeInsets.all(16.0),
// errMessage = 'The selected Cheque is already presented'; child: Center(
// } child: Text(
// _showResponseDialog('Error', errMessage); AppLocalizations.of(context)
// } .stopMultipleChequesButton,
// if(responseString.contains('INCORRECT_TPIN')){ textAlign: TextAlign.center,
// _showResponseDialog('Invalid TPIN', style: TextStyle(
// 'The TPIN you entered is incorrect. Please try again.'); fontSize: 16,
// } fontWeight: FontWeight.bold,
// } on DioException catch (e) { color: Theme.of(context)
// try { .colorScheme
// final errorBodyString = .onSecondaryContainer,
// 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'); ),
// } const SizedBox(height: 20),
// } catch (_) { Expanded(
// _showResponseDialog( child: _isLoading
// 'Error', 'Internal Server Error'); ? const Center(child: CircularProgressIndicator())
// } : _stCheque == null
// } ? Center(
// }, child: Text(AppLocalizations.of(context)
// ), .noChequeIssuedStatus))
// ), : _buildCiTile(context, _stCheque!),
// ); ),
// } ],
// }, ),
// child: Text("Revoke Stop"), ),
// ), 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 _buildCiTile(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).chequebookDetailsTitle,
style: Theme.of(context).textTheme.titleLarge),
const SizedBox(height: 8),
_buildInfoRow('Account Number:', _selectedAccount!.accountNo!),
_buildInfoRow('Customer Name:', _selectedAccount!.name!),
_buildInfoRow('CIF Number:', _selectedAccount!.cifNumber!),
_buildInfoRow('Account Type:',
_getAccountTypeDisplayName(_selectedAccount!.accountType!)),
_buildInfoRow('Branch Code:', cheque.branchCode),
_buildInfoRow('Starting Cheque Number:', cheque.fromCheque),
_buildInfoRow('Ending Cheque Number:', cheque.toCheque),
_buildInfoRow('Issue Date:', cheque.Date),
_buildInfoRow('Number of Cheques:', cheque.Chequescount),
_buildInfoRow('Instrument Type:', cheque.InstrType),
],
),
),
);
}
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,331 @@
// 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 Lost',
// 'Cheque Stolen',
// 'Cheque Missing',
// 'Cheque Damaged',
// 'Other'
// ];
// String _formatDate(String dateString) {
// if (dateString.length != 8) {
// return dateString; // Return as is if not in expected ddmmyyyy format
// }
// try {
// final day = dateString.substring(0, 2);
// final month = dateString.substring(2, 4);
// final year = dateString.substring(4, 8);
// return '$day/$month/$year';
// } catch (e) {
// return dateString; // Return original string on error
// }
// }
// 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: const Text("Revoke Stop")),
// );
// 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: 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).stopIssueDateLabel,
// 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).stopExpiryDateLabel,
// 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).stopAmountHint,
// 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).stopCommentHint,
// 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: 16),
// TextFormField(
// initialValue: _formatDate(widget.date),
// readOnly: true,
// decoration: InputDecoration(
// labelText:
// AppLocalizations.of(context).chequebookIssueDateHint,
// border: const OutlineInputBorder(),
// ),
// ),
// 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!,
// stopFromChequeNo:
// _stopFromChequeNoController.text,
// instrType: widget.instrType,
// stopToChequeNo:
// _stopFromChequeNoController.text,
// stopIssueDate: _stopIssueDateController.text,
// stopExpiryDate: _stopExpiryDateController.text,
// stopAmount: _stopAmountController.text,
// stopComment: _selectedComment == 'Other'
// ? _otherCommentController.text
// : _selectedComment ?? '',
// chequeIssueDate: widget.date,
// 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 == '0429') {
// errMessage = 'The selected Cheque is already 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("Revoke Stop"),
// ),
// ],
// ),
// ),
// );
// }
// }