From c2c87f8c7175bfb3b8e0252f4479d59d9a23a237 Mon Sep 17 00:00:00 2001 From: "tomosa.sarkar" Date: Wed, 12 Nov 2025 15:15:48 +0530 Subject: [PATCH] fix: E mandate Login and logout page --- src/app/eMandate/login/page/page.tsx | 370 +++++++++++++----------- src/app/eMandate/login/route.ts | 32 -- src/app/eMandate/logout/page.module.css | 30 ++ src/app/eMandate/logout/page.tsx | 92 ++++++ src/app/eMandate/mandate_page/page.tsx | 5 +- 5 files changed, 322 insertions(+), 207 deletions(-) create mode 100644 src/app/eMandate/logout/page.module.css create mode 100644 src/app/eMandate/logout/page.tsx diff --git a/src/app/eMandate/login/page/page.tsx b/src/app/eMandate/login/page/page.tsx index 44254a4..f6f564c 100644 --- a/src/app/eMandate/login/page/page.tsx +++ b/src/app/eMandate/login/page/page.tsx @@ -23,28 +23,28 @@ function LoginEmandate() { const data = searchParams.get("data"); const mandateReqDoc = searchParams.get("mandateReqDoc"); const mndtType = searchParams.get("mndtType"); - // const payload = searchParams.get("payload"); // useEffect(() => { - // if (payload) { - // try { - // const parsed = JSON.parse(decodeURIComponent(payload)); - // console.log("Received payload from SoftTech:", parsed); - // localStorage.setItem("Emandate_data", JSON.stringify(parsed)); - // } catch (e) { - // console.error("Failed to parse payload:", e); - // } + // if (data) { + // console.log("URL parameter 'data':", data); + // localStorage.setItem("Emendate_data", data); + // localStorage.setItem("Emendate_req_doc", mandateReqDoc || ""); + // localStorage.setItem("Emendate_type", mndtType || ""); // } - // }, [payload]); - + // }, [data]); useEffect(() => { - if (data) { - console.log("URL parameter 'data':", data); + if (data && mandateReqDoc && mndtType) { + console.log("eMandate parameters found"); localStorage.setItem("Emendate_data", data); - localStorage.setItem("Emendate_req_doc", mandateReqDoc || ""); - localStorage.setItem("Emendate_type", mndtType || ""); + localStorage.setItem("Emendate_req_doc", mandateReqDoc); + localStorage.setItem("Emendate_type", mndtType); + } else { + console.log("eMandate parameters missing — clearing localStorage"); + localStorage.removeItem("Emendate_data"); + localStorage.removeItem("Emendate_req_doc"); + localStorage.removeItem("Emendate_type"); } - }, [data]); + }, [data, mandateReqDoc, mndtType]); useEffect(() => { const loadCaptcha = async () => { @@ -54,7 +54,6 @@ function LoginEmandate() { loadCaptcha(); }, []); - const regenerateCaptcha = () => { // setCaptcha(generateCaptcha()); const loadCaptcha = async () => { @@ -208,47 +207,48 @@ function LoginEmandate() { } } - return ( - - {/* Main Screen */} -
- {/* Header */} + if (data && mandateReqDoc && mndtType) { + return ( + + {/* Main Screen */} +
+ {/* Header */} - - ebanking - - THE KANGRA CENTRAL CO-OPERATIVE BANK LTD. - Head Office: Dharmshala, District Kangra (H.P), Pin: 176215 - THE KANGRA CENTRAL - CO-OPERATIVE BANK LTD. + + ebanking + + THE KANGRA CENTRAL CO-OPERATIVE BANK LTD. + Head Office: Dharmshala, District Kangra (H.P), Pin: 176215 + THE KANGRA CENTRAL + CO-OPERATIVE BANK LTD. + - -
- {/* Movable text */} - - + {/* Movable text */} + - ⚠️ Always login to our Net Banking site directly or through Banks website. - ⚠️ Do not disclose your User Id and Password to any third party and keep Your User Id and Password strictly confidential. - ⚠️ KCC Bank never asks for User Id,Passwords and Pins through email or phone. - ⚠️ Be ware of Phishing mails with links to fake bank's websites asking for personal information are in circulation. - ⚠️ Please DO NOT Click on the links given in the emails asking for personal details like bank account number, user ID and password. - ⚠️ If you had shared your User Id and Password through such mails or links, please change your Password immediately. - ⚠️ Inform the Bank/branch in which your account is maintained for resetting your password. - - - + + - {/* Main */} - -
- ebanking -
- - + {/* Main */} + +
+ ebanking +
+ + +
+ + E-Mandate Login + + + { + const input = e.currentTarget.value.replace(/\D/g, ""); + if (input.length <= 11) SetCIF(input); + }} + withAsterisk + /> + SetPsw(e.currentTarget.value)} + withAsterisk + mt="sm" + /> + + + {captcha} + + + setInputCaptcha(e.currentTarget.value)} + withAsterisk + mt="sm" + /> + + +
+
+
+ + {/* Mobile layout */} + +
- + E-Mandate Login @@ -295,7 +353,9 @@ function LoginEmandate() { if (input.length <= 11) SetCIF(input); }} withAsterisk + mt="sm" /> + - - {captcha} - + + + {captcha} + + + +
-
- {/* Mobile layout */} - - -
- - E-Mandate Login - - - { - const input = e.currentTarget.value.replace(/\D/g, ""); - if (input.length <= 11) SetCIF(input); - }} - withAsterisk - mt="sm" - /> - - SetPsw(e.currentTarget.value)} - withAsterisk - mt="sm" - /> - - - - {captcha} - - - - - setInputCaptcha(e.currentTarget.value)} - withAsterisk - mt="sm" - /> - - - -
-
- - {/* Footer */} - - - © 2025 KCC Bank. All rights reserved. - - + {/* Footer */} + + + © 2025 KCC Bank. All rights reserved. + + +
+
+ ); + } + else { + return ( +
+ + ⚠️ Required data not found + + + Please access this page through the correct eMandate link. +
- - ); + ); + } } export default function Login() { diff --git a/src/app/eMandate/login/route.ts b/src/app/eMandate/login/route.ts index a21ffd6..aa69347 100644 --- a/src/app/eMandate/login/route.ts +++ b/src/app/eMandate/login/route.ts @@ -1,35 +1,3 @@ -// import { NextResponse } from "next/server"; -// export async function POST(req: Request) { -// try { -// const formData = await req.formData(); -// const data = formData.get("data"); -// const mandateReqDoc = formData.get("mandateReqDoc"); -// const mndtType = formData.get("mndtType"); -// // const { searchParams } = new URL(req.url); -// // const data = searchParams.get("data"); -// // const mandateReqDoc = searchParams.get("mandateReqDoc"); -// // const mndtType = searchParams.get("mndtType"); - -// console.log("Received from SoftTech:", { data, mandateReqDoc, mndtType }); -// if (!data) { -// return NextResponse.json({ error: "Missing data" }, { status: 400 }); -// } -// const encodedData = String(data); -// const forwardedHost = -// req.headers.get("x-forwarded-host") || "netbankingtest.kccb.in"; -// const forwardedProto = req.headers.get("x-forwarded-proto") || "https"; - -// const redirectUrl = `${forwardedProto}://${forwardedHost}/eMandate/login/page?data=${encodedData}`; - -// console.log("Redirecting to:", redirectUrl); -// return NextResponse.redirect(redirectUrl); - -// } catch (error) { -// console.error("Error handling POST:", error); -// return NextResponse.json({ error: "Internal Server Error" }, { status: 500 }); -// } -// } - import { NextResponse } from "next/server"; export async function POST(req: Request) { diff --git a/src/app/eMandate/logout/page.module.css b/src/app/eMandate/logout/page.module.css new file mode 100644 index 0000000..d809df9 --- /dev/null +++ b/src/app/eMandate/logout/page.module.css @@ -0,0 +1,30 @@ +/* Header */ +.header { + position: fixed; + top: 0; + left: 0; + width: 100%; + z-index: 100; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0.5rem 1rem; + background: linear-gradient(15deg, rgba(10, 114, 40, 1) 55%, rgba(101, 101, 184, 1) 100%); +} + +.header-text { + flex: 1; +} + +/* Desktop header text */ +.desktop-text { + color: white; +} + +.mobile-text { + color: white; + display: none; +} + + + diff --git a/src/app/eMandate/logout/page.tsx b/src/app/eMandate/logout/page.tsx new file mode 100644 index 0000000..2976dac --- /dev/null +++ b/src/app/eMandate/logout/page.tsx @@ -0,0 +1,92 @@ +"use client"; +import { Text, Title, Box, Image } from "@mantine/core"; +import NextImage from "next/image"; +import logo from "@/app/image/logo1.jpg"; +import { Providers } from "@/app/providers"; +import styles from "./page.module.css"; +import { useEffect } from "react"; + +export default function Logout() { + useEffect(() => { + localStorage.removeItem("mandate_token"); + localStorage.removeItem("user_name"); + localStorage.removeItem("userMobNo"); + localStorage.removeItem("Emendate_data"); + localStorage.removeItem("Emendate_req_doc"); + localStorage.removeItem("Emendate_type"); + }, []); + + return ( + +
+ {/* Header */} + + ebanking + + + THE KANGRA CENTRAL CO-OPERATIVE BANK LTD. + + + Head Office: Dharmshala, District Kangra (H.P), Pin: 176215 + + + THE KANGRA CENTRAL + + + CO-OPERATIVE BANK LTD. + + + + + {/* Centered Message */} +
+ + ✅ You have successfully logged out + + + Please access this eMandate login page through the correct eMandate link. + +
+ + {/* Footer */} + + © 2025 KCC Bank. All rights reserved. + +
+
+ ); +} diff --git a/src/app/eMandate/mandate_page/page.tsx b/src/app/eMandate/mandate_page/page.tsx index 0da4938..60b5b82 100644 --- a/src/app/eMandate/mandate_page/page.tsx +++ b/src/app/eMandate/mandate_page/page.tsx @@ -117,7 +117,10 @@ export default function MandatePage() { localStorage.removeItem("mandate_token"); localStorage.removeItem("user_name"); localStorage.removeItem("userMobNo"); - router.push("/eMandate/login"); + localStorage.removeItem("Emendate_data"); + localStorage.removeItem("Emendate_req_doc"); + localStorage.removeItem("Emendate_type"); + router.push("/eMandate/logout"); }; const handleFetchUserName = async () => {