Fix random errors (#205)

* Fix warning in ShareMarket component

* Fix NewContract component to use keys on category list

* Refactor NewContract component to assign `value` to `select`
This commit is contained in:
Marshall Polaris 2022-05-13 16:42:48 -07:00 committed by GitHub
parent 0e64e0f9f9
commit babca140f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -13,6 +13,7 @@ export function ShareMarket(props: { contract: Contract; className?: string }) {
<Row className="mb-6 items-center"> <Row className="mb-6 items-center">
<input <input
className="input input-bordered flex-1 rounded-r-none text-gray-500" className="input input-bordered flex-1 rounded-r-none text-gray-500"
readOnly
type="text" type="text"
value={contractUrl(contract)} value={contractUrl(contract)}
/> />

View File

@ -20,7 +20,7 @@ import { MAX_DESCRIPTION_LENGTH, outcomeType } from 'common/contract'
import { formatMoney } from 'common/util/format' import { formatMoney } from 'common/util/format'
import { useHasCreatedContractToday } from 'web/hooks/use-has-created-contract-today' import { useHasCreatedContractToday } from 'web/hooks/use-has-created-contract-today'
import { removeUndefinedProps } from '../../common/util/object' import { removeUndefinedProps } from '../../common/util/object'
import { CATEGORIES, CATEGORY_LIST, TO_CATEGORY } from 'common/categories' import { CATEGORIES } from 'common/categories'
export default function Create() { export default function Create() {
const [question, setQuestion] = useState('') const [question, setQuestion] = useState('')
@ -214,15 +214,13 @@ export function NewContract(props: { question: string; tag?: string }) {
<select <select
className="select select-bordered w-full max-w-xs" className="select select-bordered w-full max-w-xs"
onChange={(e) => value={category}
setCategory(TO_CATEGORY[e.currentTarget.value] ?? '') onChange={(e) => setCategory(e.currentTarget.value ?? '')}
}
> >
<option selected={category === ''}></option> <option value={''}></option>
{Object.entries(CATEGORIES).map(([id, name]) => (
{CATEGORY_LIST.map((cat) => ( <option key={id} value={id}>
<option selected={category === cat} value={CATEGORIES[cat]}> {name}
{CATEGORIES[cat]}
</option> </option>
))} ))}
</select> </select>