Skip to content

Commit 189dff4

Browse files
author
Andrei Alexandru
committed
DepartmentAttributes component
1 parent fe625f9 commit 189dff4

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, {Component} from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
class DepartmentAttributes extends Component {
5+
6+
render() {
7+
const department = this.props.department;
8+
return (
9+
<div key={department._id}>
10+
<div className="department-attribute">
11+
<span>Name:</span> {department.name}
12+
</div>
13+
<div className="department-attribute">
14+
<span>Abbreviation:</span> {department.abbreviation}
15+
</div>
16+
<div className="department-attribute">
17+
<span>Description:</span> {department.description}
18+
</div>
19+
<hr />
20+
</div>
21+
)
22+
}
23+
}
24+
25+
export default DepartmentAttributes;
26+
27+
DepartmentAttributes.propTypes = {
28+
department: PropTypes.object
29+
}

views/src/screens/Departments.jsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Footer from '../components/Footer.jsx';
88
import CustomButton from '../components/CustomButton.jsx';
99
import ProductsAutocomplete from '../components/ProductsAutocomplete.jsx';
1010
import DepartmentsAutocomplete from '../components/DepartmentsAutocomplete.jsx';
11-
11+
import DepartmentAttributes from '../components/DepartmentAttributes.jsx';
1212
import {departmentsProductAdd} from '../actions/DepartmentsProductsActions.js';
1313

1414
const mapStateToProps = state => {
@@ -96,22 +96,8 @@ class Departments extends Component {
9696
text="Add product in department" />
9797
<hr />
9898
<h3>Departments List</h3>
99-
{this.state.departments.map(department => {
100-
return (
101-
<div key={department._id}>
102-
<div className="department-attribute">
103-
<span>Name:</span> {department.name}
104-
</div>
105-
<div className="department-attribute">
106-
<span>Abbreviation:</span> {department.abbreviation}
107-
</div>
108-
<div className="department-attribute">
109-
<span>Description:</span> {department.description}
110-
</div>
111-
<hr />
112-
</div>
113-
)
114-
}
99+
{this.state.departments.map(department =>
100+
<DepartmentAttributes department={department} key={department._id}/>
115101
)}
116102
</div>
117103
</div>

0 commit comments

Comments
 (0)