Skip to content

Commit bce3a2d

Browse files
committed
Add initial unit info reducer and connection
1 parent db59695 commit bce3a2d

File tree

4 files changed

+48
-21
lines changed

4 files changed

+48
-21
lines changed

src/app/reducers/rootReducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import {combineReducers} from "redux";
22

33
import tabReducer from "features/tabs/tabReducer";
4+
import unitInfoReducer from "features/unitInfo/unitInfoReducer";
45

56
const rootReducer = combineReducers({
7+
unitInfo : unitInfoReducer,
68
tabs : tabReducer,
79
});
810

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import React from "react";
1+
import React, {Component} from "react";
2+
import {connect} from "react-redux";
23
import {
34
Form,
45
Dropdown,
56
Segment
67
} from "semantic-ui-react";
78

9+
import {selectUnitInfo} from "../unitInfoSelectors";
10+
811
const FACTIONS = [
912
{value : "cc", text : "Capellan Confederation"},
1013
{value : "dc", text : "Draconis Combine"},
@@ -16,27 +19,35 @@ const FACTIONS = [
1619
{value : "wd", text : "Wolf's Dragoons"},
1720
];
1821

19-
const UnitInfo = () => {
22+
const mapState = (state) => ({
23+
unitInfo : selectUnitInfo(state),
24+
});
25+
26+
class UnitInfo extends Component {
27+
render() {
28+
const {unitInfo} = this.props;
29+
const {name, affiliation} = unitInfo;
2030

21-
return (
22-
<Segment attached="bottom">
23-
<Form size="large">
24-
<Form.Field name="name" width={6} >
25-
<label>Unit Name</label>
26-
<input placeholder="Name" value="Black Widow Company"/>
27-
</Form.Field>
28-
<Form.Field name="affiliation" width={6}>
29-
<label>Affiliation</label>
30-
<Dropdown
31-
selection
32-
options={FACTIONS}
33-
value="wd"
34-
/>
35-
</Form.Field>
36-
</Form>
37-
</Segment>
38-
);
31+
return (
32+
<Segment attached="bottom">
33+
<Form size="large">
34+
<Form.Field name="name" width={6}>
35+
<label>Unit Name</label>
36+
<input placeholder="Name" value={name}/>
37+
</Form.Field>
38+
<Form.Field name="affiliation" width={6}>
39+
<label>Affiliation</label>
40+
<Dropdown
41+
selection
42+
options={FACTIONS}
43+
value={affiliation}
44+
/>
45+
</Form.Field>
46+
</Form>
47+
</Segment>
48+
);
49+
}
3950
}
4051

4152

42-
export default UnitInfo;
53+
export default connect(mapState)(UnitInfo);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {createReducer} from "common/utils/reducerUtils";
2+
3+
4+
const initialState = {
5+
name : "Black Widow Company",
6+
affiliation : "wd",
7+
};
8+
9+
10+
export default createReducer(initialState, {
11+
12+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
export const selectUnitInfo = state => state.unitInfo;

0 commit comments

Comments
 (0)