diff --git a/src/app/(main)/funds_transfer/add_beneficiary/page.tsx b/src/app/(main)/funds_transfer/add_beneficiary/page.tsx index dd778bc..68a5a3e 100644 --- a/src/app/(main)/funds_transfer/add_beneficiary/page.tsx +++ b/src/app/(main)/funds_transfer/add_beneficiary/page.tsx @@ -5,7 +5,7 @@ import {TextInput,Button,Select,Title,Paper,Grid,Group,Radio,Text,PasswordInput} import { useRouter } from "next/navigation"; import { notifications } from '@mantine/notifications'; import AddBeneficiaryOthers from './addBeneficiaryOthers'; -import { generateOTP } from '@/app/OTPGenerator'; + const bankOptions = [ { value: 'KCCB', label: 'KCCB - The Kangra Central Co-Operative Bank' }, @@ -30,7 +30,6 @@ const AddBeneficiary: React.FC = () => { const getFullMaskedAccount = (acc: string) => { return "X".repeat(acc.length); }; const handleGenerateOtp = async () => { - // const value = await generateOTP(6); const value = "123456"; // Or generate a random OTP setGeneratedOtp(value); return value; diff --git a/src/app/(main)/funds_transfer/outside_quick_pay.tsx b/src/app/(main)/funds_transfer/outside_quick_pay.tsx index 4d8128d..d06be0c 100644 --- a/src/app/(main)/funds_transfer/outside_quick_pay.tsx +++ b/src/app/(main)/funds_transfer/outside_quick_pay.tsx @@ -1,451 +1,451 @@ -"use client"; +// "use client"; -import React, { useEffect, useRef, useState } from "react"; -import { Button, Group, Modal, Paper, Radio, ScrollArea, Select, Stack, Text, TextInput, Title } from "@mantine/core"; -import { notifications } from "@mantine/notifications"; -import { useRouter } from "next/navigation"; -import { generateOTP } from '@/app/OTPGenerator'; +// import React, { useEffect, useRef, useState } from "react"; +// import { Button, Group, Modal, Paper, Radio, ScrollArea, Select, Stack, Text, TextInput, Title } from "@mantine/core"; +// import { notifications } from "@mantine/notifications"; +// import { useRouter } from "next/navigation"; -interface accountData { - stAccountNo: string; - stAccountType: string; - stAvailableBalance: string; - custname: string; -} -export default function OutsideQuickPay() { - const router = useRouter(); - const [authorized, setAuthorized] = useState(null); - const [accountData, setAccountData] = useState([]); - const [selectedAccNo, setSelectedAccNo] = useState(null); - const [beneficiaryAcc, setBeneficiaryAcc] = useState(""); - const [showPayeeAcc, setShowPayeeAcc] = useState(true); - const [confirmBeneficiaryAcc, setConfirmBeneficiaryAcc] = useState(""); - const [paymentMode, setPaymentMode] = useState('IMPS'); - const [beneficiaryType, setBeneficiaryType] = useState(null); - const [isVisibilityLocked, setIsVisibilityLocked] = useState(false); - const [amount, setAmount] = useState(""); - const [remarks, setRemarks] = useState(""); - const [showConfirmModel, setConfirmModel] = useState(false); - const [showTxnPassword, setShowTxnPassword] = useState(false); - const [txnPassword, setTxnPassword] = useState(""); - const [isSubmitting, setIsSubmitting] = useState(false); - const [validationStatus, setValidationStatus] = useState<"success" | "error" | null>(null); - const [beneficiaryName, setBeneficiaryName] = useState(null); - const [showOtpField, setShowOtpField] = useState(false); - const [otp, setOtp] = useState(""); - const [generateOtp, setGenerateOtp] = useState(""); +// interface accountData { +// stAccountNo: string; +// stAccountType: string; +// stAvailableBalance: string; +// custname: string; +// } - async function handleGenerateOtp() { - // const value = await generateOTP(6); - const value = "123456"; - setGenerateOtp(value); - return value; - } +// export default function OutsideQuickPay() { +// const router = useRouter(); +// const [authorized, setAuthorized] = useState(null); +// const [accountData, setAccountData] = useState([]); +// const [selectedAccNo, setSelectedAccNo] = useState(null); +// const [beneficiaryAcc, setBeneficiaryAcc] = useState(""); +// const [showPayeeAcc, setShowPayeeAcc] = useState(true); +// const [confirmBeneficiaryAcc, setConfirmBeneficiaryAcc] = useState(""); +// const [paymentMode, setPaymentMode] = useState('IMPS'); +// const [beneficiaryType, setBeneficiaryType] = useState(null); +// const [isVisibilityLocked, setIsVisibilityLocked] = useState(false); +// const [amount, setAmount] = useState(""); +// const [remarks, setRemarks] = useState(""); +// const [showConfirmModel, setConfirmModel] = useState(false); +// const [showTxnPassword, setShowTxnPassword] = useState(false); +// const [txnPassword, setTxnPassword] = useState(""); +// const [isSubmitting, setIsSubmitting] = useState(false); +// const [validationStatus, setValidationStatus] = useState<"success" | "error" | null>(null); +// const [beneficiaryName, setBeneficiaryName] = useState(null); +// const [showOtpField, setShowOtpField] = useState(false); +// const [otp, setOtp] = useState(""); +// const [generateOtp, setGenerateOtp] = useState(""); - const selectedAccount = accountData.find((acc) => acc.stAccountNo === selectedAccNo); - const getFullMaskedAccount = (acc: string) => { return "X".repeat(acc.length); }; +// async function handleGenerateOtp() { +// // const value = await generateOTP(6); +// const value = "123456"; +// setGenerateOtp(value); +// return value; +// } - const accountOptions = accountData.map((acc) => ({ - value: acc.stAccountNo, - label: `${acc.stAccountNo} (${acc.stAccountType})`, - })); +// const selectedAccount = accountData.find((acc) => acc.stAccountNo === selectedAccNo); +// const getFullMaskedAccount = (acc: string) => { return "X".repeat(acc.length); }; - const FetchAccountDetails = async () => { - try { - const token = localStorage.getItem("access_token"); - const response = await fetch("/api/customer", { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${token}`, - }, - }); - const data = await response.json(); - if (response.ok && Array.isArray(data)) { - const filterSAaccount = data.filter((acc) => ['SA', 'SB'].includes(acc.stAccountType)); - setAccountData(filterSAaccount); - } - } catch { - notifications.show({ - withBorder: true, - color: "red", - title: "Please try again later", - message: "Unable to Fetch, Please try again later", - autoClose: 5000, - }); - } - }; +// const accountOptions = accountData.map((acc) => ({ +// value: acc.stAccountNo, +// label: `${acc.stAccountNo} (${acc.stAccountType})`, +// })); - useEffect(() => { - const token = localStorage.getItem("access_token"); - if (!token) { - setAuthorized(false); - router.push("/login"); - } else { - setAuthorized(true); - } - }, []); +// const FetchAccountDetails = async () => { +// try { +// const token = localStorage.getItem("access_token"); +// const response = await fetch("/api/customer", { +// method: "GET", +// headers: { +// "Content-Type": "application/json", +// Authorization: `Bearer ${token}`, +// }, +// }); +// const data = await response.json(); +// if (response.ok && Array.isArray(data)) { +// const filterSAaccount = data.filter((acc) => ['SA', 'SB'].includes(acc.stAccountType)); +// setAccountData(filterSAaccount); +// } +// } catch { +// notifications.show({ +// withBorder: true, +// color: "red", +// title: "Please try again later", +// message: "Unable to Fetch, Please try again later", +// autoClose: 5000, +// }); +// } +// }; - useEffect(() => { - if (authorized) { - FetchAccountDetails(); - } - }, [authorized]); +// useEffect(() => { +// const token = localStorage.getItem("access_token"); +// if (!token) { +// setAuthorized(false); +// router.push("/login"); +// } else { +// setAuthorized(true); +// } +// }, []); - async function handleValidate() { - if (!selectedAccNo || !beneficiaryAcc || - !confirmBeneficiaryAcc - ) { - notifications.show({ - title: "Validation Error", - message: "Please fill debit account, beneficiary account number and confirm beneficiary account number", - color: "red", - }); - return; - } - if (beneficiaryAcc.length < 10 || beneficiaryAcc.length > 17) { - notifications.show({ - title: "Invalid Account Number", - message: "Please Enter valid account Number", - color: "red", - }); - return; - } - if (beneficiaryAcc !== confirmBeneficiaryAcc) { - notifications.show({ - title: "Mismatch", - message: "Beneficiary account numbers do not match", - color: "red", - }); - return; - } +// useEffect(() => { +// if (authorized) { +// FetchAccountDetails(); +// } +// }, [authorized]); - try { - const token = localStorage.getItem("access_token"); - // Need to change with proper API - const response = await fetch(`/api/beneficiary/validate/within-bank?accountNumber=${beneficiaryAcc}`, { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${token}`, - }, - }); - const data = await response.json(); +// async function handleValidate() { +// if (!selectedAccNo || !beneficiaryAcc || +// !confirmBeneficiaryAcc +// ) { +// notifications.show({ +// title: "Validation Error", +// message: "Please fill debit account, beneficiary account number and confirm beneficiary account number", +// color: "red", +// }); +// return; +// } +// if (beneficiaryAcc.length < 10 || beneficiaryAcc.length > 17) { +// notifications.show({ +// title: "Invalid Account Number", +// message: "Please Enter valid account Number", +// color: "red", +// }); +// return; +// } +// if (beneficiaryAcc !== confirmBeneficiaryAcc) { +// notifications.show({ +// title: "Mismatch", +// message: "Beneficiary account numbers do not match", +// color: "red", +// }); +// return; +// } - if (response.ok && data?.name) { - setBeneficiaryName(data.name); - setValidationStatus("success"); - setIsVisibilityLocked(true); - } else { - setBeneficiaryName("Invalid account number"); - setValidationStatus("error"); - setBeneficiaryAcc(""); - setConfirmBeneficiaryAcc(""); - } - } catch { - setBeneficiaryName("Invalid account number"); - setValidationStatus("error"); - } - }; +// try { +// const token = localStorage.getItem("access_token"); +// // Need to change with proper API +// const response = await fetch(`/api/beneficiary/validate/within-bank?accountNumber=${beneficiaryAcc}`, { +// method: "GET", +// headers: { +// "Content-Type": "application/json", +// Authorization: `Bearer ${token}`, +// }, +// }); +// const data = await response.json(); - async function handleProceed() { - if (!selectedAccNo || !beneficiaryAcc || !confirmBeneficiaryAcc || !paymentMode || !beneficiaryType || !amount || !remarks) { - notifications.show({ - title: "Validation Error", - message: "Please fill all required fields", - color: "red", - }); - return; - } +// if (response.ok && data?.name) { +// setBeneficiaryName(data.name); +// setValidationStatus("success"); +// setIsVisibilityLocked(true); +// } else { +// setBeneficiaryName("Invalid account number"); +// setValidationStatus("error"); +// setBeneficiaryAcc(""); +// setConfirmBeneficiaryAcc(""); +// } +// } catch { +// setBeneficiaryName("Invalid account number"); +// setValidationStatus("error"); +// } +// }; - if (validationStatus !== "success") { - notifications.show({ - title: "Validation Required", - message: "Please validate beneficiary before proceeding", - color: "red", - }); - return; - } - if (parseInt(amount) <= 0) { - notifications.show({ - title: "Invalid amount", - message: "Amount Can not be less than Zero", - color: "red", - }); - return; +// async function handleProceed() { +// if (!selectedAccNo || !beneficiaryAcc || !confirmBeneficiaryAcc || !paymentMode || !beneficiaryType || !amount || !remarks) { +// notifications.show({ +// title: "Validation Error", +// message: "Please fill all required fields", +// color: "red", +// }); +// return; +// } - } +// if (validationStatus !== "success") { +// notifications.show({ +// title: "Validation Required", +// message: "Please validate beneficiary before proceeding", +// color: "red", +// }); +// return; +// } +// if (parseInt(amount) <= 0) { +// notifications.show({ +// title: "Invalid amount", +// message: "Amount Can not be less than Zero", +// color: "red", +// }); +// return; - if (!showOtpField && !showTxnPassword && !showConfirmModel) { - setConfirmModel(true); - return; - } +// } - if (!otp) { - notifications.show({ - title: "Enter OTP", - message: "Please enter the OTP", - color: "red", - }); - return; - } - if (otp !== generateOtp) { - notifications.show({ - title: "Invalid OTP", - message: "The OTP entered does not match", - color: "red", - }); - return; - } +// if (!showOtpField && !showTxnPassword && !showConfirmModel) { +// setConfirmModel(true); +// return; +// } - if (!showTxnPassword) { - setShowTxnPassword(true); - return; - } +// if (!otp) { +// notifications.show({ +// title: "Enter OTP", +// message: "Please enter the OTP", +// color: "red", +// }); +// return; +// } +// if (otp !== generateOtp) { +// notifications.show({ +// title: "Invalid OTP", +// message: "The OTP entered does not match", +// color: "red", +// }); +// return; +// } - if (!txnPassword) { - notifications.show({ - title: "Missing field", - message: "Please Enter Transaction Password Before Proceed", - color: "red", - }); - return; - } - try { - setIsSubmitting(true); - const token = localStorage.getItem("access_token"); - // Need to change with proper API - const res = await fetch("/api/payment/transfer", { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${token}`, - }, - body: JSON.stringify({ - fromAccount: selectedAccNo, - toAccount: beneficiaryAcc, - toAccountType: beneficiaryType, - amount: amount, - narration: remarks, - tpassword: txnPassword, - }), - }); - const result = await res.json(); - if (res.ok) { - notifications.show({ - title: "Success", - message: "Transaction successful", - color: "green", - }); - setShowTxnPassword(false); - setTxnPassword(""); - setShowOtpField(false); - setOtp(""); - setValidationStatus(null); - setBeneficiaryName(null); - } else { - notifications.show({ - title: "Error", - message: result?.error || "Transaction failed", - color: "red", - }); - } - } catch { - notifications.show({ - title: "Error", - message: "Something went wrong", - color: "red", - }); - } finally { - setIsSubmitting(false); - } - }; +// if (!showTxnPassword) { +// setShowTxnPassword(true); +// return; +// } - if (!authorized) return null; +// if (!txnPassword) { +// notifications.show({ +// title: "Missing field", +// message: "Please Enter Transaction Password Before Proceed", +// color: "red", +// }); +// return; +// } +// try { +// setIsSubmitting(true); +// const token = localStorage.getItem("access_token"); +// // Need to change with proper API +// const res = await fetch("/api/payment/transfer", { +// method: "POST", +// headers: { +// "Content-Type": "application/json", +// Authorization: `Bearer ${token}`, +// }, +// body: JSON.stringify({ +// fromAccount: selectedAccNo, +// toAccount: beneficiaryAcc, +// toAccountType: beneficiaryType, +// amount: amount, +// narration: remarks, +// tpassword: txnPassword, +// }), +// }); +// const result = await res.json(); +// if (res.ok) { +// notifications.show({ +// title: "Success", +// message: "Transaction successful", +// color: "green", +// }); +// setShowTxnPassword(false); +// setTxnPassword(""); +// setShowOtpField(false); +// setOtp(""); +// setValidationStatus(null); +// setBeneficiaryName(null); +// } else { +// notifications.show({ +// title: "Error", +// message: result?.error || "Transaction failed", +// color: "red", +// }); +// } +// } catch { +// notifications.show({ +// title: "Error", +// message: "Something went wrong", +// color: "red", +// }); +// } finally { +// setIsSubmitting(false); +// } +// }; - return ( - <> - setConfirmModel(false)} - // title="Confirm Transaction" - centered - > - - Confirm Transaction - Debit Account: {selectedAccNo} - Payee Account: {beneficiaryAcc} - Payee Name: {beneficiaryName} - Amount: ₹ {amount} - Remarks: {remarks} - - - - - - - {/* main content */} -
- - - +// { +// const value = e.currentTarget.value; +// if (/^\d*$/.test(value)) { +// setBeneficiaryAcc(value); +// setShowPayeeAcc(true); +// } +// }} +// onBlur={() => setShowPayeeAcc(false)} +// onFocus={() => setShowPayeeAcc(true)} +// withAsterisk +// readOnly={isVisibilityLocked} +// /> - - setRemarks(e.currentTarget.value)} - withAsterisk - readOnly={showOtpField} - /> - - - {showOtpField && ( - setOtp(e.currentTarget.value)} - withAsterisk - disabled={showTxnPassword} - /> - )} - {showTxnPassword && ( - setTxnPassword(e.currentTarget.value)} - withAsterisk - /> - )} - +// setAmount(e.currentTarget.value)} +// error={ +// selectedAccount && Number(amount) > Number(selectedAccount.stAvailableBalance) ? +// "Amount exceeds available balance" : false} +// withAsterisk +// readOnly={showOtpField} +// /> - - - - - -
- - ); -} +// setRemarks(e.currentTarget.value)} +// withAsterisk +// readOnly={showOtpField} +// /> +// +// +// {showOtpField && ( +// setOtp(e.currentTarget.value)} +// withAsterisk +// disabled={showTxnPassword} +// /> +// )} +// {showTxnPassword && ( +// setTxnPassword(e.currentTarget.value)} +// withAsterisk +// /> +// )} +// + +// +// +// +// +// +// +// +// ); +// } diff --git a/src/app/(main)/funds_transfer/page.tsx b/src/app/(main)/funds_transfer/page.tsx index f2b49f0..2ad2b74 100644 --- a/src/app/(main)/funds_transfer/page.tsx +++ b/src/app/(main)/funds_transfer/page.tsx @@ -4,8 +4,6 @@ import React, { useEffect, useRef, useState } from "react"; import { Button, Group, Modal, Paper, PasswordInput, Radio, ScrollArea, Select, Stack, Text, TextInput, Title } from "@mantine/core"; import { notifications } from "@mantine/notifications"; import { useRouter } from "next/navigation"; -import { generateOTP } from '@/app/OTPGenerator'; -import OutsideQuickPay from "./outside_quick_pay"; import { IconRefresh } from "@tabler/icons-react"; import Image from "next/image"; import img from '@/app/image/logo1.jpg' @@ -20,7 +18,6 @@ interface accountData { export default function QuickPay() { const router = useRouter(); - // const [bankType, setBankType] = useState("own"); const [authorized, setAuthorized] = useState(null); const [accountData, setAccountData] = useState([]); const [selectedAccNo, setSelectedAccNo] = useState(null); @@ -237,14 +234,6 @@ export default function QuickPay() { }); return; } - // if (otp !== generateOtp) { - // notifications.show({ - // title: "Invalid OTP", - // message: "The OTP entered does not match", - // color: "red", - // }); - // return; - // } const verified = await handleVerifyOtp(); if (!verified) { notifications.show({ @@ -564,11 +553,6 @@ export default function QuickPay() { - {/* ) : ( -
- -
- )} */} ); diff --git a/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx b/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx index dccfcfe..3088e72 100644 --- a/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx +++ b/src/app/(main)/funds_transfer/send_beneficiary/sendBeneficiaryOthers.tsx @@ -256,22 +256,6 @@ export default function SendToBeneficiaryOthers() { return; } - // if (!otp) { - // notifications.show({ - // title: "Enter OTP", - // message: "Please enter the OTP", - // color: "red", - // }); - // return; - // } - // if (otp !== generateOtp) { - // notifications.show({ - // title: "Invalid OTP", - // message: "The OTP entered does not match", - // color: "red", - // }); - // return; - // } if (showOtpField && !showTxnPassword) { if (!otp) { notifications.show({ diff --git a/src/app/OTPGenerator.ts b/src/app/OTPGenerator.ts deleted file mode 100644 index 0fff599..0000000 --- a/src/app/OTPGenerator.ts +++ /dev/null @@ -1,10 +0,0 @@ -// export function generateOTP(length: number) { -// const digits = '0123456789'; -// let otp = ''; -// otp += digits[Math.floor(Math.random() * 9)+1]; //first digit cannot be zero -// for (let i = 1; i < length; i++) { -// otp += digits[Math.floor(Math.random() * digits.length)]; -// } -// // console.log("OTP generate :",otp); -// return otp; -// } \ No newline at end of file diff --git a/src/app/SetPassword/page.tsx b/src/app/SetPassword/page.tsx index 110addd..9d40db4 100644 --- a/src/app/SetPassword/page.tsx +++ b/src/app/SetPassword/page.tsx @@ -9,7 +9,6 @@ import logo from '@/app/image/logo1.jpg'; import changePwdImage from '@/app/image/set_log_pass.jpg'; import { IconLock, IconLogout, IconRefresh } from '@tabler/icons-react'; import { generateCaptcha } from '@/app/captcha'; -import { generateOTP } from "../OTPGenerator"; import { sendOtp, verifyOtp } from "../_util/otp"; //const [showOtpField, setShowOtpField] = useState(false); diff --git a/src/app/SetTxn/page.tsx b/src/app/SetTxn/page.tsx index 89bef69..a973f97 100644 --- a/src/app/SetTxn/page.tsx +++ b/src/app/SetTxn/page.tsx @@ -67,7 +67,6 @@ export default function SetTransactionPwd() { } async function handleGenerateOtp() { - // const value = await generateOTP(6); const value = "123456"; setGenerateOtp(value); setCountdown(60); diff --git a/src/app/ValidateUser/page.tsx b/src/app/ValidateUser/page.tsx index 410c52c..a4feaa7 100644 --- a/src/app/ValidateUser/page.tsx +++ b/src/app/ValidateUser/page.tsx @@ -7,7 +7,7 @@ import NextImage from "next/image"; import logo from '@/app/image/logo1.jpg'; import changePwdImage from '@/app/image/changepw.png'; import { useRouter } from "next/navigation"; -import { generateOTP } from '@/app/OTPGenerator'; + export default function ValidateUser() { const router = useRouter(); @@ -24,7 +24,6 @@ export default function ValidateUser() { { cif: "11122233344", mobile: "9998887776" }, ]; async function handleGenerateOtp() { - // const value = await generateOTP(6); const value = "123456"; setGenerateOtp(value); return value;