44 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-04-13 19:57:32 -05:00
import Button from 'react-bootstrap/Button'
2021-04-12 13:05:09 -05:00
import { useRouter } from 'next/router'
import Link from 'next/link'
2021-05-06 16:15:22 -05:00
import LayoutCenter from '../components/layout-center'
2021-05-24 19:08:56 -05:00
import { useMe } from '../components/me'
2021-08-11 15:13:10 -05:00
import { DiscussionForm } from '../components/discussion-form'
import { LinkForm } from '../components/link-form'
2021-04-12 13:05:09 -05:00
export function PostForm () {
const router = useRouter()
2021-05-24 19:08:56 -05:00
const me = useMe()
2021-04-12 13:05:09 -05:00
if (!router.query.type) {
return (
<div className='align-items-center'>
<Link href='/post?type=link'>
2021-04-13 19:57:32 -05:00
<Button variant='secondary'>link</Button>
2021-04-12 13:05:09 -05:00
</Link>
<span className='mx-3 font-weight-bold text-muted'>or</span>
<Link href='/post?type=discussion'>
2021-05-06 16:15:22 -05:00
<Button variant='secondary'>discussion</Button>
2021-04-12 13:05:09 -05:00
</Link>
2021-05-24 19:08:56 -05:00
{me?.freePosts
? <div className='text-center font-weight-bold mt-3 text-success'>{me.freePosts} free posts left</div>
: null}
2021-04-12 13:05:09 -05:00
</div>
)
}
if (router.query.type === 'discussion') {
return <DiscussionForm />
} else {
return <LinkForm />
}
}
export default function Post () {
return (
2021-05-06 16:15:22 -05:00
<LayoutCenter>
<PostForm />
</LayoutCenter>
2021-04-12 13:05:09 -05:00
)
}