stacker.news/components/recent-header.js

26 lines
748 B
JavaScript
Raw Normal View History

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