Change market description editor to rich text
This commit is contained in:
parent
517ece5d21
commit
322ffd7c36
|
@ -27,6 +27,8 @@ import { track } from 'web/lib/service/analytics'
|
||||||
import { GroupSelector } from 'web/components/groups/group-selector'
|
import { GroupSelector } from 'web/components/groups/group-selector'
|
||||||
import { CATEGORIES } from 'common/categories'
|
import { CATEGORIES } from 'common/categories'
|
||||||
import { User } from 'common/user'
|
import { User } from 'common/user'
|
||||||
|
import { TextEditor } from 'web/components/editor'
|
||||||
|
import { JSONContent } from '@tiptap/react'
|
||||||
|
|
||||||
export default function Create() {
|
export default function Create() {
|
||||||
const [question, setQuestion] = useState('')
|
const [question, setQuestion] = useState('')
|
||||||
|
@ -87,7 +89,6 @@ export function NewContract(props: {
|
||||||
const [initialProb] = useState(50)
|
const [initialProb] = useState(50)
|
||||||
const [minString, setMinString] = useState('')
|
const [minString, setMinString] = useState('')
|
||||||
const [maxString, setMaxString] = useState('')
|
const [maxString, setMaxString] = useState('')
|
||||||
const [description, setDescription] = useState('')
|
|
||||||
// const [tagText, setTagText] = useState<string>(tag ?? '')
|
// const [tagText, setTagText] = useState<string>(tag ?? '')
|
||||||
// const tags = parseWordsAsTags(tagText)
|
// const tags = parseWordsAsTags(tagText)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -132,8 +133,7 @@ export function NewContract(props: {
|
||||||
// get days from today until the end of this year:
|
// get days from today until the end of this year:
|
||||||
const daysLeftInTheYear = dayjs().endOf('year').diff(dayjs(), 'day')
|
const daysLeftInTheYear = dayjs().endOf('year').diff(dayjs(), 'day')
|
||||||
|
|
||||||
const hasUnsavedChanges = !isSubmitting && Boolean(question || description)
|
useWarnUnsavedChanges(!isSubmitting && Boolean(question))
|
||||||
useWarnUnsavedChanges(hasUnsavedChanges)
|
|
||||||
|
|
||||||
const isValid =
|
const isValid =
|
||||||
(outcomeType === 'BINARY' ? initialProb >= 5 && initialProb <= 95 : true) &&
|
(outcomeType === 'BINARY' ? initialProb >= 5 && initialProb <= 95 : true) &&
|
||||||
|
@ -158,11 +158,13 @@ export function NewContract(props: {
|
||||||
setCloseDate(newCloseDate)
|
setCloseDate(newCloseDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submit() {
|
function submit() {
|
||||||
// TODO: Tell users why their contract is invalid
|
// TODO: Tell users why their contract is invalid
|
||||||
if (!creator || !isValid) return
|
if (!creator || !isValid) return
|
||||||
|
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSubmit(description?: JSONContent) {
|
||||||
// TODO: add contract id to the group contractIds
|
// TODO: add contract id to the group contractIds
|
||||||
try {
|
try {
|
||||||
const result = await createMarket(
|
const result = await createMarket(
|
||||||
|
@ -353,15 +355,13 @@ export function NewContract(props: {
|
||||||
<span className="mb-1">Description</span>
|
<span className="mb-1">Description</span>
|
||||||
<InfoTooltip text="Optional. Describe how you will resolve this question." />
|
<InfoTooltip text="Optional. Describe how you will resolve this question." />
|
||||||
</label>
|
</label>
|
||||||
<Textarea
|
<TextEditor
|
||||||
className="textarea textarea-bordered w-full resize-none"
|
className="w-full"
|
||||||
rows={3}
|
rows={3}
|
||||||
maxLength={MAX_DESCRIPTION_LENGTH}
|
max={MAX_DESCRIPTION_LENGTH}
|
||||||
placeholder={descriptionPlaceholder}
|
placeholder={descriptionPlaceholder}
|
||||||
value={description}
|
sending={isSubmitting}
|
||||||
disabled={isSubmitting}
|
onSend={onSubmit}
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
onChange={(e) => setDescription(e.target.value || '')}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user