Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial unit info reducer and connection
- Loading branch information
1 parent
5bc2c28
commit 0c93284
Showing
4 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {createReducer} from "common/utils/reducerUtils"; | ||
|
||
|
||
const initialState = { | ||
name : "Black Widow Company", | ||
affiliation : "wd", | ||
}; | ||
|
||
|
||
export default createReducer(initialState, { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const selectUnitInfo = state => state.unitInfo; |