2018-02-02 21:22:06 +00:00
|
|
|
import React, { Component } from 'react';
|
2018-02-03 03:53:08 +00:00
|
|
|
import Categories from './Categories';
|
|
|
|
import Category from './Category';
|
2018-02-03 06:41:30 +00:00
|
|
|
import Tool from './Tool';
|
2018-02-03 08:48:49 +00:00
|
|
|
import { Container, Dimmer, Dropdown, Header, Icon, Item, Loader, Menu, Segment, Input } from 'semantic-ui-react';
|
2018-02-03 03:53:08 +00:00
|
|
|
import { Link, Route } from 'react-router-dom';
|
|
|
|
|
2018-02-02 21:22:06 +00:00
|
|
|
class App extends Component {
|
2018-02-03 08:48:49 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
toolData: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
fetch('http://localhost:8080/api/client')
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => this.setState({ toolData: data }));
|
|
|
|
}
|
|
|
|
|
2018-02-03 03:53:08 +00:00
|
|
|
render() {
|
2018-02-03 08:48:49 +00:00
|
|
|
const toolData = this.state.toolData;
|
|
|
|
|
2018-02-03 03:53:08 +00:00
|
|
|
return (
|
2018-02-03 06:41:30 +00:00
|
|
|
<div>
|
|
|
|
<Menu fixed='top' borderless inverted>
|
|
|
|
<Menu.Item>
|
|
|
|
<Icon name='bars' size='big' />
|
|
|
|
</Menu.Item>
|
|
|
|
<Menu.Item as={Link} to='/'>
|
|
|
|
<Icon name='home' size='big' />
|
|
|
|
</Menu.Item>
|
|
|
|
<Menu.Menu position='right'>
|
|
|
|
<Menu.Item position='right'>
|
|
|
|
<Input transparent inverted placeholder='Search...' icon='search' />
|
|
|
|
</Menu.Item>
|
|
|
|
</Menu.Menu>
|
|
|
|
</Menu>
|
|
|
|
<div style={{height: '70px', display: 'inline-block'}} />
|
2018-02-03 03:53:08 +00:00
|
|
|
|
|
|
|
|
2018-02-03 08:48:49 +00:00
|
|
|
{toolData ?
|
|
|
|
<div>
|
|
|
|
<Route exact path='/' render={props =>
|
|
|
|
<Categories {...props} data={toolData} />
|
|
|
|
} />
|
|
|
|
|
|
|
|
<Route exact path='/:category' render={props =>
|
|
|
|
<Category {...props} data={toolData} />
|
|
|
|
} />
|
2018-02-03 03:53:08 +00:00
|
|
|
|
2018-02-03 08:48:49 +00:00
|
|
|
<Route exact path='/:category/:id' render={props =>
|
|
|
|
<Tool {...props} data={toolData} />
|
|
|
|
} />
|
|
|
|
</div>
|
|
|
|
:
|
|
|
|
<Dimmer active>
|
|
|
|
<Loader>Loading</Loader>
|
|
|
|
</Dimmer>
|
|
|
|
}
|
2018-02-03 03:53:08 +00:00
|
|
|
|
2018-02-03 06:41:30 +00:00
|
|
|
</div>
|
2018-02-03 03:53:08 +00:00
|
|
|
);
|
|
|
|
}
|
2018-02-02 21:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|