2018-09-17 14:01:51 +02:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
options: string[],
|
2018-09-17 16:31:19 +02:00
|
|
|
optionSelected: string => void,
|
2018-10-16 17:04:28 +02:00
|
|
|
preselectedOption?: string
|
2018-10-04 20:02:18 +02:00
|
|
|
};
|
2018-09-17 14:01:51 +02:00
|
|
|
|
|
|
|
|
class DropDown extends React.Component<Props> {
|
|
|
|
|
render() {
|
2018-10-04 20:02:18 +02:00
|
|
|
const { options, preselectedOption } = this.props;
|
|
|
|
|
return (
|
|
|
|
|
<div className="select">
|
2018-10-16 17:04:28 +02:00
|
|
|
<select
|
|
|
|
|
value={preselectedOption ? preselectedOption : ""}
|
|
|
|
|
onChange={this.change}
|
|
|
|
|
>
|
2018-10-04 20:02:18 +02:00
|
|
|
<option key="" />
|
|
|
|
|
{options.map(option => {
|
|
|
|
|
return (
|
|
|
|
|
<option key={option} value={option}>
|
|
|
|
|
{option}
|
|
|
|
|
</option>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2018-09-17 14:01:51 +02:00
|
|
|
}
|
|
|
|
|
|
2018-10-16 17:04:28 +02:00
|
|
|
change = (event: Event) => {
|
2018-09-17 14:01:51 +02:00
|
|
|
this.props.optionSelected(event.target.value);
|
2018-10-04 20:02:18 +02:00
|
|
|
};
|
2018-09-17 14:01:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DropDown;
|