Mobile Number Implemented in OTP
This commit is contained in:
@@ -5,7 +5,8 @@ import 'package:kmobile/api/services/change_password_service.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
|
||||
class TpinOtpScreen extends StatefulWidget {
|
||||
const TpinOtpScreen({super.key});
|
||||
final String mobileNumber;
|
||||
const TpinOtpScreen({super.key, required this.mobileNumber});
|
||||
|
||||
@override
|
||||
State<TpinOtpScreen> createState() => _TpinOtpScreenState();
|
||||
@@ -49,10 +50,9 @@ void _verifyOtp() async {
|
||||
});
|
||||
|
||||
try {
|
||||
// IMPORTANT: You may need to pass the mobile number here as well
|
||||
await _changePasswordService.validateOtp(
|
||||
otp: _enteredOtp,
|
||||
mobileNumber: '8981274001', // Replace with actual mobile number
|
||||
mobileNumber: widget.mobileNumber,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
@@ -151,7 +151,6 @@ void _verifyOtp() async {
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton.icon(
|
||||
// Update icon to show a loading indicator
|
||||
icon: _isLoading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
|
||||
import 'package:kmobile/features/auth/controllers/auth_state.dart';
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_otp_screen.dart';
|
||||
@@ -12,7 +16,7 @@ class TpinSetupPromptScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TpinSetupPromptScreenState extends State<TpinSetupPromptScreen> {
|
||||
// 3. Add state variables
|
||||
int selectedAccountIndex = 0;
|
||||
bool _isLoading = false;
|
||||
final ChangePasswordService _changePasswordService = getIt<ChangePasswordService>();
|
||||
Future<void> _getOtp() async {
|
||||
@@ -21,11 +25,18 @@ class TpinSetupPromptScreen extends StatefulWidget {
|
||||
});
|
||||
|
||||
try {
|
||||
await _changePasswordService.getOtp(mobileNumber: '8981274001');
|
||||
final authState = context.read<AuthCubit>().state;
|
||||
String mobileNumberToPass = '';
|
||||
if (authState is Authenticated) {
|
||||
if (selectedAccountIndex >= 0 && selectedAccountIndex < authState.users.length) {
|
||||
mobileNumberToPass = authState.users[selectedAccountIndex].mobileNo ?? '';
|
||||
}
|
||||
}
|
||||
await _changePasswordService.getOtp(mobileNumber: mobileNumberToPass);
|
||||
if (mounted) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const TpinOtpScreen()),
|
||||
MaterialPageRoute(builder: (_) => TpinOtpScreen(mobileNumber: mobileNumberToPass,)),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user