You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
922 B
39 lines
922 B
import React, { FC } from 'react'
|
|
import noop from 'lodash/noop'
|
|
|
|
import { FormNotification } from 'src/types'
|
|
|
|
interface SelectOptions {
|
|
[value: string]: string
|
|
}
|
|
|
|
export interface Props {
|
|
name: string
|
|
label: string
|
|
options: SelectOptions
|
|
value?: string
|
|
notification?: FormNotification
|
|
setValue?: (value: string) => void
|
|
}
|
|
|
|
const SelectField: FC<Props> = ({
|
|
label,
|
|
options = {},
|
|
value = '',
|
|
setValue = noop,
|
|
}) => {
|
|
const opts = Object.entries(options)
|
|
|
|
return (
|
|
<div className="field">
|
|
<label className="label">{label}</label>
|
|
<div className="select is-small">
|
|
<select value={value} onChange={(e) => setValue(e.target.value)}>
|
|
{opts.map(([key, value]) => <option key={key} value={key}>{value}</option>)}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default SelectField
|