Permalink
Browse files

Add initial unit info reducer and connection

  • Loading branch information...
markerikson committed Dec 1, 2016
1 parent db59695 commit bce3a2d3d4220eb0d80c2bc1d5c7ecc97c0c1e75
@@ -1,8 +1,10 @@
import {combineReducers} from "redux";
import tabReducer from "features/tabs/tabReducer";
import unitInfoReducer from "features/unitInfo/unitInfoReducer";
const rootReducer = combineReducers({
unitInfo : unitInfoReducer,
tabs : tabReducer,
});
@@ -1,10 +1,13 @@
import React from "react";
import React, {Component} from "react";
import {connect} from "react-redux";
import {
Form,
Dropdown,
Segment
} from "semantic-ui-react";
import {selectUnitInfo} from "../unitInfoSelectors";
const FACTIONS = [
{value : "cc", text : "Capellan Confederation"},
{value : "dc", text : "Draconis Combine"},
@@ -16,27 +19,35 @@ const FACTIONS = [
{value : "wd", text : "Wolf's Dragoons"},
];
const UnitInfo = () => {
const mapState = (state) => ({
unitInfo : selectUnitInfo(state),
});
class UnitInfo extends Component {
render() {
const {unitInfo} = this.props;
const {name, affiliation} = unitInfo;
return (
<Segment attached="bottom">
<Form size="large">
<Form.Field name="name" width={6} >
<label>Unit Name</label>
<input placeholder="Name" value="Black Widow Company"/>
</Form.Field>
<Form.Field name="affiliation" width={6}>
<label>Affiliation</label>
<Dropdown
selection
options={FACTIONS}
value="wd"
/>
</Form.Field>
</Form>
</Segment>
);
return (
<Segment attached="bottom">
<Form size="large">
<Form.Field name="name" width={6}>
<label>Unit Name</label>
<input placeholder="Name" value={name}/>
</Form.Field>
<Form.Field name="affiliation" width={6}>
<label>Affiliation</label>
<Dropdown
selection
options={FACTIONS}
value={affiliation}
/>
</Form.Field>
</Form>
</Segment>
);
}
}
export default UnitInfo;
export default connect(mapState)(UnitInfo);
@@ -0,0 +1,12 @@
import {createReducer} from "common/utils/reducerUtils";
const initialState = {
name : "Black Widow Company",
affiliation : "wd",
};
export default createReducer(initialState, {
});
@@ -0,0 +1,2 @@
export const selectUnitInfo = state => state.unitInfo;

0 comments on commit bce3a2d

Please sign in to comment.