Skip to content

Commit 94087e2

Browse files
Merge pull request #25 from highideas/develop
Develop
2 parents 44466ec + 4d5585a commit 94087e2

File tree

12 files changed

+519
-17
lines changed

12 files changed

+519
-17
lines changed

app/App.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import 'style-loader!css-loader!less-loader!font-awesome-webpack/font-awesome-st
66

77
import iClientComponent from 'components/IClient/IClient'
88
import HomeComponent from 'components/Home/Home'
9-
import AreaComponent from 'components/Area/Area'
9+
import AreaComponent from 'components/Area/List/Area'
10+
import LastVisitsComponent from 'components/Area/Area'
1011
import ListClientComponent from 'components/Client/List/Client'
1112
import ProfileClientComponent from 'components/Client/Profile/Client'
1213
import SaveClientComponent from 'components/Client/Save/Client'
1314
import CreateVisitComponent from 'components/Visit/Create/Visit'
15+
import ShowVisitComponent from 'components/Visit/Show/Visit'
1416
import CreateAreaComponent from 'components/Area/Create/Area'
1517

1618
ReactDOM.render(
@@ -24,7 +26,8 @@ ReactDOM.render(
2426
<Route path="areas" component={AreaComponent} />
2527
<Route path="area" component={CreateAreaComponent} />
2628
<Route path="visit/:clientId/" component={CreateVisitComponent} />
27-
<Route path="visit/:id" component={AreaComponent} />
29+
<Route path="visit/:id" component={ShowVisitComponent} />
30+
<Route path="lastVisits" component={LastVisitsComponent} />
2831
</Route>
2932
</Router>,
3033
document.getElementById('app')

app/components/Area/Area.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,6 @@ class Area extends React.Component
5757
}
5858
return (
5959
<div className="container hello">
60-
<div className="level header">
61-
<div className="level-left">
62-
<h2 className="title is-2">iClient</h2>
63-
</div>
64-
<div className="level-right">
65-
<Link to='/area' className="button is-info is-medium">
66-
<span className="icon">
67-
<i className="fa fa-plus"></i>
68-
</span>
69-
<span>New Area</span>
70-
</Link>
71-
</div>
72-
</div>
7360
{ this.state.areas }
7461
</div>
7562
);

app/components/Area/List/Area.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React from 'react';
2+
import { Link } from 'react-router'
3+
4+
import AreaService from 'services/Area'
5+
6+
import Error from 'components/Error/Error'
7+
8+
class Area extends React.Component
9+
{
10+
constructor(props) {
11+
super(props);
12+
this.state = {
13+
areas : null,
14+
error : ''
15+
};
16+
this.getAreas();
17+
}
18+
19+
getAreas() {
20+
AreaService.getAll().then((response) => {
21+
this.setState({areas: response.data.areas});
22+
}).catch((error) => {
23+
this.setState({error: 'Error Found: Trying get area'});
24+
if (typeof error.response.data.error !== 'undefined') {
25+
this.setState({error: error.response.data.error});
26+
}
27+
});
28+
}
29+
30+
render() {
31+
if (this.state.error) {
32+
return (<Error error={this.state.error} />);
33+
}
34+
if (!this.state.areas) {
35+
return <div>Loading...</div>;
36+
}
37+
const areaList = this.state.areas.map((area, key) => {
38+
let line = ((key % 2) ? 'is-success' : 'is-info');
39+
return (
40+
<tr key={key}>
41+
<td>
42+
{ area._id }
43+
</td>
44+
</tr>
45+
);
46+
});
47+
48+
return (
49+
<section className="">
50+
<div className="container hello">
51+
<div className="level header">
52+
<div className="level-left">
53+
<h2 className="title is-2">Areas</h2>
54+
</div>
55+
<div className="level-right">
56+
<Link to='/area' className="button is-info is-medium">
57+
<span className="icon">
58+
<i className="fa fa-plus"></i>
59+
</span>
60+
<span>New Area</span>
61+
</Link>
62+
</div>
63+
</div>
64+
<table className="table">
65+
<tbody>
66+
{ areaList }
67+
</tbody>
68+
</table>
69+
</div>
70+
</section>
71+
);
72+
}
73+
}
74+
75+
export default Area;

app/components/Menu/Menu.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Menu extends React.Component{
1414
links: [
1515
[ '/', 'Home'],
1616
['/clients', 'Clients'],
17+
['/lastVisits', 'Last Visits'],
1718
['/areas', 'Areas']
1819
]
1920
};

app/components/Visit/Show/Visit.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React from 'react';
2+
import { Link } from 'react-router'
3+
4+
import VisitService from 'services/Visit'
5+
import Error from 'components/Error/Error'
6+
import styles from 'components/Visit/Show/styles.css'
7+
import DateHelper from 'helpers/DateHelper'
8+
9+
class Visit extends React.Component
10+
{
11+
constructor(props) {
12+
super(props);
13+
this.state = {
14+
visit : null,
15+
error: ''
16+
};
17+
this.getVisit(this.props.params.id);
18+
}
19+
20+
getVisit(id) {
21+
VisitService.find(id).then((response) => {
22+
this.setState({visit: response.data.visit.shift()});
23+
}).catch((error) => {
24+
this.setState({error: 'Error Found: Trying get visit'});
25+
let isValidResponse = typeof error.response.data !== 'undefined'
26+
if (typeof error.response.data.error !== 'undefined') {
27+
this.setState({error: error.response.data.error});
28+
}
29+
});
30+
}
31+
32+
render() {
33+
if (this.state.error) {
34+
return (<Error error={this.state.error} />);
35+
}
36+
if (!this.state.visit) {
37+
return <div>Loading...</div>;
38+
}
39+
40+
return (
41+
<div className="container column is-12">
42+
<div className="section profile-heading profile-heading-color profile-visit">
43+
<div className="columns">
44+
<div className="column is-4">
45+
<div className="image is-2by1">
46+
<img src="https://placehold.it/256x256" />
47+
</div>
48+
</div>
49+
<div className="column is-4 name">
50+
<h3 className="title is-3 color-black">
51+
<strong>{this.state.visit.client.name}</strong>
52+
</h3>
53+
<p className="tagline">
54+
<strong>Visit Date: </strong>{DateHelper.formateDate(this.state.visit.visit_date)}
55+
</p>
56+
<p className="tagline">
57+
<strong>Address: </strong>{this.state.visit.client.address}
58+
</p>
59+
<p className="tagline">
60+
<strong>Area: </strong>{this.state.visit.client.area._id}
61+
</p>
62+
</div>
63+
<div className="column is-2 followers has-text-centered">
64+
<p className="stat-val"><strong>R$ {this.state.visit.value_received}</strong></p>
65+
<p className="stat-key">Value Received</p>
66+
</div>
67+
<div className="column is-2 likes has-text-centered">
68+
<p className="stat-val"><strong>{this.state.visit.sales_quantity}</strong></p>
69+
<p className="stat-key">Sales Quantity</p>
70+
</div>
71+
</div>
72+
</div>
73+
</div>
74+
);
75+
}
76+
}
77+
78+
export default Visit;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
body {
2+
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
3+
}
4+
.container.profile {
5+
margin-top:50px;
6+
}
7+
.section.profile-visit {
8+
padding-bottom: 50px!important;
9+
}
10+
.section.profile-visit .stat-key{
11+
font-weight: normal!important;
12+
font-size: 14px!important;
13+
}
14+
.section.profile-visit .tagline {
15+
padding: 20px 0;
16+
line-height: 0.1;
17+
font-size: 14px!important;
18+
}
19+
20+
.profile-heading .followers, .profile-heading .following {
21+
border-right: 1px solid #f1f1f1;
22+
margin: -30px 0;
23+
padding: 70px 30px;
24+
}
25+
.profile-heading .likes {
26+
margin: -30px 0;
27+
padding: 70px 30px;
28+
border-right:none!important;
29+
}
30+
.profile-heading .name {
31+
border-right: 1px solid #f1f1f1;
32+
margin:-30px 0;
33+
padding: 40px 30px 0 30px;
34+
}
35+
.profile-heading .followers, .profile-heading .following {
36+
border-right: 1px solid #f1f1f1;
37+
margin:-30px 0;
38+
padding: 70px 30px;
39+
}
40+
.profile-heading .likes {
41+
margin:-30px 0;
42+
padding: 70px 30px;
43+
}
44+
.profile-heading .stat-key {
45+
font-size: 20px;
46+
font-weight: 200;
47+
}
48+
.profile-heading .stat-val {
49+
font-size: 35px;
50+
font-weight: bold;
51+
}
52+
.profile-options {
53+
background-color: #f1f1f1;
54+
margin:-20px 0 20px 0;
55+
}
56+
.profile-options .link a {
57+
padding:18px;
58+
font-size: 18px;
59+
}
60+
.profile-options .link .icon {
61+
font-size: 16px;
62+
padding-top:2px;
63+
}
64+
.tagline {
65+
padding:20px 0;
66+
font-size: 16px;
67+
line-height: 1.4;
68+
}
69+
.avatar {
70+
float: right;
71+
}
72+
.follow {
73+
float: right;
74+
}
75+
.avatar img {
76+
border-radius: 200px;
77+
}
78+
p.title.is-bold {
79+
font-weight: bold;
80+
}
81+
.card .timestamp {
82+
float:right;
83+
color:#bbb;
84+
}
85+
.profile-heading-color {
86+
color: #333;
87+
}
88+
.color-black {
89+
color: black !important;
90+
}

app/helpers/DateHelper.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const DateHelper = {
2+
formateDate(date) {
3+
let dateObj = new Date(date);
4+
let options = {
5+
day: '2-digit',
6+
month: '2-digit',
7+
year: 'numeric'
8+
}
9+
return dateObj.toLocaleDateString("en-US", options);
10+
}
11+
}
12+
13+
export default DateHelper;

app/services/Visit.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const Visit = {
2222

2323
save(data) {
2424
return axios.post(this.getEntryPoint().join('/'), data, this.getConfig());
25+
},
26+
27+
find(id) {
28+
let url = this.getEntryPoint();
29+
url.push(id);
30+
31+
return axios.get(url.join('/'), this.getConfig());
2532
}
2633
};
2734

codecov.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ codecov:
44
require_ci_to_pass: true
55
comment:
66
behavior: default
7-
layout: header, diff
7+
layout: header, diff, sunburst
88
require_changes: false
99
coverage:
1010
precision: 2
@@ -26,3 +26,14 @@ parsers:
2626
javascript:
2727
enable_partials: false
2828

29+
status:
30+
project:
31+
default:
32+
enabled: yes
33+
target: auto
34+
branches: null
35+
threshold: null
36+
if_no_uploads: error
37+
if_not_found: success
38+
if_ci_failed: error
39+

0 commit comments

Comments
 (0)