From dc399109d5152296859fc85ec8e9b11be29b963c Mon Sep 17 00:00:00 2001 From: devketanpro <73937490+devketanpro@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:22:08 +0530 Subject: [PATCH] Fix : enable news more button for company unlimited seats [NHUB-293] (#403) * enable news more button for company unlimited seats * fix black --- assets/components/cards/render/CardRow.jsx | 13 ++++++++++--- assets/home/reducers.js | 1 + newsroom/wire/views.py | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/components/cards/render/CardRow.jsx b/assets/components/cards/render/CardRow.jsx index b2525f554..d5933842a 100644 --- a/assets/components/cards/render/CardRow.jsx +++ b/assets/components/cards/render/CardRow.jsx @@ -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 ( @@ -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 = { diff --git a/assets/home/reducers.js b/assets/home/reducers.js index ae8dd7ef5..0a52851ca 100644 --- a/assets/home/reducers.js +++ b/assets/home/reducers.js @@ -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 || [], diff --git a/newsroom/wire/views.py b/newsroom/wire/views.py index ee8900773..0e3cf2a2e 100644 --- a/newsroom/wire/views.py +++ b/newsroom/wire/views.py @@ -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"],