Permalink
Browse files

Implement initial change handling for UnitInfo

  • Loading branch information...
markerikson committed Jan 11, 2017
1 parent 7352c4f commit dc4d179e8ed10f517648d82124f353e6dafda346
Showing with 18 additions and 2 deletions.
  1. +18 −2 src/features/unitInfo/UnitInfo/UnitInfo.jsx
@@ -7,6 +7,7 @@ import {
} from "semantic-ui-react";
import {selectUnitInfo} from "../unitInfoSelectors";
import {updateUnitInfo} from "../unitInfoActions";
const FACTIONS = [
{value : "cc", text : "Capellan Confederation"},
@@ -23,7 +24,20 @@ const mapState = (state) => ({
unitInfo : selectUnitInfo(state),
});
const actions = {
updateUnitInfo,
};
class UnitInfo extends Component {
onAffiliationChanged = (e, result) => {
const {name, value} = result;
const newValues = { [name] : value};
this.props.updateUnitInfo(newValues);
}
render() {
const {unitInfo} = this.props;
const {name, affiliation} = unitInfo;
@@ -33,14 +47,16 @@ class UnitInfo extends Component {
<Form size="large">
<Form.Field name="name" width={6}>
<label>Unit Name</label>
<input placeholder="Name" value={name}/>
<input placeholder="Name" name="name" value={name}/>
</Form.Field>
<Form.Field name="affiliation" width={6}>
<label>Affiliation</label>
<Dropdown
name="affiliation"
selection
options={FACTIONS}
value={affiliation}
onChange={this.onAffiliationChanged}
/>
</Form.Field>
</Form>
@@ -50,4 +66,4 @@ class UnitInfo extends Component {
}
export default connect(mapState)(UnitInfo);
export default connect(mapState, actions)(UnitInfo);

0 comments on commit dc4d179

Please sign in to comment.