Name | +Amount | +Category | +
---|---|---|
{txn.name} | +{txn.amount} | +{txn.category} | +
Name | +Amount | +Category | +Date | +
---|---|---|---|
{txn.name} | +{txn.amount} | +{txn.category} | ++ {format(new Date(txn.date), 'MMMM do, yyyy')} + | +
Week Dashboard
; +} diff --git a/components/dashboard/year/index.tsx b/components/dashboard/year/index.tsx new file mode 100644 index 0000000..ba8f273 --- /dev/null +++ b/components/dashboard/year/index.tsx @@ -0,0 +1,3 @@ +export default function YearDashboard() { + returnYear Dashboard
; +} diff --git a/components/edit-entry-form/index.tsx b/components/edit-entry-form/index.tsx deleted file mode 100644 index f84307d..0000000 --- a/components/edit-entry-form/index.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { useState, useEffect } from 'react' -import Router, { useRouter } from 'next/router' - -import Button from '../button' - -export default function EntryForm() { - const [_title, setTitle] = useState('') - const [_content, setContent] = useState('') - const [submitting, setSubmitting] = useState(false) - const router = useRouter() - const { id, title, content } = router.query - - useEffect(() => { - if (typeof title === 'string') { - setTitle(title) - } - if (typeof content === 'string') { - setContent(content) - } - }, [title, content]) - - async function submitHandler(e) { - e.preventDefault() - setSubmitting(true) - try { - const res = await fetch('/api/edit-entry', { - method: 'PATCH', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - id, - title: _title, - content: _content, - }), - }) - const json = await res.json() - setSubmitting(false) - if (!res.ok) throw Error(json.message) - Router.push('/') - } catch (e) { - throw Error(e.message) - } - } - - return ( - - ) -} diff --git a/components/entries/entry/index.tsx b/components/entries/entry/index.tsx deleted file mode 100644 index 376e835..0000000 --- a/components/entries/entry/index.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { useState } from 'react' -import Link from 'next/link' -import { mutate } from 'swr' - -import ButtonLink from '@/components/button-link' -import Button from '@/components/button' - -function Entry({ id, name, amount, date, category }) { - const [deleting, setDeleting] = useState(false) - - async function deleteTxn() { - setDeleting(true) - let res = await fetch(`/api/delete-transaction?id=${id}`, { method: 'DELETE' }) - let json = await res.json() - if (!res.ok) throw Error(json.message) - mutate('/api/get-transactions') - setDeleting(false) - } - return ( -{amount}
-{data.amount}
-{data.date}
-{data.category}
-...
-