-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionDropdown.js
53 lines (45 loc) · 1.45 KB
/
OptionDropdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// React & Redux
import React from 'react';
import { connect } from 'react-redux';
// Reduc Store
import { mapOptionStateToProps, mapOptionDispatchToProps } from '../actions/optionActions';
// Material UI
import SelectField from 'material-ui/SelectField';
import MenuItem from 'material-ui/MenuItem';
// CSS
import { dropdownStyle } from '../jss/OptionDropdown';
const OptionDropdown = ({ options, changeHandler, currentStyle, styleName, floatingLabelText }) => (
<div>
<SelectField
name={styleName}
floatingLabelText={floatingLabelText}
value={currentStyle}
style={dropdownStyle}
onChange={(event, index, value) => changeHandler(value, styleName)}
>
{options.map(({ value, text }) => {
if (currentStyle === value) {
return (
<MenuItem style={dropdownStyle} value={value} primaryText={text} />
);
}
return (
<MenuItem style={dropdownStyle} value={value} primaryText={text} />
);
})}
</SelectField>
{/* <select name={styleName} onChange={e => changeHandler(e)}>
{options.map(({ value, text }) => {
if (currentStyle === value) {
return (
<option selected value={value}>{text}</option>
);
}
return (
<option value={value}>{text}</option>
);
})}
</select> */}
</div>
);
export default connect(mapOptionStateToProps, mapOptionDispatchToProps)(OptionDropdown);