2023-05-11 00:26:07 +00:00
|
|
|
import JobForm from './job-form'
|
|
|
|
import Link from 'next/link'
|
2023-07-24 18:35:05 +00:00
|
|
|
import Button from 'react-bootstrap/Button'
|
2023-05-11 00:26:07 +00:00
|
|
|
import AccordianItem from './accordian-item'
|
|
|
|
import { useMe } from './me'
|
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
import { DiscussionForm } from './discussion-form'
|
|
|
|
import { LinkForm } from './link-form'
|
|
|
|
import { PollForm } from './poll-form'
|
|
|
|
import { BountyForm } from './bounty-form'
|
|
|
|
import SubSelect from './sub-select-form'
|
2023-06-20 17:55:45 +00:00
|
|
|
import Info from './info'
|
|
|
|
|
|
|
|
function FreebieDialog () {
|
|
|
|
return (
|
|
|
|
<div className='text-center mb-4 text-muted'>
|
|
|
|
you have no sats, so this one is on us
|
|
|
|
<Info>
|
2023-07-24 18:35:05 +00:00
|
|
|
<ul className='fw-bold'>
|
2023-06-20 17:55:45 +00:00
|
|
|
<li>Free posts have limited visibility and are hidden on the recent tab until other stackers zap them.</li>
|
|
|
|
<li>Free posts will not cover posts that cost more than 1 sat.</li>
|
|
|
|
<li>To get fully visibile and unrestricted posts right away, fund your account with a few sats or earn some on Stacker News.</li>
|
|
|
|
</ul>
|
|
|
|
</Info>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2023-05-11 00:26:07 +00:00
|
|
|
|
|
|
|
export function PostForm ({ type, sub, children }) {
|
|
|
|
const me = useMe()
|
|
|
|
|
|
|
|
const prefix = sub?.name ? `/~${sub.name}` : ''
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
return (
|
|
|
|
<div className='align-items-center'>
|
2023-06-20 17:55:45 +00:00
|
|
|
{me?.sats < 1 && <FreebieDialog />}
|
2023-06-01 00:54:35 +00:00
|
|
|
<SubSelect noForm sub={sub?.name} />
|
2023-05-11 00:26:07 +00:00
|
|
|
<Link href={prefix + '/post?type=link'}>
|
|
|
|
<Button variant='secondary'>link</Button>
|
|
|
|
</Link>
|
2023-07-24 18:35:05 +00:00
|
|
|
<span className='mx-3 fw-bold text-muted'>or</span>
|
2023-05-11 00:26:07 +00:00
|
|
|
<Link href={prefix + '/post?type=discussion'}>
|
|
|
|
<Button variant='secondary'>discussion</Button>
|
|
|
|
</Link>
|
2023-06-20 17:55:45 +00:00
|
|
|
<div className='d-flex mt-4'>
|
2023-05-11 00:26:07 +00:00
|
|
|
<AccordianItem
|
|
|
|
headerColor='#6c757d'
|
2023-07-24 18:35:05 +00:00
|
|
|
header={<div className='fw-bold text-muted'>more types</div>}
|
2023-05-11 00:26:07 +00:00
|
|
|
body={
|
|
|
|
<div className='align-items-center'>
|
|
|
|
<Link href={prefix + '/post?type=poll'}>
|
|
|
|
<Button variant='info'>poll</Button>
|
|
|
|
</Link>
|
2023-07-24 18:35:05 +00:00
|
|
|
<span className='mx-3 fw-bold text-muted'>or</span>
|
2023-05-11 00:26:07 +00:00
|
|
|
<Link href={prefix + '/post?type=bounty'}>
|
|
|
|
<Button variant='info'>bounty</Button>
|
|
|
|
</Link>
|
|
|
|
<div className='mt-3 d-flex justify-content-center'>
|
|
|
|
<Link href='/~jobs/post'>
|
|
|
|
<Button variant='info'>job</Button>
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
let FormType = JobForm
|
|
|
|
if (type === 'discussion') {
|
|
|
|
FormType = DiscussionForm
|
|
|
|
} else if (type === 'link') {
|
|
|
|
FormType = LinkForm
|
|
|
|
} else if (type === 'poll') {
|
|
|
|
FormType = PollForm
|
|
|
|
} else if (type === 'bounty') {
|
|
|
|
FormType = BountyForm
|
|
|
|
}
|
|
|
|
|
|
|
|
return <FormType sub={sub}>{children}</FormType>
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Post ({ sub }) {
|
|
|
|
const router = useRouter()
|
|
|
|
let type = router.query.type
|
|
|
|
|
|
|
|
if (sub?.postTypes?.length === 1) {
|
|
|
|
type = sub.postTypes[0].toLowerCase()
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PostForm type={type} sub={sub}>
|
|
|
|
{sub?.name !== 'jobs' && <SubSelect label='sub' />}
|
|
|
|
</PostForm>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|