account count not doing the count

This commit is contained in:
Elijah Lucian 2021-07-15 23:10:50 -06:00
parent 01a1876b3d
commit 4cfdd5a677
5 changed files with 16 additions and 20 deletions

View File

@ -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 = () => {
<BrowserRouter>
<AppContextProvider baseURL={baseURL}>
<UserContextProvider>
<CoreLayout />
<MainLayout />
</UserContextProvider>
</AppContextProvider>
</BrowserRouter>

View File

@ -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 = () => {
<Route path="/transactions/new" component={TransactionForm} />
<Route path="/transactions" component={TransactionList} />
<Route path="/accounts/new" component={AccountForm} />
<Route path="/accounts" component={AccountForm} />
<Route path="/accounts" component={AccountList} />
<Route path="/" component={Dashboard} />
</Switch>
)}

View File

@ -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')
}

View File

@ -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)

View File

@ -0,0 +1,7 @@
import { useAccounts } from '../../hooks/getMany/useAccounts'
export const AccountList = () => {
const accounts = useAccounts()
return <div>Account Count: {accounts.data?.length}</div>
}