-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from marcoaraujojunior/feature/include_test
Feature/include test
- Loading branch information
Showing
35 changed files
with
1,555 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
node_modules/** | ||
public/dist/** | ||
public/css/** | ||
jest/** | ||
coverage/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: node_js | ||
node_js: | ||
- "6" | ||
|
||
services: | ||
- mongodb | ||
|
||
before_script: | ||
- cd /client/ | ||
- npm install | ||
|
||
script: | ||
- npm run coverage | ||
- codecov | ||
|
||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Router, Route, IndexRoute } from 'react-router' | ||
import { Router, Route, IndexRoute, hashHistory } from 'react-router' | ||
import 'bulma/css/bulma.css' | ||
import 'font-awesome-webpack' | ||
|
||
import iClientComponent from './components/iClient/iClientComponent'; | ||
import HomeComponent from './components/Home/HomeComponent'; | ||
import ClientComponent from './components/Client/ClientComponent'; | ||
import iClientComponent from 'components/IClient/IClient'; | ||
import HomeComponent from 'components/Home/Home'; | ||
import ClientComponent from 'components/Client/Client'; | ||
import AreaComponent from 'components/Area/Area'; | ||
|
||
ReactDOM.render( | ||
<section className="hero is-fullheight is-primary"> | ||
<Router> | ||
<Route path="/" component={iClientComponent} > | ||
<IndexRoute component={HomeComponent} /> | ||
<Route path="client" component={ClientComponent} /> | ||
</Route> | ||
</Router> | ||
</section>, | ||
<Router history={hashHistory} > | ||
<Route path="/" component={iClientComponent} > | ||
<IndexRoute component={HomeComponent} /> | ||
<Route path="client" component={ClientComponent} /> | ||
<Route path="area" component={AreaComponent} /> | ||
<Route path="visit/:id" component={AreaComponent} /> | ||
</Route> | ||
</Router>, | ||
document.getElementById('app') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router' | ||
|
||
import VisitService from 'services/Visit' | ||
|
||
import Visit from 'components/Visit/Visit' | ||
import ErrorComponent from 'components/Error/Error' | ||
|
||
class Area extends React.Component | ||
{ | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
areas : [], | ||
error : '' | ||
}; | ||
this.generate = this.generate.bind(this); | ||
this.generateError = this.generateError.bind(this); | ||
this.getVisitGroupByArea = this.getVisitGroupByArea.bind(this); | ||
this.getVisitGroupByArea(); | ||
} | ||
|
||
getVisitGroupByArea() { | ||
VisitService.getGroupByArea().then((response) => { | ||
this.setState({error: ''}); | ||
this.setState({ | ||
areas: this.generate(response.data.visits) | ||
}); | ||
}).catch((error) => { | ||
if (error.response) { | ||
this.setState({error: error.response.data.error}); | ||
} | ||
}); | ||
} | ||
|
||
generateError(error) { | ||
return ( | ||
<ErrorComponent error={this.state.error} /> | ||
); | ||
} | ||
|
||
generate(areas) { | ||
return areas.map((area, key) => { | ||
return ( | ||
<div className="area" key={ key }> | ||
<h3 className="title is-3">{area._id}</h3> | ||
<Visit visits={area.visits} /> | ||
</div> | ||
); | ||
}); | ||
} | ||
|
||
render() { | ||
if (this.state.error) { | ||
let error = this.generateError(this.state.error); | ||
return error; | ||
} | ||
return ( | ||
<div className="container hello"> | ||
{ this.state.areas } | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Area; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
|
||
const Error = ({error}) => ( | ||
error ? | ||
<div className="notification is-danger"> | ||
{error} | ||
</div> : null | ||
); | ||
|
||
export default Error; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
|
||
class Home extends React.Component{ | ||
|
||
render() { | ||
return ( | ||
<div className="hero-body"> | ||
<div className="container"> | ||
<div className="is-half is-offset-one-quarter"> | ||
<h1 className="title has-text-centered is-1">Welcome to IClient</h1> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Home; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
|
||
import LoginComponent from 'components/Login/Login'; | ||
import MenuComponent from 'components/Menu/Menu'; | ||
|
||
class IClient extends React.Component | ||
{ | ||
constructor(props, context) { | ||
super(props, context); | ||
this.handleView = this.handleView.bind(this); | ||
} | ||
|
||
handleView() { | ||
return ( | ||
<div> | ||
<MenuComponent /> | ||
<section className="hero is-fullheight is-primary"> | ||
{this.props.children} | ||
</section> | ||
</div> | ||
); | ||
} | ||
|
||
render() { | ||
let view = this.handleView(); | ||
|
||
if (!window.localStorage.getItem('token')) { | ||
view = <LoginComponent />; | ||
} | ||
return ( | ||
view | ||
); | ||
} | ||
} | ||
|
||
export default IClient; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router' | ||
|
||
class LinksApp extends React.Component | ||
{ | ||
constructor(props, context) { | ||
super(props, context); | ||
this.generate = this.generate.bind(this); | ||
this.handleClick = this.handleClick.bind(this); | ||
this.state = { | ||
links: this.props.links | ||
}; | ||
} | ||
|
||
handleClick(e) { | ||
if (this.context.onClick) { | ||
this.context.onClick(); | ||
} | ||
} | ||
|
||
generate() { | ||
return this.state.links.map((link, index) => { | ||
return ( | ||
<Link to={link[0]} | ||
key={index} | ||
className="nav-item is-tab" | ||
onlyActiveOnIndex={true} | ||
activeClassName="is-active" | ||
onClick={this.handleClick} | ||
> | ||
{link[1]} | ||
</Link> | ||
); | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<span className="nav-right nav-menu is-active"> | ||
{this.generate()} | ||
</span> | ||
); | ||
} | ||
} | ||
|
||
LinksApp.propTypes = { | ||
links: React.PropTypes.array.isRequired | ||
}; | ||
|
||
LinksApp.contextTypes = { | ||
onClick: React.PropTypes.func | ||
}; | ||
|
||
export default LinksApp; | ||
|
Oops, something went wrong.