Feat : Fetching daily limit is working
This commit is contained in:
@@ -4,21 +4,6 @@ const isWindows = os.platform() === "win32";
|
|||||||
|
|
||||||
// Security headers
|
// Security headers
|
||||||
const securityHeaders = [
|
const securityHeaders = [
|
||||||
{
|
|
||||||
key: "Content-Security-Policy",
|
|
||||||
value: `
|
|
||||||
default-src 'self';
|
|
||||||
script-src 'self' 'unsafe-inline' 'unsafe-eval';
|
|
||||||
style-src 'self' 'unsafe-inline';
|
|
||||||
img-src 'self' data:;
|
|
||||||
font-src 'self';
|
|
||||||
connect-src 'self' http://localhost:8080 https://yourdomain.com;
|
|
||||||
frame-ancestors 'none';
|
|
||||||
object-src 'none';
|
|
||||||
base-uri 'self';
|
|
||||||
form-action 'self';
|
|
||||||
`.replace(/\n/g, ""), // remove newlines
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "Referrer-Policy",
|
key: "Referrer-Policy",
|
||||||
value: "strict-origin-when-cross-origin",
|
value: "strict-origin-when-cross-origin",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { 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";
|
import { sendOtp, verifyOtp } from "@/app/_util/otp";
|
||||||
|
import { getDailyLimit } from "@/app/_util/transactionLimit";
|
||||||
|
|
||||||
interface accountData {
|
interface accountData {
|
||||||
stAccountNo: string;
|
stAccountNo: string;
|
||||||
@@ -38,6 +39,26 @@ export default function QuickPay() {
|
|||||||
const [countdown, setCountdown] = useState(180);
|
const [countdown, setCountdown] = useState(180);
|
||||||
const [timerActive, setTimerActive] = useState(false);
|
const [timerActive, setTimerActive] = useState(false);
|
||||||
const [otp, setOtp] = useState("");
|
const [otp, setOtp] = useState("");
|
||||||
|
const [dailyLimit, setDailyLimit] = useState<number | null>(null);
|
||||||
|
const [usedLimit, setUsedLimit] = useState<number | null>(null);
|
||||||
|
|
||||||
|
const FetchDailyLimit = async () => {
|
||||||
|
try {
|
||||||
|
const token = localStorage.getItem("access_token");
|
||||||
|
if (!token) return;
|
||||||
|
const data = await getDailyLimit(token);
|
||||||
|
if (data) {
|
||||||
|
setDailyLimit(data.dailyLimit);
|
||||||
|
setUsedLimit(data.usedLimit);
|
||||||
|
} else {
|
||||||
|
setDailyLimit(null);
|
||||||
|
setUsedLimit(null);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setDailyLimit(null);
|
||||||
|
setUsedLimit(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async function handleSendOtp() {
|
async function handleSendOtp() {
|
||||||
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
||||||
@@ -121,6 +142,7 @@ export default function QuickPay() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (authorized) {
|
if (authorized) {
|
||||||
FetchAccountDetails();
|
FetchAccountDetails();
|
||||||
|
FetchDailyLimit();
|
||||||
}
|
}
|
||||||
}, [authorized]);
|
}, [authorized]);
|
||||||
|
|
||||||
@@ -286,6 +308,7 @@ export default function QuickPay() {
|
|||||||
message: "Transaction successful",
|
message: "Transaction successful",
|
||||||
color: "green",
|
color: "green",
|
||||||
});
|
});
|
||||||
|
await FetchDailyLimit();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
@@ -544,12 +567,21 @@ export default function QuickPay() {
|
|||||||
<Text size="xs" c="green">
|
<Text size="xs" c="green">
|
||||||
• Minimum Transfer Amount on this Day is Rs. 1.00
|
• Minimum Transfer Amount on this Day is Rs. 1.00
|
||||||
</Text>
|
</Text>
|
||||||
<Text size="xs" c="green">
|
{dailyLimit !== null ? (
|
||||||
• Maximum Transfer Limit per Day is Rs. 500000.00
|
<>
|
||||||
</Text>
|
<Text size="xs" c="green">
|
||||||
<Text size="xs" c="green">
|
• Maximum Transfer Limit per Day is Rs. {dailyLimit.toFixed(2)}
|
||||||
• Available Transfer Amount on this Day is Rs. 500000.00
|
</Text>
|
||||||
</Text>
|
<Text size="xs" c="green">
|
||||||
|
• Available Transfer Amount on this Day is Rs.{" "}
|
||||||
|
{usedLimit?.toFixed(2)}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Text size="xs" c="red">
|
||||||
|
• No daily limit set for this user
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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';
|
import { sendOtp, verifyOtp } from '@/app/_util/otp';
|
||||||
|
import { getDailyLimit } from "@/app/_util/transactionLimit";
|
||||||
|
|
||||||
|
|
||||||
interface accountData {
|
interface accountData {
|
||||||
@@ -39,6 +40,26 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
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 [dailyLimit, setDailyLimit] = useState<number | null>(null);
|
||||||
|
const [usedLimit, setUsedLimit] = useState<number | null>(null);
|
||||||
|
|
||||||
|
const FetchDailyLimit = async () => {
|
||||||
|
try {
|
||||||
|
const token = localStorage.getItem("access_token");
|
||||||
|
if (!token) return;
|
||||||
|
const data = await getDailyLimit(token);
|
||||||
|
if (data) {
|
||||||
|
setDailyLimit(data.dailyLimit);
|
||||||
|
setUsedLimit(data.usedLimit);
|
||||||
|
} else {
|
||||||
|
setDailyLimit(null);
|
||||||
|
setUsedLimit(null);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setDailyLimit(null);
|
||||||
|
setUsedLimit(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async function handleSendOtp() {
|
async function handleSendOtp() {
|
||||||
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
||||||
@@ -150,6 +171,7 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
if (authorized) {
|
if (authorized) {
|
||||||
FetchAccountDetails();
|
FetchAccountDetails();
|
||||||
FetchBeneficiaryDetails();
|
FetchBeneficiaryDetails();
|
||||||
|
FetchDailyLimit();
|
||||||
}
|
}
|
||||||
}, [authorized]);
|
}, [authorized]);
|
||||||
|
|
||||||
@@ -289,6 +311,7 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
setShowOtpField(false);
|
setShowOtpField(false);
|
||||||
setOtp("");
|
setOtp("");
|
||||||
setBeneficiaryName('');
|
setBeneficiaryName('');
|
||||||
|
await FetchDailyLimit();
|
||||||
} else {
|
} else {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
@@ -526,15 +549,21 @@ export default function SendToBeneficiaryOwn() {
|
|||||||
<Text size="xs" c="green">
|
<Text size="xs" c="green">
|
||||||
• Minimum Transfer Amount on this Day is Rs. 1.00
|
• Minimum Transfer Amount on this Day is Rs. 1.00
|
||||||
</Text>
|
</Text>
|
||||||
<Text size="xs" c="green">
|
{dailyLimit !== null ? (
|
||||||
• Maximum Transfer Limit per Day is Rs. 500000.00
|
<>
|
||||||
</Text>
|
<Text size="xs" c="green">
|
||||||
<Text size="xs" c="green">
|
• Maximum Transfer Limit per Day is Rs. {dailyLimit.toFixed(2)}
|
||||||
• Available Transfer Amount on this Day is Rs. 500000.00
|
</Text>
|
||||||
</Text>
|
<Text size="xs" c="green">
|
||||||
<Text size="xs" c="red" fw={700}>
|
• Available Transfer Amount on this Day is Rs.{" "}
|
||||||
NOTE : Funds Transfer can be done only to previous added Beneficiary Accounts.
|
{usedLimit?.toFixed(2)}
|
||||||
</Text>
|
</Text>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Text size="xs" c="red">
|
||||||
|
• No daily limit set for this user
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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";
|
import { sendOtp, verifyOtp } from "@/app/_util/otp";
|
||||||
|
import { getDailyLimit } from "@/app/_util/transactionLimit";
|
||||||
|
|
||||||
|
|
||||||
interface accountData {
|
interface accountData {
|
||||||
@@ -38,6 +39,26 @@ 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 [dailyLimit, setDailyLimit] = useState<number | null>(null);
|
||||||
|
const [usedLimit, setUsedLimit] = useState<number | null>(null);
|
||||||
|
|
||||||
|
const FetchDailyLimit = async () => {
|
||||||
|
try {
|
||||||
|
const token = localStorage.getItem("access_token");
|
||||||
|
if (!token) return;
|
||||||
|
const data = await getDailyLimit(token);
|
||||||
|
if (data) {
|
||||||
|
setDailyLimit(data.dailyLimit);
|
||||||
|
setUsedLimit(data.usedLimit);
|
||||||
|
} else {
|
||||||
|
setDailyLimit(null);
|
||||||
|
setUsedLimit(null);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setDailyLimit(null);
|
||||||
|
setUsedLimit(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async function handleSendOtp() {
|
async function handleSendOtp() {
|
||||||
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
||||||
@@ -207,6 +228,7 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
if (authorized) {
|
if (authorized) {
|
||||||
FetchAccountDetails();
|
FetchAccountDetails();
|
||||||
FetchBeneficiaryDetails();
|
FetchBeneficiaryDetails();
|
||||||
|
FetchDailyLimit();
|
||||||
}
|
}
|
||||||
}, [authorized]);
|
}, [authorized]);
|
||||||
|
|
||||||
@@ -337,6 +359,7 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
setShowOtpField(false);
|
setShowOtpField(false);
|
||||||
setOtp("");
|
setOtp("");
|
||||||
setBeneficiaryName('');
|
setBeneficiaryName('');
|
||||||
|
await FetchDailyLimit();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
@@ -436,7 +459,7 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
|
|
||||||
<Divider my="sm" variant="dashed" />
|
<Divider my="sm" variant="dashed" />
|
||||||
|
|
||||||
<Text size="xs" c="blue">
|
{/* <Text size="xs" c="blue">
|
||||||
• Minimum Transfer Amount on this Day is Rs. 1.00
|
• Minimum Transfer Amount on this Day is Rs. 1.00
|
||||||
</Text>
|
</Text>
|
||||||
<Text size="xs" c="blue">
|
<Text size="xs" c="blue">
|
||||||
@@ -444,7 +467,27 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
</Text>
|
</Text>
|
||||||
<Text size="xs" c="blue">
|
<Text size="xs" c="blue">
|
||||||
• Available Transfer Amount on this Day is Rs. 500000.00
|
• Available Transfer Amount on this Day is Rs. 500000.00
|
||||||
</Text>
|
</Text> */}
|
||||||
|
<Stack gap={1} mt="xs">
|
||||||
|
<Text size="xs" c="green">
|
||||||
|
• Minimum Transfer Amount on this Day is Rs. 1.00
|
||||||
|
</Text>
|
||||||
|
{dailyLimit !== null ? (
|
||||||
|
<>
|
||||||
|
<Text size="xs" c="green">
|
||||||
|
• Maximum Transfer Limit per Day is Rs. {dailyLimit.toFixed(2)}
|
||||||
|
</Text>
|
||||||
|
<Text size="xs" c="green">
|
||||||
|
• Available Transfer Amount on this Day is Rs.{" "}
|
||||||
|
{usedLimit?.toFixed(2)}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Text size="xs" c="red">
|
||||||
|
• No daily limit set for this user
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
<Group justify="flex-end" mt="md">
|
<Group justify="flex-end" mt="md">
|
||||||
<Button color="blue" onClick={() => setShowIntroModal(false)}>
|
<Button color="blue" onClick={() => setShowIntroModal(false)}>
|
||||||
@@ -682,15 +725,26 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
</List>
|
</List>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
<Text size="xs" c="dimmed">
|
<Stack gap={1} mt="xs">
|
||||||
• Minimum Transfer Limit per Day is Rs. 1.00
|
<Text size="xs" c="green">
|
||||||
</Text>
|
• Minimum Transfer Amount on this Day is Rs. 1.00
|
||||||
<Text size="xs" c="dimmed">
|
</Text>
|
||||||
• Maximum Transfer Limit per Day is Rs. 500000.00
|
{dailyLimit !== null ? (
|
||||||
</Text>
|
<>
|
||||||
<Text size="xs" c="dimmed">
|
<Text size="xs" c="green">
|
||||||
• Available Transfer Amount on this Day is Rs. 500000.00
|
• Maximum Transfer Limit per Day is Rs. {dailyLimit.toFixed(2)}
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text size="xs" c="green">
|
||||||
|
• Available Transfer Amount on this Day is Rs.{" "}
|
||||||
|
{usedLimit?.toFixed(2)}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Text size="xs" c="red">
|
||||||
|
• No daily limit set for this user
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -699,3 +753,5 @@ export default function SendToBeneficiaryOthers() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ interface SendOtpPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getStoredMobileNumber(): string {
|
function getStoredMobileNumber(): string {
|
||||||
const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
// const mobileNumber = localStorage.getItem('remitter_mobile_no');
|
||||||
// const mobileNumber = "7890544527";
|
const mobileNumber = "7890544527";
|
||||||
if (!mobileNumber) throw new Error('Mobile number not found.');
|
if (!mobileNumber) throw new Error('Mobile number not found.');
|
||||||
return mobileNumber;
|
return mobileNumber;
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/app/_util/transactionLimit.ts
Normal file
30
src/app/_util/transactionLimit.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
export async function getDailyLimit(token: string) {
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/customer/daily-limit", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Authorization": `Bearer ${token}`,
|
||||||
|
"X-Login-Type": "IB",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 400) {
|
||||||
|
const errorData = await response.json();
|
||||||
|
if (errorData?.error === "NO DAILY LIMIT SET FOR USER") {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
throw new Error(errorData?.error || "Bad Request");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch daily limit: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching daily limit:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useState, useEffect, memo, useRef } from "react";
|
|
||||||
|
import React, { useState, useEffect } from "react";
|
||||||
import { Text, Button, TextInput, PasswordInput, Title, Card, Group, Flex, Box, Image, Anchor, Tooltip, Modal, Stack } from "@mantine/core";
|
import { Text, Button, TextInput, PasswordInput, Title, Card, Group, Flex, Box, Image, Anchor, Tooltip, Modal, Stack } from "@mantine/core";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { Providers } from "@/app/providers";
|
import { Providers } from "@/app/providers";
|
||||||
@@ -9,6 +10,7 @@ import logo from '@/app/image/logo1.jpg';
|
|||||||
import frontPage from '@/app/image/EMandate.jpg';
|
import frontPage from '@/app/image/EMandate.jpg';
|
||||||
import { generateCaptcha } from '@/app/captcha';
|
import { generateCaptcha } from '@/app/captcha';
|
||||||
import styles from './Login.module.css';
|
import styles from './Login.module.css';
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
|
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
@@ -18,7 +20,15 @@ export default function Login() {
|
|||||||
const [captcha, setCaptcha] = useState("");
|
const [captcha, setCaptcha] = useState("");
|
||||||
const [inputCaptcha, setInputCaptcha] = useState("");
|
const [inputCaptcha, setInputCaptcha] = useState("");
|
||||||
const [isLogging, setIsLogging] = useState(false);
|
const [isLogging, setIsLogging] = useState(false);
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const data = searchParams.get("data");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
console.log("URL parameter 'data':", data);
|
||||||
|
localStorage.setItem("Emendate_data",data);
|
||||||
|
}
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadCaptcha = async () => {
|
const loadCaptcha = async () => {
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ export default function Login() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: mobile });
|
// await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: mobile });
|
||||||
// await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: "7890544527" });
|
await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: "7890544527" });
|
||||||
notifications.show({
|
notifications.show({
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
title: 'OTP Required',
|
title: 'OTP Required',
|
||||||
@@ -67,8 +67,8 @@ export default function Login() {
|
|||||||
async function handleVerifyOtp(mobile?: string) {
|
async function handleVerifyOtp(mobile?: string) {
|
||||||
try {
|
try {
|
||||||
if (mobile) {
|
if (mobile) {
|
||||||
await verifyLoginOtp(otp, mobile);
|
// await verifyLoginOtp(otp, mobile);
|
||||||
// await verifyLoginOtp(otp, '7890544527');
|
await verifyLoginOtp(otp, '7890544527');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,10 +296,11 @@ export default function Login() {
|
|||||||
message: "Internal Server Error, Please try again later",
|
message: "Internal Server Error, Please try again later",
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
});
|
});
|
||||||
} finally {
|
}
|
||||||
// Ensure we always stop loader if still active
|
// finally {
|
||||||
setIsLogging(false);
|
// // Ensure we always stop loader if still active
|
||||||
}
|
// setIsLogging(false);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user