Skip to content

Commit db59695

Browse files
committed
Add a Tools panel and mock API for loading sample data
1 parent 6b51219 commit db59695

File tree

7 files changed

+59
-2
lines changed

7 files changed

+59
-2
lines changed

src/app/layout/App.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import UnitInfo from "features/unitInfo/UnitInfo";
99
import Pilots from "features/pilots/Pilots";
1010
import Mechs from "features/mechs/Mechs";
1111
import UnitOrganization from "features/unitOrganization/UnitOrganization";
12-
12+
import Tools from "features/tools/Tools";
1313

1414
import './App.css';
1515

@@ -19,7 +19,8 @@ class App extends Component {
1919
{name : "unitInfo", label : "Unit Info", component : UnitInfo,},
2020
{name : "pilots", label : "Pilots", component : Pilots,},
2121
{name : "mechs", label : "Mechs", component : Mechs,},
22-
{name : "unitOrganization", label : "Unit Organization", component : UnitOrganization}
22+
{name : "unitOrganization", label : "Unit Organization", component : UnitOrganization},
23+
{name : "tools", label : "Tools", component : Tools},
2324
];
2425

2526
return (

src/data/mockAPI.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sampleData from "./sampleData";
2+
3+
export function fetchData() {
4+
return Promise.resolve(sampleData);
5+
}

src/data/sampleData.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const sampleData = {
2+
unit : {
3+
name : "Black Widow Company",
4+
affiliation : "wd",
5+
},
6+
};
7+
8+
9+
10+
export default sampleData;

src/features/tools/Tools/Tools.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React, {Component} from "react";
2+
import {connect} from "react-redux";
3+
import {
4+
Segment,
5+
Button,
6+
} from "semantic-ui-react";
7+
8+
import {loadUnitData} from "../toolActions";
9+
10+
const actions = {loadUnitData};
11+
12+
class Tools extends Component {
13+
render() {
14+
const {loadUnitData} = this.props;
15+
16+
return (
17+
<Segment attached="bottom">
18+
<Button onClick={loadUnitData}>Reload Unit Data</Button>
19+
</Segment>
20+
)
21+
}
22+
}
23+
24+
export default connect(null, actions)(Tools);

src/features/tools/Tools/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from "./Tools";

src/features/tools/toolActions.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {fetchData} from "data/mockAPI";
2+
3+
import {DATA_LOADED} from "./toolConstants";
4+
5+
export function loadUnitData() {
6+
return (dispatch, getState) => {
7+
fetchData()
8+
.then(data => {
9+
dispatch({
10+
type : DATA_LOADED,
11+
payload : data
12+
})
13+
});
14+
}
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const DATA_LOADED = "DATA_LOADED";

0 commit comments

Comments
 (0)