From 917a17d826ace6e8858159c3e3db9ff3d055bb81 Mon Sep 17 00:00:00 2001 From: "nabanita.jana" Date: Thu, 9 Oct 2025 12:46:14 +0530 Subject: [PATCH] feat: confirmation popup for Action Icon in view Beneficiary, --- .../add_beneficiary/addBeneficiaryOthers.tsx | 8 +-- .../funds_transfer/view_beneficiary/page.tsx | 70 ++++++++++++++++++- src/app/ChangePassword/page.tsx | 4 ++ 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/src/app/(main)/funds_transfer/add_beneficiary/addBeneficiaryOthers.tsx b/src/app/(main)/funds_transfer/add_beneficiary/addBeneficiaryOthers.tsx index 4c0f46a..e4eef5e 100644 --- a/src/app/(main)/funds_transfer/add_beneficiary/addBeneficiaryOthers.tsx +++ b/src/app/(main)/funds_transfer/add_beneficiary/addBeneficiaryOthers.tsx @@ -390,9 +390,9 @@ export default function AddBeneficiaryOthers() { maxLength={17} readOnly={isVisibilityLocked} withAsterisk - // onCopy={(e) => e.preventDefault()} - // onPaste={(e) => e.preventDefault()} - // onCut={(e) => e.preventDefault()} + onCopy={(e) => e.preventDefault()} + onPaste={(e) => e.preventDefault()} + onCut={(e) => e.preventDefault()} /> {validationStatus === "error" && ( @@ -454,7 +454,7 @@ export default function AddBeneficiaryOthers() { maxLength={6} disabled={otpVerified} withAsterisk - style={{ flex: 1 }} + style={{ flex: 1 }} /> {!otpVerified && ( diff --git a/src/app/(main)/funds_transfer/view_beneficiary/page.tsx b/src/app/(main)/funds_transfer/view_beneficiary/page.tsx index d9cba1b..3b4628e 100644 --- a/src/app/(main)/funds_transfer/view_beneficiary/page.tsx +++ b/src/app/(main)/funds_transfer/view_beneficiary/page.tsx @@ -1,7 +1,7 @@ "use client"; import React, { useEffect, useState } from "react"; -import { Center, Group, Loader, Paper, ScrollArea, Table, Text, Title } from "@mantine/core"; +import { Center, Group, Loader, Paper, ScrollArea, Table, Text, Title, TextInput, Button, } from "@mantine/core"; import { notifications } from "@mantine/notifications"; import { useRouter } from "next/navigation"; import Image from "next/image"; @@ -68,6 +68,63 @@ export default function ViewBeneficiary() { } if (!authorized) return null; + + //add delete beneficiary + + + async function handleDeleteBeneficiary(accountNo: string) { + const isConfirmed = window.confirm("Are you sure you want to delete this beneficiary?"); + if (!isConfirmed) return; + + try { + const token = localStorage.getItem("access_token"); + + // Step 1: generate OTP + await fetch("/api/otp/generate", { + method: "POST", + headers: { Authorization: `Bearer ${token}` }, + }); + const otp = prompt("An OTP has been sent to your registered number. Please enter it:"); + + if (!otp) return; // cancelled + + // Step 2: verify OTP + const verify = await fetch("/api/otp/verify", { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, + body: JSON.stringify({ otp }), + }); + if (!verify.ok) { + alert("Invalid OTP!"); + return; + } + + // Step 3: delete beneficiary + const res = await fetch(`/api/beneficiary/${accountNo}`, { + method: "DELETE", + headers: { Authorization: `Bearer ${token}` }, + }); + + if (res.ok) { + setBeneficiaries((prev) => prev.filter((b) => b.accountNo !== accountNo)); + alert("Beneficiary deleted successfully."); + } else { + alert("Error deleting beneficiary."); + } + } catch (err) { + alert("Something went wrong. Please try again."); + } + } + + + + + //add delete beneficiary + + return ( My Beneficiaries @@ -105,7 +162,16 @@ export default function ViewBeneficiary() { {b.name} {b.accountType} {b.ifscCode} - + {/* */} + + + handleDeleteBeneficiary(b.accountNo)} + /> + + ))} diff --git a/src/app/ChangePassword/page.tsx b/src/app/ChangePassword/page.tsx index 84f6b94..0c55906 100644 --- a/src/app/ChangePassword/page.tsx +++ b/src/app/ChangePassword/page.tsx @@ -304,6 +304,10 @@ export default function ChangePassword() { withAsterisk rightSection={icon} readOnly={step !== "form"} + + onCopy={(e) => e.preventDefault()} + onPaste={(e) => e.preventDefault()} + onCut={(e) => e.preventDefault()} /> {/* Captcha */}