Feature markets on trending

This commit is contained in:
Ian Philips 2022-08-25 07:05:26 -06:00
parent b9f0da9d3b
commit dc89d5d4d0
6 changed files with 63 additions and 2 deletions

View File

@ -58,6 +58,7 @@ export type Contract<T extends AnyContractType = AnyContractType> = {
uniqueBettorCount?: number
popularityScore?: number
followerCount?: number
featuredOnHomeRank?: number
} & T
export type BinaryContract = Contract & Binary

View File

@ -71,6 +71,7 @@ export const PROD_CONFIG: EnvConfig = {
'taowell@gmail.com', // Stephen
'abc.sinclair@gmail.com', // Sinclair
'manticmarkets@gmail.com', // Manifold
'iansphilips@gmail.com', // Ian
],
visibility: 'PUBLIC',

View File

@ -11,7 +11,8 @@ service cloud.firestore {
'jahooma@gmail.com',
'taowell@gmail.com',
'abc.sinclair@gmail.com',
'manticmarkets@gmail.com'
'manticmarkets@gmail.com',
'iansphilips@gmail.com'
]
}

View File

@ -0,0 +1,9 @@
import { SparklesIcon } from '@heroicons/react/solid'
export function FeaturedContractBadge() {
return (
<span className="inline-flex items-center gap-1 rounded-full bg-green-100 px-3 py-0.5 text-sm font-medium text-blue-800">
<SparklesIcon className="h-4 w-4" aria-hidden="true" /> Featured
</span>
)
}

View File

@ -33,6 +33,7 @@ import { insertContent } from '../editor/utils'
import clsx from 'clsx'
import { contractMetrics } from 'common/contract-details'
import { User } from 'common/user'
import { FeaturedContractBadge } from 'web/components/contract/FeaturedContractBadge'
export type ShowTime = 'resolve-date' | 'close-date'
@ -73,6 +74,8 @@ export function MiscDetails(props: {
{'Resolved '}
{fromNow(resolutionTime || 0)}
</Row>
) : (contract?.featuredOnHomeRank ?? 0) > 0 ? (
<FeaturedContractBadge />
) : volume > 0 || !isNew ? (
<Row className={'shrink-0'}>{formatMoney(contract.volume)} bet</Row>
) : (

View File

@ -7,7 +7,7 @@ import { Bet } from 'common/bet'
import { Contract } from 'common/contract'
import { formatMoney } from 'common/util/format'
import { contractPool } from 'web/lib/firebase/contracts'
import { contractPool, updateContract } from 'web/lib/firebase/contracts'
import { LiquidityPanel } from '../liquidity-panel'
import { Col } from '../layout/col'
import { Modal } from '../layout/modal'
@ -16,6 +16,7 @@ import { InfoTooltip } from '../info-tooltip'
import { useAdmin, useDev } from 'web/hooks/use-admin'
import { SiteLink } from '../site-link'
import { firestoreConsolePath } from 'common/envs/constants'
import { deleteField } from 'firebase/firestore'
export const contractDetailsButtonClassName =
'group flex items-center rounded-md px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-100 text-gray-400 hover:text-gray-500'
@ -24,6 +25,9 @@ export function ContractInfoDialog(props: { contract: Contract; bets: Bet[] }) {
const { contract, bets } = props
const [open, setOpen] = useState(false)
const [featured, setFeatured] = useState(
(contract?.featuredOnHomeRank ?? 0) > 0
)
const isDev = useDev()
const isAdmin = useAdmin()
@ -138,6 +142,48 @@ export function ContractInfoDialog(props: { contract: Contract; bets: Bet[] }) {
</td>
</tr>
)}
{isAdmin && (
<tr>
<td>Set featured</td>
<td>
<select
className="select select-bordered"
value={featured ? 'true' : 'false'}
onChange={(e) => {
const newVal = e.target.value === 'true'
if (
newVal &&
(contract.featuredOnHomeRank === 0 ||
!contract?.featuredOnHomeRank)
)
updateContract(id, {
featuredOnHomeRank: 1,
})
.then(() => {
setFeatured(true)
})
.catch(console.error)
else if (
!newVal &&
(contract?.featuredOnHomeRank ?? 0) > 0
)
updateContract(id, {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
featuredOnHomeRank: deleteField(),
})
.then(() => {
setFeatured(false)
})
.catch(console.error)
}}
>
<option value="false">false</option>
<option value="true">true</option>
</select>
</td>
</tr>
)}
</tbody>
</table>