Permalink
Browse files

Add a Tools panel and mock API for loading sample data

  • Loading branch information...
markerikson committed Dec 1, 2016
1 parent 6b51219 commit db59695446d6342faadbaec11c1af2c6b9c27f78
View
@@ -9,7 +9,7 @@ import UnitInfo from "features/unitInfo/UnitInfo";
import Pilots from "features/pilots/Pilots";
import Mechs from "features/mechs/Mechs";
import UnitOrganization from "features/unitOrganization/UnitOrganization";
import Tools from "features/tools/Tools";
import './App.css';
@@ -19,7 +19,8 @@ class App extends Component {
{name : "unitInfo", label : "Unit Info", component : UnitInfo,},
{name : "pilots", label : "Pilots", component : Pilots,},
{name : "mechs", label : "Mechs", component : Mechs,},
{name : "unitOrganization", label : "Unit Organization", component : UnitOrganization}
{name : "unitOrganization", label : "Unit Organization", component : UnitOrganization},
{name : "tools", label : "Tools", component : Tools},
];
return (
View
@@ -0,0 +1,5 @@
import sampleData from "./sampleData";
export function fetchData() {
return Promise.resolve(sampleData);
}
View
@@ -0,0 +1,10 @@
const sampleData = {
unit : {
name : "Black Widow Company",
affiliation : "wd",
},
};
export default sampleData;
@@ -0,0 +1,24 @@
import React, {Component} from "react";
import {connect} from "react-redux";
import {
Segment,
Button,
} from "semantic-ui-react";
import {loadUnitData} from "../toolActions";
const actions = {loadUnitData};
class Tools extends Component {
render() {
const {loadUnitData} = this.props;
return (
<Segment attached="bottom">
<Button onClick={loadUnitData}>Reload Unit Data</Button>
</Segment>
)
}
}
export default connect(null, actions)(Tools);
@@ -0,0 +1 @@
export {default} from "./Tools";
@@ -0,0 +1,15 @@
import {fetchData} from "data/mockAPI";
import {DATA_LOADED} from "./toolConstants";
export function loadUnitData() {
return (dispatch, getState) => {
fetchData()
.then(data => {
dispatch({
type : DATA_LOADED,
payload : data
})
});
}
}
@@ -0,0 +1 @@
export const DATA_LOADED = "DATA_LOADED";

0 comments on commit db59695

Please sign in to comment.