Skip to content

Commit

Permalink
Fix : enable news more button for company unlimited seats [NHUB-293] (#…
Browse files Browse the repository at this point in the history
…403)

* enable news more button for company unlimited seats

* fix black
  • Loading branch information
devketanpro authored Jun 14, 2023
1 parent 38b2ffd commit dc39910
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions assets/components/cards/render/CardRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ class CardRow extends React.Component {
}
}
render() {
const {title, product, children, userProducts,userType} = this.props;
const {title, product, children, userProducts, userType, companyProducts} = this.props;
let moreNews = this.props.moreNews;
if (userType !== 'administrator'){
moreNews = userProducts.some((userProduct) => userProduct._id === product._id);

if (userType !== 'administrator') {
const isProductInUserProducts = userProducts.some(userProduct => userProduct._id === product._id);
const isProductInCompanyProductsWithoutSeats = companyProducts.some(
companyProduct => companyProduct._id === product._id && !companyProduct.seats
);
moreNews = isProductInUserProducts || isProductInCompanyProductsWithoutSeats;
}

return (
Expand All @@ -38,11 +43,13 @@ CardRow.propTypes = {
user: PropTypes.object,
userProducts: PropTypes.array,
userType: PropTypes.string,
companyProducts: PropTypes.array,
};

const mapStateToProps = (state) => ({
userProducts: state.userProducts,
userType: state.userType,
companyProducts: state.companyProducts,
});

CardRow.defaultProps = {
Expand Down
1 change: 1 addition & 0 deletions assets/home/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function homeReducer(state=initialState, action) {
products: action.data.products,
user: action.data.user,
userType: action.data.userType,
companyProducts: action.data.companyProducts,
userProducts: action.data.userProducts,
company: action.data.company,
formats: action.data.formats || [],
Expand Down
1 change: 1 addition & 0 deletions newsroom/wire/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def get_home_data():
"userProducts": user.get("products") if user else [],
"userType": user.get("user_type"),
"company": company_id,
"companyProducts": company.get("products") if company else [],
"formats": [
{
"format": f["format"],
Expand Down

0 comments on commit dc39910

Please sign in to comment.