Getting Started with Account Details Page
Overview
The Account Details Page is a component in the Bank Frontend that allows users to view detailed information about a specific bank account. Users can access the Account Details Page by clicking on 'View account details' from the landing page.
Accessing the Account Details Page
Users can access the Account Details Page by clicking on 'View account details' from the landing page. This action will navigate the user to the Account Details Page where they can enter an account number to retrieve the associated account details.
Fetching Account Details
Upon entering a valid account number, the page fetches the account details from the backend and displays them in a structured format. The function getCustomerAccounts
The function getCustomerAccounts
/**
* Get the account for a given accountNumber, create an array of the response and set accountMainRow to this array
* Calls getOtherAccountsForCustomer to find the other accounts tied to this customer's number
*/
async function getCustomerAccounts(searchQuery) {
let account;
let rowBuild = [];
await axios
.get(process.env.REACT_APP_ACCOUNT_URL + `/${searchQuery}`)
.then(response => {
account = response.data;
}).catch (function (error) {
if (error.response){
displayNoResults()
console.log(error)
}
})
try {
let row;
let formattedDateOpened = getDay(account.dateOpened) + "-" + getMonth(account.dateOpened) + "-" + getYear(account.dateOpened)
let formattedLastStatementDue = getDay(account.lastStatementDate) + "-" + getMonth(account.lastStatementDate) + "-" + getYear(account.lastStatementDate)
Handling No Results
If no account is found for the entered account number, a modal is displayed informing the user that no accounts were found. The function displayNoResults
The function displayNoResults
function displayNoResults() {
setShowNoResultsModal(wasOpened => !wasOpened)
}
Main Functions
There are several main functions in this folder. Some of them are AccountDetailsPage
handleClick
getCustomerAccounts
AccountDetailsTable
handleClick
getCustomerAccounts
AccountDetailsPage
AccountDetailsPage
The AccountDetailsPage
The AccountDetailsPage
const AccountDetailsPage = () => {
const [isOpened, setIsOpened] = useState(false);
const [userInput, setUserInput] = useState("")
const [accountMainRow, setMainRow] = useState([]);
const [showNoResultsModal, setShowNoResultsModal] = useState(false)
handleClick
handleClick
The handleClick
getCustomerAccounts
The handleClick
getCustomerAccounts
function handleClick() {
let searchQuery = userInput;
if (userInput.length !== 0){
getCustomerAccounts(searchQuery)
setIsOpened(wasOpened => !wasOpened)
} else {
displayNoResults()
}
}
AccountDetailsTable
AccountDetailsTable
The AccountDetailsTable
The AccountDetailsTable
const AccountDetailsTable = ({accountMainRow}) => {
/**
* Set states for all of the current account values, before the user edits any. This provides a fallback if any fields are left blank by the user
*/
const [accountNumber, setAccountNumber] = useState("")
const [currentAccountType, setCurrentAccountType] = useState("")
const [currentOverdraft, setCurrentOverdraft] = useState("")
const [currentInterestRate, setCurrentInterestRate] = useState("")
const [accountSortCode, setAccountSortCode] = useState("")
const [currentActualBalance, setCurrentActualBalance] = useState("")
const [lastStatementDate, setLastStatementDate] = useState("")
const [nextStatementDate, setNextStatementDate] = useState("")
const [dateOpened, setDateOpened] = useState("")
const [currentAvailableBalance, setCurrentAvailableBalance] = useState("")
const [currentAccountCustomerNumber, setAccountCustomerNumber] = useState("")
/**
* States that are edited by the user
*/
const [enteredOverdraftLimit, setOverdraftLimit] = useState('');
const [enteredAccountType, setAccountType] = useState("");
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human