feat : In home page "get statement" worked.
feat : After 5 minutes session timeout automatically. feat: realtime otp feature up
This commit is contained in:
15
TODO.md
15
TODO.md
@@ -6,23 +6,28 @@
|
|||||||
- >Taking Url and try to login -Logout
|
- >Taking Url and try to login -Logout
|
||||||
|
|
||||||
### Feature
|
### Feature
|
||||||
- Password Expiry Logic
|
- >Password Expiry Logic
|
||||||
- login -> check password Expiry -> Change password -> login screen
|
- >login -> check password Expiry -> Change password -> login screen
|
||||||
- >Logout popup :
|
- >Logout popup :
|
||||||
- >Are you sure want to logout?
|
- >Are you sure want to logout?
|
||||||
- >Home page password Expiry message
|
- >Home page password Expiry message
|
||||||
- Set userId and login with userID
|
- Set userId and login with userID
|
||||||
- Limit of transaction daily
|
- Limit of transaction daily --Asif
|
||||||
- >Statement Download
|
- >Statement Download
|
||||||
- >In Every OTP page "Resend button" & 3 min timing of expiry.
|
- >In Every OTP page "Resend button" & 3 min timing of expiry.
|
||||||
- OTP binding with actual mobile number.
|
- OTP binding with actual mobile number.
|
||||||
|
- Beneficiary delete feature
|
||||||
- IN settings page NOTE position Fixing.
|
- IN settings page NOTE position Fixing.
|
||||||
- >Admin page
|
- >Admin page
|
||||||
- >give rights
|
- >give rights
|
||||||
- >view rights
|
- >view rights
|
||||||
- Forget Password
|
- Forget Password
|
||||||
- >For Migration if user not have password
|
<!-- - >For Migration if user not have password -->
|
||||||
- E-mandate
|
- E-mandate
|
||||||
- Make every page responsive
|
<!-- - Make every page responsive (need to check settings and payment tab) -->
|
||||||
|
- Locked (3 times wrong password in time of login)
|
||||||
|
- >session timeout
|
||||||
|
- login time otp
|
||||||
|
<!-- - narration (in statement) Last 10 transaction the remarks not comes from subham sites-->
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export default function AccountStatementPage() {
|
|||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
const last5 = data.slice(0, 5);
|
const last5 = data.slice(0, 10);
|
||||||
setTransactions(last5);
|
setTransactions(last5);
|
||||||
// Reuse balance logic
|
// Reuse balance logic
|
||||||
const saved = sessionStorage.getItem("accountData");
|
const saved = sessionStorage.getItem("accountData");
|
||||||
@@ -247,7 +247,7 @@ export default function AccountStatementPage() {
|
|||||||
|
|
||||||
{(!startDate && !endDate && transactions.length > 0) && (
|
{(!startDate && !endDate && transactions.length > 0) && (
|
||||||
<Text fs="italic" c="#228be6" ta="center">
|
<Text fs="italic" c="#228be6" ta="center">
|
||||||
Last 5 Transactions
|
Last 10 Transactions
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<ScrollArea style={{ flex: 1 }}>
|
<ScrollArea style={{ flex: 1 }}>
|
||||||
@@ -290,12 +290,12 @@ export default function AccountStatementPage() {
|
|||||||
// ✅ Desktop View – Table Layout
|
// ✅ Desktop View – Table Layout
|
||||||
<Table style={{ borderCollapse: "collapse", width: "100%" }}>
|
<Table style={{ borderCollapse: "collapse", width: "100%" }}>
|
||||||
<thead style={{ backgroundColor: "#3385ff" }}>
|
<thead style={{ backgroundColor: "#3385ff" }}>
|
||||||
<tr>
|
{/* <tr>
|
||||||
<th style={{ ...cellStyle, textAlign: "left", color: "white" }}>Name</th>
|
<th style={{ ...cellStyle, textAlign: "left", color: "white" }}>Narration</th>
|
||||||
<th style={{ ...cellStyle, textAlign: "left", color: "white" }}>Date</th>
|
<th style={{ ...cellStyle, textAlign: "left", color: "white" }}>Date</th>
|
||||||
<th style={{ ...cellStyle, textAlign: "right", color: "white" }}>Amount (₹)</th>
|
<th style={{ ...cellStyle, textAlign: "right", color: "white" }}>Amount (₹)</th>
|
||||||
<th style={{ ...cellStyle, textAlign: "right", color: "white" }}>Balance (₹)</th>
|
<th style={{ ...cellStyle, textAlign: "right", color: "white" }}>Balance (₹)</th>
|
||||||
</tr>
|
</tr> */}
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{transactions.map((txn, i) => (
|
{transactions.map((txn, i) => (
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default function AccountSummary() {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok && Array.isArray(data)) {
|
if (response.ok && Array.isArray(data)) {
|
||||||
setAccountData(data);
|
setAccountData(data);
|
||||||
sessionStorage.setItem("accountData", JSON.stringify(data));
|
// sessionStorage.setItem("accountData", JSON.stringify(data));
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ export default function QuickPay() {
|
|||||||
toAccount: beneficiaryAcc,
|
toAccount: beneficiaryAcc,
|
||||||
toAccountType: beneficiaryType,
|
toAccountType: beneficiaryType,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
narration: remarks,
|
remarks: remarks,
|
||||||
tpassword: txnPassword,
|
tpassword: txnPassword,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Button, Center, Group, Modal, Paper, Radio, ScrollArea, Select, Stack, Text, TextInput, Title, Box, PasswordInput } from "@mantine/core";
|
import { Button, Group, Modal, Paper, Radio, Select, Stack, Text, TextInput, Title, PasswordInput } from "@mantine/core";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { generateOTP } from '@/app/OTPGenerator';
|
|
||||||
import SendToBeneficiaryOthers from "./sendBeneficiaryOthers";
|
import SendToBeneficiaryOthers from "./sendBeneficiaryOthers";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import img from '@/app/image/logo1.jpg';
|
import img from '@/app/image/logo1.jpg';
|
||||||
import { IconRefresh } from "@tabler/icons-react";
|
import { IconRefresh } from "@tabler/icons-react";
|
||||||
|
import { sendOtp, verifyOtp } from '@/app/_util/otp';
|
||||||
|
|
||||||
|
|
||||||
interface accountData {
|
interface accountData {
|
||||||
stAccountNo: string;
|
stAccountNo: string;
|
||||||
@@ -36,25 +37,48 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const [showOtpField, setShowOtpField] = useState(false);
|
const [showOtpField, setShowOtpField] = useState(false);
|
||||||
const [otp, setOtp] = useState("");
|
const [otp, setOtp] = useState("");
|
||||||
const [generateOtp, setGenerateOtp] = useState("");
|
|
||||||
|
|
||||||
const [countdown, setCountdown] = useState(180);
|
const [countdown, setCountdown] = useState(180);
|
||||||
const [timerActive, setTimerActive] = useState(false);
|
const [timerActive, setTimerActive] = useState(false);
|
||||||
|
|
||||||
async function handleGenerateOtp() {
|
async function handleSendOtp() {
|
||||||
// const value = await generateOTP(6);
|
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
||||||
const value = "123456";
|
if (!mobileNumber) {
|
||||||
setGenerateOtp(value);
|
notifications.show({
|
||||||
setCountdown(180);
|
title: 'Error',
|
||||||
setTimerActive(true);
|
message: 'Mobile number not found.Contact to administrator',
|
||||||
return value;
|
color: 'red',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await sendOtp({ type: 'IMPS' });
|
||||||
|
setShowOtpField(true);
|
||||||
|
setCountdown(180);
|
||||||
|
setTimerActive(true);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Send OTP failed', err);
|
||||||
|
notifications.show({
|
||||||
|
title: 'Error',
|
||||||
|
message: err.message || 'Send OTP failed.Please try again later.',
|
||||||
|
color: 'red',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleVerifyOtp() {
|
||||||
|
try {
|
||||||
|
await verifyOtp(otp);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const selectedAccount = accountData.find((acc) => acc.stAccountNo === selectedAccNo);
|
const selectedAccount = accountData.find((acc) => acc.stAccountNo === selectedAccNo);
|
||||||
const accountOptions = accountData.map((acc) => ({
|
const accountOptions = accountData.map((acc) => ({
|
||||||
value: acc.stAccountNo,
|
value: acc.stAccountNo,
|
||||||
label: `${acc.stAccountNo} (${acc.stAccountType})`,
|
label: `${acc.stAccountNo} (${acc.stAccountType})`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const FetchBeneficiaryDetails = async () => {
|
const FetchBeneficiaryDetails = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem("access_token");
|
const token = localStorage.getItem("access_token");
|
||||||
@@ -66,7 +90,7 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
if (response.ok && Array.isArray(data)) {
|
if (response.ok && Array.isArray(data)) {
|
||||||
setBeneficiaryData(data);
|
setBeneficiaryData(data);
|
||||||
} else {
|
} else {
|
||||||
@@ -195,21 +219,27 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
setIsVisibilityLocked(true);
|
setIsVisibilityLocked(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (showOtpField && !showTxnPassword) {
|
||||||
|
if (!otp) {
|
||||||
|
notifications.show({
|
||||||
|
title: "Error",
|
||||||
|
message: "Please enter the OTP",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!otp) {
|
const verified = await handleVerifyOtp();
|
||||||
notifications.show({
|
if (!verified) {
|
||||||
title: "Enter OTP",
|
notifications.show({
|
||||||
message: "Please enter the OTP",
|
title: "Invalid OTP",
|
||||||
color: "red",
|
message: "The OTP entered does not match",
|
||||||
});
|
color: "red",
|
||||||
return;
|
});
|
||||||
}
|
return;
|
||||||
if (otp !== generateOtp) {
|
}
|
||||||
notifications.show({
|
// If OTP verified successfully → show transaction password field
|
||||||
title: "Invalid OTP",
|
setShowTxnPassword(true);
|
||||||
message: "The OTP entered does not match",
|
|
||||||
color: "red",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +271,7 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
toAccount: beneficiaryAcc,
|
toAccount: beneficiaryAcc,
|
||||||
toAccountType: beneficiaryType,
|
toAccountType: beneficiaryType,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
narration: remarks,
|
remarks: remarks,
|
||||||
tpassword: txnPassword,
|
tpassword: txnPassword,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@@ -325,7 +355,7 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
color="blue"
|
color="blue"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setConfirmModel(false);
|
setConfirmModel(false);
|
||||||
const otp = await handleGenerateOtp();
|
const otp = await handleSendOtp();
|
||||||
setShowOtpField(true);
|
setShowOtpField(true);
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "OTP Sent",
|
title: "OTP Sent",
|
||||||
@@ -459,7 +489,7 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
<IconRefresh
|
<IconRefresh
|
||||||
size={22}
|
size={22}
|
||||||
style={{ cursor: "pointer", color: "blue", marginBottom: "6px" }}
|
style={{ cursor: "pointer", color: "blue", marginBottom: "6px" }}
|
||||||
onClick={handleGenerateOtp}
|
onClick={handleSendOtp}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import React, { useEffect, useRef, useState } from "react";
|
|||||||
import { Button, Center, Divider, Group, List, Modal, Paper, PasswordInput, Radio, ScrollArea, Select, Stack, Text, TextInput, ThemeIcon, Title } from "@mantine/core";
|
import { Button, Center, Divider, Group, List, Modal, Paper, PasswordInput, Radio, ScrollArea, Select, Stack, Text, TextInput, ThemeIcon, Title } from "@mantine/core";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { generateOTP } from '@/app/OTPGenerator';
|
|
||||||
import { IconAlertTriangle, IconRefresh } from "@tabler/icons-react";
|
import { IconAlertTriangle, IconRefresh } from "@tabler/icons-react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import img from '@/app/image/logo1.jpg'
|
import img from '@/app/image/logo1.jpg'
|
||||||
|
import { sendOtp, verifyOtp } from "@/app/_util/otp";
|
||||||
|
|
||||||
|
|
||||||
interface accountData {
|
interface accountData {
|
||||||
@@ -38,16 +38,57 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
const [otp, setOtp] = useState("");
|
const [otp, setOtp] = useState("");
|
||||||
const [countdown, setCountdown] = useState(180);
|
const [countdown, setCountdown] = useState(180);
|
||||||
const [timerActive, setTimerActive] = useState(false);
|
const [timerActive, setTimerActive] = useState(false);
|
||||||
const [generateOtp, setGenerateOtp] = useState("");
|
|
||||||
|
|
||||||
async function handleGenerateOtp() {
|
async function handleSendOtp() {
|
||||||
// const value = await generateOTP(6);
|
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
||||||
const value = "123456";
|
if (!mobileNumber) {
|
||||||
setGenerateOtp(value);
|
notifications.show({
|
||||||
setCountdown(180);
|
title: 'Error',
|
||||||
setTimerActive(true);
|
message: 'Mobile number not found.Contact to administrator',
|
||||||
return value;
|
color: 'red',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (paymentMode === "IMPS") { await sendOtp({ type: 'IMPS' }); }
|
||||||
|
if (paymentMode === "RTGS") {
|
||||||
|
await sendOtp(
|
||||||
|
{
|
||||||
|
type: 'RTGS',
|
||||||
|
amount: amount ? Number(amount) : undefined,
|
||||||
|
beneficiary: beneficiaryName || undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (paymentMode === "NEFT") {
|
||||||
|
await sendOtp(
|
||||||
|
{
|
||||||
|
type: 'NEFT',
|
||||||
|
amount: amount ? Number(amount) : undefined,
|
||||||
|
beneficiary: beneficiaryName || undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setShowOtpField(true);
|
||||||
|
setCountdown(180);
|
||||||
|
setTimerActive(true);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Send OTP failed', err);
|
||||||
|
notifications.show({
|
||||||
|
title: 'Error',
|
||||||
|
message: err.message || 'Send OTP failed.Please try again later.',
|
||||||
|
color: 'red',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleVerifyOtp() {
|
||||||
|
try {
|
||||||
|
await verifyOtp(otp);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const getAmountError = () => {
|
const getAmountError = () => {
|
||||||
if (!amount || !selectedAccount) return null;
|
if (!amount || !selectedAccount) return null;
|
||||||
const amt = Number(amount);
|
const amt = Number(amount);
|
||||||
@@ -78,7 +119,7 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
if (response.ok && Array.isArray(data)) {
|
if (response.ok && Array.isArray(data)) {
|
||||||
setBeneficiaryData(data);
|
setBeneficiaryData(data);
|
||||||
} else {
|
} else {
|
||||||
@@ -216,20 +257,43 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!otp) {
|
// if (!otp) {
|
||||||
notifications.show({
|
// notifications.show({
|
||||||
title: "Enter OTP",
|
// title: "Enter OTP",
|
||||||
message: "Please enter the OTP",
|
// message: "Please enter the OTP",
|
||||||
color: "red",
|
// color: "red",
|
||||||
});
|
// });
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (otp !== generateOtp) {
|
// if (otp !== generateOtp) {
|
||||||
notifications.show({
|
// notifications.show({
|
||||||
title: "Invalid OTP",
|
// title: "Invalid OTP",
|
||||||
message: "The OTP entered does not match",
|
// message: "The OTP entered does not match",
|
||||||
color: "red",
|
// color: "red",
|
||||||
});
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
if (showOtpField && !showTxnPassword) {
|
||||||
|
if (!otp) {
|
||||||
|
notifications.show({
|
||||||
|
title: "Error",
|
||||||
|
message: "Please enter the OTP",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const verified = await handleVerifyOtp();
|
||||||
|
if (!verified) {
|
||||||
|
notifications.show({
|
||||||
|
title: "Invalid OTP",
|
||||||
|
message: "The OTP entered does not match",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If OTP verified successfully → show transaction password field
|
||||||
|
setShowTxnPassword(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +335,8 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
amount: amount,
|
amount: amount,
|
||||||
beneficiaryName: beneficiaryName,
|
beneficiaryName: beneficiaryName,
|
||||||
remitterName: remitter_name,
|
remitterName: remitter_name,
|
||||||
tpassword: txnPassword
|
tpassword: txnPassword,
|
||||||
|
remarks: remarks
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const result = await res.json();
|
const result = await res.json();
|
||||||
@@ -321,59 +386,6 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <Modal
|
|
||||||
opened={showIntroModal}
|
|
||||||
onClose={() => setShowIntroModal(false)}
|
|
||||||
centered
|
|
||||||
withCloseButton={false} // force them to press OK
|
|
||||||
>
|
|
||||||
<Stack gap={1}>
|
|
||||||
<Title order={4} style={{ textAlign: "center" }}>Important Note</Title>
|
|
||||||
<Text size="sm">• <strong>IMPS</strong> is available 24X7. Limit: up to ₹5,00,000. Money is transfer instantly.</Text>
|
|
||||||
<Text size="sm">• <strong>NEFT</strong> is available 24x7. Can be used for any amount but not instant.</Text>
|
|
||||||
<Text size="sm">• <strong>RTGS</strong> is for ₹2,00,000 and above. Available during banking hours.As per directions of RBI, RTGS transactions are subjected to the following{" "}
|
|
||||||
<strong>Time Varying Tariff</strong> in addition to the existing <strong>RTGS</strong>
|
|
||||||
Commission. The tariff will be calculated based on the time of completion
|
|
||||||
of transaction.</Text>
|
|
||||||
<List
|
|
||||||
spacing="xs"
|
|
||||||
size="sm"
|
|
||||||
icon={
|
|
||||||
<ThemeIcon color="red" size={20} radius="xl">
|
|
||||||
<IconAlertTriangle size={14} />
|
|
||||||
</ThemeIcon>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<List.Item>
|
|
||||||
From <strong>09:00 hrs</strong> to <strong>12:00 hrs</strong> →{" "}
|
|
||||||
<strong>₹0.00</strong>
|
|
||||||
</List.Item>
|
|
||||||
<List.Item>
|
|
||||||
After <strong>12:00 hrs</strong> up to <strong>15:30 hrs</strong> →{" "}
|
|
||||||
<strong>₹1.00</strong>
|
|
||||||
</List.Item>
|
|
||||||
<List.Item>
|
|
||||||
After <strong>15:30 hrs</strong> → <strong>₹5.00</strong>
|
|
||||||
</List.Item>
|
|
||||||
</List>
|
|
||||||
<Divider my="sm" variant="dashed" />
|
|
||||||
<Text size="xs" c="blue">
|
|
||||||
• Minimum Transfer Amount on this Day is Rs. 1.00
|
|
||||||
</Text>
|
|
||||||
<Text size="xs" c="blue">
|
|
||||||
• Maximum Transfer Limit per Day is Rs. 500000.00
|
|
||||||
</Text>
|
|
||||||
<Text size="xs" c="blue">
|
|
||||||
• Available Transfer Amount on this Day is Rs. 500000.00
|
|
||||||
</Text>
|
|
||||||
<Group justify="flex-end" mt="md">
|
|
||||||
<Button color="blue" onClick={() => setShowIntroModal(false)}>
|
|
||||||
Okay
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
</Modal> */}
|
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
opened={showIntroModal}
|
opened={showIntroModal}
|
||||||
onClose={() => setShowIntroModal(false)}
|
onClose={() => setShowIntroModal(false)}
|
||||||
@@ -456,9 +468,6 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
opened={showConfirmModel}
|
opened={showConfirmModel}
|
||||||
onClose={() => setConfirmModel(false)}
|
onClose={() => setConfirmModel(false)}
|
||||||
@@ -491,7 +500,7 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
color="blue"
|
color="blue"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setConfirmModel(false);
|
setConfirmModel(false);
|
||||||
const otp = await handleGenerateOtp();
|
const otp = await handleSendOtp();
|
||||||
setShowOtpField(true);
|
setShowOtpField(true);
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "OTP Sent",
|
title: "OTP Sent",
|
||||||
@@ -505,6 +514,7 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
{/* main content */}
|
{/* main content */}
|
||||||
{!showIntroModal && (
|
{!showIntroModal && (
|
||||||
<div style={{ maxHeight: "290px", overflowY: "auto" }}>
|
<div style={{ maxHeight: "290px", overflowY: "auto" }}>
|
||||||
@@ -625,7 +635,7 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
<IconRefresh
|
<IconRefresh
|
||||||
size={22}
|
size={22}
|
||||||
style={{ cursor: "pointer", color: "blue", marginBottom: "6px" }}
|
style={{ cursor: "pointer", color: "blue", marginBottom: "6px" }}
|
||||||
onClick={handleGenerateOtp}
|
onClick={handleSendOtp}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export default function Home() {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok && Array.isArray(data)) {
|
if (response.ok && Array.isArray(data)) {
|
||||||
SetAccountData(data);
|
SetAccountData(data);
|
||||||
|
sessionStorage.setItem("accountData", JSON.stringify(data));
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
const firstDeposit = data.find(acc => acc.stAccountType !== "LN");
|
const firstDeposit = data.find(acc => acc.stAccountType !== "LN");
|
||||||
const firstLoan = data.find(acc => acc.stAccountType === "LN");
|
const firstLoan = data.find(acc => acc.stAccountType === "LN");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Box, Button, Divider, Group, Image, Popover, Stack, Text, Title } from '@mantine/core';
|
import { Box, Button, Divider, Group, Image, Modal, Popover, Stack, Text, Title } from '@mantine/core';
|
||||||
import { IconBook, IconCurrencyRupee, IconHome, IconLogout, IconPhoneFilled, IconSettings } from '@tabler/icons-react';
|
import { IconBook, IconCurrencyRupee, IconHome, IconLogout, IconPhoneFilled, IconSettings } from '@tabler/icons-react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useRouter, usePathname } from "next/navigation";
|
import { useRouter, usePathname } from "next/navigation";
|
||||||
@@ -17,6 +17,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||||||
const [userLastLoginDetails, setUserLastLoginDetails] = useState(null);
|
const [userLastLoginDetails, setUserLastLoginDetails] = useState(null);
|
||||||
const [custname, setCustname] = useState<string | null>(null);
|
const [custname, setCustname] = useState<string | null>(null);
|
||||||
const isMobile = useMediaQuery("(max-width: 768px)");
|
const isMobile = useMediaQuery("(max-width: 768px)");
|
||||||
|
const [sessionModal, setSessionModal] = useState(false);
|
||||||
|
const [countdown, setCountdown] = useState(30); // 30 sec countdown before auto logout
|
||||||
|
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
|
|
||||||
@@ -80,6 +82,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When reload and click on back then logout
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Push fake history state to trap navigation
|
// Push fake history state to trap navigation
|
||||||
window.history.pushState(null, "", window.location.href);
|
window.history.pushState(null, "", window.location.href);
|
||||||
@@ -155,6 +159,58 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||||||
fetchLoginTime();
|
fetchLoginTime();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// LOGOUT AFTER 5 MINUTES OF INACTIVITY OR TAB SWITCH
|
||||||
|
useEffect(() => {
|
||||||
|
const INACTIVITY_LIMIT = 5 * 60 * 1000; // 5 minutes
|
||||||
|
let inactiveSince: number | null = null;
|
||||||
|
let countdownTimer: NodeJS.Timeout;
|
||||||
|
|
||||||
|
const startCountdown = () => {
|
||||||
|
setSessionModal(true);
|
||||||
|
setCountdown(30); // start from 30 seconds
|
||||||
|
|
||||||
|
countdownTimer = setInterval(() => {
|
||||||
|
setCountdown((prev) => {
|
||||||
|
if (prev <= 1) {
|
||||||
|
clearInterval(countdownTimer);
|
||||||
|
doLogout(); // auto logout after countdown
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return prev - 1;
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVisibilityChange = () => {
|
||||||
|
if (document.hidden) {
|
||||||
|
// User switched tab → mark inactive time
|
||||||
|
inactiveSince = Date.now();
|
||||||
|
} else {
|
||||||
|
// User returned to tab
|
||||||
|
if (inactiveSince && Date.now() - inactiveSince >= INACTIVITY_LIMIT) {
|
||||||
|
// Inactive for ≥ 5 min → show modal
|
||||||
|
startCountdown();
|
||||||
|
}
|
||||||
|
inactiveSince = null; // reset inactiveSince
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUserActivity = () => {
|
||||||
|
// Reset inactivity timestamp if user interacts
|
||||||
|
inactiveSince = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const activityEvents = ["mousemove", "keydown", "click", "scroll", "touchstart"];
|
||||||
|
activityEvents.forEach((event) => window.addEventListener(event, handleUserActivity));
|
||||||
|
document.addEventListener("visibilitychange", handleVisibilityChange);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
activityEvents.forEach((event) => window.removeEventListener(event, handleUserActivity));
|
||||||
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
||||||
|
clearInterval(countdownTimer);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{ href: "/home", label: "Home", icon: IconHome },
|
{ href: "/home", label: "Home", icon: IconHome },
|
||||||
{ href: "/accounts", label: "Accounts", icon: IconBook },
|
{ href: "/accounts", label: "Accounts", icon: IconBook },
|
||||||
@@ -274,6 +330,32 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Box>
|
</Box>
|
||||||
|
{/* this model for session logout */}
|
||||||
|
<Modal
|
||||||
|
opened={sessionModal}
|
||||||
|
onClose={() => setSessionModal(false)}
|
||||||
|
withCloseButton={false}
|
||||||
|
centered
|
||||||
|
closeOnClickOutside={false} // <--- prevents clicking outside to close
|
||||||
|
closeOnEscape={false} // <--- prevents ESC key
|
||||||
|
title="Session Timeout Warning"
|
||||||
|
>
|
||||||
|
<Stack align="center" gap="md">
|
||||||
|
<Text ta="center" c="red">
|
||||||
|
You have been inactive for a while.
|
||||||
|
<br />
|
||||||
|
You’ll be logged out automatically in <b>{countdown}</b> seconds.
|
||||||
|
</Text>
|
||||||
|
<Group justify="center" mt="sm">
|
||||||
|
{/* <Button color="gray" variant="default" onClick={() => setSessionModal(false)}>
|
||||||
|
Stay Logged In
|
||||||
|
</Button> */}
|
||||||
|
<Button color="red" onClick={doLogout}>
|
||||||
|
Logout Now
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
<Divider size="xs" color="blue" />
|
<Divider size="xs" color="blue" />
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export default function ChangePassword() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
console.log(result);
|
// console.log(result);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "Failed",
|
title: "Failed",
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export default function ChangePassword() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
console.log(result);
|
// console.log(result);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "Failed",
|
title: "Failed",
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ export default function ChangePassword() {
|
|||||||
color: "red",
|
color: "red",
|
||||||
autoClose: false,
|
autoClose: false,
|
||||||
});
|
});
|
||||||
|
resetForm();
|
||||||
} else {
|
} else {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "Success",
|
title: "Success",
|
||||||
@@ -199,6 +200,7 @@ export default function ChangePassword() {
|
|||||||
message: err.message || "Server error, please try again later",
|
message: err.message || "Server error, please try again later",
|
||||||
color: "red",
|
color: "red",
|
||||||
});
|
});
|
||||||
|
resetForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export default function ForgetLoginPwd() {
|
|||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
notifications.show({
|
notifications.show({
|
||||||
withBorder: true,
|
withBorder: true,
|
||||||
color: "green",
|
color: "green",
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export default function SetLoginPwd() {
|
|||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
notifications.show({
|
notifications.show({
|
||||||
withBorder: true,
|
withBorder: true,
|
||||||
color: "green",
|
color: "green",
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export default function SetTransactionPwd() {
|
|||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
notifications.show({
|
notifications.show({
|
||||||
withBorder: true,
|
withBorder: true,
|
||||||
color: "green",
|
color: "green",
|
||||||
|
|||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -188,7 +188,7 @@ export default function MandatePage() {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data)
|
// console.log(data)
|
||||||
if (!response.ok) throw new Error("Failed to send OTP");
|
if (!response.ok) throw new Error("Failed to send OTP");
|
||||||
|
|
||||||
notifications.show({
|
notifications.show({
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export default function Login() {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
if (data.error === "MIGRATED_USER_HAS_NO_PASSWORD") {
|
if (data.error === "MIGRATED_USER_HAS_NO_PASSWORD") {
|
||||||
//console.log("Migration issue detected → opening modal");
|
//console.log("Migration issue detected → opening modal");
|
||||||
setOpened(true);
|
setOpened(true);
|
||||||
@@ -141,10 +141,11 @@ export default function Login() {
|
|||||||
}
|
}
|
||||||
setIsLogging(true);
|
setIsLogging(true);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
const token = data.token;
|
const token = data.token;
|
||||||
localStorage.setItem("access_token", token);
|
localStorage.setItem("access_token", token);
|
||||||
localStorage.setItem("pswExpiryDate", data.loginPswExpiry);
|
localStorage.setItem("pswExpiryDate", data.loginPswExpiry);
|
||||||
|
// console.log("Expiry Date:",(dayjs(data.loginPswExpiry)).diff(dayjs(), "day"));
|
||||||
|
|
||||||
// Password Expiry Logic todo
|
// Password Expiry Logic todo
|
||||||
if (data.loginPswExpiry && (dayjs(data.loginPswExpiry)).diff(dayjs(), "day") < 0) {
|
if (data.loginPswExpiry && (dayjs(data.loginPswExpiry)).diff(dayjs(), "day") < 0) {
|
||||||
@@ -155,14 +156,10 @@ export default function Login() {
|
|||||||
message: "Your password has expired, please set a new one.",
|
message: "Your password has expired, please set a new one.",
|
||||||
autoClose: 4000,
|
autoClose: 4000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
router.push("/ChangePassword");
|
router.push("/ChangePassword");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (data.FirstTimeLogin === true) {
|
if (data.FirstTimeLogin === true) {
|
||||||
router.push("/SetPassword")
|
router.push("/SetPassword")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user