Skip to content

Commit

Permalink
Fix issue where accounts array was replaced with null
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnStarich committed Nov 24, 2019
1 parent 9e53a99 commit 23838f0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions web/src/Accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default function Accounts({ match }) {
const [accounts, setAccounts] = React.useState([])
React.useEffect(() => {
API.get('/v1/getAccounts')
.then(res => setAccounts(res.data.Accounts))
.then(res => {
if (res.data.Accounts) {
setAccounts(res.data.Accounts)
}
})
}, [])

const accountCreated = (...newAccounts) => {
Expand Down Expand Up @@ -68,15 +72,15 @@ export default function Accounts({ match }) {
<p>Alternatively, import an OFX or QFX file downloaded from your institution.</p>
</Col>
</Row>
{accounts ? accounts.map(a =>
{accounts.map(a =>
<Row key={a.AccountID}>
<Col>{a.AccountDescription}</Col>
<Col className="account-buttons">
<Link to={`${match.url}/edit/${a.AccountID}`} className="btn btn-outline-secondary">Edit</Link>
<Button variant="outline-danger" onClick={() => deleteAccount(a.AccountID)}>Delete</Button>
</Col>
</Row>
) : null}
)}
<Row>
<Col className="account-actions">
<Link to={`${match.url}/direct-connect`} className="btn btn-primary add-direct">Add new Direct Connect</Link>
Expand Down

0 comments on commit 23838f0

Please sign in to comment.