diff --git a/frontend/src/App.js b/frontend/src/App.js index 69a04bb..d6806f0 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,12 +1,9 @@ -import { Container } from 'reactstrap'; +import SamplePage from './pages/SamplePage'; function App() { return (
- -

Right Tree

-

Right Plant Right Place Right Time

-
+
); } diff --git a/frontend/src/pages/SamplePage.js b/frontend/src/pages/SamplePage.js new file mode 100644 index 0000000..0cd93d3 --- /dev/null +++ b/frontend/src/pages/SamplePage.js @@ -0,0 +1,46 @@ +import React from 'react' +import { Container, ListGroup, ListGroupItem } from 'reactstrap'; + +import PlantRepsostory from '../repository/PlantRepository' + +export default class SamplePage extends React.Component { + + constructor(props) { + super(props); + + this.state = { + plants: [] + } + } + + updatePlants() { + PlantRepsostory.getPlants().then(response => { + if (response.status === 200) { + this.setState({ plants: response.data }); + } + }).catch(e => { + this.setState({ plants: ["No plants found."] }); + }) + } + + componentDidMount() { + this.updatePlants() + } + + render() { + return ( + +

Right Tree

+

Right Plant Right Place Right Time

+ +
Plant List
+ + {this.state.plants.map(function (plant, i) { + return {plant.name}; + })} + +
+ ) + } + +} \ No newline at end of file diff --git a/frontend/src/repository/PlantRepository.js b/frontend/src/repository/PlantRepository.js new file mode 100644 index 0000000..65c1b98 --- /dev/null +++ b/frontend/src/repository/PlantRepository.js @@ -0,0 +1,11 @@ +import Repository from "./Repository"; + +const PlantRepsostory = { + + getPlants() { + return Repository.get(`/plants/`); + } + +} + +export default PlantRepsostory;