From 4cfdd5a677b303d7fa7933e7aef1d56ea6996cdb Mon Sep 17 00:00:00 2001 From: Elijah Lucian Date: Thu, 15 Jul 2021 23:10:50 -0600 Subject: [PATCH] account count not doing the count --- frontend/src/App.tsx | 4 ++-- frontend/src/{CoreLayout.tsx => MainLayout.tsx} | 5 +++-- frontend/src/forms/AccountForm.tsx | 11 ----------- frontend/src/layout/AppHeader/index.tsx | 9 ++++----- frontend/src/pages/AccountList/index.tsx | 7 +++++++ 5 files changed, 16 insertions(+), 20 deletions(-) rename frontend/src/{CoreLayout.tsx => MainLayout.tsx} (91%) create mode 100644 frontend/src/pages/AccountList/index.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 7efa49d..87100b0 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,6 @@ import { BrowserRouter } from 'react-router-dom' import { UserContextProvider } from './contexts/UserContext' -import { CoreLayout } from './CoreLayout' +import { MainLayout } from './MainLayout' import { AppContextProvider } from './contexts/AppContext' import './app.scss' @@ -15,7 +15,7 @@ const App = () => { - + diff --git a/frontend/src/CoreLayout.tsx b/frontend/src/MainLayout.tsx similarity index 91% rename from frontend/src/CoreLayout.tsx rename to frontend/src/MainLayout.tsx index d1a2f9c..9ddf7fc 100644 --- a/frontend/src/CoreLayout.tsx +++ b/frontend/src/MainLayout.tsx @@ -10,8 +10,9 @@ import { AppHeader } from './layout/AppHeader' import { AppFooter } from './layout/AppFooter' import { TransactionForm } from './pages/TransactionForm' import { Button } from 'antd' +import { AccountList } from './pages/AccountList' -export const CoreLayout = () => { +export const MainLayout = () => { const { user } = useUserContext() const history = useHistory() @@ -36,7 +37,7 @@ export const CoreLayout = () => { - + )} diff --git a/frontend/src/forms/AccountForm.tsx b/frontend/src/forms/AccountForm.tsx index c9e32e5..3e6481d 100644 --- a/frontend/src/forms/AccountForm.tsx +++ b/frontend/src/forms/AccountForm.tsx @@ -20,17 +20,6 @@ export const AccountForm = ({ account }: Props) => { e.preventDefault() if (!name || !income || !expenses) message.error(`fill out all the fields!`) - const body = { - name, - income, - expenses, - details, - } - - // account?.id - // ? await api.updateAccount(account.id, body) - // : await api.createAccount(body) - message.success('Yaaa') } diff --git a/frontend/src/layout/AppHeader/index.tsx b/frontend/src/layout/AppHeader/index.tsx index d2acaf0..122a460 100644 --- a/frontend/src/layout/AppHeader/index.tsx +++ b/frontend/src/layout/AppHeader/index.tsx @@ -1,8 +1,8 @@ import { ReactNode } from 'react' -import { Avatar, Dropdown, Menu } from 'antd' -import { Link, useHistory } from 'react-router-dom' +import { Link } from 'react-router-dom' import { useUserContext } from '../../contexts/UserContext' -import { Button } from '../../elements/Button' +// import { Avatar, Dropdown, Menu } from 'antd' +// import { Button } from '../../elements/Button' import './style.scss' @@ -11,8 +11,7 @@ type Props = { } export const AppHeader = ({ children }: Props) => { - const { user, handleLogout } = useUserContext() - const history = useHistory() + const { user } = useUserContext() // Unauthed Header if (!user) diff --git a/frontend/src/pages/AccountList/index.tsx b/frontend/src/pages/AccountList/index.tsx new file mode 100644 index 0000000..b746c1b --- /dev/null +++ b/frontend/src/pages/AccountList/index.tsx @@ -0,0 +1,7 @@ +import { useAccounts } from '../../hooks/getMany/useAccounts' + +export const AccountList = () => { + const accounts = useAccounts() + + return
Account Count: {accounts.data?.length}
+}