Permalink
Browse files

Add a Lance component

  • Loading branch information...
markerikson committed Jan 1, 2018
1 parent 01e506b commit b2cba10ea94a6bea5e29b94d38bcb67ad261cf58
Showing with 50 additions and 0 deletions.
  1. +50 −0 src/features/unitInfo/UnitOrganizationTree/Lance.jsx
@@ -0,0 +1,50 @@
import React from "react";
import {connect} from "react-redux";
import {
List,
} from "semantic-ui-react";
import {getEntitiesSession} from "features/entities/entitySelectors";
import LancePilot from "./LancePilot";
const mapState = (state, ownProps) => {
const session = getEntitiesSession(state);
const {Lance} = session;
let lance, pilots;
if(Lance.hasId(ownProps.lanceID)) {
const lanceModel = Lance.withId(ownProps.lanceID);
lance = lanceModel.ref;
pilots = lanceModel.pilots.toRefArray().map(pilot => pilot.id);
}
return {lance, pilots};
};
const UNKNOWN_LANCE = {name : "Unknown"}
const Lance = ({lance = UNKNOWN_LANCE, pilots = []}) => {
const {name} = lance;
const lancePilots = pilots.map(pilotID => <LancePilot key={pilotID} pilotID={pilotID} />);
return (
<List.Item>
<List.Icon name="cube" />
<List.Content>
<List.Header>{name}</List.Header>
<List.List>
{lancePilots}
</List.List>
</List.Content>
</List.Item>
)
};
export default connect(mapState)(Lance);

0 comments on commit b2cba10

Please sign in to comment.