fixes for top
This commit is contained in:
parent
a52bb610b8
commit
c1080ec4d7
|
@ -177,7 +177,7 @@ export default function Header ({ sub }) {
|
|||
</Nav.Item>
|
||||
{!prefix &&
|
||||
<Nav.Item className={className}>
|
||||
<Link href='/top/posts' passHref>
|
||||
<Link href='/top/posts/day' passHref>
|
||||
<Nav.Link eventKey='top' className={styles.navLink}>top</Nav.Link>
|
||||
</Link>
|
||||
</Nav.Item>}
|
||||
|
@ -253,7 +253,7 @@ const NavItemsStatic = ({ className }) => {
|
|||
</Link>
|
||||
</Nav.Item>
|
||||
<Nav.Item className={className}>
|
||||
<Link href='/top/posts' passHref>
|
||||
<Link href='/top/posts/day' passHref>
|
||||
<Nav.Link className={styles.navLink}>top</Nav.Link>
|
||||
</Link>
|
||||
</Nav.Item>
|
||||
|
|
|
@ -21,7 +21,7 @@ export default function MoreFooter ({ cursor, fetchMore, Skeleton, noMoreText })
|
|||
cursor
|
||||
}
|
||||
})
|
||||
setLoading(false)
|
||||
setTimeout(() => setLoading(false), 100)
|
||||
}}
|
||||
>more
|
||||
</Button>
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
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 = values.what
|
||||
delete values.what
|
||||
if (values.sort === '') delete values.sort
|
||||
if (values.when === '') delete values.when
|
||||
const { what, when, ...query } = values
|
||||
|
||||
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}`,
|
||||
query: values
|
||||
pathname: `/top/${what}/${when}`,
|
||||
query
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -41,7 +50,7 @@ export default function TopHeader ({ cat }) {
|
|||
onChange={(formik, e) => top({ ...formik?.values, sort: e.target.value })}
|
||||
name='sort'
|
||||
size='sm'
|
||||
items={cat === 'users' ? ['stacked', 'spent', 'comments', 'posts', 'referrals'] : ['votes', 'comments', 'sats']}
|
||||
items={cat === 'users' ? USER_SORTS : ITEM_SORTS}
|
||||
/>
|
||||
for
|
||||
<Select
|
||||
|
|
|
@ -99,7 +99,7 @@ export const ITEMS = gql`
|
|||
export const TOP_ITEMS = gql`
|
||||
${ITEM_FIELDS}
|
||||
|
||||
query topItems($sort: String, $cursor: String, $when: String = "day") {
|
||||
query topItems($sort: String, $cursor: String, $when: String) {
|
||||
topItems(sort: $sort, cursor: $cursor, when: $when) {
|
||||
cursor
|
||||
items {
|
||||
|
|
|
@ -134,7 +134,7 @@ export const USER_FIELDS = gql`
|
|||
}`
|
||||
|
||||
export const TOP_USERS = gql`
|
||||
query TopUsers($cursor: String, $when: String = "day", $sort: String) {
|
||||
query TopUsers($cursor: String, $when: String, $sort: String) {
|
||||
topUsers(cursor: $cursor, when: $when, sort: $sort) {
|
||||
users {
|
||||
name
|
||||
|
|
Loading…
Reference in New Issue