fixes for top

This commit is contained in:
keyan 2023-02-03 13:10:18 -06:00
parent a52bb610b8
commit c1080ec4d7
8 changed files with 21 additions and 12 deletions

View File

@ -177,7 +177,7 @@ export default function Header ({ sub }) {
</Nav.Item> </Nav.Item>
{!prefix && {!prefix &&
<Nav.Item className={className}> <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> <Nav.Link eventKey='top' className={styles.navLink}>top</Nav.Link>
</Link> </Link>
</Nav.Item>} </Nav.Item>}
@ -253,7 +253,7 @@ const NavItemsStatic = ({ className }) => {
</Link> </Link>
</Nav.Item> </Nav.Item>
<Nav.Item className={className}> <Nav.Item className={className}>
<Link href='/top/posts' passHref> <Link href='/top/posts/day' passHref>
<Nav.Link className={styles.navLink}>top</Nav.Link> <Nav.Link className={styles.navLink}>top</Nav.Link>
</Link> </Link>
</Nav.Item> </Nav.Item>

View File

@ -21,7 +21,7 @@ export default function MoreFooter ({ cursor, fetchMore, Skeleton, noMoreText })
cursor cursor
} }
}) })
setLoading(false) setTimeout(() => setLoading(false), 100)
}} }}
>more >more
</Button> </Button>

View File

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

View File

@ -99,7 +99,7 @@ export const ITEMS = gql`
export const TOP_ITEMS = gql` export const TOP_ITEMS = gql`
${ITEM_FIELDS} ${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) { topItems(sort: $sort, cursor: $cursor, when: $when) {
cursor cursor
items { items {

View File

@ -134,7 +134,7 @@ export const USER_FIELDS = gql`
}` }`
export const TOP_USERS = 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) { topUsers(cursor: $cursor, when: $when, sort: $sort) {
users { users {
name name