From 9d2aeddd4b9d527beae39ec15a966b134d942c1d Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 15 Mar 2021 10:13:25 +0100 Subject: [PATCH] clean up bank hook --- phone/src/apps/bank/components/account/BankAccount.tsx | 2 +- phone/src/apps/bank/components/home/BankHome.tsx | 2 +- .../bank/components/transactions/TransactionList.tsx | 2 +- phone/src/apps/bank/hooks/useBankNotification.ts | 9 ++------- phone/src/apps/bank/hooks/useCredentials.ts | 9 ++------- phone/src/apps/bank/hooks/useTransactions.ts | 4 ++-- typings/bank.ts | 6 ++++++ 7 files changed, 15 insertions(+), 19 deletions(-) diff --git a/phone/src/apps/bank/components/account/BankAccount.tsx b/phone/src/apps/bank/components/account/BankAccount.tsx index bf485b3..d7db9d3 100644 --- a/phone/src/apps/bank/components/account/BankAccount.tsx +++ b/phone/src/apps/bank/components/account/BankAccount.tsx @@ -18,7 +18,7 @@ const useStyles = makeStyles((theme) => ({ export const BankAccount = () => { const classes = useStyles(); - const { credentials } = useCredentials(); + const credentials = useCredentials(); const { t } = useTranslation(); return (
diff --git a/phone/src/apps/bank/components/home/BankHome.tsx b/phone/src/apps/bank/components/home/BankHome.tsx index e733161..aac1afb 100644 --- a/phone/src/apps/bank/components/home/BankHome.tsx +++ b/phone/src/apps/bank/components/home/BankHome.tsx @@ -12,7 +12,7 @@ import useStyles from './home.styles'; export const BankHome = () => { const classes = useStyles(); const { setShowBankModal } = useBankModal(); - const { credentials } = useCredentials(); + const credentials = useCredentials(); const { t } = useTranslation(); const openTransactionsModal = () => { diff --git a/phone/src/apps/bank/components/transactions/TransactionList.tsx b/phone/src/apps/bank/components/transactions/TransactionList.tsx index 346eb5b..55fa842 100644 --- a/phone/src/apps/bank/components/transactions/TransactionList.tsx +++ b/phone/src/apps/bank/components/transactions/TransactionList.tsx @@ -5,7 +5,7 @@ import TablePagination from '@material-ui/core/TablePagination'; import { useTransactions } from '../../hooks/useTransactions'; export const TransactionList = () => { - const { transactionList } = useTransactions(); + const transactionList = useTransactions(); const { t } = useTranslation(); const classes = useStyles(); const [page, setPage] = useState(0); diff --git a/phone/src/apps/bank/hooks/useBankNotification.ts b/phone/src/apps/bank/hooks/useBankNotification.ts index 0137a95..725f552 100644 --- a/phone/src/apps/bank/hooks/useBankNotification.ts +++ b/phone/src/apps/bank/hooks/useBankNotification.ts @@ -3,11 +3,6 @@ import { useRecoilValue } from 'recoil'; import { Transfer } from '../../../../../typings/bank'; import { bankState } from './state'; -interface IBankNotification { - notification: Transfer | null; -} - -export const useBankNotification = (): IBankNotification => { - const notification = useRecoilValue(bankState.notification); - return { notification }; +export const useBankNotification = () => { + return useRecoilValue(bankState.notification); }; diff --git a/phone/src/apps/bank/hooks/useCredentials.ts b/phone/src/apps/bank/hooks/useCredentials.ts index 9e70e3e..3596bc1 100644 --- a/phone/src/apps/bank/hooks/useCredentials.ts +++ b/phone/src/apps/bank/hooks/useCredentials.ts @@ -2,11 +2,6 @@ import { useRecoilValue } from 'recoil'; import { bankState } from './state'; import { IBankCredentials } from '../../../../../typings/bank'; -interface ICredentialsHook { - credentials: IBankCredentials; -} - -export const useCredentials = (): ICredentialsHook => { - const credentials = useRecoilValue(bankState.bankCredentials); - return { credentials }; +export const useCredentials = () => { + return useRecoilValue(bankState.bankCredentials); }; diff --git a/phone/src/apps/bank/hooks/useTransactions.ts b/phone/src/apps/bank/hooks/useTransactions.ts index 94be613..e1d1f43 100644 --- a/phone/src/apps/bank/hooks/useTransactions.ts +++ b/phone/src/apps/bank/hooks/useTransactions.ts @@ -1,7 +1,7 @@ import { useRecoilValue } from 'recoil'; +import { ITransactions } from '../../../../../typings/bank'; import { bankState } from './state'; export const useTransactions = () => { - const transactionList = useRecoilValue(bankState.transactions); - return { transactionList }; + return useRecoilValue(bankState.transactions); }; diff --git a/typings/bank.ts b/typings/bank.ts index d791f0c..bd8f179 100644 --- a/typings/bank.ts +++ b/typings/bank.ts @@ -11,3 +11,9 @@ export interface Transfer { transferAmount: number; message: string; } + +export interface ITransactions { + source: number; + type: string; + amount: number; +}