import { useRouter } from 'next/router' import { Form, Select } from './form' const USER_SORTS = ['stacked', 'spent', 'comments', 'posts', 'referrals'] const ITEM_SORTS = ['votes', 'comments', 'sats'] export default function TopHeader ({ cat }) { const router = useRouter() const top = async values => { const { what, when, ...query } = values if (what === 'cowboys') { await router.push({ pathname: `/top/${what}` }) return } if (typeof query.sort !== 'undefined') { if (query.sort === '' || (what === 'users' && !USER_SORTS.includes(query.sort)) || (what !== 'users' && !ITEM_SORTS.includes(query.sort))) { delete query.sort } } await router.push({ pathname: `/top/${what}/${when || 'day'}`, query }) } return (
top top({ ...formik?.values, sort: e.target.value })} name='sort' size='sm' items={cat === 'users' ? USER_SORTS : ITEM_SORTS} /> for