2023-07-23 15:08:43 +00:00
|
|
|
import { ITEM_TYPES } from '../lib/constants'
|
2023-07-25 20:29:45 +00:00
|
|
|
import { Select } from './form'
|
2022-12-01 22:22:13 +00:00
|
|
|
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-07-23 15:08:43 +00:00
|
|
|
const prefix = sub ? `/~${sub}` : ''
|
2023-05-01 20:58:30 +00:00
|
|
|
|
2023-07-23 15:08:43 +00:00
|
|
|
const items = ITEM_TYPES(sub)
|
2022-08-23 22:34:51 +00:00
|
|
|
|
2023-07-25 20:29:45 +00:00
|
|
|
type ||= router.query.type || type || 'posts'
|
2022-08-23 22:34:51 +00:00
|
|
|
return (
|
2023-07-25 20:29:45 +00:00
|
|
|
<div className='text-muted fw-bold mt-0 mb-3 d-flex justify-content-end align-items-center'>
|
|
|
|
<Select
|
|
|
|
groupClassName='mb-0 ms-2'
|
|
|
|
className='w-auto'
|
|
|
|
name='type'
|
|
|
|
size='sm'
|
|
|
|
value={type}
|
|
|
|
items={items}
|
|
|
|
noForm
|
|
|
|
onChange={(_, e) => router.push(prefix + (e.target.value === 'posts' ? '/recent' : `/recent/${e.target.value}`))}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-08-23 22:34:51 +00:00
|
|
|
)
|
|
|
|
}
|