feat : remove log in IB

This commit is contained in:
2025-10-17 12:11:44 +05:30
parent ad19f0cb4c
commit 6acb7ade49
5 changed files with 52 additions and 24 deletions

View File

@@ -15,7 +15,7 @@ const nextConfig = {
source: '/api/:path*', source: '/api/:path*',
destination: isWindows destination: isWindows
? "http://localhost:8080/api/:path*" // For Windows ? "http://localhost:8080/api/:path*" // For Windows
: "https://kccbmbnk.net/api/:path*", // For Linux/Mac/Server : "http://localhost:8080/api/:path*", // For Linux/Mac/Server
}, },
]; ];
}, },

View File

@@ -30,6 +30,7 @@ export default function Home() {
const selectedLNData = loanAccounts.find(acc => acc.stAccountNo === selectedLN); const selectedLNData = loanAccounts.find(acc => acc.stAccountNo === selectedLN);
const [showBalance, setShowBalance] = useState(false); const [showBalance, setShowBalance] = useState(false);
const PassExpiryRemains = (dayjs(localStorage.getItem("pswExpiryDate"))).diff(dayjs(), "day") const PassExpiryRemains = (dayjs(localStorage.getItem("pswExpiryDate"))).diff(dayjs(), "day")
const [loadingAccountNo, setLoadingAccountNo] = useState<string | null>(null);
// If back and forward button is clicked // If back and forward button is clicked
useEffect(() => { useEffect(() => {
@@ -93,7 +94,13 @@ export default function Home() {
} }
async function handleGetAccountStatement(accountNo: string) { async function handleGetAccountStatement(accountNo: string) {
router.push(`/accounts/account_statement?accNo=${accountNo}`); if (loadingAccountNo) return;
setLoadingAccountNo(accountNo);
// simulate loading delay
setTimeout(() => {
router.push(`/accounts/account_statement?accNo=${accountNo}`);
setLoadingAccountNo(null);
}, 5000);
} }
useEffect(() => { useEffect(() => {
@@ -116,7 +123,7 @@ export default function Home() {
return ( return (
<Providers> <Providers>
<Box p={isMobile ? "8px" : "10px"}> <Box p={isMobile ? "8px" : "10px"}>
<Title order={4} style={{fontSize: isMobile ? "18px" : "22px" }}> <Title order={4} style={{ fontSize: isMobile ? "18px" : "22px" }}>
Accounts Overview Accounts Overview
</Title> </Title>
@@ -202,8 +209,12 @@ export default function Home() {
? `${Number(selectedDAData?.stAvailableBalance || 0).toLocaleString("en-IN")}` ? `${Number(selectedDAData?.stAvailableBalance || 0).toLocaleString("en-IN")}`
: "****"} : "****"}
</Title> </Title>
<Button fullWidth mt="xs" onClick={() => handleGetAccountStatement(selectedDA)}> <Button fullWidth mt="xs"
Get Statement // loading={loadingAccountNo === selectedDA}
disabled={loadingAccountNo === selectedDA}
onClick={() => handleGetAccountStatement(selectedDA)}
>
{loadingAccountNo === selectedDA ? "Loading...Please Wait" : "Get Statement"}
</Button> </Button>
</> </>
) : ( ) : (
@@ -271,8 +282,13 @@ export default function Home() {
? `${Number(selectedLNData?.stAvailableBalance || 0).toLocaleString("en-IN")}` ? `${Number(selectedLNData?.stAvailableBalance || 0).toLocaleString("en-IN")}`
: "****"} : "****"}
</Title> </Title>
<Button fullWidth mt="xs" onClick={() => handleGetAccountStatement(selectedLN)}> <Button fullWidth mt="xs"
Get Statement // loading={loadingAccountNo === selectedLN}
disabled={loadingAccountNo === selectedLN}
onClick={() => handleGetAccountStatement(selectedLN)}
>
{/* Get Statement */}
{loadingAccountNo === selectedLN ? "Loading...Please Wait" : "Get Statement"}
</Button> </Button>
</> </>
) : ( ) : (
@@ -356,8 +372,12 @@ export default function Home() {
<Title order={2} mt="md"> <Title order={2} mt="md">
{showBalance ? `${Number(selectedDAData?.stAvailableBalance || 0).toLocaleString("en-IN")}` : "****"} {showBalance ? `${Number(selectedDAData?.stAvailableBalance || 0).toLocaleString("en-IN")}` : "****"}
</Title> </Title>
<Button fullWidth mt="xs" onClick={() => handleGetAccountStatement(selectedDA)}> <Button fullWidth mt="xs"
Get Statement // loading={loadingAccountNo === selectedDA}
disabled={loadingAccountNo === selectedDA}
onClick={() => handleGetAccountStatement(selectedDA)}
>
{loadingAccountNo === selectedDA ? "Loading... Please Wait" : "Get Statement"}
</Button> </Button>
</> </>
) : ( ) : (
@@ -409,8 +429,13 @@ export default function Home() {
<Title order={2} mt="md"> <Title order={2} mt="md">
{showBalance ? `${Number(selectedLNData?.stAvailableBalance || 0).toLocaleString("en-IN")}` : "****"} {showBalance ? `${Number(selectedLNData?.stAvailableBalance || 0).toLocaleString("en-IN")}` : "****"}
</Title> </Title>
<Button fullWidth mt="xs" onClick={() => handleGetAccountStatement(selectedLN)}> <Button fullWidth mt="xs"
Get Statement // loading={loadingAccountNo === selectedLN}
disabled={loadingAccountNo === selectedLN}
onClick={() => handleGetAccountStatement(selectedLN)}
>
{/* Get Statement */}
{loadingAccountNo === selectedLN ? "Loading...Please Wait.." : "Get Statement"}
</Button> </Button>
</> </>
) : ( ) : (

View File

@@ -1,10 +1,10 @@
export function generateOTP(length: number) { // export function generateOTP(length: number) {
const digits = '0123456789'; // const digits = '0123456789';
let otp = ''; // let otp = '';
otp += digits[Math.floor(Math.random() * 9)+1]; //first digit cannot be zero // otp += digits[Math.floor(Math.random() * 9)+1]; //first digit cannot be zero
for (let i = 1; i < length; i++) { // for (let i = 1; i < length; i++) {
otp += digits[Math.floor(Math.random() * digits.length)]; // otp += digits[Math.floor(Math.random() * digits.length)];
} // }
// console.log("OTP generate :",otp); // // console.log("OTP generate :",otp);
return otp; // return otp;
} // }

View File

@@ -37,6 +37,7 @@ export async function sendOtp(payload: SendOtpPayload) {
{ ...payload, mobileNumber }, { ...payload, mobileNumber },
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
); );
console.log('otp sended.');
return response.data; return response.data;
} catch (error: any) { } catch (error: any) {
console.error('Error sending OTP:', error.response?.data || error.message); console.error('Error sending OTP:', error.response?.data || error.message);
@@ -52,6 +53,7 @@ export async function verifyOtp(otp: string) {
{ otp }, { otp },
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
); );
console.log('Otp verified');
return response.data; return response.data;
} catch (error: any) { } catch (error: any) {
console.error('Error verifying OTP:', error.response?.data || error.message); console.error('Error verifying OTP:', error.response?.data || error.message);
@@ -67,6 +69,7 @@ export async function verifyLoginOtp(otp: string, mobileNumber: string) {
{ otp }, { otp },
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
); );
console.log('Otp verified.');
return response.data; return response.data;
} catch (error: any) { } catch (error: any) {
console.error('Error verifying OTP:', error.response?.data || error.message); console.error('Error verifying OTP:', error.response?.data || error.message);

View File

@@ -35,7 +35,7 @@ export default function Login() {
const [mobile, setMobile] = useState(""); const [mobile, setMobile] = useState("");
async function handleSendOtp(mobile?: string) { async function handleSendOtp(mobile?: string) {
console.log("hi mobile", mobile); // console.log("hi mobile", mobile);
if (!mobile) { if (!mobile) {
notifications.show({ notifications.show({
title: 'Error', title: 'Error',
@@ -45,7 +45,7 @@ export default function Login() {
return false; return false;
} }
try { try {
console.log(CIF); // console.log(CIF);
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({
@@ -186,7 +186,7 @@ export default function Login() {
}); });
const data = await response.json(); const data = await response.json();
console.log(data); // console.log(data);
// 1⃣ OTP Required // 1⃣ OTP Required
if (data.status === "OTP_REQUIRED" && response.status === 202) { if (data.status === "OTP_REQUIRED" && response.status === 202) {