Permalink
Browse files

Use faction entries to populate affiliation dropdown

  • Loading branch information...
markerikson committed Jan 1, 2018
1 parent 740e602 commit 50aaf10fa2a4abc50c952ea071d04693889815fa
Showing with 29 additions and 19 deletions.
  1. +29 −19 src/features/unitInfo/UnitInfo/UnitInfoForm.jsx
@@ -3,31 +3,34 @@ import {connect} from "react-redux";
import {
Form,
Dropdown,
Segment
} from "semantic-ui-react";
import {selectUnitInfo} from "../unitInfoSelectors";
import {updateUnitInfo, setUnitColor} from "../unitInfoActions";
import {showColorPicker} from "common/components/ColorPicker/colorPickerActions";
import {getValueFromEvent} from "common/utils/clientUtils";
import FormEditWrapper from "common/components/FormEditWrapper";
import ColorPickerButton from "common/components/ColorPicker/ColorPickerButton";
const FACTIONS = [
{value : "cc", text : "Capellan Confederation"},
{value : "dc", text : "Draconis Combine"},
{value : "elh", text : "Eridani Light Horse"},
{value : "fs", text : "Federated Suns"},
{value : "fwl", text : "Free Worlds League"},
{value : "hr", text : "Hansen's Roughriders"},
{value : "lc", text : "Lyran Commonwealth"},
{value : "wd", text : "Wolf's Dragoons"},
];
const mapState = (state) => ({
unitInfo : selectUnitInfo(state),
});
import {getEntitiesSession} from "features/entities/entitySelectors";
import {selectUnitInfo} from "../unitInfoSelectors";
import {updateUnitInfo, setUnitColor} from "../unitInfoActions";
const mapState = (state) => {
const session = getEntitiesSession(state);
const {Faction} = session;
const factions = Faction.all().toRefArray();
const unitInfo = selectUnitInfo(state);
return {
factions,
unitInfo,
};
};
const actions = {
updateUnitInfo,
@@ -56,9 +59,16 @@ class UnitInfoForm extends Component {
render() {
const {unitInfo, updateUnitInfo} = this.props;
const {unitInfo, updateUnitInfo, factions} = this.props;
const {name, affiliation, color} = unitInfo;
const displayFactions = factions.map(faction => {
return {
value : faction.id,
text : faction.name
};
});
return (
<Form size="large">
@@ -82,7 +92,7 @@ class UnitInfoForm extends Component {
<Dropdown
name="affiliation"
selection
options={FACTIONS}
options={displayFactions}
value={affiliation}
onChange={this.onAffiliationChanged}
/>

0 comments on commit 50aaf10

Please sign in to comment.