Merge pull request #5 from dank-inc/CRUD_hooks

Crud hooks
This commit is contained in:
Ievgen Dilevskyi 2021-07-14 17:22:51 -06:00 committed by GitHub
commit 1c43792db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,9 @@
import { useAppContext } from '../../contexts/AppContext'
import { Account } from '../../types'
export const useCreateAccount = () => {
const api = useAppContext()
return (body: Omit<Account, 'id'>): Promise<Account> =>
api.post<Account>('/accounts', body)
}

View File

@ -0,0 +1,9 @@
import { useAppContext } from '../../contexts/AppContext'
import { Stack } from '../../types'
export const useCreateStack = () => {
const api = useAppContext()
return (body: Omit<Stack, 'id'>): Promise<Stack> =>
api.post<Stack>('/stacks', body)
}

View File

@ -0,0 +1,9 @@
import { useAppContext } from '../../contexts/AppContext'
import { Transaction } from '../../types'
export const useCreateTransaction = () => {
const api = useAppContext()
return (body: Omit<Transaction, 'id'>): Promise<Transaction> =>
api.post<Transaction>('/transactions', body)
}