File tree Expand file tree Collapse file tree 2 files changed +32
-17
lines changed Expand file tree Collapse file tree 2 files changed +32
-17
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import Footer from '../components/Footer.jsx';
88import CustomButton from '../components/CustomButton.jsx' ;
99import ProductsAutocomplete from '../components/ProductsAutocomplete.jsx' ;
1010import DepartmentsAutocomplete from '../components/DepartmentsAutocomplete.jsx' ;
11-
11+ import DepartmentAttributes from '../components/DepartmentAttributes.jsx' ;
1212import { departmentsProductAdd } from '../actions/DepartmentsProductsActions.js' ;
1313
1414const 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 >
You can’t perform that action at this time.
0 commit comments