Show all group contracts if less than 5 open
This commit is contained in:
parent
0823414360
commit
fecf976ab9
|
@ -62,7 +62,11 @@ export async function getStaticPropz(props: { params: { slugs: string[] } }) {
|
||||||
|
|
||||||
const contracts =
|
const contracts =
|
||||||
(group && (await listContractsByGroupSlug(group.slug))) ?? []
|
(group && (await listContractsByGroupSlug(group.slug))) ?? []
|
||||||
|
const now = Date.now()
|
||||||
|
const suggestedFilter =
|
||||||
|
contracts.filter((c) => (c.closeTime ?? 0) > now).length < 5
|
||||||
|
? 'all'
|
||||||
|
: 'open'
|
||||||
const aboutPost =
|
const aboutPost =
|
||||||
group && group.aboutPostId != null && (await getPost(group.aboutPostId))
|
group && group.aboutPostId != null && (await getPost(group.aboutPostId))
|
||||||
const bets = await Promise.all(
|
const bets = await Promise.all(
|
||||||
|
@ -92,6 +96,7 @@ export async function getStaticPropz(props: { params: { slugs: string[] } }) {
|
||||||
topCreators,
|
topCreators,
|
||||||
messages,
|
messages,
|
||||||
aboutPost,
|
aboutPost,
|
||||||
|
suggestedFilter,
|
||||||
},
|
},
|
||||||
|
|
||||||
revalidate: 60, // regenerate after a minute
|
revalidate: 60, // regenerate after a minute
|
||||||
|
@ -131,6 +136,7 @@ export default function GroupPage(props: {
|
||||||
topCreators: User[]
|
topCreators: User[]
|
||||||
messages: GroupComment[]
|
messages: GroupComment[]
|
||||||
aboutPost: Post
|
aboutPost: Post
|
||||||
|
suggestedFilter: 'open' | 'all'
|
||||||
}) {
|
}) {
|
||||||
props = usePropz(props, getStaticPropz) ?? {
|
props = usePropz(props, getStaticPropz) ?? {
|
||||||
group: null,
|
group: null,
|
||||||
|
@ -141,6 +147,7 @@ export default function GroupPage(props: {
|
||||||
creatorScores: {},
|
creatorScores: {},
|
||||||
topCreators: [],
|
topCreators: [],
|
||||||
messages: [],
|
messages: [],
|
||||||
|
suggestedFilter: 'open',
|
||||||
}
|
}
|
||||||
const {
|
const {
|
||||||
creator,
|
creator,
|
||||||
|
@ -149,6 +156,7 @@ export default function GroupPage(props: {
|
||||||
topTraders,
|
topTraders,
|
||||||
creatorScores,
|
creatorScores,
|
||||||
topCreators,
|
topCreators,
|
||||||
|
suggestedFilter,
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
@ -210,7 +218,7 @@ export default function GroupPage(props: {
|
||||||
<ContractSearch
|
<ContractSearch
|
||||||
user={user}
|
user={user}
|
||||||
defaultSort={'newest'}
|
defaultSort={'newest'}
|
||||||
defaultFilter={'open'}
|
defaultFilter={suggestedFilter}
|
||||||
additionalFilter={{ groupSlug: group.slug }}
|
additionalFilter={{ groupSlug: group.slug }}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user