fix: E mandate Login and logout page
This commit is contained in:
@@ -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,6 +207,7 @@ function LoginEmandate() {
|
||||
}
|
||||
}
|
||||
|
||||
if (data && mandateReqDoc && mndtType) {
|
||||
return (
|
||||
<Providers>
|
||||
{/* Main Screen */}
|
||||
@@ -420,6 +420,28 @@ function LoginEmandate() {
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
height: "100vh",
|
||||
backgroundColor: "#f8f9fa",
|
||||
}}
|
||||
>
|
||||
<Text c="red" fw={600} size="lg">
|
||||
⚠️ Required data not found
|
||||
</Text>
|
||||
<Text c="dimmed" size="sm">
|
||||
Please access this page through the correct eMandate link.
|
||||
</Text>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default function Login() {
|
||||
return (
|
||||
|
||||
@@ -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) {
|
||||
|
||||
30
src/app/eMandate/logout/page.module.css
Normal file
30
src/app/eMandate/logout/page.module.css
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
92
src/app/eMandate/logout/page.tsx
Normal file
92
src/app/eMandate/logout/page.tsx
Normal file
@@ -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 (
|
||||
<Providers>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: "#f8f9fa",
|
||||
width: "100%",
|
||||
minHeight: "100vh",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
{/* Header */}
|
||||
<Box className={styles.header} mt="md">
|
||||
<Image
|
||||
src={logo}
|
||||
component={NextImage}
|
||||
fit="contain"
|
||||
alt="ebanking"
|
||||
style={{ width: "60px", height: "auto" }}
|
||||
/>
|
||||
<Box className={styles["header-text"]}>
|
||||
<Title className={styles["desktop-text"]} order={4}>
|
||||
THE KANGRA CENTRAL CO-OPERATIVE BANK LTD.
|
||||
</Title>
|
||||
<Text className={styles["desktop-text"]} size="xs">
|
||||
Head Office: Dharmshala, District Kangra (H.P), Pin: 176215
|
||||
</Text>
|
||||
<Title className={styles["mobile-text"]} order={5}>
|
||||
THE KANGRA CENTRAL
|
||||
</Title>
|
||||
<Title className={styles["mobile-text"]} order={5}>
|
||||
CO-OPERATIVE BANK LTD.
|
||||
</Title>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Centered Message */}
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
flexGrow: 1,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Text c="green" fw={600} size="lg">
|
||||
✅ You have successfully logged out
|
||||
</Text>
|
||||
<Text c="dimmed" size="sm" mt="xs">
|
||||
Please access this eMandate login page through the correct eMandate link.
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<Box
|
||||
component="footer"
|
||||
style={{
|
||||
width: "100%",
|
||||
textAlign: "center",
|
||||
padding: "10px 0",
|
||||
fontSize: "14px",
|
||||
color: "#6c757d",
|
||||
}}
|
||||
>
|
||||
© 2025 KCC Bank. All rights reserved.
|
||||
</Box>
|
||||
</div>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user