Skip to content

Commit 2cb2c93

Browse files
author
Andrei Alexandru
committed
departments use selected product, small css updates
1 parent 65b4ef2 commit 2cb2c93

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

views/src/screens/Departments.jsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const mapStateToProps = state => {
1212
return {
1313
serverUrl: state.serverUrl,
1414
user: state.user,
15-
links: state.links
15+
links: state.links,
16+
product: state.departments.products.selected
1617
}
1718
}
1819

@@ -27,7 +28,6 @@ class Departments extends Component {
2728

2829
this.handleDepartmentChange = this.handleDepartmentChange.bind(this);
2930
this.handleRemoveOnClick = this.handleRemoveOnClick.bind(this);
30-
// this.handleProductChange=this.handleProductChange.bind(this);
3131
this.handleDepartmentAdd=this.handleDepartmentAdd.bind(this);
3232
this.getUnassignedProducts=this.getUnassignedProducts.bind(this);
3333
}
@@ -58,15 +58,13 @@ class Departments extends Component {
5858
});
5959
}
6060

61-
// handleProductChange(e) {
62-
// const productId = e.target.value,
63-
// product = this.state.products.filter((product) => productId==product._id)[0];
64-
// this.setState({ product:product});
65-
// }
66-
6761
handleDepartmentAdd(e, departmentId) {
68-
const product = this.state.product,
69-
departments = product.departments || [] ;
62+
const product = this.props.product;
63+
if(!product) {
64+
console.warn('No product selected in Products List.');
65+
return;
66+
}
67+
const departments = product.departments || [] ;
7068

7169
departments.push(departmentId);
7270
console.log(product._id);
@@ -154,5 +152,6 @@ export default connect(mapStateToProps)(Departments);
154152

155153
Departments.propTypes = {
156154
serverUrl: PropTypes.string,
157-
links: PropTypes.array
155+
links: PropTypes.array,
156+
product: PropTypes.object
158157
}

views/src/scss/components/departments.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
}
1111
.departement-products{
1212
justify-content: space-between;
13-
display:flex;
13+
display: flex;
14+
align-items: center;
1415
}
1516

1617
.department-products-list {
1718
list-style: none;
18-
padding-left: 24px;
19+
padding-left: 6px;
1920
}
2021

2122
.departement-product-line{

0 commit comments

Comments
 (0)