Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { usePrivateUser } from 'web/hooks/use-user'
|
|
import { Button } from 'web/components/buttons/button'
|
|
import { withTracking } from 'web/lib/service/analytics'
|
|
import { toast } from 'react-hot-toast'
|
|
import { Contract } from 'common/contract'
|
|
import { api } from 'web/lib/api/api'
|
|
|
|
export function BlockMarketButton(props: { contract: Contract }) {
|
|
const { contract } = props
|
|
const privateUser = usePrivateUser()
|
|
if (!privateUser || (privateUser && privateUser.id === contract.creatorId))
|
|
return null
|
|
const isBlocked = privateUser.blockedContractIds?.includes(contract.id)
|
|
|
|
const onBlock = async () => {
|
|
await toast.promise(
|
|
api('market/:contractId/block', { contractId: contract.id }),
|
|
{
|
|
loading: 'Blocking...',
|
|
success: `You'll no longer see this question in your feed nor search.`,
|
|
error: 'Error blocking user',
|
|
}
|
|
)
|
|
}
|
|
const onUnblock = async () => {
|
|
await api('market/:contractId/unblock', { contractId: contract.id })
|
|
}
|
|
|
|
if (isBlocked) {
|
|
return (
|
|
<Button size="xs" onClick={withTracking(onUnblock, 'unblock')}>
|
|
Unblock
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
size="xs"
|
|
color="yellow-outline"
|
|
onClick={withTracking(onBlock, 'block')}
|
|
>
|
|
Block
|
|
</Button>
|
|
)
|
|
}
|