"use client"; import React, { useState, useEffect, memo, useRef } from "react"; import { Text, Button, TextInput, PasswordInput, Title, Card, Group, Flex, Box, Image, Anchor, Tooltip } from "@mantine/core"; import { notifications } from "@mantine/notifications"; import { Providers } from "@/app/providers"; import { useRouter } from "next/navigation"; import NextImage from "next/image"; import logo from '@/app/image/logo1.jpg'; import frontPage from '@/app/image/ib_front.jpg'; import dynamic from 'next/dynamic'; import { generateCaptcha } from '@/app/captcha'; import { IconShieldLockFilled } from "@tabler/icons-react"; export default function Login() { const router = useRouter(); const [CIF, SetCIF] = useState(""); const [psw, SetPsw] = useState(""); const [captcha, setCaptcha] = useState(""); const [inputCaptcha, setInputCaptcha] = useState(""); const [isLogging, setIsLogging] = useState(false); const ClientCarousel = dynamic(() => import('./clientCarousel'), { ssr: false }); const headerRef = useRef(null); useEffect(() => { const loadCaptcha = async () => { const newCaptcha = await generateCaptcha(); setCaptcha(newCaptcha); }; loadCaptcha(); }, []); const regenerateCaptcha = () => { // setCaptcha(generateCaptcha()); const loadCaptcha = async () => { const newCaptcha = await generateCaptcha(); setCaptcha(newCaptcha); }; loadCaptcha(); setInputCaptcha(""); }; async function handleLogin(e: React.FormEvent) { e.preventDefault(); const onlyDigit = /^\d{11}$/; if (!onlyDigit.test(CIF)) { // setError('Input value must be 11 digit'); notifications.show({ withBorder: true, color: "red", title: "Invalid UserId", message: "UserID must be 11 digit", autoClose: 5000, }); return; } if (!inputCaptcha) { notifications.show({ withBorder: true, color: "red", title: "Invalid Captcha", message: "Please fill the Captcha filed", autoClose: 5000, }); return; } if (inputCaptcha !== captcha) { notifications.show({ withBorder: true, color: "red", title: "Captcha Error", message: "Please enter the correct captcha", autoClose: 5000, }); regenerateCaptcha(); return; } if (!CIF || !psw) { notifications.show({ withBorder: true, color: "red", title: "Invalid Input", message: "Please fill UserId and Password", autoClose: 5000, }); return; } try { const response = await fetch('api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ customerNo: CIF, password: psw, }), }); if (!response.ok) { notifications.show({ withBorder: true, color: "red", title: "Error", message: "Internal Server Error", autoClose: 5000, }); return; } const data = await response.json(); console.log(data); setIsLogging(true); if (response.ok) { console.log(data); const token = data.token; localStorage.setItem("access_token", token); if (data.FirstTimeLogin === true) { router.push("/SetPassword") } else { router.push("/home"); } } else { setIsLogging(false); notifications.show({ withBorder: true, color: "red", title: "Wrong User Id or Password", message: "Wrong User Id or Password", autoClose: 5000, }); } } catch (error: any) { notifications.show({ withBorder: true, color: "red", title: "Error", message: "Internal Server Error,Please try again Later", autoClose: 5000, }); return; } } useEffect(() => { const headerData = [ "THE KANGRA CENTRAL CO-OPERATIVE BANK LTD.", "कांगड़ा केन्द्रीय सहकारी बैंक सीमित", ]; let index = 0; const interval = setInterval(() => { index = (index + 1) % headerData.length; if (headerRef.current) { headerRef.current.textContent = headerData[index]; } }, 2000); return () => clearInterval(interval); }, []); return (
{/* Header */} ebanking THE KANGRA CENTRAL CO-OPERATIVE BANK LTD. Head Office : Dharmshala, District: Kangra(H.P), Pin: 176215 {/* */}
{/* 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
{ const input = e.currentTarget.value.replace(/\D/g, ""); if (input.length <= 11) SetCIF(input); }} withAsterisk /> SetPsw(e.currentTarget.value)} withAsterisk mt="sm" /> router.push("/ValidateUser")} > Forgot Password? {captcha} setInputCaptcha(e.currentTarget.value)} withAsterisk mt="sm" />
{/* Carousel and Notes */} <IconShieldLockFilled />Security Notes : When you Login, Your User Id and Password travels in an encrypted and highly secured mode. For more information on Products and Services, Please Visit http://www.kccb.in/ {/* Footer */} © 2025 KCC Bank. All rights reserved. |{" "} Disclaimer |{" "} Privacy Policy |{" "} Phishing |{" "} Security Tips |{" "} Grievances
); }