Exploring the Account Deletion Page
Overview
The Account Delete Page is a part of the Bank Frontend that allows users to delete an existing bank account. Users can access this page by clicking on 'Delete account' from the landing page. The page includes a form where users can enter the account number they wish to delete. Upon submitting the account number, the page displays the account details and provides an option to confirm the deletion. The deletion process involves making a RESTful API call to the backend to remove the account from the database. If the deletion is successful, a success message is displayed; otherwise, an error message is shown.
How to Use the Account Delete Page
To remove an account, click on 'Delete account' from the landing page. Enter the account number in the provided form and submit. The page will display the account details and provide an option to confirm the deletion.
Example Usage
The AccountDeletePage
The AccountDeletePage
const AccountDeletePage = () => {
const [isOpened, setIsOpened] = useState(false);
var [searchAccountValue, setSearchAccountValue] = useState("")
function handleAccountNumberInput(e){
setSearchAccountValue(e.target.value)
}
function display() {
setIsOpened(wasOpened => !wasOpened);
}
return (
<Grid className="landing-page" fullWidth>
<Column lg={16} md={8} sm={4} className="landing-page__banner">
<Breadcrumb noTrailingSlash aria-label="Page navigation">
<BreadcrumbItem>
<a href="./">Home</a>
</BreadcrumbItem>
<BreadcrumbItem>
<a href="./#/profile/Admin">Control Panel</a>
</BreadcrumbItem>
Deletion Process
The deleteAccount
The deleteAccount
/**
* Deletes the account tied to accountNumberToDelete
* Displays either a success or failure modal once a response is received
*/
async function deleteAccount(){
let accountNumber = accountNumberToDelete
let responseData;
try{
await axios
.delete(process.env.REACT_APP_ACCOUNT_URL + `/${accountNumber}`)
.then(response => {
responseData = response.data
console.log(responseData)
}).catch(function (error){
if (error.response){
console.log(error)
displayModal()
displayUnableDeleteModal()
}
})
displayModal()
Main Functions
There are several main functions in this folder. Some of them are AccountDeleteTables
deleteAccount
displayModal
deleteAccount
displayModal
AccountDeleteTables
AccountDeleteTables
The AccountDeleteTables
The AccountDeleteTables
const AccountDeleteTables = ({accountQuery}) => {
const [mainAccountRow, setMainRows] = useState([]);
const [otherAccountRows, setOtherAccountRows] = useState([]);
getAccountByNum(accountQuery)
/**
* get the account from the given account number, create an array of the results and set mainAccountRow to this
* then call getOtherAccounts to find any other accounts belonging to the customer
*/
async function getAccountByNum(accountQuery) {
let account;
let rowBuild = [];
await axios
.get(process.env.REACT_APP_ACCOUNT_URL + `/${accountQuery}`)
.then(response => {
account = response.data;
});
try {
let row;
row = {
id : account.id,
displayModal
displayModal
The displayModal
The displayModal
function displayModal() {
setModalOpened(wasOpened => !wasOpened);
}
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human