diff --git a/src/renderer/components/account-list.tsx b/src/renderer/components/account-list.tsx index a2d8f63..8f4d498 100644 --- a/src/renderer/components/account-list.tsx +++ b/src/renderer/components/account-list.tsx @@ -1,7 +1,8 @@ import React from 'react'; -import { AccountInfo } from '../types'; +import { AccountInfo, AppReduxState } from '../types'; import { useDispatch } from 'react-redux'; -import { selectAccount } from '../lib/reducer'; +import { selectAccount, setAccounts } from '../lib/reducer'; +import { useSelector } from 'react-redux'; export default function AccountList({ accounts, @@ -11,11 +12,30 @@ export default function AccountList({ showAccountEdit: () => void; }) { const dispatch = useDispatch(); + const selectedAccount = useSelector((state: AppReduxState) => state.selectedAccount) + const hasSelectedAccountBeenDeleted = (() => { + if (selectedAccount) { + if (accounts.some(account => account.id === selectedAccount.id)) { + return false + } + return true; + } + return false; + })() + return (

Accounts

+ {hasSelectedAccountBeenDeleted && selectedAccount && }