Skip to content

Commit

Permalink
Add initial unit info reducer and connection
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Oct 22, 2017
1 parent 5bc2c28 commit 0c93284
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
6 changes: 4 additions & 2 deletions src/app/reducers/rootReducer.js
@@ -1,9 +1,11 @@
import {combineReducers} from "redux";

import tabsReducer from "features/tabs/tabsReducer";
import tabReducer from "features/tabs/tabsReducer";
import unitInfoReducer from "features/unitInfo/unitInfoReducer";

const rootReducer = combineReducers({
tabs : tabsReducer
unitInfo : unitInfoReducer,
tabs : tabReducer,
});

export default rootReducer;
55 changes: 36 additions & 19 deletions src/features/unitInfo/UnitInfo.jsx
@@ -1,30 +1,47 @@
import React 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"},
{value : "fs", text : "Federated Suns"},
{value : "fwl", text : "Free Worlds League"},
{value : "lc", text : "Lyran Commonwealth"},
{value : "wd", text : "Wolf's Dragoons"}
];

const UnitInfo = () => (
<Segment attached="bottom">
<Form size="large">
<Form.Field name="name" width={6} >
<label>Unit Name</label>
<input placeholder="Name" />
</Form.Field>
<Form.Field name="affiliation" width={6}>
<label>Affiliation</label>
<Dropdown
selection
options={FACTIONS}
/>
</Form.Field>
</Form>
</Segment>
);

export default UnitInfo;

const mapState = (state) => ({
unitInfo : selectUnitInfo(state),
});


const UnitInfo = ({unitInfo = {}}) => {
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={name}/>
</Form.Field>
<Form.Field name="affiliation" width={6}>
<label>Affiliation</label>
<Dropdown
selection
options={FACTIONS}
value={affiliation}
/>
</Form.Field>
</Form>
</Segment>
);
};


export default connect(mapState)(UnitInfo);
12 changes: 12 additions & 0 deletions src/features/unitInfo/unitInfoReducer.js
@@ -0,0 +1,12 @@
import {createReducer} from "common/utils/reducerUtils";


const initialState = {
name : "Black Widow Company",
affiliation : "wd",
};


export default createReducer(initialState, {

});
1 change: 1 addition & 0 deletions src/features/unitInfo/unitInfoSelectors.js
@@ -0,0 +1 @@
export const selectUnitInfo = state => state.unitInfo;

0 comments on commit 0c93284

Please sign in to comment.