2019-09-21 12:54:57 +02:00
|
|
|
import * as React from 'react';
|
2023-02-05 11:55:38 +01:00
|
|
|
import { getLabel } from '../../helpers/formUtils';
|
2019-09-21 12:54:57 +02:00
|
|
|
|
|
|
|
|
import IBoard from '../../interfaces/IBoard';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
boards: Array<IBoard>;
|
|
|
|
|
selectedBoardId: number;
|
|
|
|
|
|
|
|
|
|
handleChange(
|
|
|
|
|
newBoardId: number,
|
|
|
|
|
): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PostBoardSelect = ({
|
|
|
|
|
boards,
|
|
|
|
|
selectedBoardId,
|
|
|
|
|
handleChange,
|
|
|
|
|
}: Props) => (
|
|
|
|
|
<select
|
|
|
|
|
value={selectedBoardId || 'Loading...'}
|
|
|
|
|
onChange={
|
2019-09-26 11:00:32 +02:00
|
|
|
(e: React.FormEvent) => (
|
2019-09-21 12:54:57 +02:00
|
|
|
handleChange(parseInt((e.target as HTMLSelectElement).value))
|
|
|
|
|
)}
|
|
|
|
|
id="selectPickerBoard"
|
|
|
|
|
className="selectPicker"
|
|
|
|
|
>
|
2023-02-05 11:55:38 +01:00
|
|
|
<optgroup label={getLabel('board')}>
|
2019-09-21 12:54:57 +02:00
|
|
|
{boards.map((board, i) => (
|
|
|
|
|
<option value={board.id} key={i}>
|
|
|
|
|
{board.name}
|
|
|
|
|
</option>
|
|
|
|
|
))}
|
|
|
|
|
</optgroup>
|
|
|
|
|
</select>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default PostBoardSelect;
|