From ded4a2edc9a13ccfa48f6401ddb1250d1adb4743 Mon Sep 17 00:00:00 2001 From: "tomosa.sarkar" Date: Wed, 29 Oct 2025 12:40:38 +0530 Subject: [PATCH] Feat : Fetching daily limit is working --- next.config.mjs | 15 ---- src/app/(main)/funds_transfer/page.tsx | 44 +++++++++-- .../funds_transfer/send_beneficiary/page.tsx | 47 ++++++++--- .../sendBeneficiaryOthers.tsx | 78 ++++++++++++++++--- src/app/_util/otp.ts | 4 +- src/app/_util/transactionLimit.ts | 30 +++++++ src/app/eMandate/login/page.tsx | 12 ++- src/app/login/page.tsx | 17 ++-- 8 files changed, 195 insertions(+), 52 deletions(-) create mode 100644 src/app/_util/transactionLimit.ts diff --git a/next.config.mjs b/next.config.mjs index ac51b85..27b1092 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -4,21 +4,6 @@ const isWindows = os.platform() === "win32"; // Security headers 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", value: "strict-origin-when-cross-origin", diff --git a/src/app/(main)/funds_transfer/page.tsx b/src/app/(main)/funds_transfer/page.tsx index 14f7ba2..1d1f4f0 100644 --- a/src/app/(main)/funds_transfer/page.tsx +++ b/src/app/(main)/funds_transfer/page.tsx @@ -8,6 +8,7 @@ import { IconRefresh } from "@tabler/icons-react"; import Image from "next/image"; import img from '@/app/image/logo1.jpg' import { sendOtp, verifyOtp } from "@/app/_util/otp"; +import { getDailyLimit } from "@/app/_util/transactionLimit"; interface accountData { stAccountNo: string; @@ -38,6 +39,26 @@ export default function QuickPay() { const [countdown, setCountdown] = useState(180); const [timerActive, setTimerActive] = useState(false); const [otp, setOtp] = useState(""); + const [dailyLimit, setDailyLimit] = useState(null); + const [usedLimit, setUsedLimit] = useState(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() { const mobileNumber = localStorage.getItem('remitter_mobile_no'); @@ -121,6 +142,7 @@ export default function QuickPay() { useEffect(() => { if (authorized) { FetchAccountDetails(); + FetchDailyLimit(); } }, [authorized]); @@ -286,6 +308,7 @@ export default function QuickPay() { message: "Transaction successful", color: "green", }); + await FetchDailyLimit(); return; } else { notifications.show({ @@ -544,12 +567,21 @@ export default function QuickPay() { • Minimum Transfer Amount on this Day is Rs. 1.00 - - • Maximum Transfer Limit per Day is Rs. 500000.00 - - - • Available Transfer Amount on this Day is Rs. 500000.00 - + {dailyLimit !== null ? ( + <> + + • Maximum Transfer Limit per Day is Rs. {dailyLimit.toFixed(2)} + + + • Available Transfer Amount on this Day is Rs.{" "} + {usedLimit?.toFixed(2)} + + + ) : ( + + • No daily limit set for this user + + )} diff --git a/src/app/(main)/funds_transfer/send_beneficiary/page.tsx b/src/app/(main)/funds_transfer/send_beneficiary/page.tsx index df7104c..812d378 100644 --- a/src/app/(main)/funds_transfer/send_beneficiary/page.tsx +++ b/src/app/(main)/funds_transfer/send_beneficiary/page.tsx @@ -9,6 +9,7 @@ import Image from "next/image"; import img from '@/app/image/logo1.jpg'; import { IconRefresh } from "@tabler/icons-react"; import { sendOtp, verifyOtp } from '@/app/_util/otp'; +import { getDailyLimit } from "@/app/_util/transactionLimit"; interface accountData { @@ -39,6 +40,26 @@ export default function SendToBeneficiaryOwn() { const [otp, setOtp] = useState(""); const [countdown, setCountdown] = useState(180); const [timerActive, setTimerActive] = useState(false); + const [dailyLimit, setDailyLimit] = useState(null); + const [usedLimit, setUsedLimit] = useState(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() { const mobileNumber = localStorage.getItem('remitter_mobile_no'); @@ -150,6 +171,7 @@ export default function SendToBeneficiaryOwn() { if (authorized) { FetchAccountDetails(); FetchBeneficiaryDetails(); + FetchDailyLimit(); } }, [authorized]); @@ -289,6 +311,7 @@ export default function SendToBeneficiaryOwn() { setShowOtpField(false); setOtp(""); setBeneficiaryName(''); + await FetchDailyLimit(); } else { notifications.show({ title: "Error", @@ -526,15 +549,21 @@ export default function SendToBeneficiaryOwn() { • Minimum Transfer Amount on this Day is Rs. 1.00 - - • Maximum Transfer Limit per Day is Rs. 500000.00 - - - • Available Transfer Amount on this Day is Rs. 500000.00 - - - NOTE : Funds Transfer can be done only to previous added Beneficiary Accounts. - + {dailyLimit !== null ? ( + <> + + • Maximum Transfer Limit per Day is Rs. {dailyLimit.toFixed(2)} + + + • Available Transfer Amount on this Day is Rs.{" "} + {usedLimit?.toFixed(2)} + + + ) : ( + + • No daily limit set for this user + + )} diff --git a/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx b/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx index b425ac0..6082b0f 100644 --- a/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx +++ b/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx @@ -8,6 +8,7 @@ import { IconAlertTriangle, IconRefresh } from "@tabler/icons-react"; import Image from "next/image"; import img from '@/app/image/logo1.jpg' import { sendOtp, verifyOtp } from "@/app/_util/otp"; +import { getDailyLimit } from "@/app/_util/transactionLimit"; interface accountData { @@ -38,6 +39,26 @@ export default function SendToBeneficiaryOthers() { const [otp, setOtp] = useState(""); const [countdown, setCountdown] = useState(180); const [timerActive, setTimerActive] = useState(false); + const [dailyLimit, setDailyLimit] = useState(null); + const [usedLimit, setUsedLimit] = useState(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() { const mobileNumber = localStorage.getItem('remitter_mobile_no'); @@ -207,6 +228,7 @@ export default function SendToBeneficiaryOthers() { if (authorized) { FetchAccountDetails(); FetchBeneficiaryDetails(); + FetchDailyLimit(); } }, [authorized]); @@ -337,6 +359,7 @@ export default function SendToBeneficiaryOthers() { setShowOtpField(false); setOtp(""); setBeneficiaryName(''); + await FetchDailyLimit(); } else { notifications.show({ @@ -436,7 +459,7 @@ export default function SendToBeneficiaryOthers() { - + {/* • Minimum Transfer Amount on this Day is Rs. 1.00 @@ -444,7 +467,27 @@ export default function SendToBeneficiaryOthers() { • Available Transfer Amount on this Day is Rs. 500000.00 - + */} + + + • Minimum Transfer Amount on this Day is Rs. 1.00 + + {dailyLimit !== null ? ( + <> + + • Maximum Transfer Limit per Day is Rs. {dailyLimit.toFixed(2)} + + + • Available Transfer Amount on this Day is Rs.{" "} + {usedLimit?.toFixed(2)} + + + ) : ( + + • No daily limit set for this user + + )} +