"use client"; import React, { useState, useEffect } from "react"; import { Text, Button, TextInput, PasswordInput, Title, Card, Group, Flex, Box, Image, Anchor, Stack, Container, rem, Grid } from "@mantine/core"; import { notifications } from "@mantine/notifications"; import { Providers } from "@/app/providers"; import { useRouter } from "next/navigation"; import NextImage from "next/image"; import myImage from '@/app/image/ebanking.jpg'; import changePwdImage from '@/app/image/changepw.png'; import dynamic from 'next/dynamic'; import CaptchaImage from './CaptchaImage'; function generateCaptcha(length = 6) { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; return Array.from({ length }, () => chars[Math.floor(Math.random() * chars.length)]).join(""); } export default function Login() { const router = useRouter(); const [error, setError] = useState(null); const [CIF, SetCIF] = useState(""); const [psw, SetPsw] = useState(""); const [captcha, setCaptcha] = useState(""); const [inputCaptcha, setInputCaptcha] = useState(""); const ClientCarousel = dynamic(() => import('./clientCarousel'), { ssr: false }); //const [captcha, setCaptcha] = useState(''); const [captchaInput, setCaptchaInput] = useState(''); const [captchaError, setCaptchaError] = useState(''); // const [isClient,SetIsClient] =useState(false); // useEffect(()=> SetIsClient(true),[]); // useEffect(() => { // setCaptcha(generateCaptcha()); // }, []); // const regenerateCaptcha = () => { // setCaptcha(generateCaptcha()); // setInputCaptcha(""); // }; useEffect(() => { generateCaptcha(); }, []); const generateCaptcha = () => { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let result = ''; for (let i = 0; i < 6; i++) { result += chars.charAt(Math.floor(Math.random() * chars.length)); } setCaptcha(result); setCaptchaInput(''); setCaptchaError(''); }; async function handleLogin(e: React.FormEvent) { e.preventDefault(); const onlyDigit = /^\d{11}$/; if (!onlyDigit.test(CIF)) { setError('Input value must be 11 digit'); } if (inputCaptcha !== captcha) { notifications.show({ withBorder: true, color: "red", title: "Captcha Error", message: "Please enter the correct captcha", autoClose: 5000, }); return; } if (CIF === "30022497139" && psw === "SecurePass123!") { const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30"; localStorage.setItem("customerNumber", CIF); localStorage.setItem("password", psw); localStorage.setItem("access_token", token); router.push("/home"); } else { // SetCIF(''); // SetPsw(''); // setCaptcha(''); notifications.show({ withBorder: true, color: "red", title: "Wrong User Id or Password", message: "Wrong User Id or Password", autoClose: 5000, }); } } return (
ebanking
{/*
ebanking
Change User Login Password


Note: Password will contains minimum one alphabet, one digit, one special symbol and total 8 charecters.
*/} Change Password Image Change Transaction Password
e.preventDefault()} onPaste={(e) => e.preventDefault()} onCut={(e) => e.preventDefault()} /> e.preventDefault()} onPaste={(e) => e.preventDefault()} onCut={(e) => e.preventDefault()} /> {/* */} {/* CAPTCHA */}
setCaptchaInput(e.currentTarget.value)} required /> {captchaError &&

{captchaError}

}


Note: Password will contains minimum one alphabet, one digit, one special symbol and total 8 charecters.
© 2025 KCC Bank. All rights reserved. {" "}
); }