Feat : Fetching daily limit is working

This commit is contained in:
2025-10-29 12:40:38 +05:30
parent 8bf603544f
commit ded4a2edc9
8 changed files with 195 additions and 52 deletions

View File

@@ -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<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() {
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() {
<Text size="xs" c="green">
Minimum Transfer Amount on this Day is Rs. 1.00
</Text>
<Text size="xs" c="green">
Maximum Transfer Limit per Day is Rs. 500000.00
</Text>
<Text size="xs" c="green">
Available Transfer Amount on this Day is Rs. 500000.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>
</div>
</Paper>