feat : In home page "get statement" worked.
feat : After 5 minutes session timeout automatically. feat: realtime otp feature up
This commit is contained in:
60
src/app/_util/otp.ts
Normal file
60
src/app/_util/otp.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import axios from 'axios';
|
||||
|
||||
interface SendOtpPayload {
|
||||
mobileNumber?: string;
|
||||
type: string;
|
||||
amount?: number;
|
||||
beneficiary?: string;
|
||||
ifsc?: string;
|
||||
acctFrom?: string;
|
||||
acctTo?: string;
|
||||
ref?: string;
|
||||
date?: string;
|
||||
userOtp?: string;
|
||||
}
|
||||
|
||||
function getStoredMobileNumber(): string | null {
|
||||
// const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
||||
const mobileNumber= "7890544527";
|
||||
if (!mobileNumber) {
|
||||
notifications.show({
|
||||
title: 'Missing Mobile Number',
|
||||
message: 'Mobile number not found. Please re-login or update your profile.',
|
||||
color: 'red',
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return mobileNumber;
|
||||
}
|
||||
|
||||
export async function sendOtp(payload: SendOtpPayload) {
|
||||
try {
|
||||
const mobileNumber = payload.mobileNumber || getStoredMobileNumber();
|
||||
const response = await axios.post(
|
||||
'http://localhost:8080/api/otp/send',
|
||||
{ ...payload, mobileNumber },
|
||||
{ headers: { 'Content-Type': 'application/json' } }
|
||||
);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error('Error sending OTP:', error.response?.data || error.message);
|
||||
throw error.response?.data || error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function verifyOtp(otp: string) {
|
||||
try {
|
||||
const mobileNumber = getStoredMobileNumber();
|
||||
const response = await axios.post(
|
||||
`http://localhost:8080/api/otp/verify?mobileNumber=${mobileNumber}`,
|
||||
{ otp },
|
||||
{ headers: { 'Content-Type': 'application/json' } }
|
||||
);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error('Error verifying OTP:', error.response?.data || error.message);
|
||||
throw error.response?.data || error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user