Permalink
Browse files

Show lances in the Unit TOE tree based on current Unit entry contents

  • Loading branch information...
markerikson committed Jan 1, 2018
1 parent d1d5a75 commit eca88380cf56844e54d0f3804b83f7342a024093
Showing with 23 additions and 5 deletions.
  1. +23 −5 src/features/unitInfo/UnitOrganizationTree/UnitOrganizationTree.jsx
@@ -1,27 +1,45 @@
import React from "react";
import {connect} from "react-redux";
import {
List,
} from "semantic-ui-react";
import {getEntitiesSession} from "features/entities/entitySelectors";
import Lance from "./Lance";
const UnitOrganizationTree = () => {
const mapState = (state) => {
const session = getEntitiesSession(state);
const {Unit} = session;
let lances;
const unitModel = Unit.all().first();
if(unitModel) {
lances = unitModel.lances.toRefArray().map(lance => lance.id);
}
return {lances};
}
const UnitOrganizationTree = ({lances = []}) => {
const lanceEntries = lances.map(lanceID => <Lance key={lanceID} lanceID={lanceID} />);
return (
<List size="large">
<List.Item>
<List.Icon name="cubes" />
<List.Content>
<List.Header>Black Widow Company</List.Header>
<List.List>
<Lance lanceID={1} />
<Lance lanceID={2} />
<Lance lanceID={3} />
{lanceEntries}
</List.List>
</List.Content>
</List.Item>
</List>
)
}
export default UnitOrganizationTree;
export default connect(mapState)(UnitOrganizationTree);

0 comments on commit eca8838

Please sign in to comment.