2022-12-01 22:22:13 +00:00
|
|
|
import { Form, Select } from './form'
|
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
|
2023-05-01 20:58:30 +00:00
|
|
|
export default function RecentHeader ({ type, sub }) {
|
2022-12-01 22:22:13 +00:00
|
|
|
const router = useRouter()
|
2023-05-01 20:58:30 +00:00
|
|
|
const prefix = sub?.name ? `/~${sub.name}` : ''
|
|
|
|
|
|
|
|
const items = ['posts', 'bounties', 'comments', 'links', 'discussions', 'polls']
|
|
|
|
if (!sub?.name) {
|
|
|
|
items.push('bios')
|
|
|
|
}
|
2022-08-23 22:34:51 +00:00
|
|
|
|
|
|
|
return (
|
2022-12-01 22:22:13 +00:00
|
|
|
<Form
|
|
|
|
initial={{
|
|
|
|
type: router.query.type || type || 'posts'
|
|
|
|
}}
|
|
|
|
>
|
2023-05-01 20:58:30 +00:00
|
|
|
<div className='text-muted font-weight-bold mt-0 mb-3 d-flex justify-content-end align-items-center'>
|
2022-12-01 22:22:13 +00:00
|
|
|
<Select
|
|
|
|
groupClassName='mb-0 ml-2'
|
|
|
|
className='w-auto'
|
|
|
|
name='type'
|
|
|
|
size='sm'
|
2023-05-01 20:58:30 +00:00
|
|
|
items={items}
|
|
|
|
onChange={(formik, e) => router.push(prefix + (e.target.value === 'posts' ? '/recent' : `/recent/${e.target.value}`))}
|
2022-12-01 22:22:13 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Form>
|
2022-08-23 22:34:51 +00:00
|
|
|
)
|
|
|
|
}
|