diff --git a/src/app/(main)/funds_transfer/send_beneficiary/page.tsx b/src/app/(main)/funds_transfer/send_beneficiary/page.tsx index a18a8c7..775c239 100644 --- a/src/app/(main)/funds_transfer/send_beneficiary/page.tsx +++ b/src/app/(main)/funds_transfer/send_beneficiary/page.tsx @@ -14,7 +14,7 @@ interface accountData { custname: string; } -export const MockBeneficiaryData = +const MockBeneficiaryData = [ { 'stBankName': 'Kangra Central Co-operative Bank', diff --git a/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx b/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx index 38b124a..b33d04e 100644 --- a/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx +++ b/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx @@ -5,7 +5,6 @@ import { Button, Group, Modal, Paper, Radio, ScrollArea, Select, Stack, Text, Te import { notifications } from "@mantine/notifications"; import { useRouter } from "next/navigation"; import { generateOTP } from '@/app/OTPGenerator'; -import { MockBeneficiaryData } from './page'; interface accountData { stAccountNo: string; @@ -13,6 +12,37 @@ interface accountData { stAvailableBalance: string; custname: string; } +const MockBeneficiaryData = + [ + { + 'stBankName': 'Kangra Central Co-operative Bank', + 'stBenAccountNo': '50077736845', + 'stBenName': 'RAJAT MAHARANA', + }, + { + 'stBankName': 'Kangra Central Co-operative Bank', + 'stBenAccountNo': '50077742351', + 'stBenName': 'RAJAT MAHARANA', + }, + { + 'stBankName': 'Kangra Central Co-operative Bank', + 'stBenAccountNo': '20002076570', + 'stBenName': 'Mr. PUSHKAR . SHARMA', + }, + { + 'stBankName': 'State Bank of India', + 'stBenAccountNo': '50077742361', + 'stIFSC': 'SBIN0004567', + 'stBenName': 'Sachin Sharma', + }, + { + 'stBankName': 'ICICI', + 'stBenAccountNo': '90088842361', + 'stIFSC': 'ICICI0004567', + 'stBenName': 'Eshika Paul', + }, + ] + export default function SendToBeneficiaryOthers() { const router = useRouter(); diff --git a/src/app/(main)/settings/change_login_password/page.tsx b/src/app/(main)/settings/change_login_password/page.tsx new file mode 100644 index 0000000..7ed1335 --- /dev/null +++ b/src/app/(main)/settings/change_login_password/page.tsx @@ -0,0 +1,235 @@ +"use client"; + +import React, { useEffect, useState } from "react"; +import { + TextInput, + PasswordInput, + Button, + Title, + Paper, + Box, + Text, + Group, + Grid, +} from "@mantine/core"; +import { notifications } from "@mantine/notifications"; +import { IconEye, IconEyeOff, IconLock } from "@tabler/icons-react"; +import CaptchaImage from "@/app/SetPassword/CaptchaImage"; +import { generateCaptcha } from "@/app/captcha"; + +const ChangePassword: React.FC = () => { + const [oldPassword, setOldPassword] = useState(""); + const [newPassword, setNewPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); + const [captcha, setCaptcha] = useState(""); + const [showOld, setShowOld] = useState(false); + const [showNew, setShowNew] = useState(false); + const [showConfirm, setShowConfirm] = useState(false); + // const [captchaCode] = useState("X7pK9"); + const [inputCaptcha, setInputCaptcha] = useState(""); + const [captchaInput, setCaptchaInput] = useState(''); + const [captchaError, setCaptchaError] = useState(''); + const [passwordHistory] = useState(["Pass@1234", "OldPass@123", "MyPass#2023"]); + const icon = ; + + + 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(""); + }; + + + + + const validatePasswordPolicy = (password: string) => { + return /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[!@#$%^&*])[A-Za-z\d!@#$%^&*]{8,}$/.test(password); + }; + + const handleSubmit = () => { + // 1. Check all mandatory fields + if (!oldPassword || !newPassword || !confirmPassword || !captcha) { + notifications.show({ + title: "Missing Field", + message: "Please fill all mandatory fields.", + color: "red", + }); + return; + } + + // 2. Validate old password (simulate real check) + const actualOldPassword = "OldPass@123"; // Simulated stored password + if (oldPassword !== actualOldPassword) { + notifications.show({ + title: "Old Password Incorrect", + message: "Entered old password does not match.", + color: "red", + }); + return; + } + + // 3. New password validation + if (!validatePasswordPolicy(newPassword)) { + notifications.show({ + title: "Invalid Password", + message: + "Password must be at least 8 characters and contain alphanumeric and special characters.", + color: "red", + }); + return; + } + + if (passwordHistory.includes(newPassword)) { + notifications.show({ + title: "Password Reused", + message: "New password must be different from the last 3 passwords.", + color: "red", + }); + return; + } + + // 4. Confirm password check + if (newPassword !== confirmPassword) { + notifications.show({ + title: "Password Mismatch", + message: "Confirm password does not match new password.", + color: "red", + }); + return; + } + + + // else if (captchaInput !== captcha) { + // setCaptchaError("Incorrect CAPTCHA."); + // return; + // } + // // Success + // notifications.show({ + // title: "Success", + // message: "Your password has been reset successfully.", + // color: "green", + // }); + + if (captchaInput !== captcha) { + setCaptchaError("Incorrect CAPTCHA."); + return; + } + + // ✅ Clear error if CAPTCHA is correct + setCaptchaError(""); + + // Success + notifications.show({ + title: "Success", + message: "Your password has been reset successfully.", + color: "green", + }); + + }; + + return ( + + + + Change Login Password + + + {/* Scrollable form section */} +
+ setOldPassword(e.currentTarget.value)} + visible={showOld} + onVisibilityChange={setShowOld} + required + mb="xs" + /> + + setNewPassword(e.currentTarget.value)} + visible={showNew} + onVisibilityChange={setShowNew} + required + mb="xs" + /> + + setConfirmPassword(e.currentTarget.value)} + visible={showConfirm} + onVisibilityChange={setShowConfirm} + required + rightSection={icon} + mb="sm" + + onCopy={(e) => e.preventDefault()} + onPaste={(e) => e.preventDefault()} + onCut={(e) => e.preventDefault()} + /> + + {/* CAPTCHA */} +
+ + +
+ {/* CAPTCHA Image */} +
+ +
+ + {/* Refresh Button */} + + + {/* TextInput */} + setCaptchaInput(e.currentTarget.value)} + required + style={{ height: 30, flexGrow: 1 }} + /> +
+ +

+ {captchaError || '\u00A0'} +

+
+
+ + {/* Fixed Save Button */} + + +
+ + ); +}; + +export default ChangePassword; diff --git a/src/app/SetPassword/page.tsx b/src/app/SetPassword/page.tsx index 7d547dc..1aec987 100644 --- a/src/app/SetPassword/page.tsx +++ b/src/app/SetPassword/page.tsx @@ -187,15 +187,7 @@ export default function SetLoginPwd() { value={confirmPassword} onChange={(e) => setConfirmPassword(e.currentTarget.value)} type={confirmVisible ? 'text' : 'password'} - // rightSection={ - // - // } + onCopy={(e) => e.preventDefault()} onPaste={(e) => e.preventDefault()} onCut={(e) => e.preventDefault()} @@ -215,7 +207,7 @@ export default function SetLoginPwd() { onChange={(e) => setCaptchaInput(e.currentTarget.value)} required /> - {captchaError &&

{captchaError}

} + {captchaError &&

{captchaError}

}