manifold/web/components/contract/contracts-list.tsx

66 lines
1.5 KiB
TypeScript
Raw Normal View History

import { Contract } from '../../lib/firebase/contracts'
import { User } from '../../lib/firebase/users'
import { Col } from '../layout/col'
import { SiteLink } from '../site-link'
import { ContractCard } from './contract-card'
import { ContractSearch } from '../contract-search'
2021-12-14 10:27:22 +00:00
export function ContractsGrid(props: {
contracts: Contract[]
loadMore: () => void
hasMore: boolean
2022-01-17 22:54:00 +00:00
showCloseTime?: boolean
}) {
const { contracts, showCloseTime, hasMore, loadMore } = props
2021-12-16 21:20:49 +00:00
if (contracts.length === 0) {
return (
<p className="mx-2 text-gray-500">
2022-02-18 02:32:15 +00:00
No markets found. Why not{' '}
<SiteLink href="/home" className="font-bold text-gray-700">
create one?
</SiteLink>
</p>
)
}
2021-12-14 10:27:22 +00:00
return (
<Col className="gap-8">
<ul className="grid w-full grid-cols-1 gap-6 md:grid-cols-2">
{contracts.map((contract) => (
<ContractCard
contract={contract}
key={contract.id}
showCloseTime={showCloseTime}
/>
))}
</ul>
{hasMore && (
<button
className="btn btn-primary self-center normal-case"
onClick={loadMore}
>
Show more
</button>
)}
2021-12-30 20:03:32 +00:00
</Col>
)
}
export function CreatorContractsList(props: { creator: User }) {
const { creator } = props
2021-12-16 02:50:03 +00:00
return (
<ContractSearch
querySortOptions={{
filter: {
creatorId: creator.id,
},
defaultSort: 'newest',
defaultFilter: 'all',
shouldLoadFromStorage: false,
}}
/>
)
}