Merge branch 'dev' of https://7o9o-lb-526275444.ap-south-1.elb.amazonaws.com/tomosa.sarkar/IB into dev
This commit is contained in:
@@ -390,9 +390,9 @@ export default function AddBeneficiaryOthers() {
|
|||||||
maxLength={17}
|
maxLength={17}
|
||||||
readOnly={isVisibilityLocked}
|
readOnly={isVisibilityLocked}
|
||||||
withAsterisk
|
withAsterisk
|
||||||
// onCopy={(e) => e.preventDefault()}
|
onCopy={(e) => e.preventDefault()}
|
||||||
// onPaste={(e) => e.preventDefault()}
|
onPaste={(e) => e.preventDefault()}
|
||||||
// onCut={(e) => e.preventDefault()}
|
onCut={(e) => e.preventDefault()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{validationStatus === "error" && (
|
{validationStatus === "error" && (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useState } from "react";
|
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 { notifications } from "@mantine/notifications";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
@@ -68,6 +68,63 @@ export default function ViewBeneficiary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!authorized) return null;
|
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 (
|
return (
|
||||||
<Paper shadow="sm" radius="md" p="md" withBorder h={400}>
|
<Paper shadow="sm" radius="md" p="md" withBorder h={400}>
|
||||||
<Title order={3} mb="md">My Beneficiaries</Title>
|
<Title order={3} mb="md">My Beneficiaries</Title>
|
||||||
@@ -105,7 +162,16 @@ export default function ViewBeneficiary() {
|
|||||||
<Table.Td>{b.name}</Table.Td>
|
<Table.Td>{b.name}</Table.Td>
|
||||||
<Table.Td>{b.accountType}</Table.Td>
|
<Table.Td>{b.accountType}</Table.Td>
|
||||||
<Table.Td style={{ textAlign: "center" }}>{b.ifscCode}</Table.Td>
|
<Table.Td style={{ textAlign: "center" }}>{b.ifscCode}</Table.Td>
|
||||||
<Table.Td style={{ textAlign: "center" }}><IconTrash color="red" /></Table.Td>
|
{/* <Table.Td style={{ textAlign: "center" }}><IconTrash color="red" /></Table.Td> */}
|
||||||
|
|
||||||
|
<Table.Td style={{ textAlign: "center" }}>
|
||||||
|
<IconTrash
|
||||||
|
color="red"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => handleDeleteBeneficiary(b.accountNo)}
|
||||||
|
/>
|
||||||
|
</Table.Td>
|
||||||
|
|
||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
))}
|
))}
|
||||||
</Table.Tbody>
|
</Table.Tbody>
|
||||||
|
|||||||
@@ -306,6 +306,10 @@ export default function ChangePassword() {
|
|||||||
withAsterisk
|
withAsterisk
|
||||||
rightSection={icon}
|
rightSection={icon}
|
||||||
readOnly={step !== "form"}
|
readOnly={step !== "form"}
|
||||||
|
|
||||||
|
onCopy={(e) => e.preventDefault()}
|
||||||
|
onPaste={(e) => e.preventDefault()}
|
||||||
|
onCut={(e) => e.preventDefault()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Captcha */}
|
{/* Captcha */}
|
||||||
|
|||||||
Reference in New Issue
Block a user