import { Editor } from '@tiptap/react' import { Contract } from 'common/contract' import { useState } from 'react' import { Button } from '../button' import { ContractSearch } from '../contract-search' import { Col } from '../layout/col' import { Modal } from '../layout/modal' import { Row } from '../layout/row' import { LoadingIndicator } from '../loading-indicator' import { embedCode } from '../share-embed-button' import { insertContent } from './utils' export function MarketModal(props: { editor: Editor | null open: boolean setOpen: (open: boolean) => void }) { const { editor, open, setOpen } = props const [contracts, setContracts] = useState([]) const [loading, setLoading] = useState(false) async function addContract(contract: Contract) { if (contracts.map((c) => c.id).includes(contract.id)) { setContracts(contracts.filter((c) => c.id !== contract.id)) } else setContracts([...contracts, contract]) } async function doneAddingContracts() { setLoading(true) insertContent(editor, ...contracts.map(embedCode)) setLoading(false) setOpen(false) setContracts([]) } return (
Embed a market
{!loading && ( {contracts.length > 0 && ( )} )}
{loading && (
)}
c.id), highlightClassName: '!bg-indigo-100 outline outline-2 outline-indigo-300', }} additionalFilter={{}} /* hide pills */ headerClassName="bg-white" />
) }